Skip to content

Commit 64d9665

Browse files
authored
Merge pull request #2833 from sarahmarshy/eclipse-ref
[Exporters] Add support for Eclipse Export
2 parents ddc823a + 3cf4d02 commit 64d9665

File tree

6 files changed

+247
-2
lines changed

6 files changed

+247
-2
lines changed

tools/export/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from tools.export import uvision4, uvision5, codered, makefile, ds5_5, iar
2323
from tools.export import emblocks, coide, kds, simplicityv3, atmelstudio
24-
from tools.export import sw4stm32, e2studio, zip
24+
from tools.export import sw4stm32, e2studio, zip, cdt
2525
from tools.export.exporters import OldLibrariesException, FailedBuildException
2626
from tools.targets import TARGET_NAMES, EXPORT_MAP, TARGET_MAP
2727

@@ -45,7 +45,10 @@
4545
'atmelstudio' : atmelstudio.AtmelStudio,
4646
'sw4stm32' : sw4stm32.Sw4STM32,
4747
'e2studio' : e2studio.E2Studio,
48-
'zip' : zip.ZIP,
48+
'eclipse_gcc_arm' : cdt.EclipseGcc,
49+
'eclipse_iar' : cdt.EclipseIAR,
50+
'eclipse_armc5' : cdt.EclipseArmc5,
51+
'zip' : zip.ZIP
4952
}
5053

