blob: a7654ff997fb1f73c2a7fc30d94c907a7f07b67f [file] [log] [blame]
David Svantessone0c42ef2022-12-15 16:25:57 +00001# Copyright (c) 2023 Arm Limited.
2#
3# SPDX-License-Identifier: MIT
4#
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to
7# deal in the Software without restriction, including without limitation the
8# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9# sell copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11#
12# The above copyright notice and this permission notice shall be included in all
13# copies or substantial portions of the Software.
14#
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE.
22
23import sys
24import os
25
26VERSION = "v0.0-unreleased"
27
28
29def make_version_file(build_args, git_hash):
30 build_info = "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (
31 VERSION, build_args, git_hash.strip())
32 return build_info
33
David Svantesson90d15b92023-06-08 10:05:59 +000034def make_version_file_from_sconscript(build_args, git_hash):
35 VERSION = "v0.0-unreleased"
36 fp = None
37 if os.path.exists("external/compute_library/SConscript"):
38 fp = "external/compute_library/SConscript"
39 elif os.path.exists("SConscript"):
40 fp = "SConscript"
41 if fp:
42 with open(fp) as scons_file:
43 for line in scons_file:
44 if "VERSION = " in line:
45 VERSION = line.split("=")[-1].strip().replace("\"", "")
46 break
47 return "\"arm_compute_version=%s Build options: %s Git hash=%s\"" % (
48 VERSION, build_args, git_hash.strip())
David Svantessone0c42ef2022-12-15 16:25:57 +000049
David Svantesson90d15b92023-06-08 10:05:59 +000050if __name__ == "__main__":
51 if len(sys.argv) == 4 and sys.argv[3].lower() == "true":
52 print(make_version_file_from_sconscript(sys.argv[1], sys.argv[2]))
53 else:
54 print(make_version_file(sys.argv[1], sys.argv[2]))
55