CI: Store artifacts durring build

Add new option -A is added to tools/testbuild.sh that will take the
created build executable and store it in a folder for the config
that generated it under $ARTIFACTDIR which can be set via an
environment variable or defaulted to $(TOPDIR)/buildartifacts

This is also helpful for local testing because you can now run
tools/testbuild.sh -A sim.dat and have all of the simulation
targets generated without having to rebuild along the way.

In the GitHub Actions workflow the artifacs are uploaded
two two bundles one for macOS and one for Linux

Signed-off-by: Brennan Ashton <bashton@brennanashton.com>
This commit is contained in:
Brennan Ashton 2020-10-25 21:18:43 -07:00 committed by Xiang Xiao
parent d0bde1114d
commit 162da1169e
6 changed files with 39 additions and 4 deletions

View File

@ -161,8 +161,13 @@ jobs:
export CCACHE_DIR=`pwd`/ccache export CCACHE_DIR=`pwd`/ccache
mkdir $CCACHE_DIR mkdir $CCACHE_DIR
cd sources/testing cd sources/testing
./cibuild.sh -c testlist/${{matrix.boards}}.dat export ARTIFACTDIR=`pwd`/../../buildartifacts
./cibuild.sh -A -c testlist/${{matrix.boards}}.dat
ccache -s ccache -s
- uses: actions/upload-artifact@v2
with:
name: linux-builds
path: buildartifacts/
macOS: macOS:
runs-on: macos-10.15 runs-on: macos-10.15
@ -195,5 +200,10 @@ jobs:
export CCACHE_DIR=`pwd`/ccache export CCACHE_DIR=`pwd`/ccache
mkdir $CCACHE_DIR mkdir $CCACHE_DIR
cd sources/testing cd sources/testing
./cibuild.sh -i -c testlist/${{matrix.boards}}.dat export ARTIFACTDIR=`pwd`/../../buildartifacts
./cibuild.sh -i -A -c testlist/${{matrix.boards}}.dat
ccache -s ccache -s
- uses: actions/upload-artifact@v2
with:
name: macos-builds
path: buildartifacts/

View File

@ -56,6 +56,7 @@ define POSTBUILD
dd if=$(PARTITION_TABLE) bs=1 seek=$(shell printf "%d" 0x8000) of=flash_image.bin conv=notrunc && \ dd if=$(PARTITION_TABLE) bs=1 seek=$(shell printf "%d" 0x8000) of=flash_image.bin conv=notrunc && \
dd if=$(NUTTXNAME).bin bs=1 seek=$(shell printf "%d" 0x10000) of=flash_image.bin conv=notrunc && \ dd if=$(NUTTXNAME).bin bs=1 seek=$(shell printf "%d" 0x10000) of=flash_image.bin conv=notrunc && \
echo "Generated: flash_image.bin (it can be run with 'qemu-system-xtensa -nographic -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw')"; \ echo "Generated: flash_image.bin (it can be run with 'qemu-system-xtensa -nographic -machine esp32 -drive file=flash_image.bin,if=mtd,format=raw')"; \
echo "flash_image.bin" >> $(NUTTXNAME).manifest; \
fi fi
endef endef
endif endif

View File

@ -424,17 +424,22 @@ endif
$(Q) if [ -w /tftpboot ] ; then \ $(Q) if [ -w /tftpboot ] ; then \
cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \ cp -f $(BIN) /tftpboot/$(BIN).${CONFIG_ARCH}; \
fi fi
echo $(BIN) > $(NUTTXNAME).manifest
printf "%s\n" *.map >> $(NUTTXNAME).manifest
ifeq ($(CONFIG_INTELHEX_BINARY),y) ifeq ($(CONFIG_INTELHEX_BINARY),y)
@echo "CP: $(NUTTXNAME).hex" @echo "CP: $(NUTTXNAME).hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(NUTTXNAME).hex $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(NUTTXNAME).hex
echo $(NUTTXNAME).hex >> $(NUTTXNAME).manifest
endif endif
ifeq ($(CONFIG_MOTOROLA_SREC),y) ifeq ($(CONFIG_MOTOROLA_SREC),y)
@echo "CP: $(NUTTXNAME).srec" @echo "CP: $(NUTTXNAME).srec"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(NUTTXNAME).srec $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(NUTTXNAME).srec
echo $(NUTTXNAME).srec >> $(NUTTXNAME).manifest
endif endif
ifeq ($(CONFIG_RAW_BINARY),y) ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: $(NUTTXNAME).bin" @echo "CP: $(NUTTXNAME).bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(NUTTXNAME).bin $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(NUTTXNAME).bin
echo $(NUTTXNAME).bin >> $(NUTTXNAME).manifest
endif endif
ifeq ($(CONFIG_UBOOT_UIMAGE),y) ifeq ($(CONFIG_UBOOT_UIMAGE),y)
@echo "MKIMAGE: uImage" @echo "MKIMAGE: uImage"
@ -443,6 +448,7 @@ ifeq ($(CONFIG_UBOOT_UIMAGE),y)
$(Q) if [ -w /tftpboot ] ; then \ $(Q) if [ -w /tftpboot ] ; then \
cp -f uImage /tftpboot/uImage; \ cp -f uImage /tftpboot/uImage; \
fi fi
echo "uImage" >> $(NUTTXNAME).manifest
endif endif
$(call POSTBUILD, $(TOPDIR)) $(call POSTBUILD, $(TOPDIR))

