2024-03-02 11:41:07 +00:00
|
|
|
From 3ee494686859ff54de39d9b9732ea8661182a8aa Mon Sep 17 00:00:00 2001
|
2022-10-22 19:17:54 +00:00
|
|
|
From: Luke Granger-Brown <git@lukegb.com>
|
2024-03-02 11:41:07 +00:00
|
|
|
Date: Sat, 2 Mar 2024 00:05:17 +0000
|
2023-07-19 02:54:50 +00:00
|
|
|
Subject: [PATCH 2/5] proto_ver_generator: use changelog, not git
|
2022-10-22 19:17:54 +00:00
|
|
|
|
|
|
|
---
|
2024-03-02 11:41:07 +00:00
|
|
|
scripts/fbt_tools/fbt_assets.py | 42 ++++++++-------------------------
|
|
|
|
1 file changed, 10 insertions(+), 32 deletions(-)
|
2022-10-22 19:17:54 +00:00
|
|
|
|
|
|
|
diff --git a/scripts/fbt_tools/fbt_assets.py b/scripts/fbt_tools/fbt_assets.py
|
2024-03-02 11:41:07 +00:00
|
|
|
index 492a66b66..e6e31beae 100644
|
2022-10-22 19:17:54 +00:00
|
|
|
--- a/scripts/fbt_tools/fbt_assets.py
|
|
|
|
+++ b/scripts/fbt_tools/fbt_assets.py
|
2024-03-02 11:41:07 +00:00
|
|
|
@@ -78,39 +78,17 @@ def __invoke_git(args, source_dir):
|
2022-08-28 16:33:45 +00:00
|
|
|
|
|
|
|
|
2024-03-02 11:41:07 +00:00
|
|
|
def _proto_ver_generator(target, source, env):
|
2022-08-28 16:33:45 +00:00
|
|
|
+ changelog_content = source[0].get_text_contents()
|
|
|
|
+ for ln in changelog_content.split('\n'):
|
|
|
|
+ ln = ln.strip()
|
|
|
|
+ if ln.startswith('## ['):
|
|
|
|
+ version = ln[len('## ['):-1]
|
|
|
|
+ break
|
|
|
|
+ else:
|
|
|
|
+ print("couldn't parse version from changelog " + str(source[0]))
|
|
|
|
+ Exit()
|
|
|
|
target_file = target[0]
|
|
|
|
- src_dir = source[0].dir.abspath
|
|
|
|
-
|
2024-03-02 11:41:07 +00:00
|
|
|
- def fetch(unshallow=False):
|
|
|
|
- git_args = ["fetch", "--tags"]
|
|
|
|
- if unshallow:
|
|
|
|
- git_args.append("--unshallow")
|
|
|
|
-
|
|
|
|
- try:
|
|
|
|
- __invoke_git(git_args, source_dir=src_dir)
|
|
|
|
- except (subprocess.CalledProcessError, EnvironmentError):
|
|
|
|
- # Not great, not terrible
|
|
|
|
- print(fg.boldred("Git: fetch failed"))
|
|
|
|
-
|
|
|
|
- def describe():
|
|
|
|
- try:
|
|
|
|
- return __invoke_git(
|
|
|
|
- ["describe", "--tags", "--abbrev=0"],
|
|
|
|
- source_dir=src_dir,
|
|
|
|
- )
|
|
|
|
- except (subprocess.CalledProcessError, EnvironmentError):
|
|
|
|
- return None
|
|
|
|
-
|
|
|
|
- fetch()
|
|
|
|
- git_describe = describe()
|
|
|
|
- if not git_describe:
|
|
|
|
- fetch(unshallow=True)
|
|
|
|
- git_describe = describe()
|
|
|
|
-
|
|
|
|
- if not git_describe:
|
|
|
|
- raise StopError("Failed to process git tags for protobuf versioning")
|
|
|
|
-
|
2022-08-28 16:33:45 +00:00
|
|
|
- git_major, git_minor = git_describe.split(".")
|
|
|
|
+ git_major, git_minor = version.split(".")
|
|
|
|
version_file_data = (
|
|
|
|
"#pragma once",
|
|
|
|
f"#define PROTOBUF_MAJOR_VERSION {git_major}",
|
2022-10-22 19:17:54 +00:00
|
|
|
--
|
2024-03-02 11:41:07 +00:00
|
|
|
2.43.0
|
2022-10-22 19:17:54 +00:00
|
|
|
|