def gen_projxfile(tree, target, buildstring, Projects): project_path = os.path.dirname(os.path.abspath(target)) boardname = buildstring.split("@")[1] project_opts_path = os.path.join(project_path, "opts") if not os.path.isdir(project_opts_path): os.makedirs(project_opts_path) root = tree.getroot() get_element_value(element_dict, buildstring) for key in element_dict: xpath = element_dict[key]["xpath"] value = element_dict[key]["value"] changeItemForMcu(tree, xpath, value) # add group groups = tree.find('Targets/Target/Groups') if groups is None: groups = SubElement(tree.find('Targets/Target'), 'Groups') groups.clear() # clean old groups for group in Projects: # don't add an empty group if len(group['src']) != 0: group_tree = add_group(groups, group['name'], group['src'], project_path) # add GroupOption GroupOption = SubElement(group_tree, 'GroupOption') GroupArmAds = SubElement(GroupOption, 'GroupArmAds') Cads = SubElement(GroupArmAds, 'Cads') VariousControls = SubElement(Cads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') MiscControls.text = "--via %s%s.c_opts" % (OPT_DIR, group["name"]) Aads = SubElement(GroupArmAds, 'Aads') VariousControls = SubElement(Aads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') MiscControls.text = "--via %s%s.as_opts" % (OPT_DIR, group["name"]) if group['c_opts_keil']: filename = os.path.join(project_opts_path, "%s.c_opts" % group['name']) create_file(group['c_opts_keil'], filename) if group['as_opts_keil']: filename = os.path.join(project_opts_path, "%s.as_opts" % group['name']) create_file(group['as_opts_keil'], filename) gen_indent(root) with open(target, 'wb') as f: f.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n') f.write(etree.tostring(root, encoding='utf-8'))
def gen_project(target, script, buildstring): project_path = os.path.dirname(os.path.abspath(target)) project_opts_path = os.path.join(project_path, "opts") if not os.path.isdir(project_opts_path): os.makedirs(project_opts_path) get_element_value(element_dict, buildstring) boardname = buildstring.split("@")[1] projfilename = 'build/scripts/template_%s.ewp' % (boardname) if os.path.exists(projfilename) == False: projfilename = 'build/scripts/template.ewp' tree = etree.parse(projfilename) root = tree.getroot() existedFileNameString = [] # copy repeat source file and replace old one for group in script: for filePath in group['src']: filename = os.path.splitext(basename(filePath)) if existedFileNameString.count(filename): repeat_path.append(filePath) else: existedFileNameString.append(filename) if group['c_opts_iar']: filename = os.path.join(project_opts_path, "%s.c_opts" % group['name']) create_file(group['c_opts_iar'], filename) if group['as_opts_iar']: filename = os.path.join(project_opts_path, "%s.as_opts" % group['name']) # strip '--cpu xxx' from as_opts_iar which causes IAR IDE build failed as_opts_tmp = re.sub(r'^\s*Cortex-M\d+ ', '', group['as_opts_iar']) create_file(as_opts_tmp, filename) if len(repeat_path): print('repeat name files:', repeat_path) print('will copy them to ' + project_path + '/ !') # add group for group in script: add_group(root, group['name'], group['src'], group['include'], project_path) changeItemForMcu(tree, element_dict, buildstring) gen_indent(root) projString = etree.tostring(root, encoding='utf-8') with open(target, "w") as out: out.write(projString.decode()) gen_workspace(target, buildstring)
def gen_project(tree, target, script): project_path = os.path.dirname(os.path.abspath(target)) root = tree.getroot() out = file(target, 'wb') out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n') #change target name TargetName = tree.find('Targets/Target/TargetName') TargetName.text = buildstring OutputName = tree.find( 'Targets/Target/TargetOption/TargetCommonOption/OutputName') OutputName.text = buildstring # add group groups = tree.find('Targets/Target/Groups') if groups is None: groups = SubElement(tree.find('Targets/Target'), 'Groups') groups.clear() # clean old groups for group in script: # don't add an empty group if len(group['src']) != 0: group_tree = add_group(groups, group['name'], group['src'], project_path) # add GroupOption GroupOption = SubElement(group_tree, 'GroupOption') GroupArmAds = SubElement(GroupOption, 'GroupArmAds') Cads = SubElement(GroupArmAds, 'Cads') VariousControls = SubElement(Cads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') MiscControls.text = '--via ' + opt_dir + group['name'] + '.c_opts' Aads = SubElement(GroupArmAds, 'Aads') VariousControls = SubElement(Aads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') MiscControls.text = '--via ' + opt_dir + group['name'] + '.as_opts' # set <OutputName>B-L475E-IOT01</OutputName> gen_indent(root) changeItemForMcu(tree) projString = ModifyProjString(etree.tostring(root, encoding='utf-8')) out.write(projString) out.close()
def gen_project(tree, target, script): project_path = os.path.dirname(os.path.abspath(target)) root = tree.getroot() out = file(target, 'wb') out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n') #change target name TargetName = tree.find('Targets/Target/TargetName') TargetName.text = buildstring OutputName = tree.find('Targets/Target/TargetOption/TargetCommonOption/OutputName') OutputName.text = buildstring # add group groups = tree.find('Targets/Target/Groups') if groups is None: groups = SubElement(tree.find('Targets/Target'), 'Groups') groups.clear() # clean old groups for group in script: # don't add an empty group if len(group['src']) != 0: group_tree = add_group(groups, group['name'], group['src'], project_path) # add GroupOption GroupOption = SubElement(group_tree, 'GroupOption') GroupArmAds = SubElement(GroupOption, 'GroupArmAds') Cads = SubElement(GroupArmAds, 'Cads') VariousControls = SubElement(Cads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') MiscControls.text = '--via '+opt_dir+group['name']+'.c_opts' Aads = SubElement(GroupArmAds, 'Aads') VariousControls = SubElement(Aads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') MiscControls.text = '--via '+opt_dir+group['name']+'.as_opts' # set <OutputName>B-L475E-IOT01</OutputName> gen_indent(root) changeItemForMcu(tree) projString = ModifyProjString( etree.tostring(root, encoding='utf-8') ) out.write(projString) out.close()
def gen_project(target, script): project_path = os.path.dirname(os.path.abspath(target)) tree = etree.parse('build/scripts/template.ewp') root = tree.getroot() out = file(target, 'wb') existedFileNameString = [] # copy repeat source file and replace old one for group in script: for filePath in group['src']: filename = os.path.splitext(basename(filePath)) if existedFileNameString.count(filename): repeat_path.append(filePath) else: existedFileNameString.append(filename) if len(repeat_path): print 'repeat name files:', repeat_path print 'will copy them to ' + proj_output_dir + '/ !' # add group for group in script: add_group(root, group['name'], group['src'], group['include'], project_path) changeItemForMcu(tree) gen_indent(root) projString = etree.tostring(root, encoding='utf-8') if 'starterkit' in buildstring: projString = projString.replace('STM32L475VG', 'STM32L433RC') if 'stm32l432' in buildstring: projString = projString.replace('STM32L475VG', 'STM32L432KC') if 'stm32l053' in buildstring: projString = projString.replace('STM32L475VG', 'STM32L053R8') if 'stm32l031' in buildstring: projString = projString.replace('STM32L475VG', 'STM32L031K6') if 'stm32f429' in buildstring: projString = projString.replace('STM32L475VG', 'STM32F429ZI') out.write(projString) out.close() gen_workspace(target)
def gen_project(target, script): project_path = os.path.dirname(os.path.abspath(target)) tree = etree.parse('build/scripts/template.ewp') root = tree.getroot() out = file(target, 'wb') existedFileNameString=[] # copy repeat source file and replace old one for group in script: for filePath in group['src']: filename = os.path.splitext(basename(filePath)) if existedFileNameString.count(filename): repeat_path.append(filePath) else: existedFileNameString.append(filename) if len(repeat_path): print 'repeat name files:', repeat_path print 'will copy them to '+proj_output_dir+'/ !' # add group for group in script: add_group(root, group['name'], group['src'], group['include'], project_path) changeItemForMcu(tree) gen_indent(root) projString = etree.tostring(root, encoding='utf-8') if 'starterkit' in buildstring: projString = projString.replace('STM32L475VG','STM32L433RC') if 'stm32l432' in buildstring: projString = projString.replace('STM32L475VG','STM32L432KC') out.write(projString) out.close() gen_workspace(target)