forked from RT-Thread/rt-thread
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tools] Add a draft project generator for SES.
- Loading branch information
1 parent
25ee668
commit 27ec671
Showing
3 changed files
with
144 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE CrossStudio_Project_File> | ||
<solution Name="RT-Thread" target="8" version="2"> | ||
<project Name="rtthread"> | ||
<configuration | ||
Name="Common" | ||
arm_architecture="v7M" | ||
arm_core_type="Cortex-M3" | ||
arm_endian="Little" | ||
arm_fp_abi="Soft" | ||
arm_fpu_type="None" | ||
arm_linker_heap_size="1024" | ||
arm_linker_process_stack_size="0" | ||
arm_linker_stack_size="1024" | ||
arm_linker_variant="SEGGER" | ||
arm_simulator_memory_simulation_parameter="RWX 00000000,00100000,FFFFFFFF;RWX 20000000,00010000,CDCDCDCD" | ||
arm_target_device_name="Cortex-M3" | ||
arm_target_interface_type="SWD" | ||
debug_target_connection="Simulator" | ||
link_linker_script_file="$(StudioDir)/samples/SEGGER_Flash.icf" | ||
linker_output_format="hex" | ||
linker_section_placements_segments="FLASH RX 0x00000000 0x00100000;RAM RWX 0x20000000 0x00010000" | ||
project_directory="" | ||
project_type="Executable" /> | ||
<configuration | ||
Name="Debug" | ||
arm_linker_variant="GNU" | ||
c_preprocessor_definitions="RT_USING_NEWLIB" | ||
c_user_include_directories="." | ||
gcc_entry_point="Reset_Handler" | ||
link_linker_script_file="$(ProjectDir)/stm32_rom.ld" | ||
link_use_linker_script_file="Yes" | ||
linker_output_format="bin" /> | ||
</project> | ||
<configuration | ||
Name="Debug" | ||
c_preprocessor_definitions="DEBUG" | ||
gcc_debugging_level="Level 3" | ||
gcc_optimization_level="None" /> | ||
<configuration | ||
Name="Release" | ||
c_preprocessor_definitions="NDEBUG" | ||
gcc_debugging_level="None" | ||
gcc_omit_frame_pointer="Yes" | ||
gcc_optimization_level="Level 1" /> | ||
</solution> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# SEGGER Embedded Studio Project Generator | ||
|
||
import os | ||
import sys | ||
|
||
import xml.etree.ElementTree as etree | ||
from xml.etree.ElementTree import SubElement | ||
from utils import _make_path_relative | ||
from utils import xml_indent | ||
from utils import ProjectInfo | ||
|
||
def SDKAddGroup(parent, name, files, project_path): | ||
# don't add an empty group | ||
if len(files) == 0: | ||
return | ||
|
||
group = SubElement(parent, 'folder', attrib={'Name': name}) | ||
|
||
for f in files: | ||
fn = f.rfile() | ||
name = fn.name | ||
path = os.path.dirname(fn.abspath) | ||
|
||
basename = os.path.basename(path) | ||
path = _make_path_relative(project_path, path) | ||
elm_attr_name = os.path.join(path, name) | ||
|
||
file = SubElement(group, 'file', attrib={'file_name': elm_attr_name}) | ||
|
||
return group | ||
|
||
def SESProject(env) : | ||
target = 'project.emProject' | ||
tree = etree.parse('template.emProject') | ||
# print(etree.dump(tree.getroot())) | ||
# etree.dump(tree.getroot()) | ||
|
||
project = ProjectInfo(env) | ||
# print(project) | ||
# return | ||
|
||
project_path = os.path.abspath(env['BSP_ROOT']) | ||
script = env['project'] | ||
|
||
root = tree.getroot() | ||
out = file(target, 'w') | ||
out.write('<!DOCTYPE CrossStudio_Project_File>\n') | ||
|
||
CPPPATH = [] | ||
CPPDEFINES = [] | ||
LINKFLAGS = '' | ||
CCFLAGS = '' | ||
|
||
project_node = tree.find('project') | ||
|
||
for group in script: | ||
# print(group) | ||
|
||
group_tree = SDKAddGroup(project_node, group['name'], group['src'], project_path) | ||
|
||
# get each group's cc flags | ||
if group.has_key('CCFLAGS') and group['CCFLAGS']: | ||
if CCFLAGS: | ||
CCFLAGS += ' ' + group['CCFLAGS'] | ||
else: | ||
CCFLAGS += group['CCFLAGS'] | ||
|
||
# get each group's link flags | ||
if group.has_key('LINKFLAGS') and group['LINKFLAGS']: | ||
if LINKFLAGS: | ||
LINKFLAGS += ' ' + group['LINKFLAGS'] | ||
else: | ||
LINKFLAGS += group['LINKFLAGS'] | ||
|
||
# write include path, definitions and link flags | ||
path = ';'.join([_make_path_relative(project_path, os.path.normpath(i)) for i in project['CPPPATH']]) | ||
path = path.replace('\\', '/') | ||
defines = ';'.join(set(project['CPPDEFINES'])) | ||
|
||
node = tree.findall('project/configuration') | ||
for item in node: | ||
if item.get('c_preprocessor_definitions'): | ||
item.set('c_preprocessor_definitions', defines) | ||
|
||
if item.get('c_user_include_directories'): | ||
item.set('c_user_include_directories', path) | ||
|
||
xml_indent(root) | ||
out.write(etree.tostring(root, encoding='utf-8')) | ||
out.close() | ||
|
||
return |