|
@@ -1,5 +1,6 @@
|
|
import os
|
|
import os
|
|
import shutil
|
|
import shutil
|
|
|
|
+import re
|
|
import multiprocessing
|
|
import multiprocessing
|
|
|
|
|
|
|
|
|
|
@@ -17,6 +18,7 @@ def run_cmd(cmd, output_info=True):
|
|
print('\033[1;32m' + cmd + '\033[0m')
|
|
print('\033[1;32m' + cmd + '\033[0m')
|
|
|
|
|
|
output_str_list = []
|
|
output_str_list = []
|
|
|
|
+ res = 0
|
|
|
|
|
|
if output_info:
|
|
if output_info:
|
|
res = os.system(cmd + " > output.txt 2>&1")
|
|
res = os.system(cmd + " > output.txt 2>&1")
|
|
@@ -34,7 +36,7 @@ def run_cmd(cmd, output_info=True):
|
|
return output_str_list, res
|
|
return output_str_list, res
|
|
|
|
|
|
|
|
|
|
-def build_bsp(bsp):
|
|
|
|
|
|
+def build_bsp(bsp, scons_args=''):
|
|
"""
|
|
"""
|
|
build bsp.
|
|
build bsp.
|
|
|
|
|
|
@@ -46,7 +48,7 @@ def build_bsp(bsp):
|
|
pkgs --list
|
|
pkgs --list
|
|
|
|
|
|
cd {rtt_root}
|
|
cd {rtt_root}
|
|
- scons -C bsp/{bsp} -j{nproc}
|
|
|
|
|
|
+ scons -C bsp/{bsp} -j{nproc} {scons_args}
|
|
|
|
|
|
cd {rtt_root}/bsp/{bsp}
|
|
cd {rtt_root}/bsp/{bsp}
|
|
scons -c > /dev/null
|
|
scons -c > /dev/null
|
|
@@ -65,7 +67,8 @@ def build_bsp(bsp):
|
|
|
|
|
|
nproc = multiprocessing.cpu_count()
|
|
nproc = multiprocessing.cpu_count()
|
|
os.chdir(rtt_root)
|
|
os.chdir(rtt_root)
|
|
- __, res = run_cmd(f'scons -C bsp/{bsp} -j{nproc}', output_info=False)
|
|
|
|
|
|
+ cmd = f'scons -C bsp/{bsp} -j{nproc} {scons_args}'
|
|
|
|
+ __, res = run_cmd(cmd, output_info=False)
|
|
|
|
|
|
if res != 0:
|
|
if res != 0:
|
|
success = False
|
|
success = False
|
|
@@ -89,6 +92,16 @@ def append_file(source_file, destination_file):
|
|
destination.write(line)
|
|
destination.write(line)
|
|
|
|
|
|
|
|
|
|
|
|
+def check_scons_args(file_path):
|
|
|
|
+ args = []
|
|
|
|
+ with open(file_path, 'r') as file:
|
|
|
|
+ for line in file:
|
|
|
|
+ match = re.search(r'#\s*scons:\s*(.*)', line)
|
|
|
|
+ if match:
|
|
|
|
+ args.append(match.group(1).strip())
|
|
|
|
+ return ' '.join(args)
|
|
|
|
+
|
|
|
|
+
|
|
def build_bsp_attachconfig(bsp, attach_file):
|
|
def build_bsp_attachconfig(bsp, attach_file):
|
|
"""
|
|
"""
|
|
build bsp with attach config.
|
|
build bsp with attach config.
|
|
@@ -111,7 +124,9 @@ def build_bsp_attachconfig(bsp, attach_file):
|
|
|
|
|
|
append_file(attach_path, config_file)
|
|
append_file(attach_path, config_file)
|
|
|
|
|
|
- res = build_bsp(bsp)
|
|
|
|
|
|
+ scons_args = check_scons_args(attach_path)
|
|
|
|
+
|
|
|
|
+ res = build_bsp(bsp, scons_args)
|
|
|
|
|
|
shutil.copyfile(config_bacakup, config_file)
|
|
shutil.copyfile(config_bacakup, config_file)
|
|
os.remove(config_bacakup)
|
|
os.remove(config_bacakup)
|