diff --git a/tools/WCS.py b/tools/WCS.py index 8625d6fff52aaf3b7d4609b7f6efe4dc31dcaa0d..cf7de004d64e550d6918e9cba7720042f5f7eaeb 100644 --- a/tools/WCS.py +++ b/tools/WCS.py @@ -437,4 +437,4 @@ def ThreadStackStaticAnalysis(env): main() print('\nThread stack static analysis done!') - return \ No newline at end of file + return diff --git a/tools/building.py b/tools/building.py index 8e11de73e812b9180170109b22785774f6347050..55968ac56aafb122d3258dd5f10904ec5a685eba 100644 --- a/tools/building.py +++ b/tools/building.py @@ -305,7 +305,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ menuconfig(Rtt_Root) exit(0) - if GetOption('pyconfig_silent'): + if GetOption('pyconfig_silent'): from menuconfig import guiconfig_silent guiconfig_silent(Rtt_Root) @@ -694,7 +694,7 @@ def PreBuilding(): a() def GroupLibName(name, env): - + if rtconfig.PLATFORM == 'armcc': return name + '_rvds' elif rtconfig.PLATFORM == 'gcc': @@ -850,7 +850,7 @@ def GenTargetProject(program = None): if GetOption('target') == 'eclipse': from eclipse import TargetEclipse TargetEclipse(Env, GetOption('reset-project-config'), GetOption('project-name')) - + if GetOption('target') == 'codelite': from codelite import TargetCodelite TargetCodelite(Projects, program) diff --git a/tools/cdk.py b/tools/cdk.py index 09ac934ad3a4529493d0543ebc9b3515721dd9ca..89e50839ad6d1efde28985ee7cc01c8ad9fd2a02 100644 --- a/tools/cdk.py +++ b/tools/cdk.py @@ -68,7 +68,7 @@ def _CDKProject(tree, target, script): for child in root: if child.tag == 'VirtualDirectory': root.remove(child) - + for group in script: group_tree = SDKAddGroup(ProjectFiles, root, group['name'], group['src'], project_path) @@ -91,8 +91,8 @@ def _CDKProject(tree, target, script): if CCFLAGS: CCFLAGS += ' ' + group['CCFLAGS'] else: - CCFLAGS += group['CCFLAGS'] - + CCFLAGS += group['CCFLAGS'] + # get each group's link flags if 'LINKFLAGS' in group and group['LINKFLAGS']: if LINKFLAGS: @@ -114,7 +114,7 @@ def _CDKProject(tree, target, script): CC_Misc = tree.find('BuildConfigs/BuildConfig/Compiler/OtherFlags') CC_Misc.text = CCFLAGS - + LK_Misc = tree.find('BuildConfigs/BuildConfig/Linker/OtherFlags') LK_Misc.text = LINKFLAGS diff --git a/tools/codeblocks.py b/tools/codeblocks.py index 6334f9b7cddd50bdf9d0be40f4b4ee4d863ccbe3..907bd5371a9ba8f8c9a2ccd8710acccbd2cd0879 100644 --- a/tools/codeblocks.py +++ b/tools/codeblocks.py @@ -40,10 +40,10 @@ def CB_AddHeadFiles(program, elem, project_path): utils.source_ext = [] utils.source_ext = ["h"] for item in program: - utils.walk_children(item) + utils.walk_children(item) utils.source_list.sort() # print utils.source_list - + for f in utils.source_list: path = _make_path_relative(project_path, f) Unit = SubElement(elem, 'Unit') @@ -70,14 +70,14 @@ def CBProject(target, script, program): tree = etree.parse('template.cbp') else: tree = etree.parse(os.path.join(os.path.dirname(__file__), 'template.cbp')) - + root = tree.getroot() - + out = open(target, 'w') out.write('\n') - + ProjectFiles = [] - + # SECTION 1. add "*.c|*.h" files group for elem in tree.iter(tag='Project'): # print elem.tag, elem.attrib @@ -88,7 +88,7 @@ def CBProject(target, script, program): # add h files CB_AddHeadFiles(program, elem, project_path) - # SECTION 2. + # SECTION 2. # write head include path if 'CPPPATH' in building.Env: cpp_path = building.Env['CPPPATH'] @@ -96,7 +96,7 @@ def CBProject(target, script, program): for path in cpp_path: inc = _make_path_relative(project_path, os.path.normpath(path)) paths.add(inc) #.replace('\\', '/') - + paths = [i for i in paths] paths.sort() # write include path, definitions @@ -110,10 +110,10 @@ def CBProject(target, script, program): Add = SubElement(elem, 'Add') for d in macro: Add.set('option', "-D"+d) - + # write link flags ''' - # write lib dependence + # write lib dependence if 'LIBS' in building.Env: for elem in tree.iter(tag='Tool'): if elem.attrib['Name'] == 'VCLinkerTool': @@ -121,7 +121,7 @@ def CBProject(target, script, program): libs_with_extention = [i+'.lib' for i in building.Env['LIBS']] libs = ' '.join(libs_with_extention) elem.set('AdditionalDependencies', libs) - + # write lib include path if 'LIBPATH' in building.Env: lib_path = building.Env['LIBPATH'] @@ -129,7 +129,7 @@ def CBProject(target, script, program): for path in lib_path: inc = _make_path_relative(project_path, os.path.normpath(path)) paths.add(inc) #.replace('\\', '/') - + paths = [i for i in paths] paths.sort() lib_paths = ';'.join(paths) diff --git a/tools/codelite.py b/tools/codelite.py index f4e612be61f27705c06dd7e6ba573b161c06b7ae..9073cde072557dc1ac1656029a166cba95465e6b 100644 --- a/tools/codelite.py +++ b/tools/codelite.py @@ -40,15 +40,15 @@ fs_encoding = sys.getfilesystemencoding() def CLSetCFlags(root, flags): node = root.find('Settings').find('Configuration').find('Compiler') node.attrib['C_Options'] = flags - + def CLSetCxxFlags(root, flags): node = root.find('Settings').find('Configuration').find('Compiler') node.attrib['Options'] = flags - + def CLSetAsFlags(root, flags): node = root.find('Settings').find('Configuration').find('Compiler') node.attrib['Assembler'] = flags - + def CLAddIncludePath(root, path): node = root.find('Settings').find('Configuration').find('Compiler') node = SubElement(node, 'IncludePath') @@ -58,22 +58,22 @@ def CLAddPreprocessor(root, value): node = root.find('Settings').find('Configuration').find('Compiler') node = SubElement(node, 'Preprocessor') node.attrib['Value'] = value - + def CLSetLdFlags(root, flags): node = root.find('Settings').find('Configuration').find('Linker') node.attrib['Options'] = flags - + def CLAddLibrary_path(root, path): node = root.find('Settings').find('Configuration').find('Linker') node = SubElement(node, 'LibraryPath') node.attrib['Value'] = path - + def CLAddLibrary(root, lib): node = root.find('Settings').find('Configuration').find('Linker') node = SubElement(node, 'Library') node.attrib['Value'] = lib - + def CLAddFile(root, file_path): file_path = file_path.replace('\\', '/') @@ -81,12 +81,12 @@ def CLAddFile(root, file_path): dir_list.pop() if not len(dir_list): dir_list.append(os.path.abspath('.').replace('\\', '/').split('/')[-1]) - + parent = root for dir_name in dir_list: if dir_name == '..': continue - + node = None nodes = parent.findall('VirtualDirectory') for iter in nodes: @@ -101,18 +101,18 @@ def CLAddFile(root, file_path): if parent != root: node = SubElement(parent, 'File') node.attrib['Name'] = file_path - + def CLAddHeaderFiles(parent, program, project_path): utils.source_ext = [] utils.source_ext = ["h"] for item in program: utils.walk_children(item) utils.source_list.sort() - + for f in utils.source_list: path = _make_path_relative(project_path, f) CLAddFile(parent, path) - + def CLAddCFiles(parent, files, project_path): for f in files: fn = f.rfile() @@ -122,81 +122,81 @@ def CLAddCFiles(parent, files, project_path): path = _make_path_relative(project_path, path) path = os.path.join(path, name) CLAddFile(parent, path) - - + + def CLGenWorkspace(project_name, project_path): if os.path.isfile('codelite_template.workspace'): tree = etree.parse('codelite_template.workspace') else: tree = etree.parse(os.path.join(os.path.dirname(__file__), 'codelite_template.workspace')) - + root = tree.getroot() root.attrib['Name'] = project_name - + node = root.find('Project') node.attrib['Name'] = project_name node.attrib['Path'] = project_name + '.project' - + node = root.find('BuildMatrix').find('WorkspaceConfiguration').find('Project') node.attrib['Name'] = project_name - + out = open(project_name + '.workspace', 'w') out.write('\n') xml_indent(root) out.write(etree.tostring(root, encoding='utf-8')) out.close() - + def TargetCodelite(script, program): project_name = os.path.abspath('.').replace('\\', '/').split('/')[-1] #project_name.replace('-', '_') project_path = os.path.abspath('.') CLGenWorkspace(project_name, project_path) - + if os.path.isfile('codelite_template.project'): tree = etree.parse('codelite_template.project') else: tree = etree.parse(os.path.join(os.path.dirname(__file__), 'codelite_template.project')) - + root = tree.getroot() root.attrib['Name'] = project_name - + out = open(project_name + '.project', 'w') out.write('\n') - + # add files for group in script: CLAddCFiles(root, group['src'], project_path) # add header file CLAddHeaderFiles(root, program, project_path) - - # SECTION 2. + + # SECTION 2. # write head include path - + if 'CPPPATH' in building.Env: cpp_path = building.Env['CPPPATH'] paths = set() for path in cpp_path: inc = _make_path_relative(project_path, os.path.normpath(path)) paths.add(inc) #.replace('\\', '/') - + paths = [i for i in paths] paths.sort() - + # write include path, definitions for elem in tree.iter(tag='Compiler'): break - + for path in paths: CLAddIncludePath(root, path) - - + + #print building.Env.get('LIBPATH', []) #print building.Env.get('LIBS', []) - + CLSetCFlags(root, building.Env.get('CFLAGS', [])) CLSetCxxFlags(root, building.Env.get('CFLAGS', [])) - + asflags = building.Env.get('ASFLAGS', []) asflags = asflags.replace('-ffunction-sections', '') asflags = asflags.replace('-fdata-sections', '') @@ -205,11 +205,11 @@ def TargetCodelite(script, program): asflags = asflags.replace('assembler-with-cpp', '') CLSetAsFlags(root, asflags) CLSetLdFlags(root, building.Env.get('LINKFLAGS', [])) - + for macro in building.Env.get('CPPDEFINES', []): for d in macro: CLAddPreprocessor(root, d) - + xml_indent(root) out.write(etree.tostring(root, encoding='utf-8')) out.close() diff --git a/tools/eclipse.py b/tools/eclipse.py index ae363aba7fb866c7ef2724eff7eab0dc5f0b7050..766e91b017bf13204d30fada175981170e3568f4 100644 --- a/tools/eclipse.py +++ b/tools/eclipse.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2006-2019, RT-Thread Development Team +# Copyright (c) 2006-2022, RT-Thread Development Team # # SPDX-License-Identifier: Apache-2.0 # diff --git a/tools/file_check.py b/tools/file_check.py index 63767782b59295df44919b0a56843e04e3d95baf..fbb72786ad1574fb405b752a287499c4b1c279ef 100644 --- a/tools/file_check.py +++ b/tools/file_check.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2006-2021, RT-Thread Development Team +# Copyright (c) 2006-2022, RT-Thread Development Team # # SPDX-License-Identifier: Apache-2.0 # @@ -65,7 +65,7 @@ class CheckOut: if file_real_path == file_path: logging.info("ignore file path: {}".format(file_real_path)) return 0 - + file_dir_path = os.path.dirname(file_path) for _dir in dir_ignore: if _dir is not None: @@ -168,7 +168,7 @@ class FormatCheck: with open(file_path, 'r', encoding = "utf-8") as f: file_lines = f.readlines() if not self.__check_file(file_lines, file_path): - format_check_fail_files += 1 + format_check_fail_files += 1 if (not encoding_check_result) or (format_check_fail_files != 0): logging.error("files format check fail.") @@ -209,12 +209,12 @@ class LicenseCheck: logging.warning("[{0}]: license year: {} is not true: {}, please update.".format(file_path, license_year, true_year)) - + else: logging.info("[{0}]: license check success.".format(file_path)) except Exception as e: logging.error(e) - + else: logging.error("[{0}]: license check fail.".format(file_path)) check_result = False diff --git a/tools/keil.py b/tools/keil.py index ac2e2c93157b64a4227b9a5a6a4f1b64cec287d9..f85bb767bf871dcff6265ff2eb8e6c41c6772d33 100644 --- a/tools/keil.py +++ b/tools/keil.py @@ -208,7 +208,7 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path, group_scons): return group -# The common part of making MDK4/5 project +# The common part of making MDK4/5 project def MDK45Project(tree, target, script): project_path = os.path.dirname(os.path.abspath(target)) @@ -437,7 +437,7 @@ def ARMCC_Version(): stdout, stderr = child.communicate() ''' - example stdout: + example stdout: Product: MDK Plus 5.24 Component: ARM Compiler 5.06 update 5 (build 528) Tool: armcc [4d3621] diff --git a/tools/makefile.py b/tools/makefile.py index 78dbd2228a76ec07ed1cb596a86bf484f304332e..414e55a3f3770954900a3bff2bbcb052535613b7 100644 --- a/tools/makefile.py +++ b/tools/makefile.py @@ -27,7 +27,7 @@ def TargetMakefile(env): RTT_ROOT = os.path.abspath(env['RTT_ROOT']) match_bsp = False - if BSP_ROOT.startswith(RTT_ROOT): + if BSP_ROOT.startswith(RTT_ROOT): match_bsp = True make = open('config.mk', 'w') diff --git a/tools/menuconfig.py b/tools/menuconfig.py index 82274fdbb52cf2415daeb417a4ad32e354e5ab1a..043c5df0d573bbc23537f04fb69a5e6db55a26e5 100644 --- a/tools/menuconfig.py +++ b/tools/menuconfig.py @@ -150,7 +150,7 @@ def touch_env(): home_dir = os.environ['HOME'] else: home_dir = os.environ['USERPROFILE'] - + package_url = os.getenv('RTT_PACKAGE_URL') or DEFAULT_RTT_PACKAGE_URL env_dir = os.path.join(home_dir, '.env') @@ -223,7 +223,7 @@ def touch_env(): if os.path.exists(os.path.join(env_dir, 'tools', 'scripts')): os.environ["PATH"] = os.path.join(env_dir, 'tools', 'scripts') + ';' + os.environ["PATH"] -# Exclude utestcases +# Exclude utestcases def exclude_utestcases(RTT_ROOT): if os.path.isfile(os.path.join(RTT_ROOT, 'examples/utest/testcases/Kconfig')): return @@ -241,7 +241,7 @@ def exclude_utestcases(RTT_ROOT): # menuconfig for Linux def menuconfig(RTT_ROOT): - # Exclude utestcases + # Exclude utestcases exclude_utestcases(RTT_ROOT) kconfig_dir = os.path.join(RTT_ROOT, 'tools', 'kconfig-frontends') @@ -275,7 +275,7 @@ def menuconfig(RTT_ROOT): def guiconfig(RTT_ROOT): import pyguiconfig - # Exclude utestcases + # Exclude utestcases exclude_utestcases(RTT_ROOT) if sys.platform != 'win32': @@ -309,9 +309,9 @@ def guiconfig(RTT_ROOT): def guiconfig_silent(RTT_ROOT): import defconfig - # Exclude utestcases + # Exclude utestcases exclude_utestcases(RTT_ROOT) - + if sys.platform != 'win32': touch_env() diff --git a/tools/mkromfs.py b/tools/mkromfs.py index c6d6c3237a43c179469cf813beed676c31516fc2..892d57d9cec6ed47e729315a381e3231617cec61 100644 --- a/tools/mkromfs.py +++ b/tools/mkromfs.py @@ -172,7 +172,7 @@ class Folder(object): # rt_uint32_t type; # const char *name; # const rt_uint8_t *data; - # rt_size_t size; + # rt_size_t size; #} d_li = [] # payload base diff --git a/tools/package.py b/tools/package.py index d49303d0487a4a46e055695c5f009f18b1de1e11..e9c43b66b7c4361eeb7d82bdf5cfbd3a505eef9e 100644 --- a/tools/package.py +++ b/tools/package.py @@ -46,7 +46,7 @@ def BuildPackage(package): package = json.loads(package_json) - # check package name + # check package name if 'name' not in package: return [] diff --git a/tools/rt_studio.py b/tools/rt_studio.py index c43b6cba3591c321a4af4a7d32fe58d90001f42b..12392eb4c6326444a9eb1443f692cbe574a2307f 100644 --- a/tools/rt_studio.py +++ b/tools/rt_studio.py @@ -11,193 +11,193 @@ MODULE_VER_NUM = 1 cproject_temp = """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + """ project_temp = """ - __project_name_flag__ - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.rt-thread.studio.rttnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - + __project_name_flag__ + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.rt-thread.studio.rttnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + """ projcfg_ini_temp = """#RT-Thread Studio Project Configuration diff --git a/tools/sconsui.py b/tools/sconsui.py index cd623f7fb5a2b769e60a2c6c10c1c9b30ba3603a..2def194cfa4b1dda8d17f8bac9aa060b578e6db4 100644 --- a/tools/sconsui.py +++ b/tools/sconsui.py @@ -62,19 +62,19 @@ lock = None class CmdExecutor(threading.Thread): def __init__(self, cmd, output): - threading.Thread.__init__(self) + threading.Thread.__init__(self) self.cmd = cmd self.child = None def run(self): global executor, builder, lock - + if platform.system() == 'Windows': try: from win32spawn import Win32Spawn subprocess = Win32Spawn(self.cmd) subprocess.start_pipe() - + builder.progressbar.start() while not subprocess.is_terminated or subprocess.qsize() > 0: try: @@ -87,7 +87,7 @@ class CmdExecutor(threading.Thread): lock.release() except: pass - + builder.progressbar.stop() except: pass @@ -113,7 +113,7 @@ class DirSelectBox(ttk.Frame): self.entry = ttk.Entry(self, textvariable = self.dir_var) self.entry.pack(fill=BOTH, expand=1,side=LEFT) self.entry.configure(width = 50) - + self.browser_button = ttk.Button(self, text="Browser", command=self.browser) self.browser_button.pack(side=RIGHT) @@ -125,7 +125,7 @@ class DirSelectBox(ttk.Frame): def set_path(self, path): path = path.replace('\\', '/') self.dir_var.set(path) - + def get_path(self): return self.dir_var.get() @@ -147,31 +147,31 @@ class SconsUI(): theme = style.theme_use() default = style.lookup(theme, 'background') master.configure(background=default) - + notebook = ttk.Notebook(master) notebook.pack(fill=BOTH, padx=5, pady=5) - - # building page + + # building page page_building = ttk.Frame(notebook) notebook.add(page_building, padding=3) notebook.tab(0, text='Build', underline="-1") self.setup_building_ui(page_building) self.building_page = page_building - + # make project page page_project = ttk.Frame(notebook) notebook.add(page_project, padding = 3) notebook.tab(1, text = 'Project', underline = '-1') self.setup_project_ui(page_project) self.project_page = page_project - - # setting page + + # setting page page_setting = ttk.Frame(notebook) notebook.add(page_setting, padding = 3) notebook.tab(2, text = 'Setting', underline = '-1') self.setup_setting_ui(page_setting) self.setting_page = page_setting - + padding = ttk.Frame(master) padding.pack(fill=X) quit = ttk.Button(padding, text='Quit', command = self.quit) @@ -179,15 +179,15 @@ class SconsUI(): # set notebook to self self.notebook = notebook - - # read setting + + # read setting self.read_setting() self.is_makeing_project = False - + def read_setting(self): import platform import os - + home = '' if platform.system() == 'Windows': driver = os.environ['HOMEDRIVE'] @@ -195,7 +195,7 @@ class SconsUI(): home = os.path.join(driver, home) else: home = os.environ['HOME'] - + setting_path = os.path.join(home, '.rtt_scons') if os.path.exists(setting_path): setting = open(os.path.join(home, '.rtt_scons')) @@ -217,10 +217,10 @@ class SconsUI(): # set RT-Thread Root Directory according environ if 'RTT_ROOT' in os.environ: self.RTTRoot.set_path(os.environ['RTT_ROOT']) - + if self.RTTRoot.get_path() == '': rtt_root = '' - # detect RT-Thread directory + # detect RT-Thread directory if os.path.exists(os.path.join('..', 'include', 'rtthread.h')): rtt_root = os.path.join('..') elif os.path.exists(os.path.join('..', '..', 'include', 'rtthread.h')): @@ -247,7 +247,7 @@ class SconsUI(): if not self.CompilersPath['GCC'].get_path(): paths = os.environ['PATH'] paths = paths.split(';') - + for path in paths: if path.find('CodeSourcery') != -1: self.CompilersPath['GCC'].set_path(path) @@ -269,7 +269,7 @@ class SconsUI(): home = os.environ['HOME'] setting = open(os.path.join(home, '.rtt_scons'), 'w+') - # current comiler + # current comiler # line = '%s=%s\n' % ('compiler', self.compilers.get())) line = '%s=%s\n' % ('compiler', 'iar') setting.write(line) @@ -296,17 +296,17 @@ class SconsUI(): def setup_building_ui(self, frame): padding = ttk.Frame(frame) padding.pack(fill=X) - + button = ttk.Button(padding, text='Clean', command=self.do_clean) button.pack(side=RIGHT) button = ttk.Button(padding, text='Build', command=self.do_build) button.pack(side=RIGHT) label = ttk.Label(padding, relief = 'flat', text = 'Click Build or Clean to build or clean system -->') label.pack(side=RIGHT, ipady = 5) - + self.progressbar = ttk.Progressbar(frame) self.progressbar.pack(fill=X) - + separator = ttk.Separator(frame) separator.pack(fill=X) @@ -316,17 +316,17 @@ class SconsUI(): def setup_project_ui(self, frame): label = ttk.Label(frame, relief = 'flat', text = 'Choose Integrated Development Environment:') label.pack(fill=X, pady = 5) - + separator = ttk.Separator(frame) separator.pack(fill=X) - + self.ide = StringVar() self.ide.set("mdk4") # initialize - + for text,mode in IDE: radiobutton = ttk.Radiobutton(frame, text=text, variable = self.ide, value = mode) radiobutton.pack(fill=X, padx=10) - + bottom = ttk.Frame(frame) bottom.pack(side=BOTTOM, fill=X) button = ttk.Button(bottom, text="Make Project", command = self.do_make_project) @@ -336,26 +336,26 @@ class SconsUI(): row = 0 label = ttk.Label (frame, relief = 'flat', text='RT-Thread Root Folder:') label.grid(row=row, column=0,ipadx=5, ipady=5, padx = 5) - + self.RTTRoot = DirSelectBox(frame) self.RTTRoot.grid(row=row, column=1, sticky=E+W) row = row + 1 - + label = ttk.Label (frame, relief = 'flat', text='Board Support Folder:') label.grid(row=row, column=0,ipadx=5, ipady=5, padx = 5) - + self.BSPRoot = DirSelectBox(frame) self.BSPRoot.grid(row=row, column=1, sticky=E+W) row = row + 1 - + label = ttk.Label (frame, relief='flat', text='Toolchain:') label.grid(row=row, column=0,ipadx=5, ipady=5, sticky=E+W) row = row + 1 - + separator = ttk.Separator(frame) separator.grid(row = row, column = 0, columnspan = 2, sticky = E+W) row = row + 1 - + self.compilers = StringVar() self.compilers.set("GCC") # initialize @@ -368,13 +368,13 @@ class SconsUI(): self.CompilersPath[compiler] = DirSelectBox(frame) self.CompilersPath[compiler].grid(row=row, column=1, sticky=E+W) row = row + 1 - + button = ttk.Button(frame, text='Save Setting', command = self.save_setting) button.grid(row = row, column = 1, sticky = E) row = row + 1 def prepare_build(self): - # get compiler + # get compiler compiler = self.compilers.get() if compiler == 'GCC': compiler = 'gcc' @@ -385,26 +385,26 @@ class SconsUI(): # get RTT Root rtt_root = self.RTTRoot.get_path() - # get Compiler path + # get Compiler path exec_path = self.CompilersPath[self.compilers.get()].get_path() - + command = '' os.environ['RTT_ROOT'] = rtt_root os.environ['RTT_CC'] = compiler os.environ['RTT_EXEC_PATH'] = exec_path - - return command - + + return command + def check_path(self): result = True - + if self.BSPRoot.get_path() == '': result = False - + if self.RTTRoot.get_path() == '': result = False - + if not result: tkMessageBox.showinfo("RT-Thread SCons UI", "Folder is empty, please choose correct directory.") @@ -423,8 +423,8 @@ class SconsUI(): self.output.delete(1.0, END) self.output.insert(END, 'building project...\n') - ExecCmd(command) - + ExecCmd(command) + def do_clean(self): self.prepare_build() command = 'scons -c' @@ -438,18 +438,18 @@ class SconsUI(): self.output.delete(1.0, END) self.output.insert(END, 'clean project...\n') ExecCmd(command) - + def do_make_project(self): ide = self.ide.get() self.prepare_build() command = 'scons --target=%s -s' % ide - + if not self.check_path(): return - - # select build page + + # select build page self.notebook.select(self.building_page) - + bsp = self.BSPRoot.get_path() os.chdir(bsp) diff --git a/tools/ses.py b/tools/ses.py index 67ea8b0cbe1442da92e4b8168855c175e4add816..120d889e8672f2b062ed483d43fbafe06c82762e 100644 --- a/tools/ses.py +++ b/tools/ses.py @@ -37,7 +37,7 @@ def SESProject(env) : project = ProjectInfo(env) # print(project) - # return + # return project_path = os.path.abspath(env['BSP_ROOT']) script = env['project'] @@ -64,7 +64,7 @@ def SESProject(env) : CFLAGS += ' ' + group['CFLAGS'] else: CFLAGS += group['CFLAGS'] - + # get each group's link flags if 'LINKFLAGS' in group and group['LINKFLAGS']: if LINKFLAGS: diff --git a/tools/ua.py b/tools/ua.py index 08b0ef8fadc99136f82d042905f7fd812348357b..218cd09584753cf8210d111713763a8b96682b0d 100644 --- a/tools/ua.py +++ b/tools/ua.py @@ -36,7 +36,7 @@ def PrefixPath(prefix, path): if path.startswith(prefix): return True - + return False def PrepareUA(project, RTT_ROOT, BSP_ROOT): @@ -44,9 +44,9 @@ def PrepareUA(project, RTT_ROOT, BSP_ROOT): # ua.write('import os\n') # ua.write('import sys\n') ua.write('\n') - + print(RTT_ROOT) - + CPPPATH = [] CPPDEFINES = [] @@ -60,7 +60,7 @@ def PrepareUA(project, RTT_ROOT, BSP_ROOT): CPPDEFINES += group['CPPDEFINES'] if len(CPPPATH): - # use absolute path + # use absolute path for i in range(len(CPPPATH)): CPPPATH[i] = os.path.abspath(CPPPATH[i]) @@ -70,7 +70,7 @@ def PrepareUA(project, RTT_ROOT, BSP_ROOT): for path in paths: if PrefixPath(RTT_ROOT, path): CPPPATH += ['RTT_ROOT + "/%s",' % _make_path_relative(RTT_ROOT, path).replace('\\', '/')] - + elif PrefixPath(BSP_ROOT, path): CPPPATH += ['BSP_ROOT + "/%s",' % _make_path_relative(BSP_ROOT, path).replace('\\', '/')] else: diff --git a/tools/utils.py b/tools/utils.py index 1007dfab651beb07f797268a6c5a8e005bbb2524..0fa2aefcdea811562b054a3a9c8ec0067dab4547 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -139,7 +139,7 @@ def PrefixPath(prefix, path): if path.startswith(prefix): return True - + return False def ListMap(l): @@ -197,7 +197,7 @@ def ProjectInfo(env): # process FILES and DIRS if len(FILES): - # use absolute path + # use absolute path for i in range(len(FILES)): FILES[i] = os.path.abspath(str(FILES[i])) DIRS.append(os.path.dirname(FILES[i])) @@ -211,7 +211,7 @@ def ProjectInfo(env): # process CPPPATH if len(CPPPATH): - # use absolute path + # use absolute path for i in range(len(CPPPATH)): CPPPATH[i] = os.path.abspath(CPPPATH[i]) diff --git a/tools/vs.py b/tools/vs.py index 8025828b64c71b629908d75b7b06288e25b8430a..4da6dc1381977ac9849323f8353ae80ef3efe4d6 100644 --- a/tools/vs.py +++ b/tools/vs.py @@ -70,10 +70,10 @@ def VS_AddHeadFilesGroup(program, elem, project_path): utils.source_ext = [] utils.source_ext = ["h"] for item in program: - utils.walk_children(item) + utils.walk_children(item) utils.source_list.sort() # print utils.source_list - + for f in utils.source_list: path = _make_path_relative(project_path, f) File = SubElement(elem, 'File') @@ -85,15 +85,15 @@ def VS_AddHeadFilesGroup(program, elem, project_path): def VSProject(target, script, program): project_path = os.path.dirname(os.path.abspath(target)) - + tree = etree.parse('template_vs2005.vcproj') root = tree.getroot() - + out = open(target, 'w') out.write('\r\n') - + ProjectFiles = [] - + # add "*.c" files group for elem in tree.iter(tag='Filter'): if elem.attrib['Name'] == 'Source Files': @@ -120,7 +120,7 @@ def VSProject(target, script, program): if elem.attrib['Name'] == 'Header Files': break VS_AddHeadFilesGroup(program, elem, project_path) - + # write head include path if 'CPPPATH' in building.Env: cpp_path = building.Env['CPPPATH'] @@ -128,7 +128,7 @@ def VSProject(target, script, program): for path in cpp_path: inc = _make_path_relative(project_path, os.path.normpath(path)) paths.add(inc) #.replace('\\', '/') - + paths = [i for i in paths] paths.sort() cpp_path = ';'.join(paths) @@ -153,7 +153,7 @@ def VSProject(target, script, program): elem.set('PreprocessorDefinitions', definitions) # write link flags - # write lib dependence + # write lib dependence if 'LIBS' in building.Env: for elem in tree.iter(tag='Tool'): if elem.attrib['Name'] == 'VCLinkerTool': diff --git a/tools/vs2012.py b/tools/vs2012.py index c9b0c76dc74c18d352c71c4f7c17a8429645f760..72651637578a433d5f8dd651d5223938fecf1d54 100644 --- a/tools/vs2012.py +++ b/tools/vs2012.py @@ -49,7 +49,7 @@ def get_uuid(): else: # python3 is no decode function idstr = id.get_urn()[9:] #'urn:uuid:3e5526c0-2841-11e3-a376-20cf3048bcb3'[9:] - + return '{'+idstr+'}' def VS2012_AddGroup(parent, group_name, files, project_path): @@ -144,7 +144,7 @@ def VS_add_HeadFiles(program, elem, project_path): utils.source_ext = [] utils.source_ext = ["h"] for item in program: - utils.walk_children(item) + utils.walk_children(item) utils.source_list.sort() # print utils.source_list ItemGroup = SubElement(elem, 'ItemGroup') @@ -174,7 +174,7 @@ def VS_add_HeadFiles(program, elem, project_path): def VS2012Project(target, script, program): project_path = os.path.dirname(os.path.abspath(target)) - + tree = etree.parse('template_vs2012.vcxproj') root = tree.getroot() elem = root @@ -201,7 +201,7 @@ def VS2012Project(target, script, program): for path in cpp_path: inc = _make_path_relative(project_path, os.path.normpath(path)) paths.add(inc) #.replace('\\', '/') - + paths = [i for i in paths] paths.sort() cpp_path = ';'.join(paths) + ';%(AdditionalIncludeDirectories)' @@ -243,7 +243,7 @@ def VS2012Project(target, script, program): for path in lib_path: inc = _make_path_relative(project_path, os.path.normpath(path)) paths.add(inc) - + paths = [i for i in paths] paths.sort() lib_paths = ';'.join(paths) + ';%(AdditionalLibraryDirectories)' diff --git a/tools/win32spawn.py b/tools/win32spawn.py index 1c2cfcf83bf68feb3e9f4c26b9bb7bfa82a0b0d2..605e194713968fcf5e0e42e5dc29326e3907eccd 100644 --- a/tools/win32spawn.py +++ b/tools/win32spawn.py @@ -32,7 +32,7 @@ if _PY2: else: import queue as Queue -# Windows import +# Windows import import win32file import win32pipe import win32api @@ -46,11 +46,11 @@ class Win32Spawn(object): self.queue = Queue.Queue() self.is_terminated = False self.wake_up_event = win32event.CreateEvent(None, 0, 0, None) - + exec_dir = os.getcwd() comspec = os.environ.get("COMSPEC", "cmd.exe") cmd = comspec + ' /c ' + cmd - + win32event.ResetEvent(self.wake_up_event) currproc = win32api.GetCurrentProcess() @@ -83,7 +83,7 @@ class Win32Spawn(object): self.h_process, h_thread, dw_pid, dw_tid = win32process.CreateProcess(None, cmd, None, None, 1, cr_flags, env, os.path.abspath(exec_dir), startup_info) - + win32api.CloseHandle(h_thread) win32file.CloseHandle(child_stdin_rd) @@ -115,7 +115,7 @@ class Win32Spawn(object): else: # The wake_up_event must have been signalled return False - + def get(self, block=True, timeout=None): return self.queue.get(block=block, timeout=timeout) @@ -158,7 +158,7 @@ class Win32Spawn(object): result = self.exit_code == 0 self.close() self.is_terminated = True - + return result # This method gets called on a worker thread to read from either a stderr @@ -180,6 +180,6 @@ class Win32Spawn(object): def start_pipe(self): def worker(pipe): return pipe.wait() - + thrd = threading.Thread(target=worker, args=(self, )) thrd.start() diff --git a/tools/wizard.py b/tools/wizard.py index c5773527c6302740732d4ee8b9c098616371bb82..d0f39ae01c7ccfd74daf4f4f1caf59019dc1c8aa 100644 --- a/tools/wizard.py +++ b/tools/wizard.py @@ -26,11 +26,11 @@ # """ -wizard.py - a script to generate SConscript in RT-Thread RTOS. +wizard.py - a script to generate SConscript in RT-Thread RTOS. `wizard --component name' to generate SConscript for name component. -`wizard --bridge' to generate SConscript as a bridge to connect each -SConscript script file of sub-directory. +`wizard --bridge' to generate SConscript as a bridge to connect each +SConscript script file of sub-directory. """ import sys @@ -86,7 +86,7 @@ if __name__ == '__main__': if len(sys.argv) == 1: usage() sys.exit(2) - + if sys.argv[1] == '--component': gen_component(sys.argv[2]) elif sys.argv[1] == '--bridge': diff --git a/tools/xmake.py b/tools/xmake.py index bf263bc281c87fd2222a957fec6ad56eaa01f412..2fee979d70ef55ed99f96192c7a978b7b0fa1ed6 100644 --- a/tools/xmake.py +++ b/tools/xmake.py @@ -71,8 +71,8 @@ class XmakeProject: with open(template_path, "r") as f: data = f.read() data = Template(data) - data = data.safe_substitute(toolchain=self.toolchain, sdkdir=self.sdkdir, src_path=self.src_path, inc_path=self.inc_path, - define=self.define, cflags=self.cflags, cxxflags=self.cxxflags, asflags=self.asflags, + data = data.safe_substitute(toolchain=self.toolchain, sdkdir=self.sdkdir, src_path=self.src_path, inc_path=self.inc_path, + define=self.define, cflags=self.cflags, cxxflags=self.cxxflags, asflags=self.asflags, ldflags=self.ldflags, target="rt-thread") with open("xmake.lua", "w") as f: f.write(data) @@ -88,4 +88,4 @@ def XMakeProject(env,project): print('Done!') - return \ No newline at end of file + return