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
mkdir $CCACHE_DIR
cd sources/testing
./cibuild.sh -c testlist/${{matrix.boards}}.dat
export ARTIFACTDIR=`pwd`/../../buildartifacts
./cibuild.sh -A -c testlist/${{matrix.boards}}.dat
ccache -s
- uses: actions/upload-artifact@v2
with:
name: linux-builds
path: buildartifacts/
macOS:
runs-on: macos-10.15
@ -195,5 +200,10 @@ jobs:
export CCACHE_DIR=`pwd`/ccache
mkdir $CCACHE_DIR
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
- 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=$(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 "flash_image.bin" >> $(NUTTXNAME).manifest; \
fi
endef
endif

View File

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

View File

@ -32,7 +32,7 @@ define POSTBUILD
+$(Q) $(MAKE) -C $(TOPDIR)$(DELIM)tools$(DELIM)cxd56 -f Makefile.host
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
endif

View File

@ -38,6 +38,9 @@ nuttx=$WD/../nuttx
progname=$0
fail=0
APPSDIR=$WD/../apps
if [ -z $ARTIFACTDIR ]; then
ARTIFACTDIR=$WD/../buildartifacts
fi
MAKE_FLAGS=-k
EXTRA_FLAGS="EXTRAFLAGS="
MAKE=make
@ -46,6 +49,7 @@ unset HOPTION
unset JOPTION
PRINTLISTONLY=0
GITCLEAN=0
SAVEARTIFACTS=0
case $(uname -s) in
Darwin*)
@ -77,8 +81,9 @@ function showusage {
echo " -x exit on build failures"
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 " -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 " -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 " This option may speed up the builds. However, note that:"
echo " * This assumes that your trees are git based."
@ -130,6 +135,9 @@ while [ ! -z "$1" ]; do
-G )
GITCLEAN=1
;;
-A )
SAVEARTIFACTS=1
;;
-h )
showusage
;;
@ -247,6 +255,11 @@ function configure {
function build {
echo " Building NuttX..."
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