Skip to content

Commit

Permalink
Travis. Run both unit tests and target builds. (#1511)
Browse files Browse the repository at this point in the history
* Travis. Run both unit tests and target builds.
  • Loading branch information
AndersHoglund committed Nov 9, 2016
1 parent 096dcfe commit 446959e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
16 changes: 5 additions & 11 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ TARGET_FILE=obj/betaflight_${TARGET}
TRAVIS_REPO_SLUG=${TRAVIS_REPO_SLUG:=$USER/undefined}
BUILDNAME=${BUILDNAME:=travis}
TRAVIS_BUILD_NUMBER=${TRAVIS_BUILD_NUMBER:=undefined}
MAKEFILE="-f Makefile"

CURL_BASEOPTS=(
"--retry" "10"
Expand All @@ -22,12 +21,8 @@ CURL_PUB_BASEOPTS=(
"--form" "github_repo=${TRAVIS_REPO_SLUG}"
"--form" "build_name=${BUILDNAME}" )

# 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 [ $PUBLISHDOCS ] ; then
if [ $PUBLISH_URL ] ; then

# Patch Gimli to fix underscores_inside_words
Expand All @@ -51,8 +46,8 @@ elif [ $PUBLISHMETA ] ; then
fi

elif [ $TARGET ] ; then
make $TARGET
if [ $PUBLISH_URL ] ; then
make -j2 $MAKEFILE
if [ -f ${TARGET_FILE}.bin ] ; then
TARGET_FILE=${TARGET_FILE}.bin
elif [ -f ${TARGET_FILE}.hex ] ; then
Expand All @@ -64,10 +59,9 @@ elif [ $TARGET ] ; then

curl -k "${CURL_BASEOPTS[@]}" "${CURL_PUB_BASEOPTS[@]}" --form "file=@${TARGET_FILE}" ${PUBLISH_URL} || true
exit 0;
else
make -j2 $MAKEFILE
fi
else
# No target specified, build all with very low verbosity.
elif [ $GOAL ] ; then
make V=0 $GOAL
else
make V=0 all
fi
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

env:
# Specify target(s) to build, or none to build all.
# - RUNTESTS=True
# - PUBLISHMETA=True
# - PUBLISHDOCS=True
# Specify the main Mafile supported goals.
- GOAL=test
- GOAL=all
# Or specify targets to run.
# - TARGET=AFROMINI
# - TARGET=AIORACERF3
# - TARGET=AIR32
Expand Down Expand Up @@ -79,7 +81,11 @@ compiler: clang
install:
- make arm_sdk_install

before_script: tools/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc --version
before_script:
- tools/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc --version
- clang --version
- clang++ --version

script: ./.travis.sh

cache:
Expand All @@ -100,4 +106,3 @@ notifications:
on_success: always # options: [always|never|change] default: always
on_failure: always # options: [always|never|change] default: always
on_start: always # options: [always|never|change] default: always

14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ CCACHE :=
endif

# Tool names
CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc
CPP := $(CCACHE) $(ARM_SDK_PREFIX)g++
CROSS_CC := $(CCACHE) $(ARM_SDK_PREFIX)gcc
CROSS_CXX := $(CCACHE) $(ARM_SDK_PREFIX)g++
OBJCOPY := $(ARM_SDK_PREFIX)objcopy
SIZE := $(ARM_SDK_PREFIX)size

Expand Down Expand Up @@ -833,25 +833,25 @@ $(TARGET_BIN): $(TARGET_ELF)

$(TARGET_ELF): $(TARGET_OBJS)
$(V1) echo Linking $(TARGET)
$(V1) $(CC) -o $@ $^ $(LDFLAGS)
$(V1) $(CROSS_CC) -o $@ $^ $(LDFLAGS)
$(V0) $(SIZE) $(TARGET_ELF)

# Compile
$(OBJECT_DIR)/$(TARGET)/%.o: %.c
$(V1) mkdir -p $(dir $@)
$(V1) echo "%% $(notdir $<)" "$(STDOUT)"
$(V1) $(CC) -c -o $@ $(CFLAGS) $<
$(V1) $(CROSS_CC) -c -o $@ $(CFLAGS) $<

# Assemble
$(OBJECT_DIR)/$(TARGET)/%.o: %.s
$(V1) mkdir -p $(dir $@)
$(V1) echo "%% $(notdir $<)" "$(STDOUT)"
$(V1) $(CC) -c -o $@ $(ASFLAGS) $<
$(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<

$(OBJECT_DIR)/$(TARGET)/%.o: %.S
$(V1) mkdir -p $(dir $@)
$(V1) echo "%% $(notdir $<)" "$(STDOUT)"
$(V1) $(CC) -c -o $@ $(ASFLAGS) $<
$(V1) $(CROSS_CC) -c -o $@ $(ASFLAGS) $<

## sample : Build all sample (travis) targets
sample: $(SAMPLE_TARGETS)
Expand Down Expand Up @@ -963,7 +963,7 @@ targets:
## test : run the cleanflight test suite
## junittest : run the cleanflight test suite, producing Junit XML result files.
test junittest:
$(V0) cd src/test && $(MAKE) $@ || true
$(V0) cd src/test && $(MAKE) $@

# rebuild everything when makefile changes
$(TARGET_OBJS) : Makefile
Expand Down

0 comments on commit 446959e

Please sign in to comment.