Skip to content

Commit a8103c3

Browse files
committed
add ability for custom code.py contents
1 parent 1c53919 commit a8103c3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

py/circuitpy_mpconfig.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ CIRCUITPY_MESSAGE_COMPRESSION_LEVEL ?= 9
6767
CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 0
6868
CFLAGS += -DCIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE=$(CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE)
6969

70+
# The contents of compiled-in code.py file.
71+
# Ports can override to import frozen modules to compile-in running code
72+
CIRCUITPY_CODEPY_CONTENTS ?= "print(\"Hello World!\")\n"
73+
CFLAGS += -DCIRCUITPY_CODEPY_CONTENTS='$(CIRCUITPY_CODEPY_CONTENTS)'
74+
7075
# async/await language keyword support
7176
MICROPY_PY_ASYNC_AWAIT ?= $(CIRCUITPY_FULL_BUILD)
7277
CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT)

supervisor/shared/filesystem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ bool filesystem_init(bool create_allowed, bool force_create) {
134134
make_empty_file(&vfs_fat->fatfs, "/settings.toml");
135135
#endif
136136
// make a sample code.py file
137-
MAKE_FILE_WITH_OPTIONAL_CONTENTS(&vfs_fat->fatfs, "/code.py", "print(\"Hello World!\")\n");
137+
MAKE_FILE_WITH_OPTIONAL_CONTENTS(&vfs_fat->fatfs, "/code.py", CIRCUITPY_CODEPY_CONTENTS);
138138

139139
// create empty lib directory
140140
res = f_mkdir(&vfs_fat->fatfs, "/lib");

0 commit comments

Comments
 (0)