Skip to content

Commit d611c0c

Browse files
committed
cmake_file: Remove unecessary function
1 parent 3aa9594 commit d611c0c

File tree

3 files changed

+12
-34
lines changed

3 files changed

+12
-34
lines changed

src/mbed_tools/build/_internal/cmake_file.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,10 @@
1414
TEMPLATE_NAME = "mbed_config.tmpl"
1515

1616

17-
def generate_mbed_config_cmake_file(
18-
mbed_target_name: str, target_build_attributes: dict, config: Config, toolchain_name: str
19-
) -> str:
20-
"""Generate the top-level CMakeLists.txt file containing the correct definitions for a build.
21-
22-
Args:
23-
mbed_target: the target the application is being built for
24-
target_build_attributes: map of target attributes
25-
program_path: the path to the local Mbed program
26-
toolchain_name: the toolchain to be used to build the application
27-
28-
Returns:
29-
A string of rendered contents for the file.
30-
"""
31-
return _render_mbed_config_cmake_template(target_build_attributes, config, toolchain_name, mbed_target_name,)
32-
33-
34-
def _render_mbed_config_cmake_template(
17+
def render_mbed_config_cmake_template(
3518
target_build_attributes: dict, config: Config, toolchain_name: str, target_name: str
3619
) -> str:
37-
"""Renders the mbed_config template with the relevant information.
20+
"""Renders the mbed_config jinja template with the target and project config settings.
3821
3922
Args:
4023
target_build_attributes: Target config object.

src/mbed_tools/build/config.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from mbed_tools.lib.json_helpers import decode_json_file
99
from mbed_tools.project import MbedProgram
1010
from mbed_tools.targets import get_target_by_name
11-
from mbed_tools.build._internal.cmake_file import generate_mbed_config_cmake_file
11+
from mbed_tools.build._internal.cmake_file import render_mbed_config_cmake_template
1212
from mbed_tools.build._internal.config.assemble_build_config import assemble_config
1313
from mbed_tools.build._internal.write_files import write_file
1414

@@ -26,7 +26,12 @@ def generate_config(target_name: str, toolchain: str, program: MbedProgram) -> p
2626
"""
2727
target_build_attributes = get_target_by_name(target_name, decode_json_file(program.mbed_os.targets_json_file))
2828
config = assemble_config(target_build_attributes, program.root, program.files.app_config_file)
29-
cmake_file_contents = generate_mbed_config_cmake_file(target_name, target_build_attributes, config, toolchain)
29+
cmake_file_contents = render_mbed_config_cmake_template(
30+
target_name=target_name,
31+
target_build_attributes=target_build_attributes,
32+
config=config,
33+
toolchain_name=toolchain,
34+
)
3035
cmake_config_file_path = program.files.cmake_config_file
3136
write_file(cmake_config_file_path.parent, cmake_config_file_path.name, cmake_file_contents)
3237
return cmake_config_file_path

tests/build/_internal/test_cmake_file.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from tests.build._internal.config.factories import ConfigFactory, SourceFactory
8-
from mbed_tools.build._internal.cmake_file import generate_mbed_config_cmake_file, _render_mbed_config_cmake_template
8+
from mbed_tools.build._internal.cmake_file import render_mbed_config_cmake_template
99
from mbed_tools.build._internal.config.config import _create_config_option
1010

1111

@@ -30,20 +30,10 @@ def fake_target():
3030
}
3131

3232

33-
class TestGenerateCMakeListsFile:
34-
def test_correct_arguments_passed(self, fake_target):
35-
config = ConfigFactory()
36-
mbed_target = "K64F"
37-
38-
result = generate_mbed_config_cmake_file(mbed_target, fake_target, config, TOOLCHAIN_NAME)
39-
40-
assert result == _render_mbed_config_cmake_template(fake_target, config, TOOLCHAIN_NAME, mbed_target,)
41-
42-
4333
class TestRendersCMakeListsFile:
4434
def test_returns_rendered_content(self, fake_target):
4535
config = ConfigFactory()
46-
result = _render_mbed_config_cmake_template(fake_target, config, TOOLCHAIN_NAME, "target_name")
36+
result = render_mbed_config_cmake_template(fake_target, config, TOOLCHAIN_NAME, "target_name")
4737

4838
for label in fake_target["labels"] + fake_target["extra_labels"]:
4939
assert label in result
@@ -66,5 +56,5 @@ def test_returns_quoted_content(self, fake_target):
6656
# Add an option whose value contains quotes to the config.
6757
_create_config_option(config, "iotc-mqtt-host", '{"mqtt.2030.ltsapis.goog", IOTC_MQTT_PORT}', source)
6858

69-
result = _render_mbed_config_cmake_template(fake_target, config, TOOLCHAIN_NAME, "target_name")
59+
result = render_mbed_config_cmake_template(fake_target, config, TOOLCHAIN_NAME, "target_name")
7060
assert '"-DMBED_CONF_IOTC_MQTT_HOST={\\"mqtt.2030.ltsapis.goog\\", IOTC_MQTT_PORT}"' in result

0 commit comments

Comments
 (0)