@@ -2433,6 +2433,20 @@ def status_(ignore=False):
2433
2433
status_ (ignore )
2434
2434
2435
2435
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
+
2436
2450
# Compile command which invokes the mbed OS native build system
2437
2451
@subcommand ('compile' ,
2438
2452
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,
2501
2515
# Compile as a library (current dir is default)
2502
2516
if not build_path :
2503
2517
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 )
2504
2519
2505
2520
popen ([python_cmd , '-u' , os .path .join (tools_dir , 'build.py' )]
2506
2521
+ list (chain .from_iterable (zip (repeat ('-D' ), macros )))
@@ -2517,6 +2532,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
2517
2532
# Compile as application (root is default)
2518
2533
if not build_path :
2519
2534
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 )
2520
2536
2521
2537
popen ([python_cmd , '-u' , os .path .join (tools_dir , 'make.py' )]
2522
2538
+ 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
2611
2627
build_path = build
2612
2628
if not build_path :
2613
2629
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 )
2614
2631
2615
2632
if test_spec :
2616
2633
# Preserve path to given test spec
0 commit comments