Skip to content

Commit 020c195

Browse files
LDong-ArmPatater
authored andcommitted
configure: Add --profile for profile selection
As `mbed-tools compile` supports `-b`, `--profile` for selecting a build profile, the same should exist for `mbed-tools configure` as users may want to manually run the build step using `cmake` in some cases. This commit implements it and supplies a test. Note: This only affects the build directory - it has no impact on the contents of `mbed_config.cmake`. To actually build an application with a profile, a user needs to either run `mbed-tools compile` with `--profile <profile>`, or manually run `cmake` with `-DCMAKE_BUILD_TYPE=<profile>` after `mbed-tools configure`. Fixes #262
1 parent 90c7cb3 commit 020c195

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

news/262.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `-b`, `--profile` to the `configure` subcommand for specifying build profile.

src/mbed_tools/cli/configure.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
help="The toolchain you are using to build your app.",
2626
)
2727
@click.option("-m", "--mbed-target", required=True, help="A build target for an Mbed-enabled device, eg. K64F")
28+
@click.option("-b", "--profile", default="develop", help="The build type (release, develop or debug).")
2829
@click.option("-o", "--output-dir", type=click.Path(), default=None, help="Path to output directory.")
2930
@click.option(
3031
"-p",
@@ -42,6 +43,7 @@
4243
def configure(
4344
toolchain: str,
4445
mbed_target: str,
46+
profile: str,
4547
program_path: str,
4648
mbed_os_path: str,
4749
output_dir: str,
@@ -61,12 +63,13 @@ def configure(
6163
custom_targets_json: the path to custom_targets.json
6264
toolchain: the toolchain you are using (eg. GCC_ARM, ARM)
6365
mbed_target: the target you are building for (eg. K64F)
66+
profile: The Mbed build profile (debug, develop or release).
6467
program_path: the path to the local Mbed program
6568
mbed_os_path: the path to the local Mbed OS directory
6669
output_dir: the path to the output directory
6770
app_config: the path to the application configuration file
6871
"""
69-
cmake_build_subdir = pathlib.Path(mbed_target.upper(), "develop", toolchain.upper())
72+
cmake_build_subdir = pathlib.Path(mbed_target.upper(), profile.lower(), toolchain.upper())
7073
if mbed_os_path is None:
7174
program = MbedProgram.from_existing(pathlib.Path(program_path), cmake_build_subdir)
7275
else:

tests/cli/test_configure.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,23 @@ def test_app_config_used_when_passed(self, program, generate_config):
5959

6060
generate_config.assert_called_once_with("K64F", "GCC_ARM", program)
6161
self.assertEqual(program.files.app_config_file, app_config_path)
62+
63+
@mock.patch("mbed_tools.cli.configure.generate_config")
64+
@mock.patch("mbed_tools.cli.configure.MbedProgram")
65+
def test_profile_used_when_passed(self, program, generate_config):
66+
test_program = program.from_existing()
67+
program.reset_mock() # clear call count from previous line
68+
69+
toolchain = "gcc_arm"
70+
target = "k64f"
71+
profile = "release"
72+
73+
CliRunner().invoke(
74+
configure, ["-t", toolchain, "-m", target, "--profile", profile]
75+
)
76+
77+
program.from_existing.assert_called_once_with(
78+
pathlib.Path("."),
79+
pathlib.Path(target.upper(), profile, toolchain.upper())
80+
)
81+
generate_config.assert_called_once_with("K64F", "GCC_ARM", test_program)

0 commit comments

Comments
 (0)