@@ -2433,6 +2433,21 @@ def status_(ignore=False):
24332433 status_ (ignore )
24342434
24352435
2436+ # Helper function for compile subcommand
2437+ def _safe_append_profile_to_build_path (build_path , profile ):
2438+ append_str = 'DEFAULT'
2439+
2440+ if profile :
2441+ if isinstance (profile , basestring ):
2442+ append_str = profile
2443+ else :
2444+ append_str = profile [0 ]
2445+
2446+ build_path = os .path .join (build_path , os .path .splitext (os .path .basename (append_str ))[0 ].upper ())
2447+
2448+ return build_path
2449+
2450+
24362451# Compile command which invokes the mbed OS native build system
24372452@subcommand ('compile' ,
24382453 dict (name = ['-t' , '--toolchain' ], help = 'Compile toolchain. Example: ARM, GCC_ARM, IAR' ),
@@ -2501,6 +2516,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
25012516 # Compile as a library (current dir is default)
25022517 if not build_path :
25032518 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 ())
2519+ build_path = _safe_append_profile_to_build_path (build_path , profile )
25042520
25052521 popen ([python_cmd , '-u' , os .path .join (tools_dir , 'build.py' )]
25062522 + list (chain .from_iterable (zip (repeat ('-D' ), macros )))
@@ -2517,6 +2533,7 @@ def compile_(toolchain=None, target=None, profile=False, compile_library=False,
25172533 # Compile as application (root is default)
25182534 if not build_path :
25192535 build_path = os .path .join (os .path .relpath (program .path , orig_path ), program .build_dir , target .upper (), tchain .upper ())
2536+ build_path = _safe_append_profile_to_build_path (build_path , profile )
25202537
25212538 popen ([python_cmd , '-u' , os .path .join (tools_dir , 'make.py' )]
25222539 + list (chain .from_iterable (zip (repeat ('-D' ), macros )))
0 commit comments