|
19 | 19 | # Default paths to Mercurial and Git
|
20 | 20 | hg_cmd = 'hg'
|
21 | 21 | git_cmd = 'git'
|
22 |
| -ver = '0.3.2' |
| 22 | +ver = '0.4.0' |
23 | 23 |
|
24 | 24 | ignores = [
|
25 | 25 | # Version control folders
|
@@ -1842,6 +1842,49 @@ def default_(name, value=None):
|
1842 | 1842 | program.set_cfg(var, value)
|
1843 | 1843 | action('%s now set as default %s in program "%s"' % (value, name, program.name))
|
1844 | 1844 |
|
| 1845 | +# 'config' command (calls into tools/get_config.py) |
| 1846 | +@subcommand('config', |
| 1847 | + dict(name=['-t', '--toolchain'], help='Compile toolchain. Example: ARM, uARM, GCC_ARM, IAR'), |
| 1848 | + dict(name=['-m', '--mcu'], help='Compile target. Example: K64F, NUCLEO_F401RE, NRF51822...'), |
| 1849 | + dict(name='--source', action='append', help='Source directory. Default: . (current dir)'), |
| 1850 | + dict(name='--prefix', action='append', help='Restrict listing to parameters that have this prefix'), |
| 1851 | + help='Compile program using the native mbed OS build system.') |
| 1852 | +def config(toolchain=None, mcu=None, source=False, prefix=None): |
| 1853 | + # Find the root of the program |
| 1854 | + program = Program(os.getcwd(), True) |
| 1855 | + # Remember the original path. this is needed for compiling only the libraries and tests for the current folder. |
| 1856 | + orig_path = os.getcwd() |
| 1857 | + |
| 1858 | + with cd(program.path): |
| 1859 | + mbed_tools_path = program.get_tools_dir() |
| 1860 | + if not mbed_tools_path: |
| 1861 | + error('The mbed tools were not found in "%s". \n Run `mbed deploy` to install dependencies and tools. ' % program.path, -1) |
| 1862 | + tools_dir = os.path.abspath(mbed_tools_path) |
| 1863 | + |
| 1864 | + if not os.path.isfile(os.path.join(tools_dir, 'get_config.py')): |
| 1865 | + error("'get_config_py' not found in tools/. Please update your mbed-os clone.", -1) |
| 1866 | + |
| 1867 | + target = mcu if mcu else program.get_cfg('TARGET') |
| 1868 | + if target is None: |
| 1869 | + error('Please specify compile target using the -m switch or set default target using command "target"', 1) |
| 1870 | + |
| 1871 | + tchain = toolchain if toolchain else program.get_cfg('TOOLCHAIN') |
| 1872 | + if tchain is None: |
| 1873 | + error('Please specify compile toolchain using the -t switch or set default toolchain using command "toolchain"', 1) |
| 1874 | + |
| 1875 | + env = os.environ.copy() |
| 1876 | + env['PYTHONPATH'] = os.path.abspath(program.path) |
| 1877 | + |
| 1878 | + if not source or len(source) == 0: |
| 1879 | + source = [os.path.relpath(program.path, orig_path)] |
| 1880 | + |
| 1881 | + popen(['python', os.path.join(tools_dir, 'get_config.py')] |
| 1882 | + + ['-t', tchain, '-m', target] |
| 1883 | + + list(chain.from_iterable(izip(repeat('--source'), source))) |
| 1884 | + + (['-v'] if verbose else []) |
| 1885 | + + (list(chain.from_iterable(izip(repeat('--prefix'), prefix))) if prefix else []), |
| 1886 | + env=env) |
| 1887 | + |
1845 | 1888 | # Parse/run command
|
1846 | 1889 | if len(sys.argv) <= 1:
|
1847 | 1890 | parser.print_help()
|
|
0 commit comments