Skip to content

Commit 3161aa1

Browse files
committed
more flag allowlisting
1 parent 48fb986 commit 3161aa1

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

build_circuitpython.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@
2929
# io and collections are MP modules that fit this bill
3030
MPCONFIG_FLAGS = ["ulab", "nvm", "displayio", "warnings", "alarm"]
3131

32-
ALLOW_FLAGS = {
32+
ALLOW_MODULE_FLAGS = {
3333
pathlib.Path("main.c"): ["atexit", "board", "bleio", "canio", "collections", "cyw43", "digitalio", "epaperdisplay", "io", "keypad", "memorymonitor", "microcontroller", "socketpool", "usb_hid", "watchdog", "wifi"],
3434
"supervisor/shared/usb/usb_desc.c": ["usb_midi", "usb_hid"],
3535
"supervisor/shared/micropython.c": ["atexit", "watchdog"]
3636
}
3737

38+
ALLOW_FEATURE_FLAGS = {
39+
pathlib.Path("main.c"): ["debug", "bleio_hci", "safemode_py", "status_bar", "os_getenv", "usb_keyboard_workflow", "lto", "translate_object", "ssl_mbedtls", "opt_map_lookup_cache"],
40+
}
41+
42+
ALLOW_MICROPYTHON_FLAGS = {
43+
pathlib.Path("main.c"): ["py_async_await"],
44+
}
45+
3846
# compile_circuitpython = hancho.Rule(
3947
# desc="Compile {source_files} -> {build_files}",
4048
# command="{compiler} -MMD -Wall -Werror -Wundef {cpu_flags} {module_flags} {circuitpython_flags} {port_flags} -c {source_files} -o {build_files}",
@@ -167,7 +175,6 @@ async def board(
167175

168176
supervisor_source = [
169177
"main.c",
170-
"lib/tlsf/tlsf.c",
171178
f"ports/{port_id}/supervisor/port.c",
172179
"supervisor/stub/misc.c",
173180
]
@@ -232,14 +239,22 @@ async def board(
232239
async with asyncio.TaskGroup() as tg:
233240
extra_source_flags = {}
234241
for source_file in source_files:
235-
if source_file in ALLOW_FLAGS:
236-
extra_flags = []
237-
for module_name in ALLOW_FLAGS[source_file]:
242+
extra_flags = []
243+
if source_file in ALLOW_MODULE_FLAGS:
244+
for module_name in ALLOW_MODULE_FLAGS[source_file]:
238245
name_upper = module_name.upper()
239246
extra_flags.append(f"-DCIRCUITPY_{name_upper}={1 if kwargs.get(module_name, False) else 0}")
240-
241-
extra_source_flags[source_file] = extra_flags
247+
if source_file in ALLOW_FEATURE_FLAGS:
248+
for module_name in ALLOW_FEATURE_FLAGS[source_file]:
249+
name_upper = module_name.upper()
250+
extra_flags.append(f"-DCIRCUITPY_{name_upper}={1 if kwargs.get(module_name, False) else 0}")
251+
if source_file in ALLOW_MICROPYTHON_FLAGS:
252+
for module_name in ALLOW_MICROPYTHON_FLAGS[source_file]:
253+
name_upper = module_name.upper()
254+
extra_flags.append(f"-DMICROPY_{name_upper}={1 if kwargs.get(module_name, False) else 0}")
255+
if extra_flags:
242256
print(extra_flags)
257+
extra_source_flags[source_file] = extra_flags
243258
tg.create_task(
244259
preprocess_and_split_defs(compiler, top / source_file, build_path / board_id, [qstr_flags, *circuitpython_flags, *port_flags, *extra_source_flags.get(source_file, [])]),
245260
name=f"Split defs {source_file}",

ports/raspberrypi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ async def board(
2828
port_flags.append(f"-isystem {port_dir}/sdk/src/rp2_common/cmsis")
2929
port_flags.append(f"-isystem {port_dir}/sdk_config")
3030
port_flags.append(f"-I {port_dir}/boards/{board_id}")
31+
port_flags.append("-DPICO_RP2040")
3132
port_flags.append(
3233
"-DRASPBERRYPI -DPICO_ON_DEVICE=1 -DPICO_NO_BINARY_INFO=0 -DPICO_TIME_DEFAULT_ALARM_POOL_DISABLED=0 -DPICO_DIVIDER_CALL_IDIV0=0 -DPICO_DIVIDER_CALL_LDIV0=0 -DPICO_DIVIDER_HARDWARE=1 -DPICO_DOUBLE_ROM=1 -DPICO_FLOAT_ROM=1 -DPICO_MULTICORE=1 -DPICO_BITS_IN_RAM=0 -DPICO_DIVIDER_IN_RAM=0 -DPICO_DOUBLE_PROPAGATE_NANS=0 -DPICO_DOUBLE_IN_RAM=0 -DPICO_MEM_IN_RAM=0 -DPICO_FLOAT_IN_RAM=0 -DPICO_FLOAT_PROPAGATE_NANS=1 -DPICO_NO_FLASH=0 -DPICO_COPY_TO_RAM=0 -DPICO_DISABLE_SHARED_IRQ_HANDLERS=0 -DPICO_NO_BI_BOOTSEL_VIA_DOUBLE_RESET=0 -DDVI_1BPP_BIT_REVERSE=0"
3334
)

0 commit comments

Comments
 (0)