From 39071290c074db7e5303e0fa06b45e548568bafe Mon Sep 17 00:00:00 2001 From: mfld-fr Date: Sat, 8 Feb 2020 23:50:33 +0100 Subject: [PATCH] [CI] Simpler entry points for cross tools --- .github/workflows/cross.yml | 4 +- .github/workflows/main.yml | 2 + tools/Makefile | 111 +++++++++++++++++++++--------------- tools/build.sh | 16 ++---- tools/env.sh | 4 +- tools/prune.sh | 12 ++-- 6 files changed, 79 insertions(+), 70 deletions(-) diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 39055c16c..78ceb8b10 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -33,9 +33,9 @@ jobs: if: steps.cache.outputs.cache-hit != 'true' run: tools/build.sh - - name: packing + - name: prune if: steps.cache.outputs.cache-hit != 'true' - run: tools/pack.sh + run: tools/prune.sh - name: upload if: steps.cache.outputs.cache-hit != 'true' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b156d2312..a728f4377 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,8 @@ on: pull_request: paths: - '**' + - '!.github/workflows/cross.yml' + - '!tools/*' jobs: build: diff --git a/tools/Makefile b/tools/Makefile index af16583bd..daf557033 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -6,11 +6,16 @@ endif include $(TOPDIR)/Make.defs -.PHONY: all pack +.PHONY: all prune all:: -# SRCDIR, DISTDIR, BUILDDIR and CROSSDIR must be set in environment +# TOPDIR and CROSSDIR from environment + +SRCDIR=$(TOPDIR)/tools + +DISTDIR=$(CROSSDIR)/dist +BUILDDIR=$(CROSSDIR)/build # BINUTILS for IA16 @@ -18,24 +23,29 @@ BINUTILS_VER=3fc69e3b2e9864a7357027a9c37c37fa6c55685d BINUTILS_DIST=binutils-ia16-$(BINUTILS_VER) $(DISTDIR)/$(BINUTILS_DIST).zip: + mkdir -p $(DISTDIR) cd $(DISTDIR) && wget https://github.com/tkchia/binutils-ia16/archive/$(BINUTILS_VER).zip -O $(BINUTILS_DIST).zip -.binutils.src: $(DISTDIR)/$(BINUTILS_DIST).zip - -rm -rf $(BINUTILS_DIST) - unzip -q $(DISTDIR)/$(BINUTILS_DIST).zip - -rm -rf binutils-src - mv $(BINUTILS_DIST) binutils-src - touch .binutils.src +$(BUILDDIR)/.binutils.src: $(DISTDIR)/$(BINUTILS_DIST).zip + mkdir -p $(BUILDDIR) + rm -rf $(BUILDDIR)/$(BINUTILS_DIST) + cd $(BUILDDIR) && unzip -q $(DISTDIR)/$(BINUTILS_DIST).zip + rm -rf $(BUILDDIR)/binutils-src + cd $(BUILDDIR) && mv $(BINUTILS_DIST) binutils-src + touch $(BUILDDIR)/.binutils.src + +$(BUILDDIR)/.binutils.build: $(BUILDDIR)/.binutils.src + cd $(BUILDDIR) && rm -rf binutils-build + mkdir -p $(BUILDDIR)/binutils-build + cd $(BUILDDIR)/binutils-build && ../binutils-src/configure --target=ia16-elf --prefix="$(CROSSDIR)" --disable-gdb --disable-libdecnumber --disable-readline --disable-sim --disable-nls + $(MAKE) -C $(BUILDDIR)/binutils-build + touch $(BUILDDIR)/.binutils.build -.binutils.build: .binutils.src - -rm -rf binutils-build - mkdir binutils-build - cd binutils-build && ../binutils-src/configure --target=ia16-elf --prefix="$(CROSSDIR)" --disable-gdb --disable-libdecnumber --disable-readline --disable-sim --disable-nls - $(MAKE) -C binutils-build - $(MAKE) -C binutils-build install - touch .binutils.build +$(CROSSDIR)/.binutils.install: $(BUILDDIR)/.binutils.build + $(MAKE) -C $(BUILDDIR)/binutils-build install + touch $(CROSSDIR)/.binutils.install -all:: .binutils.build +all:: $(CROSSDIR)/.binutils.install # GCC for IA16 @@ -43,25 +53,30 @@ GCC_VER=2dd73a5500dce4be8f0f7d4bab02f5ed6bf849b0 GCC_DIST=gcc-ia16-$(GCC_VER) $(DISTDIR)/$(GCC_DIST).zip: + mkdir -p $(DISTDIR) cd $(DISTDIR) && wget https://github.com/tkchia/gcc-ia16/archive/$(GCC_VER).zip -O $(GCC_DIST).zip -.gcc.src: $(DISTDIR)/$(GCC_DIST).zip - -rm -rf $(GCC_DIST) - unzip -q $(DISTDIR)/$(GCC_DIST).zip - -rm -rf gcc-src - mv $(GCC_DIST) gcc-src - touch .gcc.src - cd gcc-src && contrib/download_prerequisites +$(BUILDDIR)/.gcc.src: $(DISTDIR)/$(GCC_DIST).zip + mkdir -p $(BUILDDIR) + rm -rf $(BUILDDIR)/$(GCC_DIST) + cd $(BUILDDIR) && unzip -q $(DISTDIR)/$(GCC_DIST).zip + rm -rf $(BUILDDIR)/gcc-src + cd $(BUILDDIR) && mv $(GCC_DIST) gcc-src + touch $(BUILDDIR)/.gcc.src + cd $(BUILDDIR)/gcc-src && contrib/download_prerequisites -.gcc.build: .gcc.src .binutils.build - -rm -rf gcc-build - mkdir gcc-build - cd gcc-build && ../gcc-src/configure --target=ia16-elf --prefix="$(CROSSDIR)" --without-headers --enable-languages=c --disable-libssp --without-isl - $(MAKE) -C gcc-build - $(MAKE) -C gcc-build install - touch .gcc.build +$(BUILDDIR)/.gcc.build: $(BUILDDIR)/.gcc.src $(BUILDDIR)/.binutils.build + cd $(BUILDDIR) && rm -rf gcc-build + mkdir $(BUILDDIR)/gcc-build + cd $(BUILDDIR)/gcc-build && ../gcc-src/configure --target=ia16-elf --prefix="$(CROSSDIR)" --without-headers --enable-languages=c --disable-libssp --without-isl + $(MAKE) -C $(BUILDDIR)/gcc-build + touch $(BUILDDIR)/.gcc.build -all:: .gcc.build +$(CROSSDIR)/.gcc.install: $(BUILDDIR)/.gcc.build + $(MAKE) -C $(BUILDDIR)/gcc-build install + touch $(CROSSDIR)/.gcc.install + +all:: $(CROSSDIR)/.gcc.install # EMU86 @@ -69,26 +84,30 @@ EMU86_VER=5ea2e76a30c75223c484c3b1bd2f67646e3cfa94 EMU86_DIST=emu86-$(EMU86_VER) $(DISTDIR)/$(EMU86_DIST).zip: + mkdir -p $(DISTDIR) cd $(DISTDIR) && wget https://github.com/mfld-fr/emu86/archive/$(EMU86_VER).zip -O $(EMU86_DIST).zip -.emu86.src: $(DISTDIR)/$(EMU86_DIST).zip - -rm -rf $(EMU86_DIST) - unzip -q $(DISTDIR)/$(EMU86_DIST).zip - -rm -rf emu86 - mv $(EMU86_DIST) emu86 - touch .emu86.src +$(BUILDDIR)/.emu86.src: $(DISTDIR)/$(EMU86_DIST).zip + mkdir -p $(BUILDDIR) + rm -rf $(BUILDDIR)/$(EMU86_DIST) + cd $(BUILDDIR) && unzip -q $(DISTDIR)/$(EMU86_DIST).zip + rm -rf $(BUILDDIR)/emu86 + cd $(BUILDDIR) && mv $(EMU86_DIST) emu86 + touch $(BUILDDIR)/.emu86.src + +$(BUILDDIR)/.emu86.build: $(BUILDDIR)/.emu86.src + $(MAKE) -C $(BUILDDIR)/emu86 all + touch $(BUILDDIR)/.emu86.build -.emu86.build: .emu86.src - $(MAKE) -C emu86 all - install emu86/emu86 $(CROSSDIR)/bin/ - install emu86/pcat $(CROSSDIR)/bin/ - touch .emu86.build +$(CROSSDIR)/.emu86.install: $(BUILDDIR)/.emu86.build + install $(BUILDDIR)/emu86/emu86 $(CROSSDIR)/bin/ + install $(BUILDDIR)/emu86/pcat $(CROSSDIR)/bin/ + touch $(CROSSDIR)/.emu86.install -all:: .emu86.build +all:: $(CROSSDIR)/.emu86.install -# Tools packing +# Tools pruning (to save disk space) -pack: +prune: -rm -rf $(DISTDIR) -rm -rf $(BUILDDIR) - diff --git a/tools/build.sh b/tools/build.sh index f67cd22a4..c297af903 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,19 +1,11 @@ #!/bin/bash -# Build the cross tools for IA16 target +# Build the cross tools for the IA16 target -# This script is the entry point for the 'cross tools build' workflow -# See .github/workflow/cross.yml +# This script is an entry point for the workflows +# See .github/workflow/*.yml SCRIPTDIR="$(dirname "$0")" . "$SCRIPTDIR/env.sh" -export SRCDIR="$TOPDIR/tools" -export DISTDIR="$CROSSDIR/dist" -export BUILDDIR="$CROSSDIR/build" - -mkdir -p "$DISTDIR" -mkdir -p "$BUILDDIR" - -cd "$BUILDDIR" -make -f "$SRCDIR/Makefile" +make -C "$SCRIPTDIR" all diff --git a/tools/env.sh b/tools/env.sh index 20679b9bd..623493729 100755 --- a/tools/env.sh +++ b/tools/env.sh @@ -6,7 +6,7 @@ if [[ ! -e "tools/env.sh" ]]; then echo "ERROR: You did not sourced this script from the top directory."; - echo " Set the top directory /elks as the current one,"; + echo " Set the top directory of ELKS as the current one,"; echo " then source this script again."; return 1; fi @@ -16,7 +16,7 @@ export TOPDIR="$(pwd)" echo TOPDIR set to $TOPDIR if [[ ! -e "$TOPDIR/cross" ]]; then - echo "ERROR: Missing folder for cross build tools."; + echo "ERROR: Missing folder for the cross build tools."; echo " Create an empty folder, either at the top of this ELKS tree," echo " or outside this tree and link it from: $TOPDIR/cross"; return 1; diff --git a/tools/prune.sh b/tools/prune.sh index a57ba013c..1c14d38a3 100755 --- a/tools/prune.sh +++ b/tools/prune.sh @@ -1,15 +1,11 @@ #!/bin/bash -# Pack the cross tools +# Prune the cross tools to save disk space -# This script is one entry point for the 'cross tools build' workflow -# See .github/workflow/cross.yml +# This script is an entry point for the workflows +# See .github/workflow/*.yml SCRIPTDIR="$(dirname "$0")" . "$SCRIPTDIR/env.sh" -export SRCDIR="$TOPDIR/tools" -export DISTDIR="$CROSSDIR/dist" -export BUILDDIR="$CROSSDIR/build" - -make -f "$SRCDIR/Makefile" pack +make -C "$SCRIPTDIR" prune