Skip to content

Commit 1661cbb

Browse files
committed
Make python detection more robust and allow setting PYTHON2 and PYTHON3 to override python executables during build.
1 parent ce5eae1 commit 1661cbb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

ports/atmel-samd/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Set default python interpreters
2+
PYTHON2 ?= $(which python2 || which python2.7)
3+
PYTHON3 ?= python3
4+
15
# Select the board to build for: if not given on the command line,
26
# then default to PYBV10.
37
BOARD ?= metro_m0_express
@@ -395,23 +399,23 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
395399
$(BUILD)/firmware.elf: $(OBJ)
396400
$(STEPECHO) "LINK $@"
397401
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
398-
$(Q)$(SIZE) $@ | python3 $(TOP)/tools/build_memory_info.py $(LD_FILE)
402+
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
399403

400404
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
401405
$(ECHO) "Create $@"
402406
$(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
403407

404408
$(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
405409
$(ECHO) "Create $@"
406-
python2 $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^
410+
$(PYTHON2) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^
407411

408412
$(BUILD)/autogen_usb_descriptor.c $(BUILD)/genhdr/autogen_usb_descriptor.h: autogen_usb_descriptor.intermediate
409413

410414
.INTERMEDIATE: autogen_usb_descriptor.intermediate
411415

412416
autogen_usb_descriptor.intermediate: tools/gen_usb_descriptor.py Makefile
413417
install -d $(BUILD)/genhdr
414-
python3 tools/gen_usb_descriptor.py \
418+
$(PYTHON3) tools/gen_usb_descriptor.py \
415419
--manufacturer $(USB_MANUFACTURER)\
416420
--product $(USB_PRODUCT)\
417421
--vid $(USB_VID)\

0 commit comments

Comments
 (0)