summaryrefslogtreecommitdiff
path: root/tools/gen_ld_files.py
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
commita52eb88031620a81521b937f2a0651dbac2bb350 (patch)
tree017cbf8f686b252241182ef61ce48e8457aa1577 /tools/gen_ld_files.py
parent090b6ba42fcdfbb16844f77892087f91aa6ea201 (diff)
run code formatting script
Diffstat (limited to 'tools/gen_ld_files.py')
-rwxr-xr-xtools/gen_ld_files.py34
1 files changed, 21 insertions, 13 deletions
diff --git a/tools/gen_ld_files.py b/tools/gen_ld_files.py
index 1fea1a7ef..28f73d9be 100755
--- a/tools/gen_ld_files.py
+++ b/tools/gen_ld_files.py
@@ -12,31 +12,39 @@ import sys
import re
from string import Template
-parser = argparse.ArgumentParser(description='Apply #define values to .template.ld file.')
-parser.add_argument('template_files', metavar='TEMPLATE_FILE', type=argparse.FileType('r'),
- nargs='+', help="template filename: <something>.template.ld")
-parser.add_argument('--defines', type=argparse.FileType('r'), required=True)
-parser.add_argument('--out_dir', required=True)
+parser = argparse.ArgumentParser(description="Apply #define values to .template.ld file.")
+parser.add_argument(
+ "template_files",
+ metavar="TEMPLATE_FILE",
+ type=argparse.FileType("r"),
+ nargs="+",
+ help="template filename: <something>.template.ld",
+)
+parser.add_argument("--defines", type=argparse.FileType("r"), required=True)
+parser.add_argument("--out_dir", required=True)
args = parser.parse_args()
defines = {}
#
-REMOVE_UL_RE = re.compile('([0-9]+)UL')
+REMOVE_UL_RE = re.compile("([0-9]+)UL")
+
+
def remove_UL(s):
- return REMOVE_UL_RE.sub(r'\1', s)
+ return REMOVE_UL_RE.sub(r"\1", s)
+
# We skip all lines before
# // START_LD_DEFINES
# Then we look for lines like this:
# /*NAME_OF_VALUE=*/ NAME_OF_VALUE;
-VALUE_LINE_RE = re.compile(r'^/\*\s*(\w+)\s*=\*/\s*(.*);\s*$')
+VALUE_LINE_RE = re.compile(r"^/\*\s*(\w+)\s*=\*/\s*(.*);\s*$")
start_processing = False
for line in args.defines:
line = line.strip()
- if line == '// START_LD_DEFINES':
+ if line == "// START_LD_DEFINES":
start_processing = True
continue
if start_processing:
@@ -50,10 +58,10 @@ fail = False
for template_file in args.template_files:
ld_template_basename = os.path.basename(template_file.name)
- ld_pathname = os.path.join(args.out_dir, ld_template_basename.replace('.template.ld', '.ld'))
- with open(ld_pathname, 'w') as output:
- for k,v in defines.items():
- print('/*', k, '=', v, '*/', file=output)
+ ld_pathname = os.path.join(args.out_dir, ld_template_basename.replace(".template.ld", ".ld"))
+ with open(ld_pathname, "w") as output:
+ for k, v in defines.items():
+ print("/*", k, "=", v, "*/", file=output)
print(file=output)
try:
output.write(Template(template_file.read()).substitute(defines))