5154
ERROR_MESSAGE_UNSUPPORTED_TOOLCHAIN = """

tools/export/cdt/.cproject.tmpl

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
3+
<storageModule moduleId="org.eclipse.cdt.core.settings">
4+
<cconfiguration id="0.936619452">
5+
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.936619452" moduleId="org.eclipse.cdt.core.settings" name="Default">
6+
<externalSettings/>
7+
<extensions>
8+
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
9+
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
10+
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
11+
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
12+
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
13+
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
14+
</extensions>
15+
</storageModule>
16+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
17+
<configuration buildProperties="" description="" id="0.936619452" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
18+
<folderInfo id="0.936619452." name="/" resourcePath="">
19+
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.957782855" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
20+
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.957782855.1870418474" name=""/>
21+
<builder arguments="-j" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.1415080330" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
22+
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.445325914" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
23+
<tool id="org.eclipse.cdt.build.core.settings.holder.302788810" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
24+
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1008027188" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
25+
{% for p in include_paths %}
26+
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/{{p}}}&quot;"/>
27+
{% endfor %}
28+
</option>
29+
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1670933615" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
30+
{% for symbol in asm_symbols %}
31+
<listOptionValue builtIn="false" value="{{symbol}}"/>
32+
{% endfor %}
33+
</option>
34+
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.775336684" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
35+
</tool>
36+
<tool id="org.eclipse.cdt.build.core.settings.holder.162714252" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
37+
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1406944528" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
38+
{% for p in include_paths %}
39+
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/{{p}}}&quot;"/>
40+
{% endfor %}
41+
</option>
42+
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.496389156" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
43+
{% for symbol in c_symbols %}
44+
<listOptionValue builtIn="false" value="{{symbol}}"/>
45+
{% endfor %}
46+
</option>
47+
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.869095164" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
48+
</tool>
49+
<tool id="org.eclipse.cdt.build.core.settings.holder.460204758" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
50+
<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.867151072" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
51+
{% for p in include_paths %}
52+
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/{{p}}}&quot;"/>
53+
{% endfor %}
54+
</option>
55+
<option id="org.eclipse.cdt.build.core.settings.holder.symbols.1395532696" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
56+
{% for symbol in c_symbols %}
57+
<listOptionValue builtIn="false" value="{{symbol}}"/>
58+
{% endfor %}
59+
</option>
60+
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1704200665" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
61+
</tool>
62+
</toolChain>
63+
</folderInfo>
64+
</configuration>
65+
</storageModule>
66+
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
67+
</cconfiguration>
68+
</storageModule>
69+
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
70+
<project id="{{name}}.null.1423711414" name="{{name}}"/>
71+
</storageModule>
72+
<storageModule moduleId="scannerConfiguration">
73+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
74+
<scannerConfigBuildInfo instanceId="0.936619452">
75+
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
76+
</scannerConfigBuildInfo>
77+
</storageModule>
78+
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
79+
<storageModule moduleId="refreshScope" versionNumber="2">
80+
<configuration configurationName="Default">
81+
<resource resourceType="PROJECT" workspacePath="/mbed-os-example-blinky"/>
82+
</configuration>
83+
</storageModule>
84+
</cproject>

tools/export/cdt/.project.tmpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>{{name}}</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
<buildCommand>
15+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
16+
<triggers>full,incremental,</triggers>
17+
<arguments>
18+
</arguments>
19+
</buildCommand>
20+
</buildSpec>
21+
<natures>
22+
<nature>org.eclipse.cdt.core.cnature</nature>
23+
<nature>org.eclipse.cdt.core.ccnature</nature>
24+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
25+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
26+
</natures>
27+
</projectDescription>

tools/export/cdt/__init__.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from os.path import join, exists, realpath, relpath, basename
2+
from os import makedirs
3+
4+
from tools.export.makefile import Makefile, GccArm, Armc5, IAR
5+
6+
class Eclipse(Makefile):
7+
"""Generic Eclipse project. Intended to be subclassed by classes that
8+
specify a type of Makefile.
9+
"""
10+
def generate(self):
11+
"""Generate Makefile, .cproject & .project Eclipse project file,
12+
py_ocd_settings launch file, and software link .p2f file
13+
"""
14+
super(Eclipse, self).generate()
15+
ctx = {
16+
'name': self.project_name,
17+
'elf_location': join('.build',self.project_name)+'.elf',
18+
'c_symbols': self.toolchain.get_symbols(),
19+
'asm_symbols': self.toolchain.get_symbols(True),
20+
'target': self.target,
21+
'include_paths': self.resources.inc_dirs,
22+
'load_exe': str(self.LOAD_EXE).lower()
23+
}
24+
25+
if not exists(join(self.export_dir,'eclipse-extras')):
26+
makedirs(join(self.export_dir,'eclipse-extras'))
27+
28+
29+
self.gen_file('cdt/pyocd_settings.tmpl', ctx,
30+
join('eclipse-extras',self.target+'_pyocd_settings.launch'))
31+
self.gen_file('cdt/necessary_software.tmpl', ctx,
32+
join('eclipse-extras','necessary_software.p2f'))
33+
34+
cproj = relpath('.cproject',self.export_dir)
35+
self.gen_file('cdt/.cproject.tmpl', ctx,
36+
cproj)
37+
proj = relpath('.project',self.export_dir)
38+
self.gen_file('cdt/.project.tmpl', ctx,
39+
proj)
40+
41+
42+
class EclipseGcc(Eclipse, GccArm):
43+
LOAD_EXE = True
44+
45+
class EclipseArmc5(Eclipse, Armc5):
46+
LOAD_EXE = False
47+
48+
class EclipseIAR(Eclipse, IAR):
49+
LOAD_EXE = True
50+
51+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
<?p2f version='1.0.0'?>
3+
<p2f version='1.0.0'>
4+
<ius size='1'>
5+
<iu id='ilg.gnuarmeclipse.debug.gdbjtag.pyocd.feature.group' name='GNU ARM C/C++ PyOCD Debugging' version='1.1.1.201606210758'>
6+
<repositories size='1'>
7+
<repository location='http://gnuarmeclipse.sourceforge.net/updates'/>
8+
</repositories>
9+
</iu>
10+
</ius>
11+
</p2f>

tools/export/cdt/pyocd_settings.tmpl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.launchConfigurationType">
3+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doContinue" value="true"/>
4+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doDebugInRam" value="false"/>
5+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doFirstReset" value="true"/>
6+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doGdbServerAllocateConsole" value="true"/>
7+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doGdbServerAllocateSemihostingConsole" value="true"/>
8+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doSecondReset" value="true"/>
9+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.doStartGdbServer" value="true"/>
10+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.enableSemihosting" value="true"/>
11+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.firstResetType" value="init"/>
12+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbClientOtherCommands" value="set mem inaccessible-by-default off"/>
13+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbClientOtherOptions" value=""/>
14+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerBoardId" value=""/>
15+
<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerBusSpeed" value="1000000"/>
16+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerConnectionAddress" value=""/>
17+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerEnableSemihosting" value="true"/>
18+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerExecutable" value="${pyocd_path}/${pyocd_executable}"/>
19+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerFlashFastVerify" value="false"/>
20+
<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerFlashMode" value="0"/>
21+
<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerGdbPortNumber" value="3333"/>
22+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerHaltAtHardFault" value="true"/>
23+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerLog" value=""/>
24+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerOther" value=""/>
25+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerOverrideTarget" value="false"/>
26+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerStepIntoInterrutps" value="false"/>
27+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerTargetName" value=""/>
28+
<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerTelnetPortNumber" value="4444"/>
29+
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.gdbServerUseGdbSyscalls" value="false"/>
30+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.otherInitCommands" value=""/>
31+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.otherRunCommands" value=""/>
32+
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.pyocd.secondResetType" value="halt"/>
33+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
34+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
35+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
36+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="GNU ARM PyOCD"/>
37+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="{{load_exe}}"/>
38+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="false"/>
39+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
40+
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="3333"/>
41+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
42+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
43+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
44+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
45+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
46+
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
47+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
48+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
49+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
50+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
51+
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
52+
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb.exe"/>
53+
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
54+
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
55+
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
56+
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
57+
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="{{elf_location}}"/>
58+
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="{{name}}"/>
59+
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
60+
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
61+
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
62+
<listEntry value="/{{name}}"/>
63+
</listAttribute>
64+
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
65+
<listEntry value="4"/>
66+
</listAttribute>
67+
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;Context string&quot;/&gt;&#13;&#10;"/>
68+
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
69+
</launchConfiguration>

0 commit comments

Comments
 (0)