View File

@ -392,17 +392,22 @@ ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)" $(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
endif endif
$(Q) $(MAKE) -C $(ARCH_SRC) EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" $(BIN) $(Q) $(MAKE) -C $(ARCH_SRC) EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" $(BIN)
echo $(BIN) > $(NUTTXNAME).manifest
printf '%s\n' *.map >> $(NUTTXNAME).manifest
ifeq ($(CONFIG_INTELHEX_BINARY),y) ifeq ($(CONFIG_INTELHEX_BINARY),y)
@echo "CP: $(NUTTXNAME).hex" @echo "CP: $(NUTTXNAME).hex"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(NUTTXNAME).hex $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O ihex $(BIN) $(NUTTXNAME).hex
echo $(NUTTXNAME).hex >> $(NUTTXNAME).manifest
endif endif
ifeq ($(CONFIG_MOTOROLA_SREC),y) ifeq ($(CONFIG_MOTOROLA_SREC),y)
@echo "CP: $(NUTTXNAME).srec" @echo "CP: $(NUTTXNAME).srec"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(NUTTXNAME).srec $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O srec $(BIN) $(NUTTXNAME).srec
echo $(NUTTXNAME).srec >> $(NUTTXNAME).manifest
endif endif
ifeq ($(CONFIG_RAW_BINARY),y) ifeq ($(CONFIG_RAW_BINARY),y)
@echo "CP: $(NUTTXNAME).bin" @echo "CP: $(NUTTXNAME).bin"
$(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(NUTTXNAME).bin $(Q) $(OBJCOPY) $(OBJCOPYARGS) -O binary $(BIN) $(NUTTXNAME).bin
echo $(NUTTXNAME).bin >> $(NUTTXNAME).manifest
endif endif
$(call POSTBUILD, $(TOPDIR)) $(call POSTBUILD, $(TOPDIR))

View File

@ -32,7 +32,7 @@ define POSTBUILD
+$(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools$(DELIM)cxd56 -f Makefile.host +$(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools$(DELIM)cxd56 -f Makefile.host
tools$(DELIM)cxd56$(DELIM)mkspk$(HOSTEXEEXT) -c2 nuttx nuttx nuttx.spk; tools$(DELIM)cxd56$(DELIM)mkspk$(HOSTEXEEXT) -c2 nuttx nuttx nuttx.spk;
$(Q)([ $$? -eq 0 ] && echo "Done.") $(Q)([ $$? -eq 0 ] && echo nuttx.spk >> $(NUTTXNAME).manifest && echo "Done.")
endef endef
endif endif

View File

@ -38,6 +38,9 @@ nuttx=$WD/../nuttx
progname=$0 progname=$0
fail=0 fail=0
APPSDIR=$WD/../apps APPSDIR=$WD/../apps
if [ -z $ARTIFACTDIR ]; then
ARTIFACTDIR=$WD/../buildartifacts
fi
MAKE_FLAGS=-k MAKE_FLAGS=-k
EXTRA_FLAGS="EXTRAFLAGS=" EXTRA_FLAGS="EXTRAFLAGS="
MAKE=make MAKE=make
@ -46,6 +49,7 @@ unset HOPTION
unset JOPTION unset JOPTION
PRINTLISTONLY=0 PRINTLISTONLY=0
GITCLEAN=0 GITCLEAN=0
SAVEARTIFACTS=0
case $(uname -s) in case $(uname -s) in
Darwin*) Darwin*)
@ -77,8 +81,9 @@ function showusage {
echo " -x exit on build failures" echo " -x exit on build failures"
echo " -j <ncpus> passed on to make. Default: No -j make option." echo " -j <ncpus> passed on to make. Default: No -j make option."
echo " -a <appsdir> provides the relative path to the apps/ directory. Default ../apps" echo " -a <appsdir> provides the relative path to the apps/ directory. Default ../apps"
echo " -t <topdir> provides the absolute path to top nuttx/ directory. Default $PWD/../nuttx" echo " -t <topdir> provides the absolute path to top nuttx/ directory. Default ../nuttx"
echo " -p only print the list of configs without running any builds" echo " -p only print the list of configs without running any builds"
echo " -A store the build executable artifact in ARTIFACTDIR (defaults to ../buildartifacts"
echo " -G Use \"git clean -xfdq\" instead of \"make distclean\" to clean the tree." echo " -G Use \"git clean -xfdq\" instead of \"make distclean\" to clean the tree."
echo " This option may speed up the builds. However, note that:" echo " This option may speed up the builds. However, note that:"
echo " * This assumes that your trees are git based." echo " * This assumes that your trees are git based."
@ -130,6 +135,9 @@ while [ ! -z "$1" ]; do
-G ) -G )
GITCLEAN=1 GITCLEAN=1
;; ;;
-A )
SAVEARTIFACTS=1
;;
-h ) -h )
showusage showusage
;; ;;
@ -247,6 +255,11 @@ function configure {
function build { function build {
echo " Building NuttX..." echo " Building NuttX..."
makefunc makefunc
if [ ${SAVEARTIFACTS} -eq 1 ]; then
artifactconfigdir=$ARTIFACTDIR/$(echo $config | sed "s/:/\//")/
mkdir -p $artifactconfigdir
xargs -a $nuttx/nuttx.manifest cp -t $artifactconfigdir
fi
# Ensure defconfig in the canonical form # Ensure defconfig in the canonical form