Skip to content

Commit

Permalink
Use environment variable instead of multiple make files
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-urban committed Sep 16, 2024
1 parent 7509554 commit b3ad728
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 110 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/test-alternative-compilers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: run gsw_check (alternative compilers)

on:
pull_request:
push:
#branches: [master]
workflow_dispatch:

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: windows / clang-cl (c++)
os: windows-latest
compiler: 'clang-cl /TP'
make_tool: "nmake"
- name: linux / g++ (c++)
os: ubuntu-latest
compiler: 'g++ -x c++'
make_tool: "make"
- name: linux / clang (c)
os: ubuntu-latest
compiler: 'clang'
make_tool: "make"
- name: linux / clang (c++)
os: ubuntu-latest
compiler: 'clang -x c++'
make_tool: "make"
- name: macos / g++ (c++)
os: macos-latest
compiler: 'g++ -x c++'
make_tool: "make"
- name: macos / clang (c)
os: macos-latest
compiler: 'clang'
make_tool: "make"
- name: macos / clang (c++)
os: macos-latest
compiler: 'clang -x c++'
make_tool: "make"
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1

- name: Check COMPILER variable
shell: bash
env:
COMPILER: ${{ matrix.compiler }}
run: |
output=$(${{ matrix.make_tool }} name_compiler)
echo "$output"
if [[ "$output" != *"${{ matrix.compiler }}"* ]]; then
echo "COMPILER '${{ matrix.compiler }}'' variable not used by the make file!"
#exit 1
fi
- name: Compile
shell: bash
env:
COMPILER: ${{ matrix.compiler }}
run: ${{ matrix.make_tool }}

- name: Tests
shell: bash
run: |
./gsw_check
24 changes: 0 additions & 24 deletions .github/workflows/test-g++.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/tests-clang-cl.yml

This file was deleted.

7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ include TOOLS.gcc # \
all: $(Program) $(Library)

$(Program):
$(CPP) $(CRELEASE) $(PROGRAM_SOURCES) $(LIBS) $(OUT)$(Program)$(X)
$(COMPILER) $(CRELEASE) $(PROGRAM_SOURCES) $(LIBS) $(OUT)$(Program)$(X)

library: $(Library)
$(Library):
$(CPP) $(LFLAGS) $(LIBRARY_SRCS) $(LIBS) $(OUT)$(Library)$(SHARED_POSTFIX)
$(COMPILER) $(LFLAGS) $(LIBRARY_SRCS) $(LIBS) $(OUT)$(Library)$(SHARED_POSTFIX)

clean:
$(RM) *.o *.obj *.ilk *.pdb *.tmp *.i *~
$(RM) $(Library)$(SHARED_POSTFIX)
$(RM) $(Program)$(X)

name_compiler:
@echo $(COMPILER_NAME)
30 changes: 0 additions & 30 deletions Makefile-clang-cl

This file was deleted.

30 changes: 0 additions & 30 deletions Makefile-g++

This file was deleted.

3 changes: 3 additions & 0 deletions TOOLS.gcc
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ CPP = gcc
X =
O = .o
SHARED_POSTFIX = .so

# Optionally set the compiler using the environment variable COMPILER
COMPILER ?= $(CPP)
3 changes: 3 additions & 0 deletions TOOLS.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ CPP = $(CC) /TP
X = .exe
O = .obj
SHARED_POSTFIX = .dll
# set the compiler using the environment variable COMPILER
# to override with environment variable use nmake /E
COMPILER = $(CPP)

0 comments on commit b3ad728

Please sign in to comment.