Skip to content

Commit 1faf380

Browse files
committed
Add default target/toolchain during 'mbed compile' if no defaults are set #207
1 parent 8c90be2 commit 1faf380

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mbed/mbed.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,15 +1239,21 @@ def get_tools(self):
12391239
return mbed_tools_path
12401240

12411241
def get_mcu(self, mcu=None):
1242-
target = mcu if mcu else self.get_cfg('TARGET')
1242+
target_cfg = self.get_cfg('TARGET')
1243+
target = mcu if mcu else target_cfg
12431244
if target is None:
12441245
error('Please specify compile target using the -m switch or set default target using command "target"', 1)
1246+
elif not target_cfg:
1247+
self.set_cfg('TARGET', target)
12451248
return target
12461249

12471250
def get_toolchain(self, toolchain=None):
1248-
tchain = toolchain if toolchain else self.get_cfg('TOOLCHAIN')
1251+
toolchain_cfg = self.get_cfg('TOOLCHAIN')
1252+
tchain = toolchain if toolchain else toolchain_cfg
12491253
if tchain is None:
12501254
error('Please specify compile toolchain using the -t switch or set default toolchain using command "toolchain"', 1)
1255+
elif not toolchain_cfg:
1256+
self.set_cfg('TOOLCHAIN', tchain)
12511257
return tchain
12521258

12531259
def get_macros(self):

0 commit comments

Comments
 (0)