diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-29 17:51:30 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-29 17:51:30 +0200 |
commit | 77891f7dbad2c05aaffc54b4f1e26c060480201c (patch) | |
tree | edc92ea6208ccba0879da56a66b775722e7ce350 /rules/CC/auto | |
parent | 39e9a2d9f0f370b744f74b14223b29e783f30ce7 (diff) | |
parent | 5a365857fb8edb719b687b989351287b0ae09532 (diff) | |
download | rules-cc-77891f7dbad2c05aaffc54b4f1e26c060480201c.tar.gz |
Merge subtree 'rules' into rules-cc
Diffstat (limited to 'rules/CC/auto')
-rwxr-xr-x | rules/CC/auto/runner | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/rules/CC/auto/runner b/rules/CC/auto/runner index f938c27..27aef0c 100755 --- a/rules/CC/auto/runner +++ b/rules/CC/auto/runner @@ -24,7 +24,6 @@ param_file = argv[2] magic_string = argv[3] at_only = argv[4] == "true" - with open(param_file) as f: param = json.loads(f.read()) @@ -41,8 +40,8 @@ with open(input_file) as i: with open("out", "w") as o: for line in i.readlines(): if x := re.search( - r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", line - ): + r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", + line): # get the VAR key = x.groups()[-1] if key in param: @@ -52,16 +51,16 @@ with open(input_file) as i: line, ) else: - line = f"/* #undef {x.groups()[-1]} */\n" + line = f"/* #undef {x.groups()[-1]} */\n" if x := re.search( - r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", line - ): + r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", + line): # get the VAR key = x.groups()[-1] line = sub( f"{x.group()[1:]}", - f"{x.groups()[0]}define {x.groups()[2]}{key} " - + str(1 if key in param else 0), + f"{x.groups()[0]}define {x.groups()[2]}{key} " + + str(1 if key in param else 0), line, ) if match("#[ \t]*define", line): @@ -71,6 +70,7 @@ with open(input_file) as i: if not at_only: if x := re.search(r"\${([a-zA-Z0-9-_]+)}", line): key = x.groups()[0] - line = sub(r"\${" + key + r"}", param.get(key, ""), line) + line = sub(r"\${" + key + r"}", param.get(key, ""), + line) print(line, end="", file=o) |