Skip to content

Commit b1c42e0

Browse files
committed
emscripten: refactor Makefile
1 parent 1bce4b9 commit b1c42e0

File tree

1 file changed

+10
-65
lines changed

1 file changed

+10
-65
lines changed

emscripten/Makefile

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include ../py/mkenv.mk
22

3-
CROSS = 0
43
# clang has slightly different options to GCC
54
CLANG = 1
65
EMSCRIPTEN = 1
@@ -11,54 +10,33 @@ QSTR_DEFS = qstrdefsport.h
1110
# include py core make definitions
1211
include ../py/py.mk
1312

14-
ifeq ($(CROSS), 1)
15-
CROSS_COMPILE = arm-none-eabi-
16-
endif
17-
18-
ifeq ($(EMSCRIPTEN), 1)
19-
CC = emcc -g4
13+
CC = emcc
2014
CPP = gcc -E
2115
CLANG = 1
2216
SIZE = echo
23-
LD = emcc -g4
24-
endif
17+
LD = emcc
2518

2619
INC += -I.
2720
INC += -I..
28-
INC += -I../lib/mp-readline
29-
INC += -I../stmhal
3021
INC += -I$(BUILD)
3122

32-
ifeq ($(CROSS), 1)
33-
DFU = ../tools/dfu.py
34-
PYDFU = ../tools/pydfu.py
35-
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
36-
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) $(COPT)
37-
else
38-
CFLAGS = -m32 $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT)
39-
endif
23+
CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT)
4024

4125
#Debugging/Optimization
4226
ifeq ($(DEBUG), 1)
4327
CFLAGS += -O0
28+
CC += -g4
29+
LD += -g4
4430
else
4531
CFLAGS += -Os -DNDEBUG
4632
endif
4733

4834
CFLAGS += -D MICROPY_NLR_SETJMP=1
4935
CFLAGS += -D MICROPY_USE_INTERNAL_PRINTF=0
5036

51-
ifeq ($(CROSS), 1)
52-
LDFLAGS = -nostdlib -T stm32f405.ld -Map=$@.map --cref
53-
else
54-
ifeq ($(CLANG), 1)
5537
LD = $(CC)
56-
LDFLAGS = -m32 -Wl,-map,$@.map -Wl,-dead_strip -Wl,-no_pie -s EXPORTED_FUNCTIONS="['_mp_js_init', '_mp_js_run']"
57-
else
58-
LD = gcc
59-
LDFLAGS = -m32 -Wl,-Map=$@.map,--cref
60-
endif
61-
endif
38+
LDFLAGS = -Wl,-map,$@.map -Wl,-dead_strip -Wl,-no_pie -s EXPORTED_FUNCTIONS="['_mp_js_init', '_mp_js_run']"
39+
6240
LIBS =
6341

6442
SRC_C = \
@@ -71,50 +49,17 @@ SRC_C = \
7149

7250
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
7351

74-
ifeq ($(CROSS), 1)
75-
all: $(BUILD)/firmware.dfu
76-
else
77-
ifeq ($(EMSCRIPTEN), 1)
78-
all: $(BUILD)/firmware.js
79-
else
80-
all: $(BUILD)/firmware.elf
81-
endif
82-
endif
52+
all: $(BUILD)/micropython.js
8353

8454
$(BUILD)/_frozen_mpy.c: frozentest.mpy $(BUILD)/genhdr/qstrdefs.generated.h
8555
$(ECHO) "MISC freezing bytecode"
8656
$(Q)../tools/mpy-tool.py -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h -mlongint-impl=none $< > $@
8757

88-
$(BUILD)/firmware.elf: $(OBJ)
89-
$(ECHO) "LINK $@"
90-
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
91-
$(Q)$(SIZE) $@
92-
93-
$(BUILD)/firmware.js: $(OBJ)
58+
$(BUILD)/micropython.js: $(OBJ)
9459
$(ECHO) "LINK $@"
9560
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
9661

97-
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
98-
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
99-
100-
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
101-
$(ECHO) "Create $@"
102-
$(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/firmware.bin $@
103-
104-
deploy: $(BUILD)/firmware.dfu
105-
$(ECHO) "Writing $< to the board"
106-
$(Q)$(PYTHON) $(PYDFU) -u $<
107-
108-
# Run emulation build on a POSIX system with suitable terminal settings
10962
run:
110-
stty raw opost -echo
111-
build/firmware.elf
112-
@echo Resetting terminal...
113-
# This sleep is useful to spot segfaults
114-
sleep 1
115-
reset
116-
117-
test: $(BUILD)/firmware.elf
118-
$(Q)/bin/echo -e "print('hello world!', list(x+1 for x in range(10)), end='eol\\\\n')\\r\\n\\x04" | $(BUILD)/firmware.elf | tail -n2 | grep "^hello world! \\[1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\]eol"
63+
node repl.js
11964

12065
include ../py/mkrules.mk

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy