@@ -2433,6 +2433,20 @@ def status_(ignore=False):
24332433 status_ (ignore )
24342434
24352435
2436+ # Helper function for compile and test subcommands
2437+ def _safe_append_profile_to_build_path (build_path , profile ):
2438+ if profile :
2439+ # profile is (or can be) a list, so just get the first element
2440+ if not isinstance (profile , basestring ):
2441+ profile = profile [0 ]
2442+
2443+ if profile :
2444+ profile_name_without_extension = os .path .splitext (os .path .basename (profile ))[0 ].upper ()
2445+ build_path += '-' + profile_name_without_extension
2446+
2447+ return build_path
2448+
2449+
24362450# Compile command which invokes the mbed OS native build system
24372451@subcommand ('compile' ,
24382452 dict (name = ['-t' , '--toolchain' ], help = 'Compile toolchain. Example: ARM, GCC_ARM, IAR' ),
@@ -2501,6 +2515,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
25012515 # Compile as a library (current dir is default)
25022516 if not build_path :
25032517 build_path = os .path .join (os .path .relpath (program .path , orig_path ), program .build_dir , 'libraries' , os .path .basename (orig_path ), target .upper (), tchain .upper ())
2518+ build_path = _safe_append_profile_to_build_path (build_path , profile )
25042519
25052520 popen ([python_cmd , '-u' , os .path .join (tools_dir , 'build.py' )]
25062521 + list (chain .from_iterable (zip (repeat ('-D' ), macros )))
@@ -2517,6 +2532,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
25172532 # Compile as application (root is default)
25182533 if not build_path :
25192534 build_path = os .path .join (os .path .relpath (program .path , orig_path ), program .build_dir , target .upper (), tchain .upper ())
2535+ build_path = _safe_append_profile_to_build_path (build_path , profile )
25202536
25212537 popen ([python_cmd , '-u' , os .path .join (tools_dir , 'make.py' )]
25222538 + list (chain .from_iterable (zip (repeat ('-D' ), macros )))
@@ -2611,6 +2627,7 @@ def test_(toolchain=None, target=None, compile_list=False, run_list=False, compi
26112627 build_path = build
26122628 if not build_path :
26132629 build_path = os .path .join (os .path .relpath (program .path , orig_path ), program .build_dir , 'tests' , target .upper (), tchain .upper ())
2630+ build_path = _safe_append_profile_to_build_path (build_path , profile )
26142631
26152632 if test_spec :
26162633 # Preserve path to given test spec
0 commit comments