From d2bd93e8d530d8d960ae310495d9dec6ce7bd739 Mon Sep 17 00:00:00 2001 From: Diogo Diniz Date: Thu, 22 Jan 2026 14:52:09 +0000 Subject: [PATCH] fix: Library type is now object and fixed duplication of call to my_main --- mx_convert/mx_convert.py | 8 +++----- pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mx_convert/mx_convert.py b/mx_convert/mx_convert.py index 4b032ee..15bbbd5 100644 --- a/mx_convert/mx_convert.py +++ b/mx_convert/mx_convert.py @@ -3,7 +3,6 @@ from shutil import rmtree from sys import argv from argparse import ArgumentParser, Namespace import tomllib as toml -import re MX_DISCARD_PATHS = [ "cmake", @@ -74,7 +73,7 @@ def recurse_cmakelists(path: Path): if has_headers: lines.append("target_include_directories(%s PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})"%(CMAKE_TARGET)) if len(sources) != 0: - lines.append("target_sources(%s PUBLIC"%(CMAKE_TARGET)) + lines.append("target_sources(%s PRIVATE"%(CMAKE_TARGET)) lines += ["\t%s"%(src.name) for src in sources] lines.append(")") lines += ["add_subdirectory(%s)"%(directory.name) for directory in dirs] @@ -92,10 +91,9 @@ def root_cmakelists(path: Path): lists_path = path / "CMakeLists.txt" # Define custom libraries - lines.append("add_library(%s STATIC)"%(CMAKE_TARGET)) + lines.append("add_library(%s OBJECT)"%(CMAKE_TARGET)) lines.append("target_compile_definitions(%s PRIVATE ${COMPILER_DEFINES})"%(CMAKE_TARGET)) lines.append("target_compile_options(%s PRIVATE -Os -ffunction-sections -fdata-sections -g -flto)"%(CMAKE_TARGET)) - lines.append("target_link_options(%s PRIVATE -T ${LINKER_SCRIPT} -Wl,--gc-sections -flto)"%(CMAKE_TARGET)) # Read previously generated contents with open(lists_path, "r") as _if: @@ -131,7 +129,7 @@ def call_my_main(path: Path): with open(main_c, "r") as _if: content = _if.read() - patched = content.replace("/* USER CODE BEGIN PFP */", "/* USER CODE BEGIN PFP */\nvoid my_main();").replace("/* USER CODE BEGIN WHILE */", "/* USER CODE BEGIN WHILE */\nmy_main();") + patched = content.replace("/* USER CODE BEGIN PFP */", "/* USER CODE BEGIN PFP */\nvoid my_main();").replace("/* USER CODE BEGIN WHILE */\n while (1)", "/* USER CODE BEGIN WHILE */\nmy_main();\n while (1)") with open(main_c, "w") as of: of.write(patched) diff --git a/pyproject.toml b/pyproject.toml index ee7cbf5..e9910c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "mx_convert" -version = "0.5.4" +version = "0.5.5" description = "A Cube MX projct conversion helper" authors = [{ name = "Didas72" }] dependencies = []