Skip to content

Commit

Permalink
[CI] Simpler entry points for cross tools
Browse files Browse the repository at this point in the history
  • Loading branch information
mfld-fr committed Feb 8, 2020
1 parent 69600c6 commit 3907129
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cross.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
pull_request:
paths:
- '**'
- '!.github/workflows/cross.yml'
- '!tools/*'

jobs:
build:
Expand Down
111 changes: 65 additions & 46 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,89 +6,108 @@ 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

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

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

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)

16 changes: 4 additions & 12 deletions tools/build.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tools/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
12 changes: 4 additions & 8 deletions tools/prune.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3907129

Please sign in to comment.