@@ -2022,30 +2022,46 @@ def test_(toolchain=None, mcu=None, compile_list=False, run_list=False, compile_
2022
2022
2023
2023
# Export command
2024
2024
@subcommand ('export' ,
2025
- dict (name = ['-i' , '--ide' ], help = 'IDE to create project files for. Example: UVISION,DS5, IAR' , required = True ),
2025
+ dict (name = ['-i' , '--ide' ], help = 'IDE to create project files for. Example: UVISION4, UVISION5, GCC_ARM, IAR, COIDE ' , required = True ),
2026
2026
dict (name = ['-m' , '--mcu' ], help = 'Export for target MCU. Example: K64F, NUCLEO_F401RE, NRF51822...' ),
2027
+ dict (name = '--source' , action = 'append' , help = 'Source directory. Default: . (current dir)' ),
2028
+ dict (name = ['-c' , '--clean' ], action = 'store_true' , help = 'Clean the build directory before compiling' ),
2029
+ dict (name = ['-S' , '--supported' ], dest = 'supported' , action = 'store_true' , help = 'Shows supported matrix of targets and toolchains' ),
2027
2030
help = 'Generate an IDE project' ,
2028
2031
description = (
2029
2032
"Generate IDE project files for the current program." ))
2030
- def export (ide = None , mcu = None ):
2033
+ def export (ide = None , mcu = None , source = False , clean = False , supported = False ):
2031
2034
# Gather remaining arguments
2032
2035
args = remainder
2033
2036
# Find the root of the program
2034
2037
program = Program (os .getcwd (), True )
2038
+ # Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
2039
+ orig_path = os .getcwd ()
2035
2040
# Change directories to the program root to use mbed OS tools
2036
2041
with cd (program .path ):
2037
2042
tools_dir = program .get_tools ()
2038
- target = program .get_mcu (mcu )
2039
- macros = program .get_macros ()
2040
-
2041
2043
env = os .environ .copy ()
2042
2044
env ['PYTHONPATH' ] = os .path .abspath (program .path )
2043
2045
2046
+ if supported :
2044
2047
popen (['python' , '-u' , os .path .join (tools_dir , 'project.py' )]
2045
- + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
2046
- + ['-i' , ide , '-m' , target , '--source=%s' % program .path ]
2047
- + args ,
2048
+ + (['-S' ] if supported else []) + (['-v' ] if very_verbose else []),
2048
2049
env = env )
2050
+ return
2051
+
2052
+ target = program .get_mcu (mcu )
2053
+ macros = program .get_macros ()
2054
+
2055
+ if not source or len (source ) == 0 :
2056
+ source = [os .path .relpath (program .path , orig_path )]
2057
+
2058
+ popen (['python' , '-u' , os .path .join (tools_dir , 'project.py' )]
2059
+ + list (chain .from_iterable (izip (repeat ('-D' ), macros )))
2060
+ + ['-i' , ide .lower (), '-m' , target ]
2061
+ + (['-c' ] if clean else [])
2062
+ + list (chain .from_iterable (izip (repeat ('--source' ), source )))
2063
+ + args ,
2064
+ env = env )
2049
2065
2050
2066
2051
2067
# Test command
0 commit comments