Changed library type to object and fixed duplication of call to my_main
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user