提交 eafcdd0b 编写于 作者: mysterywolf's avatar mysterywolf 提交者: mysterywolf

[tools] format python code

上级 af82606d
......@@ -437,4 +437,4 @@ def ThreadStackStaticAnalysis(env):
main()
print('\nThread stack static analysis done!')
return
\ No newline at end of file
return
......@@ -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)
......
......@@ -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
......
......@@ -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('<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>\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)
......
......@@ -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('<?xml version="1.0" encoding="UTF-8"?>\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('<?xml version="1.0" encoding="UTF-8"?>\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()
#
# Copyright (c) 2006-2019, RT-Thread Development Team
# Copyright (c) 2006-2022, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0
#
......
#
# 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
......
......@@ -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]
......
......@@ -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')
......
......@@ -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()
......
......@@ -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
......
......@@ -46,7 +46,7 @@ def BuildPackage(package):
package = json.loads(package_json)
# check package name
# check package name
if 'name' not in package:
return []
......
此差异已折叠。
......@@ -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)
......
......@@ -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:
......
......@@ -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:
......
......@@ -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])
......
......@@ -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('<?xml version="1.0" encoding="UTF-8"?>\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':
......
......@@ -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)'
......
......@@ -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()
......@@ -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':
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册