Skip to content

Commit 442e564

Browse files
committed
Set default toolchain and target only after successful compile/test/export execution
1 parent e29da23 commit 442e564

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

mbed/mbed.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
# Application version
38-
ver = '0.7.13'
38+
ver = '0.7.14'
3939

4040
# Default paths to Mercurial and Git
4141
hg_cmd = 'hg'
@@ -1253,27 +1253,28 @@ def get_mcu(self, mcu=None):
12531253
target = mcu if mcu else target_cfg
12541254
if target is None:
12551255
error('Please specify compile target using the -m switch or set default target using command "target"', 1)
1256-
elif not target_cfg:
1257-
self.set_cfg('TARGET', target)
12581256
return target
12591257

12601258
def get_toolchain(self, toolchain=None):
12611259
toolchain_cfg = self.get_cfg('TOOLCHAIN')
12621260
tchain = toolchain if toolchain else toolchain_cfg
12631261
if tchain is None:
12641262
error('Please specify compile toolchain using the -t switch or set default toolchain using command "toolchain"', 1)
1265-
elif not toolchain_cfg:
1266-
self.set_cfg('TOOLCHAIN', tchain)
12671263
return tchain
12681264

1265+
def set_defaults(self, target=None, toolchain=None):
1266+
if target and not self.get_cfg('TARGET'):
1267+
self.set_cfg('TARGET', target)
1268+
if toolchain and not self.get_cfg('TOOLCHAIN'):
1269+
self.set_cfg('TOOLCHAIN', toolchain)
1270+
12691271
def get_macros(self):
12701272
macros = []
12711273
if os.path.isfile('MACROS.txt'):
12721274
with open('MACROS.txt') as f:
12731275
macros = f.read().splitlines()
12741276
return macros
12751277

1276-
12771278
# Global class, used for global config
12781279
class Global(object):
12791280
def __init__(self):
@@ -1953,6 +1954,8 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
19531954
+ args,
19541955
env=env)
19551956

1957+
program.set_defaults(target=target, toolchain=tchain)
1958+
19561959

19571960
# Test command
19581961
@subcommand('test',
@@ -2033,6 +2036,8 @@ def test_(toolchain=None, mcu=None, compile_list=False, run_list=False, compile_
20332036
+ args,
20342037
env=env)
20352038

2039+
program.set_defaults(target=target, toolchain=tchain)
2040+
20362041

20372042
# Export command
20382043
@subcommand('export',
@@ -2078,6 +2083,8 @@ def export(ide=None, mcu=None, source=False, clean=False, supported=False):
20782083
+ args,
20792084
env=env)
20802085

2086+
program.set_defaults(target=target)
2087+
20812088

20822089
# Test command
20832090
@subcommand('detect',

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def read(fname):
1919
setup(
2020
name="mbed-cli",
2121
packages=["mbed"],
22-
version="0.7.13",
22+
version="0.7.14",
2323
url='http://github.com/ARMmbed/mbed-cli',
2424
author='ARM mbed',
2525
author_email='[email protected]',

0 commit comments

Comments
 (0)