4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-01-31 02:50:26 +08:00

format code

This commit is contained in:
yaxing.chen 2021-01-26 19:35:30 +08:00
parent 822e825c8f
commit 25147060dd

View File

@ -273,50 +273,50 @@ def gen_org_eclipse_core_runtime_prefs(output_file_path):
def gen_cproject_file(output_file_path): def gen_cproject_file(output_file_path):
template_file_path = os.path.join(os.path.dirname(output_file_path),"template.cproject") template_file_path = os.path.join(os.path.dirname(output_file_path), "template.cproject")
if os.path.exists(template_file_path): if os.path.exists(template_file_path):
try: try:
shutil.copy(template_file_path, output_file_path) shutil.copy(template_file_path, output_file_path)
except Exception as e: except Exception as e:
print(e) print(e)
return True return True
else: else:
CFLAGS = rtconfig.CFLAGS CFLAGS = rtconfig.CFLAGS
AFLAGS = rtconfig.AFLAGS AFLAGS = rtconfig.AFLAGS
LFLAGS = rtconfig.LFLAGS LFLAGS = rtconfig.LFLAGS
if 'CXXFLAGS' in dir(rtconfig): if 'CXXFLAGS' in dir(rtconfig):
CXXFLAGS = rtconfig.CXXFLAGS CXXFLAGS = rtconfig.CXXFLAGS
else: else:
CXXFLAGS = "" CXXFLAGS = ""
if "-T" in LFLAGS: if "-T" in LFLAGS:
items = str(LFLAGS).split() items = str(LFLAGS).split()
t_index = items.index("-T") t_index = items.index("-T")
items[t_index] = "" items[t_index] = ""
items[t_index + 1] = "" items[t_index + 1] = ""
LFLAGS = " ".join(items) LFLAGS = " ".join(items)
try: try:
w_str = cproject_temp w_str = cproject_temp
if "a_misc_flag" in w_str: if "a_misc_flag" in w_str:
w_str = w_str.replace("a_misc_flag", AFLAGS) w_str = w_str.replace("a_misc_flag", AFLAGS)
if "c_misc_flag" in w_str: if "c_misc_flag" in w_str:
w_str = w_str.replace("c_misc_flag", CFLAGS) w_str = w_str.replace("c_misc_flag", CFLAGS)
if "cpp_misc_flag" in w_str: if "cpp_misc_flag" in w_str:
w_str = w_str.replace("cpp_misc_flag", CXXFLAGS) w_str = w_str.replace("cpp_misc_flag", CXXFLAGS)
if "c_link_misc_flag" in w_str: if "c_link_misc_flag" in w_str:
w_str = w_str.replace("c_link_misc_flag", LFLAGS) w_str = w_str.replace("c_link_misc_flag", LFLAGS)
if "cpp_link_misc_flag" in w_str: if "cpp_link_misc_flag" in w_str:
w_str = w_str.replace("cpp_link_misc_flag", LFLAGS) w_str = w_str.replace("cpp_link_misc_flag", LFLAGS)
dir_name = os.path.dirname(output_file_path) dir_name = os.path.dirname(output_file_path)
if not os.path.exists(dir_name): if not os.path.exists(dir_name):
os.makedirs(dir_name) os.makedirs(dir_name)
with open(output_file_path, 'w') as f: with open(output_file_path, 'w') as f:
f.write(w_str) f.write(w_str)
return True return True
except Exception as e: except Exception as e:
return False return False
def gen_project_file(output_file_path): def gen_project_file(output_file_path):