add ESP32 build system with xtensa-esp-elf toolchain
This commit is contained in:
61
build/esp32/Makefile
Normal file
61
build/esp32/Makefile
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# ========================================================== #
|
||||||
|
# Spider Runtime - ESP32 Build System #
|
||||||
|
# Toolchain: Espressif ESP-IDF (xtensa-esp-elf-g++) #
|
||||||
|
# ========================================================== #
|
||||||
|
|
||||||
|
CC := xtensa-esp-elf-g++
|
||||||
|
TARGET := spider_esp32.elf
|
||||||
|
SRCDIR := ../../src
|
||||||
|
BUILDDIR := bin
|
||||||
|
TARGETDIR := out
|
||||||
|
SRCEXT := cpp
|
||||||
|
OBJEXT := o
|
||||||
|
|
||||||
|
ESP_FLAGS := -DESP32 -DSPIDER_DISTRO_MICRO -DSPIDER_OS_NONE -mlongcalls -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
|
CFLAGS := -Wall -std=c++20 -DSPIDER_COMPILING $(ESP_FLAGS)
|
||||||
|
LFLAGS := -Wl,--gc-sections -mlongcalls
|
||||||
|
INC := -I../../src/
|
||||||
|
|
||||||
|
# Exclude desktop-only modules
|
||||||
|
EXCLUDE := $(SRCDIR)/spider/runtime/util/Terminal.cpp \
|
||||||
|
$(SRCDIR)/spider/runtime/debug/LiveDebug.cpp \
|
||||||
|
$(SRCDIR)/spider/SpiderRuntime.cpp
|
||||||
|
|
||||||
|
# ESP32 specific entry point (local to this build folder)
|
||||||
|
EXTRA := ./main_esp32.cpp
|
||||||
|
|
||||||
|
SOURCES := $(filter-out $(EXCLUDE), $(shell find $(SRCDIR) -type f -name "*.$(SRCEXT)" 2>/dev/null)) $(EXTRA)
|
||||||
|
OBJECTS := $(patsubst ./%,$(BUILDDIR)/%,$(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT))))
|
||||||
|
|
||||||
|
all: directories $(TARGET)
|
||||||
|
@echo "Build complete: $(TARGETDIR)/$(TARGET)"
|
||||||
|
|
||||||
|
remake: cleaner all
|
||||||
|
|
||||||
|
directories:
|
||||||
|
@mkdir -p $(TARGETDIR)
|
||||||
|
@mkdir -p $(BUILDDIR)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@$(RM) -rf $(BUILDDIR)
|
||||||
|
|
||||||
|
cleaner: clean
|
||||||
|
@$(RM) -rf $(TARGETDIR)
|
||||||
|
|
||||||
|
$(TARGET): $(OBJECTS)
|
||||||
|
@echo "Linking $(TARGET)..."
|
||||||
|
$(CC) $(LFLAGS) -o $(TARGETDIR)/$(TARGET) $^
|
||||||
|
@echo "Done!"
|
||||||
|
|
||||||
|
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@echo "Compiling $<..."
|
||||||
|
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
|
||||||
|
|
||||||
|
$(BUILDDIR)/%.$(OBJEXT): ./%.$(SRCEXT)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@echo "Compiling $<..."
|
||||||
|
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
|
||||||
|
|
||||||
|
.PHONY: all remake clean cleaner
|
||||||
BIN
build/esp32/bin/main_esp32.o
Normal file
BIN
build/esp32/bin/main_esp32.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/Runtime.o
Normal file
BIN
build/esp32/bin/spider/runtime/Runtime.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/cpu/CPU.o
Normal file
BIN
build/esp32/bin/spider/runtime/cpu/CPU.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/instr/Instr_00-1F.o
Normal file
BIN
build/esp32/bin/spider/runtime/instr/Instr_00-1F.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/math/Quat.o
Normal file
BIN
build/esp32/bin/spider/runtime/math/Quat.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/memory/ByteArray.o
Normal file
BIN
build/esp32/bin/spider/runtime/memory/ByteArray.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/memory/RAM.o
Normal file
BIN
build/esp32/bin/spider/runtime/memory/RAM.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/reel/InstrReel.o
Normal file
BIN
build/esp32/bin/spider/runtime/reel/InstrReel.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/reel/InstrReelDyn.o
Normal file
BIN
build/esp32/bin/spider/runtime/reel/InstrReelDyn.o
Normal file
Binary file not shown.
BIN
build/esp32/bin/spider/runtime/reel/InstrReelFixed.o
Normal file
BIN
build/esp32/bin/spider/runtime/reel/InstrReelFixed.o
Normal file
Binary file not shown.
69
build/esp32/gen_makefile.py
Normal file
69
build/esp32/gen_makefile.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
tab = '\t'
|
||||||
|
dollar = '$'
|
||||||
|
|
||||||
|
content = f"""# ========================================================== #
|
||||||
|
# Spider Runtime - ESP32 Build System #
|
||||||
|
# Toolchain: Espressif ESP-IDF (xtensa-esp-elf-g++) #
|
||||||
|
# ========================================================== #
|
||||||
|
|
||||||
|
CC := xtensa-esp-elf-g++
|
||||||
|
TARGET := spider_esp32.elf
|
||||||
|
SRCDIR := ../../src
|
||||||
|
BUILDDIR := bin
|
||||||
|
TARGETDIR := out
|
||||||
|
SRCEXT := cpp
|
||||||
|
OBJEXT := o
|
||||||
|
|
||||||
|
ESP_FLAGS := -DESP32 -DSPIDER_DISTRO_MICRO -DSPIDER_OS_NONE -mlongcalls -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
|
CFLAGS := -Wall -std=c++20 -DSPIDER_COMPILING {dollar}(ESP_FLAGS)
|
||||||
|
LFLAGS := -Wl,--gc-sections -mlongcalls
|
||||||
|
INC := -I../../src/
|
||||||
|
|
||||||
|
# Exclude desktop-only modules
|
||||||
|
EXCLUDE := {dollar}(SRCDIR)/spider/runtime/util/Terminal.cpp \\
|
||||||
|
{dollar}(SRCDIR)/spider/runtime/debug/LiveDebug.cpp \\
|
||||||
|
{dollar}(SRCDIR)/spider/SpiderRuntime.cpp
|
||||||
|
|
||||||
|
# ESP32 specific entry point (local to this build folder)
|
||||||
|
EXTRA := ./main_esp32.cpp
|
||||||
|
|
||||||
|
SOURCES := {dollar}(filter-out {dollar}(EXCLUDE), {dollar}(shell find {dollar}(SRCDIR) -type f -name "*.{dollar}(SRCEXT)" 2>/dev/null)) {dollar}(EXTRA)
|
||||||
|
OBJECTS := {dollar}(patsubst ./%,{dollar}(BUILDDIR)/%,{dollar}(patsubst {dollar}(SRCDIR)/%,{dollar}(BUILDDIR)/%,{dollar}(SOURCES:.{dollar}(SRCEXT)=.{dollar}(OBJEXT))))
|
||||||
|
|
||||||
|
all: directories {dollar}(TARGET)
|
||||||
|
{tab}@echo "Build complete: {dollar}(TARGETDIR)/{dollar}(TARGET)"
|
||||||
|
|
||||||
|
remake: cleaner all
|
||||||
|
|
||||||
|
directories:
|
||||||
|
{tab}@mkdir -p {dollar}(TARGETDIR)
|
||||||
|
{tab}@mkdir -p {dollar}(BUILDDIR)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
{tab}@{dollar}(RM) -rf {dollar}(BUILDDIR)
|
||||||
|
|
||||||
|
cleaner: clean
|
||||||
|
{tab}@{dollar}(RM) -rf {dollar}(TARGETDIR)
|
||||||
|
|
||||||
|
{dollar}(TARGET): {dollar}(OBJECTS)
|
||||||
|
{tab}@echo "Linking {dollar}(TARGET)..."
|
||||||
|
{tab}{dollar}(CC) {dollar}(LFLAGS) -o {dollar}(TARGETDIR)/{dollar}(TARGET) {dollar}^
|
||||||
|
{tab}@echo "Done!"
|
||||||
|
|
||||||
|
{dollar}(BUILDDIR)/%.{dollar}(OBJEXT): {dollar}(SRCDIR)/%.{dollar}(SRCEXT)
|
||||||
|
{tab}@mkdir -p {dollar}(dir {dollar}@)
|
||||||
|
{tab}@echo "Compiling {dollar}<..."
|
||||||
|
{tab}{dollar}(CC) {dollar}(CFLAGS) {dollar}(INC) -c -o {dollar}@ {dollar}<
|
||||||
|
|
||||||
|
{dollar}(BUILDDIR)/%.{dollar}(OBJEXT): ./%.{dollar}(SRCEXT)
|
||||||
|
{tab}@mkdir -p {dollar}(dir {dollar}@)
|
||||||
|
{tab}@echo "Compiling {dollar}<..."
|
||||||
|
{tab}{dollar}(CC) {dollar}(CFLAGS) {dollar}(INC) -c -o {dollar}@ {dollar}<
|
||||||
|
|
||||||
|
.PHONY: all remake clean cleaner
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open('Makefile', 'w', newline='\n') as f:
|
||||||
|
f.write(content)
|
||||||
|
print("Makefile generated successfully!")
|
||||||
8
build/esp32/main_esp32.cpp
Normal file
8
build/esp32/main_esp32.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// ESP32 entry point for Spider Runtime
|
||||||
|
// This replaces SpiderRuntime.cpp for microcontroller builds
|
||||||
|
#include <spider/SpiderRuntime.hpp>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// TODO: initialize Spider runtime for ESP32
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
BIN
build/esp32/out/spider_esp32.elf
Normal file
BIN
build/esp32/out/spider_esp32.elf
Normal file
Binary file not shown.
Reference in New Issue
Block a user