From 23d02d5156be319637817bc11b6a3fffe990aad2 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 6 Jan 2024 13:39:54 +0100 Subject: [PATCH] fix: makefile builds with mingw --- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ Makefile | 2 +- test/Makefile | 6 +++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b171b9a3..1916526b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -212,3 +212,34 @@ jobs: - name: CTest shell: msys2 {0} run: ctest --no-tests=error --test-dir out -VV --build-config Release + + msys2-makefile-test: + name: msys2-makefile-${{ matrix.msystem }} + needs: makefile-analysis + runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + include: + - { msystem: msys, toolchain: "gcc" } + # - { msystem: mingw32, env: mingw-w64-i686- } disabled, c.f. https://github.com/aklomp/base64/issues/131 + - { msystem: mingw64, env: mingw-w64-x86_64- } + - { msystem: ucrt64, env: mingw-w64-ucrt-x86_64- } + # - { msystem: clang32, env: mingw-w64-clang-i686- } disabled, lld does not support the "-r" option + # - { msystem: clang64, env: mingw-w64-clang-x86_64- } disabled, lld does not support the "-r" option + env: + CC: cc.exe + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup MSYS2 ${{matrix.msystem}} + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.msystem}} + update: true + install: >- + make + ${{ matrix.env }}${{ matrix.toolchain || 'toolchain' }} + - name: Run tests + shell: msys2 {0} + run: ./test/ci/test.sh diff --git a/Makefile b/Makefile index bcb94455..e5c2e3a9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -std=c99 -O3 -Wall -Wextra -pedantic +CFLAGS += -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE # Set OBJCOPY if not defined by environment: OBJCOPY ?= objcopy diff --git a/test/Makefile b/test/Makefile index c896627e..edfc3eed 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -std=c99 -O3 -Wall -Wextra -pedantic +CFLAGS += -std=c99 -O3 -Wall -Wextra -pedantic -DBASE64_STATIC_DEFINE ifdef OPENMP CFLAGS += -fopenmp endif @@ -6,6 +6,8 @@ endif TARGET := $(shell $(CC) -dumpmachine) ifneq (, $(findstring darwin, $(TARGET))) BENCH_LDFLAGS= +else ifneq (, $(findstring mingw, $(TARGET))) + BENCH_LDFLAGS= else # default to linux, -lrt needed BENCH_LDFLAGS=-lrt @@ -15,7 +17,9 @@ endif test: clean test_base64 benchmark ./test_base64 +ifeq (, $(findstring mingw, $(TARGET))) # no "/dev/urandom" on Windows ./benchmark +endif valgrind: clean test_base64 valgrind --error-exitcode=2 ./test_base64