Add phony target to run pre-build hook script
This commit is contained in:
parent
f1a79dbb3f
commit
6c56c4bf14
3 changed files with 32 additions and 2 deletions
12
Arduino.mk
12
Arduino.mk
|
@ -465,6 +465,10 @@ else
|
||||||
$(call show_config_variable,USER_LIB_PATH,[USER])
|
$(call show_config_variable,USER_LIB_PATH,[USER])
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef PRE_BUILD_HOOK
|
||||||
|
PRE_BUILD_HOOK = pre-build-hook.sh
|
||||||
|
endif
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# boards.txt parsing
|
# boards.txt parsing
|
||||||
|
|
||||||
|
@ -1102,9 +1106,12 @@ all: $(TARGET_EEP) $(TARGET_HEX)
|
||||||
# prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prerequisite
|
# prerequisite" (e.g., put "| $(OBJDIR)" at the end of the prerequisite
|
||||||
# list) to prevent remaking the target when any file in the directory
|
# list) to prevent remaking the target when any file in the directory
|
||||||
# changes.
|
# changes.
|
||||||
$(OBJDIR):
|
$(OBJDIR): pre-build
|
||||||
$(MKDIR) $(OBJDIR)
|
$(MKDIR) $(OBJDIR)
|
||||||
|
|
||||||
|
pre-build:
|
||||||
|
$(call runscript_if_exists,$(PRE_BUILD_HOOK))
|
||||||
|
|
||||||
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
|
$(TARGET_ELF): $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS)
|
||||||
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm
|
$(CC) $(LDFLAGS) -o $@ $(LOCAL_OBJS) $(CORE_LIB) $(OTHER_OBJS) -lc -lm
|
||||||
|
|
||||||
|
@ -1114,6 +1121,7 @@ $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS)
|
||||||
error_on_caterina:
|
error_on_caterina:
|
||||||
$(ERROR_ON_CATERINA)
|
$(ERROR_ON_CATERINA)
|
||||||
|
|
||||||
|
|
||||||
# Use submake so we can guarantee the reset happens
|
# Use submake so we can guarantee the reset happens
|
||||||
# before the upload, even with make -j
|
# before the upload, even with make -j
|
||||||
upload: $(TARGET_HEX) verify_size
|
upload: $(TARGET_HEX) verify_size
|
||||||
|
@ -1240,7 +1248,7 @@ help:
|
||||||
|
|
||||||
.PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload \
|
.PHONY: all upload raw_upload raw_eeprom error_on_caterina reset reset_stty ispload \
|
||||||
clean depends size show_boards monitor disasm symbol_sizes generated_assembly \
|
clean depends size show_boards monitor disasm symbol_sizes generated_assembly \
|
||||||
generate_assembly verify_size burn_bootloader help
|
generate_assembly verify_size burn_bootloader help pre-build
|
||||||
|
|
||||||
# added - in the beginning, so that we don't get an error if the file is not present
|
# added - in the beginning, so that we don't get an error if the file is not present
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
# (directory and optional filename) exists
|
# (directory and optional filename) exists
|
||||||
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
|
dir_if_exists = $(if $(wildcard $(1)$(2)),$(1))
|
||||||
|
|
||||||
|
# Run a shell script if it exists.
|
||||||
|
runscript_if_exists = $(if $(wildcard $(1)), $(shell sh $(1)))
|
||||||
|
|
||||||
# For message printing: pad the right side of the first argument with spaces to
|
# For message printing: pad the right side of the first argument with spaces to
|
||||||
# the number of bytes indicated by the second argument.
|
# the number of bytes indicated by the second argument.
|
||||||
space_pad_to = $(shell echo $(1) " " | head -c$(2))
|
space_pad_to = $(shell echo $(1) " " | head -c$(2))
|
||||||
|
|
|
@ -776,6 +776,25 @@ MONITOR_CMD = minicom
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
### PRE_BUILD_HOOK
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
|
||||||
|
Path to shell script to be executed before build. Could be used to automatically
|
||||||
|
bump revision number for example.
|
||||||
|
|
||||||
|
Defaults to `pre-build-hook.sh`
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```Makefile
|
||||||
|
PRE_BUILD_HOOK = ~/bin/bump-revision.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
**Requirement:** *Optional*
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
## Avrdude setting variables
|
## Avrdude setting variables
|
||||||
|
|
||||||
### AVRDUDE
|
### AVRDUDE
|
||||||
|
|
Loading…
Reference in a new issue