Skip to content

Commit

Permalink
add ability for custom code.py contents
Browse files Browse the repository at this point in the history
  • Loading branch information
todbot committed Feb 16, 2025
1 parent 1c53919 commit a8103c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions py/circuitpy_mpconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ CIRCUITPY_MESSAGE_COMPRESSION_LEVEL ?= 9
CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE ?= 0
CFLAGS += -DCIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE=$(CIRCUITPY_OPTIMIZE_PROPERTY_FLASH_SIZE)

# The contents of compiled-in code.py file.
# Ports can override to import frozen modules to compile-in running code
CIRCUITPY_CODEPY_CONTENTS ?= "print(\"Hello World!\")\n"
CFLAGS += -DCIRCUITPY_CODEPY_CONTENTS='$(CIRCUITPY_CODEPY_CONTENTS)'

# async/await language keyword support
MICROPY_PY_ASYNC_AWAIT ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DMICROPY_PY_ASYNC_AWAIT=$(MICROPY_PY_ASYNC_AWAIT)
Expand Down
2 changes: 1 addition & 1 deletion supervisor/shared/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ bool filesystem_init(bool create_allowed, bool force_create) {
make_empty_file(&vfs_fat->fatfs, "/settings.toml");
#endif
// make a sample code.py file
MAKE_FILE_WITH_OPTIONAL_CONTENTS(&vfs_fat->fatfs, "/code.py", "print(\"Hello World!\")\n");
MAKE_FILE_WITH_OPTIONAL_CONTENTS(&vfs_fat->fatfs, "/code.py", CIRCUITPY_CODEPY_CONTENTS);

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

0 comments on commit a8103c3

Please sign in to comment.