diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 0b3e83d57..9cbebb3f9 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -7,17 +7,23 @@ on: pull_request: branches: - "*" + workflow_dispatch: + inputs: + debug_enabled: + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' + required: false + default: false jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - - name: install-mingw + - name: Install MinGW run: "sudo apt-get install gcc-mingw-w64-i686" - uses: actions/checkout@v2 - name: make run: make zip - - name: succ + - name: Work around silly artifact uploader run: unzip flexptools.zip -d flexptools-zip - run: unzip spin2cpp.zip -d spin2cpp-zip - uses: actions/upload-artifact@v2.1.3 @@ -29,10 +35,20 @@ jobs: name: spin2cpp-git path: "spin2cpp-zip/*" test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - name: make - run: make - - name: test - run: make test_offline + - uses: actions/checkout@v2 + # Enable tmate debugging of manually-triggered workflows if the input option was provided + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} + - name: Install non-buggy GCC/GCOV + run: "sudo apt-get install gcc-8" + - name: make + run: make all TEST_COVERAGE=1 CC=gcc-8 CCOV=gcov-8 + - name: test + run: make test_offline TEST_COVERAGE=1 CC=gcc-8 CCOV=gcov-8 + - name: gcov + run: make coverage TEST_COVERAGE=1 CC=gcc-8 CCOV=gcov-8 + - name: Upload coverage + run: "bash <(curl -s https://codecov.io/bash) -X gcov" diff --git a/Makefile b/Makefile index d3eca7c0a..b50ea8640 100644 --- a/Makefile +++ b/Makefile @@ -68,16 +68,29 @@ else ifeq ($(CROSS),macosx) CC=o64-clang -DMACOSX -O EXT= BUILD=./build-macosx -else ifeq ($(OS),Windows_NT) - CC=gcc +else ifeq ($(OS),Windows_NT) + ifeq ($(CC),cc) + # Workaround for weird windows/mingw/msys/whatever nonsense + CC=gcc + endif + CC?=gcc EXT=.exe BUILD=./build else - CC=gcc + CC?=gcc EXT= BUILD=./build endif +CCOV?=gcov + +ifdef TEST_COVERAGE + BUILD=./build-gcov + CFLAGS+=--coverage -fprofile-dir=$(realpath .) -fprofile-abs-path +endif + +export BUILD + INC=-I. -I$(BUILD) DEFS=-DFLEXSPIN_BUILD @@ -106,9 +119,9 @@ endif #check: # echo YACC="$(RUNYACC)" YACCVER="$(YACCVER)" YACC_CHECK="$(YACC_CHECK)" -CFLAGS = -g -Wall $(INC) $(DEFS) -#CFLAGS = -no-pie -pg -Wall $(INC) $(DEFS) -#CFLAGS = -g -Og -Wall -Wc++-compat -Werror $(INC) $(DEFS) +CFLAGS += -g -Wall $(INC) $(DEFS) +#CFLAGS += -no-pie -pg -Wall $(INC) $(DEFS) +#CFLAGS += -g -Og -Wall -Wc++-compat -Werror $(INC) $(DEFS) LIBS = -lm RM = rm -rf @@ -151,7 +164,7 @@ help: all: $(BUILD) $(PROGS) -$(BUILD)/testlex$(EXT): testlex.c $(LEXOBJS) +$(BUILD)/testlex$(EXT): $(LEXOBJS) $(BUILD)/testlex.o $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(BUILD)/spin.tab.c $(BUILD)/spin.tab.h: frontends/spin/spin.y @@ -172,10 +185,16 @@ preproc: preprocess.c $(UTIL) clean: $(RM) $(PROGS) $(BUILD)/* *.zip -test_offline: lextest asmtest cpptest errtest p2test +clean_profile: + $(RM) $(BUILD)/*.gcda $(BUILD)/*.gcov + +test_offline: $(BUILD) lextest asmtest cpptest errtest p2test test: test_offline runtest #test: lextest asmtest cpptest errtest runtest +coverage: + (cd $(BUILD); $(CCOV) testlex.c cmdline.c spin2cpp.c flexspin.c flexcc.c $(SPINSRCS)) + lextest: $(PROGS) $(BUILD)/testlex @@ -194,13 +213,13 @@ p2test: $(PROGS) runtest: $(PROGS) (cd Test; ./runtests.sh) -$(BUILD)/spin2cpp$(EXT): spin2cpp.c cmdline.c $(OBJS) +$(BUILD)/spin2cpp$(EXT): $(BUILD)/spin2cpp.o $(BUILD)/cmdline.o $(OBJS) $(CC) $(CFLAGS) -o $@ $^ $(LIBS) -$(BUILD)/flexspin$(EXT): flexspin.c cmdline.c $(OBJS) +$(BUILD)/flexspin$(EXT): $(BUILD)/flexspin.o $(BUILD)/cmdline.o $(OBJS) $(CC) $(CFLAGS) -o $@ $^ $(LIBS) -$(BUILD)/flexcc$(EXT): flexcc.c cmdline.c $(OBJS) +$(BUILD)/flexcc$(EXT): $(BUILD)/flexcc.o $(BUILD)/cmdline.o $(OBJS) $(CC) $(CFLAGS) -o $@ $^ $(LIBS) $(BUILD): diff --git a/Test/asmtests.sh b/Test/asmtests.sh index 5e85dd8c4..5421759eb 100755 --- a/Test/asmtests.sh +++ b/Test/asmtests.sh @@ -3,7 +3,7 @@ if [ "$1" != "" ]; then SPIN2CPP=$1 else - SPIN2CPP=../build/spin2cpp + SPIN2CPP=../${BUILD:='./build'}/spin2cpp fi PROG="$SPIN2CPP -I../Lib" diff --git a/Test/cpptests.sh b/Test/cpptests.sh index ce81c3c9f..165dd7ff4 100755 --- a/Test/cpptests.sh +++ b/Test/cpptests.sh @@ -3,7 +3,7 @@ if [ "$1" != "" ]; then SPIN2CPP=$1 else - SPIN2CPP=../build/spin2cpp + SPIN2CPP=../${BUILD:='./build'}/spin2cpp fi PROG="$SPIN2CPP -I../Lib" diff --git a/Test/errtests.sh b/Test/errtests.sh index 06421d2cc..266c4b65c 100755 --- a/Test/errtests.sh +++ b/Test/errtests.sh @@ -3,7 +3,7 @@ if [ "$1" != "" ]; then PROG=$1 else - PROG=../build/spin2cpp + PROG=../${BUILD:='./build'}/spin2cpp fi CC=propeller-elf-gcc ok="ok" diff --git a/Test/p2bin.sh b/Test/p2bin.sh index fce123b71..0234f78b2 100755 --- a/Test/p2bin.sh +++ b/Test/p2bin.sh @@ -3,7 +3,7 @@ if [ "$1" != "" ]; then FASTSPIN=$1 else - FASTSPIN=../build/flexspin + FASTSPIN=../${BUILD:='./build'}/flexspin fi PROG="$FASTSPIN -q -2b -I../Lib" diff --git a/Test/runtests.sh b/Test/runtests.sh index 741e9ae26..6c3f1d426 100755 --- a/Test/runtests.sh +++ b/Test/runtests.sh @@ -4,8 +4,8 @@ if [ "$1" != "" ]; then SPIN2CPP=$1 FASTSPIN="$1 --asm --binary --code=hub" else - SPIN2CPP=../build/spin2cpp - FASTSPIN="../build/flexspin -g -q" + SPIN2CPP=../${BUILD:='./build'}/spin2cpp + FASTSPIN="../${BUILD:='./build'}/flexspin -g -q" fi PROG_C="$SPIN2CPP -I../Lib" diff --git a/Test/runtests_bc.sh b/Test/runtests_bc.sh index fb5e77217..26923ca1a 100755 --- a/Test/runtests_bc.sh +++ b/Test/runtests_bc.sh @@ -4,8 +4,8 @@ if [ "$1" != "" ]; then SPIN2CPP=$1 FASTSPIN="$1 -g -q --interp=rom" else - SPIN2CPP=../build/spin2cpp - FASTSPIN="../build/flexspin -g -q --interp=rom" + SPIN2CPP=../${BUILD:='./build'}/spin2cpp + FASTSPIN="../${BUILD:='./build'}/flexspin -g -q --interp=rom" fi PROG_ASM="$FASTSPIN -I../Lib" diff --git a/Test/runtests_p2.sh b/Test/runtests_p2.sh index 5a9c476ba..7c8f855e2 100755 --- a/Test/runtests_p2.sh +++ b/Test/runtests_p2.sh @@ -4,8 +4,8 @@ if [ "$1" != "" ]; then SPIN2CPP=$1 FASTSPIN="$1 --asm --binary --code=hub" else - SPIN2CPP=../build/spin2cpp - FASTSPIN="../build/flexspin -2 -O2 -g -q" + SPIN2CPP=../${BUILD:='./build'}/spin2cpp + FASTSPIN="../${BUILD:='./build'}/flexspin -2 -O2 -g -q" fi PROG_C="$SPIN2CPP -I../Lib"