@@ -1860,6 +1860,50 @@ def compile(toolchain=None, mcu=None, source=False, build=False, clean=False, su
1860
1860
env = env )
1861
1861
1862
1862
1863
+ # 'config' command (calls into tools/get_config.py)
1864
+ @subcommand ('config' ,
1865
+ dict (name = ['-t' , '--toolchain' ], help = 'Compile toolchain. Example: ARM, uARM, GCC_ARM, IAR' ),
1866
+ dict (name = ['-m' , '--mcu' ], help = 'Compile target. Example: K64F, NUCLEO_F401RE, NRF51822...' ),
1867
+ dict (name = '--source' , action = 'append' , help = 'Source directory. Default: . (current dir)' ),
1868
+ dict (name = '--prefix' , action = 'append' , help = 'Restrict listing to parameters that have this prefix' ),
1869
+ help = 'Display program\' s compile configuration.' )
1870
+ def config (toolchain = None , mcu = None , source = False , prefix = None ):
1871
+ # Find the root of the program
1872
+ program = Program (os .getcwd (), True )
1873
+ # Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
1874
+ orig_path = os .getcwd ()
1875
+
1876
+ with cd (program .path ):
1877
+ mbed_tools_path = program .get_tools_dir ()
1878
+ if not mbed_tools_path :
1879
+ error ('The mbed tools were not found in "%s". \n Run `mbed deploy` to install dependencies and tools. ' % program .path , - 1 )
1880
+ tools_dir = os .path .abspath (mbed_tools_path )
1881
+
1882
+ if not os .path .isfile (os .path .join (tools_dir , 'get_config.py' )):
1883
+ error ("'get_config_py' not found in tools/. Please update mbed-os to get the latest tools." , - 1 )
1884
+
1885
+ target = mcu if mcu else program .get_cfg ('TARGET' )
1886
+ if target is None :
1887
+ error ('Please specify compile target using the -m switch or set default target using command "target"' , 1 )
1888
+
1889
+ tchain = toolchain if toolchain else program .get_cfg ('TOOLCHAIN' )
1890
+ if tchain is None :
1891
+ error ('Please specify compile toolchain using the -t switch or set default toolchain using command "toolchain"' , 1 )
1892
+
1893
+ env = os .environ .copy ()
1894
+ env ['PYTHONPATH' ] = os .path .abspath (program .path )
1895
+
1896
+ if not source or len (source ) == 0 :
1897
+ source = [os .path .relpath (program .path , orig_path )]
1898
+
1899
+ popen (['python' , os .path .join (tools_dir , 'get_config.py' )]
1900
+ + ['-t' , tchain , '-m' , target ]
1901
+ + list (chain .from_iterable (izip (repeat ('--source' ), source )))
1902
+ + (['-v' ] if verbose else [])
1903
+ + (list (chain .from_iterable (izip (repeat ('--prefix' ), prefix ))) if prefix else []),
1904
+ env = env )
1905
+
1906
+
1863
1907
# Test command
1864
1908
@subcommand ('test' ,
1865
1909
dict (name = ['-l' , '--list' ], dest = 'tlist' , action = 'store_true' , help = 'List all of the available tests' ),
@@ -1983,48 +2027,6 @@ def default_(name, value=None, unset=False):
1983
2027
value = g .get_cfg (var )
1984
2028
action (('%s' % value ) if value else 'No global %s set' % (name ))
1985
2029
1986
- # 'config' command (calls into tools/get_config.py)
1987
- @subcommand ('config' ,
1988
- dict (name = ['-t' , '--toolchain' ], help = 'Compile toolchain. Example: ARM, uARM, GCC_ARM, IAR' ),
1989
- dict (name = ['-m' , '--mcu' ], help = 'Compile target. Example: K64F, NUCLEO_F401RE, NRF51822...' ),
1990
- dict (name = '--source' , action = 'append' , help = 'Source directory. Default: . (current dir)' ),
1991
- dict (name = '--prefix' , action = 'append' , help = 'Restrict listing to parameters that have this prefix' ),
1992
- help = 'Display the project configuration.' )
1993
- def config (toolchain = None , mcu = None , source = False , prefix = None ):
1994
- # Find the root of the program
1995
- program = Program (os .getcwd (), True )
1996
- # Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
1997
- orig_path = os .getcwd ()
1998
-
1999
- with cd (program .path ):
2000
- mbed_tools_path = program .get_tools_dir ()
2001
- if not mbed_tools_path :
2002
- error ('The mbed tools were not found in "%s". \n Run `mbed deploy` to install dependencies and tools. ' % program .path , - 1 )
2003
- tools_dir = os .path .abspath (mbed_tools_path )
2004
-
2005
- if not os .path .isfile (os .path .join (tools_dir , 'get_config.py' )):
2006
- error ("'get_config_py' not found in tools/. Please update mbed-os to get the latest tools." , - 1 )
2007
-
2008
- target = mcu if mcu else program .get_cfg ('TARGET' )
2009
- if target is None :
2010
- error ('Please specify compile target using the -m switch or set default target using command "target"' , 1 )
2011
-
2012
- tchain = toolchain if toolchain else program .get_cfg ('TOOLCHAIN' )
2013
- if tchain is None :
2014
- error ('Please specify compile toolchain using the -t switch or set default toolchain using command "toolchain"' , 1 )
2015
-
2016
- env = os .environ .copy ()
2017
- env ['PYTHONPATH' ] = os .path .abspath (program .path )
2018
-
2019
- if not source or len (source ) == 0 :
2020
- source = [os .path .relpath (program .path , orig_path )]
2021
-
2022
- popen (['python' , os .path .join (tools_dir , 'get_config.py' )]
2023
- + ['-t' , tchain , '-m' , target ]
2024
- + list (chain .from_iterable (izip (repeat ('--source' ), source )))
2025
- + (['-v' ] if verbose else [])
2026
- + (list (chain .from_iterable (izip (repeat ('--prefix' ), prefix ))) if prefix else []),
2027
- env = env )
2028
2030
2029
2031
# Parse/run command
2030
2032
if len (sys .argv ) <= 1 :
0 commit comments