From 5b1c273a780b3f4a9cff6c46422b87fdc49b6fb9 Mon Sep 17 00:00:00 2001 From: Ivan Zorin Date: Wed, 14 Jun 2023 15:34:51 +0300 Subject: [PATCH] source/Makefile: add HOST_PYTHON, extend clean target, remove -.d generation (#1701) * source/Makefile modifications: add HOST_PYTHON variable for flexibility of environment setup / extend clean target to make source directory as new / rename -.d autogenerated temp file * Makefile: keep Hexfile dir by clean target, add mrproper target to clean all * Makefile: rename mrproper target to clean-all --------- Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com> --- source/Makefile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/source/Makefile b/source/Makefile index d2b69a89..092b4e4c 100644 --- a/source/Makefile +++ b/source/Makefile @@ -38,6 +38,11 @@ LANGUAGE_GROUP_EUR_NAME=European LANGUAGE_GROUPS=CUSTOM CJK CYRILLIC EUR +# Define for host Python +ifndef HOST_PYTHON +HOST_PYTHON:=python3 +endif + # Defines for host tools ifeq ($(HOST_CC),) HOST_CC := gcc @@ -589,7 +594,7 @@ firmware-%: $(HEXFILE_DIR)/$(model)_%.hex $(HEXFILE_DIR)/$(model)_%.bin $(HEXFIL $(SIZE) $< %.dfu : %.bin Makefile - python3 dfuse-pack.py -b $(DEVICE_DFU_ADDRESS)@0:$< -D $(DEVICE_DFU_VID_PID) $@ + $(HOST_PYTHON) dfuse-pack.py -b $(DEVICE_DFU_ADDRESS)@0:$< -D $(DEVICE_DFU_VID_PID) $@ $(HEXFILE_DIR)/$(model)_%.elf : \ $(OUT_OBJS_S) $(OUT_OBJS) $(OUT_OBJS_CPP) \ @@ -649,7 +654,7 @@ Core/Gen/Translation.%.cpp $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle: .. @test -d Core/Gen || mkdir -p Core/Gen @test -d $(OUTPUT_DIR)/Core/Gen/translation.files || mkdir -p $(OUTPUT_DIR)/Core/Gen/translation.files @echo 'Generating translations for language $*' - @python3 ../Translations/make_translation.py \ + @$(HOST_PYTHON) ../Translations/make_translation.py \ --macros $(PWD)/Core/Gen/macros.txt \ -o $(PWD)/Core/Gen/Translation.$*.cpp \ --output-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \ @@ -657,7 +662,8 @@ Core/Gen/Translation.%.cpp $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle: .. Core/Gen/macros.txt: Makefile @test -d Core/Gen || mkdir -p Core/Gen - echo "#include " | $(CC) -dM -E $(CFLAGS) - > $(PWD)/Core/Gen/macros.txt + echo "#include " | $(CC) -dM -E $(CFLAGS) -MF Core/Gen/macros.tmp - > $(PWD)/Core/Gen/macros.txt + # # The recipes to produce compressed translation data: @@ -681,7 +687,7 @@ $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so: Core/brieflz/brieflz.c Core/brieflz/de Core/Gen/Translation_brieflz.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.o $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt @test -d $(@D) || mkdir -p $(@D) @echo Generating BriefLZ compressed translation for $* - @OBJCOPY=$(OBJCOPY) python3 ../Translations/make_translation.py \ + @OBJCOPY=$(OBJCOPY) $(HOST_PYTHON) ../Translations/make_translation.py \ --macros $(PWD)/Core/Gen/macros.txt \ -o $(PWD)/Core/Gen/Translation_brieflz.$*.cpp \ --input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \ @@ -691,7 +697,7 @@ Core/Gen/Translation_brieflz.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.o Core/Gen/Translation_brieflz_font.%.cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/%.pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt @test -d $(@D) || mkdir -p $(@D) @echo Generating BriefLZ compressed translation for $* - @python3 ../Translations/make_translation.py \ + @$(HOST_PYTHON) ../Translations/make_translation.py \ --macros $(PWD)/Core/Gen/macros.txt \ -o $(PWD)/Core/Gen/Translation_brieflz_font.$*.cpp \ --input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/$*.pickle \ @@ -738,7 +744,7 @@ Core/Gen/Translation_multi.$(1).cpp: $(patsubst %,../Translations/translation_%. @test -d Core/Gen || mkdir -p Core/Gen @test -d $(OUTPUT_DIR)/Core/Gen/translation.files || mkdir -p $(OUTPUT_DIR)/Core/Gen/translation.files @echo 'Generating translations for multi-language $(2)' - @python3 ../Translations/make_translation.py \ + @$(HOST_PYTHON) ../Translations/make_translation.py \ --macros $(PWD)/Core/Gen/macros.txt \ -o $(PWD)/Core/Gen/Translation_multi.$(1).cpp \ --output-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle \ @@ -749,7 +755,7 @@ $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle: Core/Gen/Translation Core/Gen/Translation_brieflz_multi.$(1).cpp: $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).o $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle $(HOST_OUTPUT_DIR)/brieflz/libbrieflz.so Core/Gen/macros.txt @test -d $$(@D) || mkdir -p $$(@D) @echo Generating BriefLZ compressed translation for multi-language $(2) - @OBJCOPY=$(OBJCOPY) python3 ../Translations/make_translation.py \ + @OBJCOPY=$(OBJCOPY) $(HOST_PYTHON) ../Translations/make_translation.py \ --macros $(PWD)/Core/Gen/macros.txt \ -o $(PWD)/Core/Gen/Translation_brieflz_multi.$(1).cpp \ --input-pickled $(OUTPUT_DIR)/Core/Gen/translation.files/multi.$(1).pickle \ @@ -764,10 +770,14 @@ endef # multi_lang_rule $(foreach group_code,$(LANGUAGE_GROUPS),$(eval $(call multi_lang_rule,$(group_code),$(LANGUAGE_GROUP_$(group_code)_NAME),$(LANGUAGE_GROUP_$(group_code)_LANGS)))) -clean : +clean: rm -Rf Core/Gen rm -Rf $(OUTPUT_DIR_BASE) rm -Rf $(HEXFILE_DIR)/* + rm -Rf ../Translations/__pycache__ + +clean-all: clean + rm -Rf $(HEXFILE_DIR) style: @for src in $(ALL_SOURCE) $(ALL_INCLUDES); do \ @@ -787,7 +797,7 @@ check-style: done @echo "Style check passed" -.PHONY: style all clean default +.PHONY: style all clean default clean-all .SECONDARY: # pull in dependency info for *existing* .o files