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 | 5a365857fb8edb719b687b989351287b0ae09532 (patch) | |
tree | 82881ad0e7f26a845e2c19aa7f1db5382cf03b41 /CC/auto/runner | |
parent | 764d38fbebe1cb82ff9c309b33478575357e98de (diff) | |
parent | f41343abe847fa88a4cbb46d856bfc44efa8595a (diff) | |
download | rules-cc-5a365857fb8edb719b687b989351287b0ae09532.tar.gz |
Merge branch 'just-rules' into rules
Diffstat (limited to 'CC/auto/runner')
-rwxr-xr-x | CC/auto/runner | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/CC/auto/runner b/CC/auto/runner index f938c27..27aef0c 100755 --- a/CC/auto/runner +++ b/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) |