1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-13 11:29:56 +03:00

Travis and makefile optimisations (#890)

Travis and makefile optimisations
This commit is contained in:
Konstantin Sharlaimov 2016-12-12 11:18:56 +10:00 committed by GitHub
parent 38e9dd0743
commit 5dda5c0597
4 changed files with 109 additions and 77 deletions

View file

@ -24,7 +24,6 @@ CURL_PUB_BASEOPTS=(
# A hacky way of running the unit tests at the same time as the normal builds. # A hacky way of running the unit tests at the same time as the normal builds.
if [ $RUNTESTS ] ; then if [ $RUNTESTS ] ; then
cd ./src/test && make test cd ./src/test && make test
# A hacky way of building the docs at the same time as the normal builds. # A hacky way of building the docs at the same time as the normal builds.
elif [ $PUBLISHDOCS ] ; then elif [ $PUBLISHDOCS ] ; then
if [ $PUBLISH_URL ] ; then if [ $PUBLISH_URL ] ; then
@ -42,14 +41,12 @@ elif [ $PUBLISHDOCS ] ; then
curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "manual=@docs/Manual.pdf" ${PUBLISH_URL} || true curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "manual=@docs/Manual.pdf" ${PUBLISH_URL} || true
fi fi
elif [ $PUBLISHMETA ] ; then elif [ $PUBLISHMETA ] ; then
if [ $PUBLISH_URL ] ; then if [ $PUBLISH_URL ] ; then
RECENT_COMMITS=$(git shortlog -n25) RECENT_COMMITS=$(git shortlog -n25)
curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "recent_commits=${RECENT_COMMITS}" ${PUBLISH_URL} || true curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "recent_commits=${RECENT_COMMITS}" ${PUBLISH_URL} || true
fi fi
elif [ $TARGET ] ; then
else
if [ $PUBLISH_URL ] ; then if [ $PUBLISH_URL ] ; then
make -j2 make -j2
if [ -f ${TARGET_FILE}.bin ] ; then if [ -f ${TARGET_FILE}.bin ] ; then
@ -64,6 +61,9 @@ else
curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "file=@${TARGET_FILE}" ${PUBLISH_URL} || true curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "file=@${TARGET_FILE}" ${PUBLISH_URL} || true
exit 0; exit 0;
else else
make -j2 make -j2 $MAKEFILE
fi fi
else
# No target specified, build all with very low verbosity.
make V=0 all
fi fi

View file

@ -1,37 +1,34 @@
env: env:
- TARGET=CC3D # - TARGET=CC3D
- TARGET=CJMCU # - TARGET=CJMCU
- TARGET=NAZE # - TARGET=NAZE
- TARGET=STM32F3DISCOVERY # - TARGET=STM32F3DISCOVERY
- TARGET=RMDO # - TARGET=RMDO
- TARGET=SPRACINGF3 # - TARGET=SPRACINGF3
- TARGET=SPRACINGF3EVO # - TARGET=SPRACINGF3EVO
- TARGET=SPARKY # - TARGET=SPARKY
- TARGET=FURYF3 # - TARGET=FURYF3
- TARGET=RCEXPLORERF3 # - TARGET=RCEXPLORERF3
- TARGET=REVO # - TARGET=REVO
# use new docker environment # use new docker environment
sudo: false sudo: false
git:
depth: 5
addons: addons:
apt: apt:
packages: packages:
- build-essential - build-essential
- git - git
- libc6-i386 - libc6-i386
- zlib1g-dev
- libssl-dev
- wkhtmltopdf
- libxml2-dev
- libxslt-dev
# We use cpp for unit tests, and c for the main project. # We use cpp for unit tests, and c for the main project.
language: cpp language: cpp
compiler: clang compiler: clang
before_install: before_install: ./install-toolchain.sh
- curl --retry 10 --retry-max-time 120 -L "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2" | tar xfj -
install: install:
- export PATH=$PATH:$PWD/gcc-arm-none-eabi-5_4-2016q2/bin - export PATH=$PATH:$PWD/gcc-arm-none-eabi-5_4-2016q2/bin
@ -39,9 +36,13 @@ install:
before_script: arm-none-eabi-gcc --version before_script: arm-none-eabi-gcc --version
script: ./.travis.sh script: ./.travis.sh
cache: apt cache:
apt: true
directories:
- $PWD/gcc-arm-none-eabi-5_4-2016q2
notifications: notifications:
#slack: inavflight:UWRoWFJ4cbbpHXT8HJJlAPXa
email: false email: false
webhooks: webhooks:
urls: urls:

132
Makefile
View file

@ -37,6 +37,26 @@ SERIAL_DEVICE ?= $(firstword $(wildcard /dev/ttyUSB*) no-port-found)
# Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override. # Flash size (KB). Some low-end chips actually have more flash than advertised, use this to override.
FLASH_SIZE ?= FLASH_SIZE ?=
## V : Set verbosity level based on the V= parameter
## V=0 Low
## V=1 High
export AT := @
ifndef V
export V0 :=
export V1 := $(AT)
export STDOUT :=
else ifeq ($(V), 0)
export V0 := $(AT)
export V1 := $(AT)
export STDOUT:= "> /dev/null"
export MAKE := $(MAKE) --no-print-directory
else ifeq ($(V), 1)
export V0 :=
export V1 :=
export STDOUT :=
endif
############################################################################### ###############################################################################
# Things that need to be maintained as the source changes # Things that need to be maintained as the source changes
# #
@ -686,72 +706,78 @@ CLEAN_ARTIFACTS += $(TARGET_ELF) $(TARGET_OBJS) $(TARGET_MAP)
# It would be nice to compute these lists, but that seems to be just beyond make. # It would be nice to compute these lists, but that seems to be just beyond make.
$(TARGET_HEX): $(TARGET_ELF) $(TARGET_HEX): $(TARGET_ELF)
$(OBJCOPY) -O ihex --set-start 0x8000000 $< $@ $(V0) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
$(TARGET_BIN): $(TARGET_ELF) $(TARGET_BIN): $(TARGET_ELF)
$(OBJCOPY) -O binary $< $@ $(V0) $(OBJCOPY) -O binary $< $@
$(TARGET_ELF): $(TARGET_OBJS) $(TARGET_ELF): $(TARGET_OBJS)
@echo LD $(notdir $@) $(V1) echo Linking $(TARGET)
@$(CC) -o $@ $^ $(LDFLAGS) $(V1) $(CC) -o $@ $^ $(LDFLAGS)
$(SIZE) $(TARGET_ELF) $(V0) $(SIZE) $(TARGET_ELF)
# Compile # Compile
$(OBJECT_DIR)/$(TARGET)/%.o: %.c $(OBJECT_DIR)/$(TARGET)/%.o: %.c
@mkdir -p $(dir $@) $(V1) mkdir -p $(dir $@)
@echo %% $(notdir $<) $(V1) echo %% $(notdir $<) "$(STDOUT)"
@$(CC) -c -o $@ $(CFLAGS) $< $(V1) $(CC) -c -o $@ $(CFLAGS) $<
# Assemble # Assemble
$(OBJECT_DIR)/$(TARGET)/%.o: %.s $(OBJECT_DIR)/$(TARGET)/%.o: %.s
@mkdir -p $(dir $@) $(V1) mkdir -p $(dir $@)
@echo %% $(notdir $<) $(V1) echo %% $(notdir $<) "$(STDOUT)"
@$(CC) -c -o $@ $(ASFLAGS) $< $(V1) $(CC) -c -o $@ $(ASFLAGS) $<
$(OBJECT_DIR)/$(TARGET)/%.o: %.S $(OBJECT_DIR)/$(TARGET)/%.o: %.S
@mkdir -p $(dir $@) $(V1) mkdir -p $(dir $@)
@echo %% $(notdir $<) $(V1) echo %% $(notdir $<) "$(STDOUT)"
@$(CC) -c -o $@ $(ASFLAGS) $< $(V1) $(CC) -c -o $@ $(ASFLAGS) $<
## all : Build all valid targets ## all : Build all valid targets
all: $(VALID_TARGETS) all: $(VALID_TARGETS)
$(VALID_TARGETS): $(VALID_TARGETS):
echo "" && \ $(V0) echo "" && \
echo "Building $@" && \ echo "Building $@" && \
$(MAKE) -j TARGET=$@ && \ $(MAKE) -j TARGET=$@ && \
echo "Building $@ succeeded." echo "Building $@ succeeded."
## clean : clean up all temporary / machine-generated files ## clean : clean up all temporary / machine-generated files
clean: clean:
rm -f $(CLEAN_ARTIFACTS) $(V0) echo "Cleaning $(TARGET)"
rm -rf $(OBJECT_DIR)/$(TARGET) $(V0) rm -f $(CLEAN_ARTIFACTS)
$(V0) rm -rf $(OBJECT_DIR)/$(TARGET)
$(V0) echo "Cleaning $(TARGET) succeeded."
## clean_test : clean up all temporary / machine-generated files (tests) ## clean_test : clean up all temporary / machine-generated files (tests)
clean_test: clean_test:
cd src/test && $(MAKE) clean || true $(V0) cd src/test && $(MAKE) clean || true
## clean_all_targets : clean all valid target platforms ## clean_<TARGET> : clean up one specific target
clean_all: $(CLEAN_TARGETS) :
for clean_target in $(VALID_TARGETS); do \ $(V0) $(MAKE) -j TARGET=$(subst clean_,,$@) clean
echo "" && \
echo "Cleaning $$clean_target" && \ ## <TARGET>_clean : clean up one specific target (alias for above)
$(MAKE) -j TARGET=$$clean_target clean || \ $(TARGETS_CLEAN) :
break; \ $(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean
echo "Cleaning $$clean_target succeeded."; \
done ## clean_all : clean all valid targets
clean_all:$(CLEAN_TARGETS)
## all_clean : clean all valid targets (alias for above)
all_clean:$(TARGETS_CLEAN)
flash_$(TARGET): $(TARGET_HEX) flash_$(TARGET): $(TARGET_HEX)
stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
echo -n 'R' >$(SERIAL_DEVICE) $(V0) echo -n 'R' >$(SERIAL_DEVICE)
stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE) $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
## flash : flash firmware (.hex) onto flight controller ## flash : flash firmware (.hex) onto flight controller
flash: flash_$(TARGET) flash: flash_$(TARGET)
st-flash_$(TARGET): $(TARGET_BIN) st-flash_$(TARGET): $(TARGET_BIN)
st-flash --reset write $< 0x08000000 $(V0) st-flash --reset write $< 0x08000000
## st-flash : flash firmware (.bin) onto flight controller ## st-flash : flash firmware (.bin) onto flight controller
st-flash: st-flash_$(TARGET) st-flash: st-flash_$(TARGET)
@ -760,42 +786,42 @@ binary: $(TARGET_BIN)
hex: $(TARGET_HEX) hex: $(TARGET_HEX)
unbrick_$(TARGET): $(TARGET_HEX) unbrick_$(TARGET): $(TARGET_HEX)
stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon $(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE) $(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
## unbrick : unbrick flight controller ## unbrick : unbrick flight controller
unbrick: unbrick_$(TARGET) unbrick: unbrick_$(TARGET)
## cppcheck : run static analysis on C source code ## cppcheck : run static analysis on C source code
cppcheck: $(CSOURCES) cppcheck: $(CSOURCES)
$(CPPCHECK) $(V0) $(CPPCHECK)
cppcheck-result.xml: $(CSOURCES) cppcheck-result.xml: $(CSOURCES)
$(CPPCHECK) --xml-version=2 2> cppcheck-result.xml $(V0) $(CPPCHECK) --xml-version=2 2> cppcheck-result.xml
## help : print this help message and exit ## help : print this help message and exit
help: Makefile help: Makefile
@echo "" $(V0) @echo ""
@echo "Makefile for the $(FORKNAME) firmware" $(V0) @echo "Makefile for the $(FORKNAME) firmware"
@echo "" $(V0) @echo ""
@echo "Usage:" $(V0) @echo "Usage:"
@echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]" $(V0) @echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]"
@echo "Or:" $(V0) @echo "Or:"
@echo " make <target> [OPTIONS=\"<options>\"]" $(V0) @echo " make <target> [OPTIONS=\"<options>\"]"
@echo "" $(V0) @echo ""
@echo "Valid TARGET values are: $(VALID_TARGETS)" $(V0) @echo "Valid TARGET values are: $(VALID_TARGETS)"
@echo "" $(V0) @echo ""
@sed -n 's/^## //p' $< $(V0) @sed -n 's/^## //p' $<
## targets : print a list of all valid target platforms (for consumption by scripts) ## targets : print a list of all valid target platforms (for consumption by scripts)
targets: targets:
@echo "Valid targets: $(VALID_TARGETS)" $(V0) @echo "Valid targets: $(VALID_TARGETS)"
@echo "Target: $(TARGET)" $(V0) @echo "Target: $(TARGET)"
@echo "Base target: $(BASE_TARGET)" $(V0) @echo "Base target: $(BASE_TARGET)"
## test : run the cleanflight test suite ## test : run the cleanflight test suite
test: test:
cd src/test && $(MAKE) test || true $(V0) cd src/test && $(MAKE) test || true
# rebuild everything when makefile changes # rebuild everything when makefile changes
$(TARGET_OBJS) : Makefile $(TARGET_OBJS) : Makefile

5
install-toolchain.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
if [ ! -d $PWD/gcc-arm-none-eabi-5_4-2016q2/bin ] ; then
curl --retry 10 --retry-max-time 120 -L "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2" | tar xfj -
fi