mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-13 03:19:58 +03:00
Travis and makefile optimisations (#890)
Travis and makefile optimisations
This commit is contained in:
parent
38e9dd0743
commit
5dda5c0597
4 changed files with 109 additions and 77 deletions
10
.travis.sh
10
.travis.sh
|
@ -24,7 +24,6 @@ CURL_PUB_BASEOPTS=(
|
|||
# A hacky way of running the unit tests at the same time as the normal builds.
|
||||
if [ $RUNTESTS ] ; then
|
||||
cd ./src/test && make test
|
||||
|
||||
# A hacky way of building the docs at the same time as the normal builds.
|
||||
elif [ $PUBLISHDOCS ] ; 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
|
||||
fi
|
||||
|
||||
elif [ $PUBLISHMETA ] ; then
|
||||
if [ $PUBLISH_URL ] ; then
|
||||
RECENT_COMMITS=$(git shortlog -n25)
|
||||
curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "recent_commits=${RECENT_COMMITS}" ${PUBLISH_URL} || true
|
||||
fi
|
||||
|
||||
else
|
||||
elif [ $TARGET ] ; then
|
||||
if [ $PUBLISH_URL ] ; then
|
||||
make -j2
|
||||
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
|
||||
exit 0;
|
||||
else
|
||||
make -j2
|
||||
make -j2 $MAKEFILE
|
||||
fi
|
||||
else
|
||||
# No target specified, build all with very low verbosity.
|
||||
make V=0 all
|
||||
fi
|
||||
|
|
39
.travis.yml
39
.travis.yml
|
@ -1,37 +1,34 @@
|
|||
env:
|
||||
- TARGET=CC3D
|
||||
- TARGET=CJMCU
|
||||
- TARGET=NAZE
|
||||
- TARGET=STM32F3DISCOVERY
|
||||
- TARGET=RMDO
|
||||
- TARGET=SPRACINGF3
|
||||
- TARGET=SPRACINGF3EVO
|
||||
- TARGET=SPARKY
|
||||
- TARGET=FURYF3
|
||||
- TARGET=RCEXPLORERF3
|
||||
- TARGET=REVO
|
||||
# - TARGET=CC3D
|
||||
# - TARGET=CJMCU
|
||||
# - TARGET=NAZE
|
||||
# - TARGET=STM32F3DISCOVERY
|
||||
# - TARGET=RMDO
|
||||
# - TARGET=SPRACINGF3
|
||||
# - TARGET=SPRACINGF3EVO
|
||||
# - TARGET=SPARKY
|
||||
# - TARGET=FURYF3
|
||||
# - TARGET=RCEXPLORERF3
|
||||
# - TARGET=REVO
|
||||
|
||||
# use new docker environment
|
||||
sudo: false
|
||||
|
||||
git:
|
||||
depth: 5
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- build-essential
|
||||
- git
|
||||
- libc6-i386
|
||||
- zlib1g-dev
|
||||
- libssl-dev
|
||||
- wkhtmltopdf
|
||||
- libxml2-dev
|
||||
- libxslt-dev
|
||||
|
||||
# We use cpp for unit tests, and c for the main project.
|
||||
language: cpp
|
||||
compiler: clang
|
||||
|
||||
before_install:
|
||||
- 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 -
|
||||
before_install: ./install-toolchain.sh
|
||||
|
||||
install:
|
||||
- export PATH=$PATH:$PWD/gcc-arm-none-eabi-5_4-2016q2/bin
|
||||
|
@ -39,9 +36,13 @@ install:
|
|||
before_script: arm-none-eabi-gcc --version
|
||||
script: ./.travis.sh
|
||||
|
||||
cache: apt
|
||||
cache:
|
||||
apt: true
|
||||
directories:
|
||||
- $PWD/gcc-arm-none-eabi-5_4-2016q2
|
||||
|
||||
notifications:
|
||||
#slack: inavflight:UWRoWFJ4cbbpHXT8HJJlAPXa
|
||||
email: false
|
||||
webhooks:
|
||||
urls:
|
||||
|
|
132
Makefile
132
Makefile
|
@ -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 ?=
|
||||
|
||||
## 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
|
||||
#
|
||||
|
@ -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.
|
||||
|
||||
$(TARGET_HEX): $(TARGET_ELF)
|
||||
$(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
|
||||
$(V0) $(OBJCOPY) -O ihex --set-start 0x8000000 $< $@
|
||||
|
||||
$(TARGET_BIN): $(TARGET_ELF)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(V0) $(OBJCOPY) -O binary $< $@
|
||||
|
||||
$(TARGET_ELF): $(TARGET_OBJS)
|
||||
@echo LD $(notdir $@)
|
||||
@$(CC) -o $@ $^ $(LDFLAGS)
|
||||
$(SIZE) $(TARGET_ELF)
|
||||
$(V1) echo Linking $(TARGET)
|
||||
$(V1) $(CC) -o $@ $^ $(LDFLAGS)
|
||||
$(V0) $(SIZE) $(TARGET_ELF)
|
||||
|
||||
# Compile
|
||||
$(OBJECT_DIR)/$(TARGET)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
@echo %% $(notdir $<)
|
||||
@$(CC) -c -o $@ $(CFLAGS) $<
|
||||
$(V1) mkdir -p $(dir $@)
|
||||
$(V1) echo %% $(notdir $<) "$(STDOUT)"
|
||||
$(V1) $(CC) -c -o $@ $(CFLAGS) $<
|
||||
|
||||
# Assemble
|
||||
$(OBJECT_DIR)/$(TARGET)/%.o: %.s
|
||||
@mkdir -p $(dir $@)
|
||||
@echo %% $(notdir $<)
|
||||
@$(CC) -c -o $@ $(ASFLAGS) $<
|
||||
$(V1) mkdir -p $(dir $@)
|
||||
$(V1) echo %% $(notdir $<) "$(STDOUT)"
|
||||
$(V1) $(CC) -c -o $@ $(ASFLAGS) $<
|
||||
|
||||
$(OBJECT_DIR)/$(TARGET)/%.o: %.S
|
||||
@mkdir -p $(dir $@)
|
||||
@echo %% $(notdir $<)
|
||||
@$(CC) -c -o $@ $(ASFLAGS) $<
|
||||
$(V1) mkdir -p $(dir $@)
|
||||
$(V1) echo %% $(notdir $<) "$(STDOUT)"
|
||||
$(V1) $(CC) -c -o $@ $(ASFLAGS) $<
|
||||
|
||||
|
||||
## all : Build all valid targets
|
||||
all: $(VALID_TARGETS)
|
||||
|
||||
$(VALID_TARGETS):
|
||||
echo "" && \
|
||||
echo "Building $@" && \
|
||||
$(MAKE) -j TARGET=$@ && \
|
||||
echo "Building $@ succeeded."
|
||||
$(V0) echo "" && \
|
||||
echo "Building $@" && \
|
||||
$(MAKE) -j TARGET=$@ && \
|
||||
echo "Building $@ succeeded."
|
||||
|
||||
## clean : clean up all temporary / machine-generated files
|
||||
clean:
|
||||
rm -f $(CLEAN_ARTIFACTS)
|
||||
rm -rf $(OBJECT_DIR)/$(TARGET)
|
||||
$(V0) echo "Cleaning $(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:
|
||||
cd src/test && $(MAKE) clean || true
|
||||
$(V0) cd src/test && $(MAKE) clean || true
|
||||
|
||||
## clean_all_targets : clean all valid target platforms
|
||||
clean_all:
|
||||
for clean_target in $(VALID_TARGETS); do \
|
||||
echo "" && \
|
||||
echo "Cleaning $$clean_target" && \
|
||||
$(MAKE) -j TARGET=$$clean_target clean || \
|
||||
break; \
|
||||
echo "Cleaning $$clean_target succeeded."; \
|
||||
done
|
||||
## clean_<TARGET> : clean up one specific target
|
||||
$(CLEAN_TARGETS) :
|
||||
$(V0) $(MAKE) -j TARGET=$(subst clean_,,$@) clean
|
||||
|
||||
## <TARGET>_clean : clean up one specific target (alias for above)
|
||||
$(TARGETS_CLEAN) :
|
||||
$(V0) $(MAKE) -j TARGET=$(subst _clean,,$@) clean
|
||||
|
||||
## 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)
|
||||
stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
|
||||
echo -n 'R' >$(SERIAL_DEVICE)
|
||||
stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
|
||||
$(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
|
||||
$(V0) echo -n 'R' >$(SERIAL_DEVICE)
|
||||
$(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
|
||||
|
||||
## flash : flash firmware (.hex) onto flight controller
|
||||
flash: flash_$(TARGET)
|
||||
|
||||
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: st-flash_$(TARGET)
|
||||
|
@ -760,42 +786,42 @@ binary: $(TARGET_BIN)
|
|||
hex: $(TARGET_HEX)
|
||||
|
||||
unbrick_$(TARGET): $(TARGET_HEX)
|
||||
stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
|
||||
stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
|
||||
$(V0) stty -F $(SERIAL_DEVICE) raw speed 115200 -crtscts cs8 -parenb -cstopb -ixon
|
||||
$(V0) stm32flash -w $(TARGET_HEX) -v -g 0x0 -b 115200 $(SERIAL_DEVICE)
|
||||
|
||||
## unbrick : unbrick flight controller
|
||||
unbrick: unbrick_$(TARGET)
|
||||
|
||||
## cppcheck : run static analysis on C source code
|
||||
cppcheck: $(CSOURCES)
|
||||
$(CPPCHECK)
|
||||
$(V0) $(CPPCHECK)
|
||||
|
||||
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: Makefile
|
||||
@echo ""
|
||||
@echo "Makefile for the $(FORKNAME) firmware"
|
||||
@echo ""
|
||||
@echo "Usage:"
|
||||
@echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]"
|
||||
@echo "Or:"
|
||||
@echo " make <target> [OPTIONS=\"<options>\"]"
|
||||
@echo ""
|
||||
@echo "Valid TARGET values are: $(VALID_TARGETS)"
|
||||
@echo ""
|
||||
@sed -n 's/^## //p' $<
|
||||
$(V0) @echo ""
|
||||
$(V0) @echo "Makefile for the $(FORKNAME) firmware"
|
||||
$(V0) @echo ""
|
||||
$(V0) @echo "Usage:"
|
||||
$(V0) @echo " make [TARGET=<target>] [OPTIONS=\"<options>\"]"
|
||||
$(V0) @echo "Or:"
|
||||
$(V0) @echo " make <target> [OPTIONS=\"<options>\"]"
|
||||
$(V0) @echo ""
|
||||
$(V0) @echo "Valid TARGET values are: $(VALID_TARGETS)"
|
||||
$(V0) @echo ""
|
||||
$(V0) @sed -n 's/^## //p' $<
|
||||
|
||||
## targets : print a list of all valid target platforms (for consumption by scripts)
|
||||
targets:
|
||||
@echo "Valid targets: $(VALID_TARGETS)"
|
||||
@echo "Target: $(TARGET)"
|
||||
@echo "Base target: $(BASE_TARGET)"
|
||||
$(V0) @echo "Valid targets: $(VALID_TARGETS)"
|
||||
$(V0) @echo "Target: $(TARGET)"
|
||||
$(V0) @echo "Base target: $(BASE_TARGET)"
|
||||
|
||||
## test : run the cleanflight test suite
|
||||
test:
|
||||
cd src/test && $(MAKE) test || true
|
||||
$(V0) cd src/test && $(MAKE) test || true
|
||||
|
||||
# rebuild everything when makefile changes
|
||||
$(TARGET_OBJS) : Makefile
|
||||
|
|
5
install-toolchain.sh
Executable file
5
install-toolchain.sh
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue