diff options
Diffstat (limited to 'zephyr/zmake/zmake/version.py')
-rw-r--r-- | zephyr/zmake/zmake/version.py | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/zephyr/zmake/zmake/version.py b/zephyr/zmake/zmake/version.py index c5506e9921..47aba6d804 100644 --- a/zephyr/zmake/zmake/version.py +++ b/zephyr/zmake/zmake/version.py @@ -86,14 +86,12 @@ def get_version_string(project, zephyr_base, modules, static=False): commits. Returns: - A tuple of version string which can be placed in FRID, FWID, or used in - the build for the OS, and a shortened string which is 31 chars or less. + A version string which can be placed in FRID, FWID, or used in + the build for the OS. """ major_version, minor_version, *_ = util.read_zephyr_version(zephyr_base) project_id = project.project_dir.parts[-1] num_commits = 0 - # Omit num_commits from short version string. - short_version_string = "{}_v{}.{}".format(project_id, major_version, minor_version) if static: vcs_hashes = "STATIC" @@ -106,38 +104,23 @@ def get_version_string(project, zephyr_base, modules, static=False): for repo in repos.values(): num_commits += _get_num_commits(repo) - vcs_parts = [] - for name, repo in sorted( - repos.items(), - # Put the EC module first, then Zephyr OS kernel, as - # these are probably the most important hashes to - # developers. - key=lambda p: (p[0] != "ec", p[0] != "os", p), - ): - # Add hashes to vcs_hashes and short_version_string if it is still - # short enough. - new_short_ver = short_version_string - val = "{}:{}".format(name, _get_revision(repo)[:6]) - vcs_parts.append(val) - vcs_hashes = ",".join(vcs_parts) - new_short_ver = "{}_v{}.{}-{}".format( - project_id, major_version, minor_version, vcs_hashes + vcs_hashes = ",".join( + "{}:{}".format(name, _get_revision(repo)[:6]) + for name, repo in sorted( + repos.items(), + # Put the EC module first, then Zephyr OS kernel, as + # these are probably the most important hashes to + # developers. + key=lambda p: (p[0] != "ec", p[0] != "os", p), ) + ) - if len(new_short_ver) <= 31: - short_version_string = new_short_ver - - long_version_string = "{}_v{}.{}.{}-{}".format( + return "{}_v{}.{}.{}-{}".format( project_id, major_version, minor_version, num_commits, vcs_hashes ) - # If the long version string is short enough use it. - if len(long_version_string) <= 31: - short_version_string = long_version_string - assert len(short_version_string) <= 31 - return long_version_string, short_version_string -def write_version_header(version_str, short_version_str, output_path, static=False): +def write_version_header(version_str, output_path, static=False): """Generate a version header and write it to the specified path. Generate a version header in the format expected by the EC build @@ -165,7 +148,7 @@ def write_version_header(version_str, short_version_str, output_path, static=Fal output.write("#define {} {}\n".format(name, value)) add_def("VERSION", version_str) - add_def("CROS_EC_VERSION32", short_version_str) + add_def("CROS_EC_VERSION32", version_str[:31]) if static: add_def("BUILDER", "reproducible@build") |