Skip to content

Commit 52209c6

Browse files
committed
feat: CMake prototype for L433RCTxP.
Most CMakeLists.txt here are autogenerated: - /cores/arduino - /libraries - /variants
1 parent 6ba929e commit 52209c6

File tree

536 files changed

+4963
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

536 files changed

+4963
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include(handle_sketch)
2+
3+
handle_sketch(BareMinimum ${CMAKE_CURRENT_BINARY_DIR}/BareMinimum.map ./BareMinimum.ino)
4+
5+
elf2bin(bin BareMinimum)
6+
elf2hex(hex BareMinimum)
7+
8+
option(GRAPHING OFF "")
9+
if (${GRAPHING})
10+
incgv(incntr.gv inctr.gv BareMinimum)
11+
gv2svg(inc_nontr incntr.gv)
12+
gv2svg(inc_tr inctr.gv)
13+
14+
symgv(symfull.gv symsummary.gv ${CMAKE_CURRENT_BINARY_DIR}/BareMinimum.map)
15+
gv2svg(symfull symfull.gv)
16+
gv2svg(symsummary symsummary.gv)
17+
endif()

CI/update/cmake_core.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
import sys
3+
from pathlib import Path
4+
5+
from jinja2 import Environment, FileSystemLoader
6+
7+
if len(sys.argv) != 2 :
8+
print("Usage: cmake_core.py <.../cores/arduino>")
9+
print("Generates a CMakeLists.txt describing a core")
10+
print("The resulting static library will be named \"core\".")
11+
12+
13+
SOURCEFILE_EXTS = (".c", ".cpp", ".S")
14+
15+
rootdir = Path(sys.argv[1]).resolve()
16+
script_path = Path(__file__).parent.resolve()
17+
templates_dir = script_path / "templates"
18+
j2_env = Environment(
19+
loader=FileSystemLoader(str(templates_dir)), trim_blocks=True, lstrip_blocks=True
20+
)
21+
cmake_template = j2_env.get_template("CMakeLists.txt")
22+
23+
sources = [
24+
file.relative_to(rootdir)
25+
for file in rootdir.rglob("*")
26+
if file.is_file() and file.suffix in SOURCEFILE_EXTS
27+
]
28+
29+
with open(rootdir / "CMakeLists.txt", "w") as outfile :
30+
outfile.write(cmake_template.render(
31+
target="core",
32+
objlib=False,
33+
sources=sources,
34+
includedir=None,
35+
))

CI/update/cmake_libs.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
import sys
3+
from pathlib import Path
4+
5+
from jinja2 import Environment, FileSystemLoader
6+
7+
if len(sys.argv) != 2 :
8+
print("Usage: cmake_libs.py <.../libraries>")
9+
print("Generates a CMakeLists.txt describing a library")
10+
print("The resulting object library will be named like the folder.")
11+
12+
13+
SOURCEFILE_EXTS = (".c", ".cpp", ".S", )
14+
15+
rootdir = Path(sys.argv[1]).resolve()
16+
script_path = Path(__file__).parent.resolve()
17+
templates_dir = script_path / "templates"
18+
j2_env = Environment(
19+
loader=FileSystemLoader(str(templates_dir)), trim_blocks=True, lstrip_blocks=True
20+
)
21+
cmake_template = j2_env.get_template("CMakeLists.txt")
22+
23+
if not (rootdir.exists() and rootdir.name == "libraries") :
24+
print(f"Invalid variant folder : {rootdir}")
25+
exit()
26+
27+
for lib in rootdir.iterdir() :
28+
# technically several variants may be gathered in the same folder
29+
if not lib.is_dir() :
30+
continue
31+
32+
sources = [
33+
file.relative_to(lib)
34+
for file in (lib / "src").rglob("*")
35+
if file.is_file() and file.suffix in SOURCEFILE_EXTS
36+
]
37+
38+
with open(lib / "CMakeLists.txt", "w") as outfile :
39+
outfile.write(cmake_template.render(
40+
target=lib.name,
41+
objlib=True,
42+
sources=sources,
43+
includedir=(lib / "src").relative_to(lib),
44+
))

CI/update/cmake_variant.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
import sys
3+
from pathlib import Path
4+
5+
from jinja2 import Environment, FileSystemLoader
6+
7+
if len(sys.argv) != 2 :
8+
print("Usage: cmake_variant.py <.../variants>")
9+
print("Generates a CMakeLists.txt describing a variant folder")
10+
print("The resulting static library will be named \"variant\".")
11+
12+
13+
SOURCEFILE_EXTS = (".c", ".cpp", ".S")
14+
15+
rootdir = Path(sys.argv[1]).resolve()
16+
script_path = Path(__file__).parent.resolve()
17+
templates_dir = script_path / "templates"
18+
j2_env = Environment(
19+
loader=FileSystemLoader(str(templates_dir)), trim_blocks=True, lstrip_blocks=True
20+
)
21+
cmake_template = j2_env.get_template("CMakeLists.txt")
22+
23+
if not (rootdir.exists() and rootdir.name == "variants") :
24+
print(f"Invalid variant folder : {rootdir}")
25+
exit()
26+
27+
for family in rootdir.iterdir() :
28+
if not family.is_dir() :
29+
continue
30+
for variant in family.iterdir() :
31+
# technically several variants may be gathered in the same folder
32+
if not variant.is_dir() :
33+
continue
34+
35+
sources = [
36+
file.relative_to(variant)
37+
for file in variant.iterdir()
38+
if file.is_file() and file.suffix in SOURCEFILE_EXTS
39+
]
40+
41+
with open(variant / "CMakeLists.txt", "w") as outfile :
42+
# I'd gladly name the target something less generic;
43+
# if only the variant folder were a valid identifier...
44+
outfile.write(cmake_template.render(
45+
target="variant",
46+
objlib=False,
47+
sources=sources,
48+
includedir=None,
49+
))

CI/update/templates/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
add_library({{ target }}{{" OBJECT" if objlib}} EXCLUDE_FROM_ALL
3+
{% for file in sources %}
4+
{{ file }}
5+
{% endfor %}
6+
)
7+
8+
{% if includedir %}
9+
target_include_directories({{ target }} PUBLIC
10+
{{ includedir }}
11+
)
12+
{% endif %}

0 commit comments

Comments
 (0)