@@ -1722,13 +1722,11 @@ def get_target(self, target=None):
1722
1722
target_cfg = self .get_cfg ('TARGET' )
1723
1723
target = target if target else target_cfg
1724
1724
1725
- if target and (target .lower () == 'detect' or target .lower () == 'auto' ):
1725
+ if not target or (target .lower () == 'detect' or target .lower () == 'auto' ):
1726
1726
detected = self .detect_single_target ()
1727
1727
if detected :
1728
1728
target = detected ['name' ]
1729
1729
1730
- if target is None :
1731
- error ("Please specify target using the -m switch or set default target using command \" mbed target\" " , 1 )
1732
1730
return target
1733
1731
1734
1732
def get_toolchain (self , toolchain = None ):
@@ -1770,7 +1768,7 @@ def detect_single_target(self, info=None):
1770
1768
elif len (targets ) > 1 :
1771
1769
error ("Multiple targets were detected.\n Only 1 target board should be connected to your system." , 1 )
1772
1770
elif len (targets ) == 0 :
1773
- error ("No targets were detected.\n Please make sure a target board is connected to this system." , 1 )
1771
+ error ("No targets were detected.\n Please make sure a target board is connected to this system.\n Alternatively, you can specify target using the -m switch or set default target using command \" mbed target \" " , 1 )
1774
1772
else :
1775
1773
action ("Detected \" %s\" connected to \" %s\" and using com port \" %s\" " % (targets [0 ]['name' ], targets [0 ]['mount' ], targets [0 ]['serial' ]))
1776
1774
info = targets [0 ]
@@ -2618,6 +2616,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
2618
2616
program .check_requirements (True )
2619
2617
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
2620
2618
orig_path = getcwd ()
2619
+ orig_target = target
2621
2620
2622
2621
with cd (program .path ):
2623
2622
tools_dir = os .path .abspath (program .get_tools ())
@@ -2724,7 +2723,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
2724
2723
if not connected :
2725
2724
error ("The target board you compiled for is not connected to your system.\n Please reconnect it and retry the last command." , 1 )
2726
2725
2727
- program .set_defaults (target = target , toolchain = tchain )
2726
+ program .set_defaults (target = orig_target , toolchain = tchain )
2728
2727
2729
2728
2730
2729
# Test command
@@ -2787,6 +2786,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False,
2787
2786
2788
2787
# Save original working directory
2789
2788
orig_path = getcwd ()
2789
+ orig_target = target
2790
2790
2791
2791
macros = program .get_macros ()
2792
2792
tools_dir = program .get_tools ()
@@ -2940,7 +2940,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False,
2940
2940
if run_only or build_and_run_tests :
2941
2941
popen (icetea_command )
2942
2942
2943
- program .set_defaults (target = target , toolchain = tchain )
2943
+ program .set_defaults (target = orig_target , toolchain = tchain )
2944
2944
2945
2945
2946
2946
# device management commands
@@ -3016,6 +3016,7 @@ def export(ide=None, target=None, source=False, clean=False, supported=False, ap
3016
3016
program .check_requirements (True )
3017
3017
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
3018
3018
orig_path = getcwd ()
3019
+ orig_target = target
3019
3020
# Change directories to the program root to use mbed OS tools
3020
3021
with cd (program .path ):
3021
3022
tools_dir = program .get_tools ()
@@ -3050,7 +3051,7 @@ def export(ide=None, target=None, source=False, clean=False, supported=False, ap
3050
3051
+ args ,
3051
3052
env = env )
3052
3053
3053
- program .set_defaults (target = target )
3054
+ program .set_defaults (target = orig_target )
3054
3055
3055
3056
3056
3057
# Detect command
0 commit comments