Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/262.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `-b`, `--profile` to the `configure` subcommand for specifying build profile.
5 changes: 4 additions & 1 deletion src/mbed_tools/cli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
help="The toolchain you are using to build your app.",
)
@click.option("-m", "--mbed-target", required=True, help="A build target for an Mbed-enabled device, eg. K64F")
@click.option("-b", "--profile", default="develop", help="The build type (release, develop or debug).")
@click.option("-o", "--output-dir", type=click.Path(), default=None, help="Path to output directory.")
@click.option(
"-p",
Expand All @@ -42,6 +43,7 @@
def configure(
toolchain: str,
mbed_target: str,
profile: str,
program_path: str,
mbed_os_path: str,
output_dir: str,
Expand All @@ -61,12 +63,13 @@ def configure(
custom_targets_json: the path to custom_targets.json
toolchain: the toolchain you are using (eg. GCC_ARM, ARM)
mbed_target: the target you are building for (eg. K64F)
profile: The Mbed build profile (debug, develop or release).
program_path: the path to the local Mbed program
mbed_os_path: the path to the local Mbed OS directory
output_dir: the path to the output directory
app_config: the path to the application configuration file
"""
cmake_build_subdir = pathlib.Path(mbed_target.upper(), "develop", toolchain.upper())
cmake_build_subdir = pathlib.Path(mbed_target.upper(), profile.lower(), toolchain.upper())
if mbed_os_path is None:
program = MbedProgram.from_existing(pathlib.Path(program_path), cmake_build_subdir)
else:
Expand Down
23 changes: 23 additions & 0 deletions tests/cli/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,29 @@ def test_app_config_used_when_passed(
generate_config.assert_called_once_with(target.upper(), toolchain.upper(), program)
self.assertEqual(program.files.app_config_file, app_config_path)

def test_profile_used_when_passed(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

self, generate_config, mbed_program, build_project, generate_build_system
):
program = mbed_program.from_existing()
mbed_program.reset_mock() # clear call count from previous line

with mock_project_directory(program, mbed_config_exists=True, build_tree_exists=True):
generate_config.return_value = [mock.MagicMock(), mock.MagicMock()]

toolchain = "gcc_arm"
target = "k64f"
profile = "release"

runner = CliRunner()
runner.invoke(build, ["-t", toolchain, "-m", target, "--profile", profile])

mbed_program.from_existing.assert_called_once_with(
pathlib.Path(os.getcwd()),
pathlib.Path(target.upper(), profile, toolchain.upper())
)
generate_config.assert_called_once_with(target.upper(), toolchain.upper(), program)
generate_build_system.assert_called_once_with(program.root, program.files.cmake_build_dir, profile)

def test_build_folder_removed_when_clean_flag_passed(
self, generate_config, mbed_program, build_project, generate_build_system
):
Expand Down
20 changes: 20 additions & 0 deletions tests/cli/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,23 @@ def test_app_config_used_when_passed(self, program, generate_config):

generate_config.assert_called_once_with("K64F", "GCC_ARM", program)
self.assertEqual(program.files.app_config_file, app_config_path)

@mock.patch("mbed_tools.cli.configure.generate_config")
@mock.patch("mbed_tools.cli.configure.MbedProgram")
def test_profile_used_when_passed(self, program, generate_config):
test_program = program.from_existing()
program.reset_mock() # clear call count from previous line

toolchain = "gcc_arm"
target = "k64f"
profile = "release"

CliRunner().invoke(
configure, ["-t", toolchain, "-m", target, "--profile", profile]
)

program.from_existing.assert_called_once_with(
pathlib.Path("."),
pathlib.Path(target.upper(), profile, toolchain.upper())
)
generate_config.assert_called_once_with("K64F", "GCC_ARM", test_program)