From 51d03d35de59a8ce8f56d8dc5574715d549291a2 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 24 Aug 2023 10:18:44 -0400 Subject: [PATCH 01/27] Add macOS CI --- .github/workflows/boxes.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 8b21317b..58243410 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -45,3 +45,30 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} file: out/lcov-total.info format: lcov + + build-macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + + - name: add-packages + run: | + brew update + brew install flex bison libunistring pcre2 ncurses diffutils lcov cmocka + brew upgrade + + - name: make cov + run: make cov + + - name: Run white-box tests + run: make utest + + - name: Run black-box tests + run: make covtest + + - name: Coveralls + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + file: out/lcov-total.info + format: lcov From f80372da01cf0a557d61149175031c4da3608145 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Thu, 24 Aug 2023 11:56:05 -0400 Subject: [PATCH 02/27] Explicit LEX and YACC --- .github/workflows/boxes.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 58243410..d821e03a 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -53,18 +53,16 @@ jobs: - name: add-packages run: | - brew update brew install flex bison libunistring pcre2 ncurses diffutils lcov cmocka - brew upgrade - name: make cov - run: make cov + run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison - name: Run white-box tests - run: make utest + run: make utest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison - name: Run black-box tests - run: make covtest + run: make covtest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison - name: Coveralls uses: coverallsapp/github-action@v2 From a7f8206c22fba5d39679b1fffa335a581647a986 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 14:15:57 +0200 Subject: [PATCH 03/27] Allow override of LEX and YACC; merge changes from macos-ci branch --- .github/workflows/boxes.yml | 4 ++-- Makefile | 9 +++++++-- src/Makefile | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index d821e03a..c203c4ef 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -46,14 +46,14 @@ jobs: file: out/lcov-total.info format: lcov - build-macos: + build-mac: runs-on: macos-latest steps: - uses: actions/checkout@v3 - name: add-packages run: | - brew install flex bison libunistring pcre2 ncurses diffutils lcov cmocka + brew install git flex bison libunistring pcre2 ncurses diffutils lcov cmocka - name: make cov run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison diff --git a/Makefile b/Makefile index acd64d98..7cddb321 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,11 @@ DOC_FILES = doc/boxes.1 doc/boxes.el PKG_NAME = boxes-$(BVERSION) OUT_DIR = out +# Set some defaults for LEX and YACC but allow env +# variables to override them. +LEX ?= flex +YACC ?= bison + PCRE2_VERSION = 10.40 PCRE2_DIR = vendor/pcre2-$(PCRE2_VERSION) LIBUNISTRING_VERSION = 1.0 @@ -44,7 +49,7 @@ WIN_CMOCKA_DIR = vendor/cmocka-$(WIN_CMOCKA_VERSION) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - build cov debug: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=unix LEX=flex YACC=bison $@ + $(MAKE) -C src BOXES_PLATFORM=unix LEX=$(LEX) YACC=$(YACC) $@ win32: infomsg replaceinfos $(MAKE) -C src BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ @@ -124,7 +129,7 @@ $(LIBNCURSES_DIR)/lib/libncurses.a: vendor/libncurses-$(LIBNCURSES_VERSION).tar. cd $(LIBNCURSES_DIR) ; ./configure --enable-static ; $(MAKE) static: infomsg replaceinfos $(LIBUNISTRING_DIR)/lib/.libs/libunistring.a $(PCRE2_DIR)/.libs/libpcre2-32.a $(LIBNCURSES_DIR)/lib/libncurses.a - $(MAKE) -C src BOXES_PLATFORM=static LEX=flex YACC=bison LIBUNISTRING_DIR=$(LIBUNISTRING_DIR) \ + $(MAKE) -C src BOXES_PLATFORM=static LEX=$(LEX) YACC=$(YACC) LIBUNISTRING_DIR=$(LIBUNISTRING_DIR) \ PCRE2_DIR=$(PCRE2_DIR) LIBNCURSES_DIR=$(LIBNCURSES_DIR) LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) $@ diff --git a/src/Makefile b/src/Makefile index e04ee37f..8752d465 100644 --- a/src/Makefile +++ b/src/Makefile @@ -102,7 +102,7 @@ flags_: exit 1 parser.c parser.h: parser.y lex.yy.h | check_dir - $(YACC) --warnings=all --verbose --defines=parser.h --output=parser.c $< + $(YACC) -Wall --verbose --header=parser.h -o parser.c $< lex.yy.c lex.yy.h: lexer.l | check_dir $(LEX) --header-file=lex.yy.h $< From 582f1fa1738e0079d7b0d64352412c145678b4bc Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 08:26:04 -0400 Subject: [PATCH 04/27] Turn off whitebox --- .github/workflows/boxes.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index c203c4ef..e21aab19 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -58,8 +58,8 @@ jobs: - name: make cov run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison - - name: Run white-box tests - run: make utest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison + #- name: Run white-box tests + #run: make utest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison - name: Run black-box tests run: make covtest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison From 5262bce6fc8c26f50b4796b527ae9437c0be5be4 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 08:31:34 -0400 Subject: [PATCH 05/27] Use GNU grep on macos --- .github/workflows/boxes.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index e21aab19..e22688e7 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -51,9 +51,11 @@ jobs: steps: - uses: actions/checkout@v3 + # We need to use GNU grep on macOS - name: add-packages run: | - brew install git flex bison libunistring pcre2 ncurses diffutils lcov cmocka + brew install git flex bison libunistring pcre2 ncurses diffutils lcov cmocka grep + echo '/usr/local/opt/grep/libexec/gnubin' >> $GITHUB_PATH - name: make cov run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison From b292c9982faa2f67bf32cc366b924bac6eaac45f Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 08:37:11 -0400 Subject: [PATCH 06/27] macos runners have git libunistring pcre2 and ncurses by default --- .github/workflows/boxes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index e22688e7..7cd87eb9 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -54,7 +54,7 @@ jobs: # We need to use GNU grep on macOS - name: add-packages run: | - brew install git flex bison libunistring pcre2 ncurses diffutils lcov cmocka grep + brew install flex bison diffutils lcov cmocka grep echo '/usr/local/opt/grep/libexec/gnubin' >> $GITHUB_PATH - name: make cov From 2e1ac9cc2a036912b47840fd07b9064b8547ab51 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 08:38:11 -0400 Subject: [PATCH 07/27] Add gnu-sed --- .github/workflows/boxes.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 7cd87eb9..bccb1f7c 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -51,15 +51,18 @@ jobs: steps: - uses: actions/checkout@v3 - # We need to use GNU grep on macOS + # We need to use GNU grep and sed on macOS - name: add-packages run: | - brew install flex bison diffutils lcov cmocka grep + brew install flex bison diffutils lcov cmocka grep gnu-sed echo '/usr/local/opt/grep/libexec/gnubin' >> $GITHUB_PATH + echo '/usr/local/opt/gnu-sed/libexec/gnubin' >> $GITHUB_PATH - name: make cov run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison + # This uses ld --wrap to mock the cmocka functions but + # macOS ld does not support --wrap #- name: Run white-box tests #run: make utest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison From efa6e2dd3f5d0ec463e862df0ccb24f408ad702e Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 08:47:59 -0400 Subject: [PATCH 08/27] Add findutils for xargs --- .github/workflows/boxes.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index bccb1f7c..58c6e38b 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -51,12 +51,13 @@ jobs: steps: - uses: actions/checkout@v3 - # We need to use GNU grep and sed on macOS + # We need to use GNU grep, sed, and xargs on macOS - name: add-packages run: | - brew install flex bison diffutils lcov cmocka grep gnu-sed + brew install flex bison diffutils lcov cmocka grep gnu-sed findutils echo '/usr/local/opt/grep/libexec/gnubin' >> $GITHUB_PATH echo '/usr/local/opt/gnu-sed/libexec/gnubin' >> $GITHUB_PATH + echo '/usr/local/opt/findutils/libexec/gnubin' >> $GITHUB_PATH - name: make cov run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison From 37c85d413e4ae6d772309252261cc9a46433c16b Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 09:07:18 -0400 Subject: [PATCH 09/27] Add LC_ALL --- .github/workflows/boxes.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 58c6e38b..8853e226 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -48,6 +48,11 @@ jobs: build-mac: runs-on: macos-latest + env: + LANG: C + LC_ALL: C + LEX: /usr/local/opt/flex/bin/flex + YACC: /usr/local/opt/bison/bin/bison steps: - uses: actions/checkout@v3 @@ -60,15 +65,15 @@ jobs: echo '/usr/local/opt/findutils/libexec/gnubin' >> $GITHUB_PATH - name: make cov - run: make cov LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison + run: make cov # This uses ld --wrap to mock the cmocka functions but # macOS ld does not support --wrap #- name: Run white-box tests - #run: make utest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison + #run: make utest - name: Run black-box tests - run: make covtest LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison + run: make covtest - name: Coveralls uses: coverallsapp/github-action@v2 From 4457fea199c315a9d5fd2227e4a370aa848183da Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Wed, 30 Aug 2023 09:18:35 -0400 Subject: [PATCH 10/27] Remove LC_ALL as more tests crashed with it --- .github/workflows/boxes.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 8853e226..ecd72f2f 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -49,8 +49,6 @@ jobs: build-mac: runs-on: macos-latest env: - LANG: C - LC_ALL: C LEX: /usr/local/opt/flex/bin/flex YACC: /usr/local/opt/bison/bin/bison steps: From 282a537250e2cbeeb16a5930e78aa429ccae3b76 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sat, 25 Nov 2023 14:24:20 -0500 Subject: [PATCH 11/27] Update to checkout v4 --- .github/workflows/boxes.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index ecd72f2f..3a460add 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -23,7 +23,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: add-packages run: | @@ -52,7 +52,7 @@ jobs: LEX: /usr/local/opt/flex/bin/flex YACC: /usr/local/opt/bison/bin/bison steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # We need to use GNU grep, sed, and xargs on macOS - name: add-packages From c637469e57d25f42b7123677548015c3a50b9b10 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sat, 25 Nov 2023 14:32:28 -0500 Subject: [PATCH 12/27] move to branch_coverage to avoid warning --- test/testrunner.sh | 2 +- utest/report.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/testrunner.sh b/test/testrunner.sh index 9b60a9e5..4039556a 100755 --- a/test/testrunner.sh +++ b/test/testrunner.sh @@ -140,7 +140,7 @@ function measure_coverage() mkdir -p "${testResultsDir}" cp ${OUT_DIR}/*.gc* "${testResultsDir}" lcov --capture --directory "${testResultsDir}" --base-directory ${SRC_DIR} --test-name "${tcBaseName}" --quiet \ - --exclude '*/lex.yy.c' --exclude '*/parser.c' --rc lcov_branch_coverage=1 \ + --exclude '*/lex.yy.c' --exclude '*/parser.c' --rc branch_coverage=1 \ --output-file "${testResultsDir}/coverage.info" echo -n " Coverage: " lcov --summary "${testResultsDir}/coverage.info" 2>&1 | grep 'lines...' | grep -oP '\d+\.\d*%' diff --git a/utest/report.sh b/utest/report.sh index f1b997ea..224a54f8 100755 --- a/utest/report.sh +++ b/utest/report.sh @@ -29,7 +29,7 @@ then mkdir -p ${testReportDir} cp ${OUT_DIR}/*.gc* ${testResultsDir} lcov --capture --directory ${testResultsDir} --base-directory ${SRC_DIR} --test-name ${tcBaseName} --quiet \ - --exclude '*/lex.yy.c' --exclude '*/parser.c' --rc lcov_branch_coverage=1 \ + --exclude '*/lex.yy.c' --exclude '*/parser.c' --rc branch_coverage=1 \ --output-file ${testResultsDir}/coverage.info echo -n "[ Coverage ] " genhtml --title "Boxes / Unit Tests" --branch-coverage --legend --output-directory ${testReportDir} \ From b52709b731d840768ae67a7e103862fa97d93303 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sat, 25 Nov 2023 14:35:30 -0500 Subject: [PATCH 13/27] Ignore unused error --- test/testrunner.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testrunner.sh b/test/testrunner.sh index 4039556a..cd0bf9a6 100755 --- a/test/testrunner.sh +++ b/test/testrunner.sh @@ -154,7 +154,7 @@ function consolidate_coverage() pushd ${OUT_DIR}/test-results || exit 1 find . -name "*.info" | xargs printf -- '--add-tracefile %s\n' | xargs --exit \ lcov --rc lcov_branch_coverage=1 --exclude '*/lex.yy.c' --exclude '*/parser.c' \ - --output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE} + --ignore-errors unused --output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE} popd || exit 1 echo "" } From 153b57085568c9239b417595263b6c20ecb537ce Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sat, 25 Nov 2023 14:48:22 -0500 Subject: [PATCH 14/27] Try and handle test 111 --- test/testrunner.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/testrunner.sh b/test/testrunner.sh index cd0bf9a6..c13951c9 100755 --- a/test/testrunner.sh +++ b/test/testrunner.sh @@ -117,11 +117,23 @@ function execute_suite() local countExecuted=0 local countFailed=0 local tc + + # Note we are getting an encoding error with test 111 which is + # unique and runs under ISO_8859-15. But this only happens on macOS. + # So, if we run test 111 on macOS, we should run with LC_ALL=C for tc in *.txt; do if [ ${opt_coverage} == true ]; then - $0 --coverage "${tc}" + if [[ $(uname) == "Darwin" ]] && [[ ${tc} == "111"* ]]; then + LC_ALL=C $0 --coverage "${tc}" + else + $0 --coverage "${tc}" + fi else - $0 "${tc}" + if [[ $(uname) == "Darwin" ]] && [[ ${tc} == "111"* ]]; then + LC_ALL=C $0 "${tc}" + else + $0 "${tc}" + fi fi if [ $? -ne 0 ]; then overallResult=1 From b51b2470ef4f19e800094042e92da9cf486ae8eb Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sat, 25 Nov 2023 15:00:40 -0500 Subject: [PATCH 15/27] Try and handle multiple coveralls --- .github/workflows/boxes.yml | 17 ++++++++++++++++- test/testrunner.sh | 9 ++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 3a460add..aa7a1ce3 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -45,8 +45,10 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} file: out/lcov-total.info format: lcov + flag-name: run-linux + parallel: true - build-mac: + build-macos: runs-on: macos-latest env: LEX: /usr/local/opt/flex/bin/flex @@ -79,3 +81,16 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} file: out/lcov-total.info format: lcov + flag-name: run-macos + parallel: true + + finish: + needs: [build, build-macos] + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - name: Coveralls Finished + uses: coverallsapp/github-action@v2 + with: + parallel-finished: true + carryforward: "run-linux,run-macos" diff --git a/test/testrunner.sh b/test/testrunner.sh index c13951c9..326e914f 100755 --- a/test/testrunner.sh +++ b/test/testrunner.sh @@ -159,14 +159,17 @@ function measure_coverage() fi } - +# NOTE: It is possible when the white box tests work that we can +# remove the --ignore-errors unused option. But for now, we use it so +# that the CI is "happy" and we can get a baseline. function consolidate_coverage() { echo -e "\nConsolidating test coverage ..." pushd ${OUT_DIR}/test-results || exit 1 find . -name "*.info" | xargs printf -- '--add-tracefile %s\n' | xargs --exit \ - lcov --rc lcov_branch_coverage=1 --exclude '*/lex.yy.c' --exclude '*/parser.c' \ - --ignore-errors unused --output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE} + lcov --rc branch_coverage=1 --exclude '*/lex.yy.c' --exclude '*/parser.c' \ + --ignore-errors unused \ + --output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE} popd || exit 1 echo "" } From a9d968d7f336cb49f27a93f301db6c3395ae42c3 Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Sat, 25 Nov 2023 19:32:26 +0100 Subject: [PATCH 16/27] .gitignore add VS Code and JetBrains CLion files --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 2cf5a9e9..a2f7b973 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ .cproject .project /.idea/ +/.history/ /coverage/ /cmake-build-debug/ @@ -40,6 +41,7 @@ /datagen/ /build/ CMakeUserPresets.json +*.swp # Legacy locations of generated files (no longer in use) /src/boxes @@ -59,5 +61,8 @@ CMakeUserPresets.json /boxes.portable.*.nupkg *.nupkg.zip +# MacOS +.DS_Store + # Misc /vs From 894e3cbc264a10c2c768cfbdd8bb7cab8a8e2841 Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Sat, 25 Nov 2023 11:34:07 -0700 Subject: [PATCH 17/27] Change bx_fprintf to a function pointer to enable unit testing on MacOS --- src/tools.c | 15 ++++++++++++++- src/tools.h | 21 +++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/tools.c b/src/tools.c index 4d9aca8e..58a8de7d 100644 --- a/src/tools.c +++ b/src/tools.c @@ -42,6 +42,15 @@ static pcre2_code *pattern_ascii_id = NULL; static pcre2_code *pattern_ascii_id_strict = NULL; +/** + * Initialize the `bx_fprintf` function pointer to point to the original + * `bx_fprintf` function, now renamed `bx_fprintf_original`. During unit + * tests, this will be replaced with `__wrap_bx_fprintf`, which stores + * the result that would have been printed so the output can be validated. + * This is necessary for unit testing and CI to work with MacOS. + */ +bx_fprintf_t bx_fprintf = bx_fprintf_original; + static pcre2_code *get_pattern_ascii_id(int strict) { @@ -849,7 +858,7 @@ char *bx_strndup(const char *s, size_t n) -void bx_fprintf(FILE *stream, const char *format, ...) +void bx_fprintf_original(FILE *stream, const char *format, ...) { va_list va; va_start(va, format); @@ -858,6 +867,10 @@ void bx_fprintf(FILE *stream, const char *format, ...) } +void set_bx_fprintf(bx_fprintf_t bx_fprintf_function) { + bx_fprintf = bx_fprintf_function; +} + FILE *bx_fopens(bxstr_t *pathname, char *mode) { diff --git a/src/tools.h b/src/tools.h index 65b3ba0c..b4832401 100644 --- a/src/tools.h +++ b/src/tools.h @@ -40,6 +40,18 @@ } +/** + * Define type for a function pointer to specify which `bx_fprintf` function + * will be called. This enables unit testing on MacOS, since Apple's `ld` + * linker does not support the `--wrap` flag that GNU `ld` does. + */ +typedef void (*bx_fprintf_t)(FILE *stream, const char *format, ...); + +/** + * Declare function pointer to be changed when running unit tests + */ +extern bx_fprintf_t bx_fprintf; + int empty_line(const line_t *line); @@ -173,7 +185,7 @@ int tag_is_valid(char *tag); /** * Duplicate at most `n` bytes from the given string `s`. Memory for the new string is obtained with `malloc()`, and - * can be freed with `free()`. A terminating null byte is added. We include this implementation because the libc's + * can be freed with `free()`. A terminating null byte is added. We include this implementation because the libc's * `strndup()` is not consistently available across all platforms. * @param s a string * @param n maximum number of characters to copy (excluding the null byte) @@ -187,8 +199,13 @@ char *bx_strndup(const char *s, size_t n); * @param stream Where to print, for example `stderr` * @param format the format string, followed by the arguments of the format string */ -void bx_fprintf(FILE *stream, const char *format, ...); +void bx_fprintf_original(FILE *stream, const char *format, ...); + +/** + * Set the bx_fprintf_ptr function pointer to point to a specific function + */ +void set_bx_fprintf(bx_fprintf_t func_to_use); /** * Determine if the given string is an "ASCII ID", which means: From ea541d051694b50a4803cd8ff02f9da2893bc4f7 Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Sat, 25 Nov 2023 11:35:06 -0700 Subject: [PATCH 18/27] `setup_mocks()` should set function pointer `bx_fprintf` to point to `__wrap_bx_fprintf()` --- utest/global_mock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/utest/global_mock.c b/utest/global_mock.c index 0355aa46..01e35e2a 100644 --- a/utest/global_mock.c +++ b/utest/global_mock.c @@ -101,6 +101,7 @@ void setup_mocks() setlocale(LC_ALL, ""); encoding = check_encoding("UTF-8", locale_charset()); collect_reset(); + set_bx_fprintf(__wrap_bx_fprintf); } From 8b59fa69a4a31cde3797bb6f0f61230fe7d93e7d Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Sat, 25 Nov 2023 19:36:47 +0100 Subject: [PATCH 19/27] Update Makefile, src/Makefile, and utest/Makefile to support MacOS unit tests --- Makefile | 29 +++++++++++++++++++++++------ src/Makefile | 4 ++-- utest/Makefile | 8 +++++++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 7cddb321..a17eef06 100644 --- a/Makefile +++ b/Makefile @@ -44,20 +44,37 @@ WIN_CMOCKA_DIR = vendor/cmocka-$(WIN_CMOCKA_VERSION) package win32.package package_common utest win32.utest static +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Detect platform (Apple's linker does not support --wrap) +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +BOXES_PLATFORM := "" +ifeq ($(OS),Windows_NT) + BOXES_PLATFORM := win32 +else + UNAME_S := $(shell sh -c 'uname -s 2>/dev/null || echo Unknown') + ifeq ($(UNAME_S),Darwin) + BOXES_PLATFORM := darwin + else + BOXES_PLATFORM := unix + endif +endif + + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Build # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - build cov debug: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=unix LEX=$(LEX) YACC=$(YACC) $@ + $(MAKE) -C src BOXES_PLATFORM=$(BOXES_PLATFORM) LEX=$(LEX) YACC=$(YACC) $@ win32: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ + $(MAKE) -C src BOXES_PLATFORM=$(BOXES_PLATFORM) C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ LEX=../$(WIN_FLEX_BISON_DIR)/win_flex.exe YACC=../$(WIN_FLEX_BISON_DIR)/win_bison.exe \ LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) build win32.debug: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ + $(MAKE) -C src BOXES_PLATFORM=$(BOXES_PLATFORM) C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ LEX=../$(WIN_FLEX_BISON_DIR)/win_flex.exe YACC=../$(WIN_FLEX_BISON_DIR)/win_bison.exe \ LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) debug @@ -159,7 +176,7 @@ $(OUT_DIR)/zip/$(PKG_NAME).zip: @echo Windows ZIP file created at $(OUT_DIR)/zip/$(PKG_NAME).zip package: build - $(MAKE) BOXES_PLATFORM=unix $(PKG_NAME).tar.gz + $(MAKE) BOXES_PLATFORM=$(BOXES_PLATFORM) $(PKG_NAME).tar.gz win32.package: win32 $(OUT_DIR)/zip/$(PKG_NAME).zip @@ -194,11 +211,11 @@ covtest: cd test; ./testrunner.sh --suite --coverage utest: - $(MAKE) -C utest BOXES_PLATFORM=unix utest + $(MAKE) -C utest BOXES_PLATFORM=$(BOXES_PLATFORM) utest win32.utest: $(OUT_DIR) cp $(WIN_CMOCKA_DIR)/bin/cmocka.dll $(OUT_DIR)/ - $(MAKE) -C utest BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src:../$(WIN_CMOCKA_DIR)/include \ + $(MAKE) -C utest BOXES_PLATFORM=$(BOXES_PLATFORM) C_INCLUDE_PATH=../$(PCRE2_DIR)/src:../$(WIN_CMOCKA_DIR)/include \ LDFLAGS_ADDTL="-L../$(PCRE2_DIR)/.libs -L../$(WIN_CMOCKA_DIR)/lib" utest diff --git a/src/Makefile b/src/Makefile index 8752d465..806b0849 100644 --- a/src/Makefile +++ b/src/Makefile @@ -32,7 +32,7 @@ ORIG_SRC = $(ORIG_GEN) $(ORIG_NORM) ORIG_FILES = $(ORIG_SRC) $(ORIG_HDR) -.PHONY: boxes.static check_dir clean build cov debug package static flags_unix flags_static flags_win32 flags_ +.PHONY: boxes.static check_dir clean build cov debug package static flags_unix flags_darwin flags_static flags_win32 flags_ .NOTPARALLEL: @@ -76,7 +76,7 @@ boxes.exe: $(ALL_OBJ) | check_dir if [ "$(STRIP)" = "true" ] ; then strip $@ ; fi -flags_unix: +flags_unix flags_darwin: $(eval CFLAGS := -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) $(eval LDFLAGS := $(LDFLAGS) $(LDFLAGS_ADDTL)) $(eval BOXES_EXECUTABLE_NAME := boxes) diff --git a/utest/Makefile b/utest/Makefile index 088ab0b8..6e5a5395 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -23,7 +23,7 @@ UTEST_NORM = global_mock.c bxstring_test.o cmdline_test.c tools_test.c regulex_t utest_tools.o MOCKS = bx_fprintf -.PHONY: check_dir flags_unix flags_win32 flags_ utest +.PHONY: check_dir flags_unix flags_darwin flags_win32 flags_ utest .NOTPARALLEL: @@ -42,6 +42,12 @@ flags_unix: $(eval UTEST_EXECUTABLE_NAME := unittest) $(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) +flags_darwin: + $(eval CFLAGS := -I. -I$(SRC_DIR) -O -Wall -W -Wno-stringop-overflow $(CFLAGS_ADDTL)) + $(eval LDFLAGS := $(LDFLAGS) --coverage $(LDFLAGS_ADDTL)) + $(eval UTEST_EXECUTABLE_NAME := unittest) + $(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) + flags_win32: $(eval CFLAGS := -Os -s -std=c99 -m32 -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) $(eval LDFLAGS := $(LDFLAGS) -s -std=c99 -m32 $(foreach MOCK,$(MOCKS),-Wl,--wrap=$(MOCK)) $(LDFLAGS_ADDTL)) From ce89decb1c13380b1de0e96dde13881a002baccf Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Sat, 25 Nov 2023 18:05:51 -0700 Subject: [PATCH 20/27] tools.h - change `set_bx_fprintf()` function declaration to match renamed parameter --- src/tools.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools.h b/src/tools.h index b4832401..12a12023 100644 --- a/src/tools.h +++ b/src/tools.h @@ -205,7 +205,7 @@ void bx_fprintf_original(FILE *stream, const char *format, ...); /** * Set the bx_fprintf_ptr function pointer to point to a specific function */ -void set_bx_fprintf(bx_fprintf_t func_to_use); +void set_bx_fprintf(bx_fprintf_t bx_fprintf_function); /** * Determine if the given string is an "ASCII ID", which means: From efe9fc2dd049c5b0df2a1ccbc244f1bcccb0609b Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sun, 26 Nov 2023 12:26:01 -0500 Subject: [PATCH 21/27] Enable white-box tests on macOS --- .github/workflows/boxes.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index aa7a1ce3..61638153 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -67,10 +67,8 @@ jobs: - name: make cov run: make cov - # This uses ld --wrap to mock the cmocka functions but - # macOS ld does not support --wrap - #- name: Run white-box tests - #run: make utest + - name: Run white-box tests + run: make utest - name: Run black-box tests run: make covtest From 0dbab43d40e930d23f4a2c0e98e7dd347bca1379 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sun, 26 Nov 2023 12:34:21 -0500 Subject: [PATCH 22/27] Add flex and bison to env --- .github/workflows/boxes.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 61638153..ab985390 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -22,6 +22,9 @@ env: jobs: build: runs-on: ubuntu-latest + env: + LEX: flex + YACC: bison steps: - uses: actions/checkout@v4 From e66d12bfa8cd2d3a6e5acfea430a0125e3c1f955 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Sun, 26 Nov 2023 12:37:04 -0500 Subject: [PATCH 23/27] Remove ignore errors --- .github/workflows/boxes.yml | 3 --- test/testrunner.sh | 4 ---- 2 files changed, 7 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index ab985390..61638153 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -22,9 +22,6 @@ env: jobs: build: runs-on: ubuntu-latest - env: - LEX: flex - YACC: bison steps: - uses: actions/checkout@v4 diff --git a/test/testrunner.sh b/test/testrunner.sh index 326e914f..5f239ebd 100755 --- a/test/testrunner.sh +++ b/test/testrunner.sh @@ -159,16 +159,12 @@ function measure_coverage() fi } -# NOTE: It is possible when the white box tests work that we can -# remove the --ignore-errors unused option. But for now, we use it so -# that the CI is "happy" and we can get a baseline. function consolidate_coverage() { echo -e "\nConsolidating test coverage ..." pushd ${OUT_DIR}/test-results || exit 1 find . -name "*.info" | xargs printf -- '--add-tracefile %s\n' | xargs --exit \ lcov --rc branch_coverage=1 --exclude '*/lex.yy.c' --exclude '*/parser.c' \ - --ignore-errors unused \ --output-file ../${COVERAGE_FILE} --add-tracefile ../${BASELINE_FILE} popd || exit 1 echo "" From 30a46c08e190178bc9d348325b2c42990f011b78 Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Mon, 27 Nov 2023 08:28:40 -0700 Subject: [PATCH 24/27] Update function name to be wrapped in unit testing `Makefile` --- utest/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/Makefile b/utest/Makefile index 6e5a5395..473798b5 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -21,7 +21,7 @@ VPATH = $(SRC_DIR):$(SRC_DIR)/misc:$(UTEST_DIR) UTEST_NORM = global_mock.c bxstring_test.o cmdline_test.c tools_test.c regulex_test.o main.o unicode_test.o \ utest_tools.o -MOCKS = bx_fprintf +MOCKS = bx_fprintf_original .PHONY: check_dir flags_unix flags_darwin flags_win32 flags_ utest From c874cf11c8ab8ab063a2a37f7a4952335273bf21 Mon Sep 17 00:00:00 2001 From: Matthew Thompson Date: Mon, 27 Nov 2023 18:38:10 -0500 Subject: [PATCH 25/27] use defines --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 806b0849..0121b169 100644 --- a/src/Makefile +++ b/src/Makefile @@ -102,7 +102,7 @@ flags_: exit 1 parser.c parser.h: parser.y lex.yy.h | check_dir - $(YACC) -Wall --verbose --header=parser.h -o parser.c $< + $(YACC) -Wall --verbose --defines=parser.h -o parser.c $< lex.yy.c lex.yy.h: lexer.l | check_dir $(LEX) --header-file=lex.yy.h $< From b80c0c41ccc558a7974b20e11ba46ea13138755b Mon Sep 17 00:00:00 2001 From: David Sargeant Date: Tue, 28 Nov 2023 08:19:50 -0700 Subject: [PATCH 26/27] Removed linker `--wrap` option so unit tests run on macOS --- utest/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utest/Makefile b/utest/Makefile index 473798b5..5af764ee 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -21,7 +21,6 @@ VPATH = $(SRC_DIR):$(SRC_DIR)/misc:$(UTEST_DIR) UTEST_NORM = global_mock.c bxstring_test.o cmdline_test.c tools_test.c regulex_test.o main.o unicode_test.o \ utest_tools.o -MOCKS = bx_fprintf_original .PHONY: check_dir flags_unix flags_darwin flags_win32 flags_ utest @@ -38,7 +37,7 @@ $(OUT_DIR): flags_unix: $(eval CFLAGS := -I. -I$(SRC_DIR) -O -Wall -W -Wno-stringop-overflow $(CFLAGS_ADDTL)) - $(eval LDFLAGS := $(LDFLAGS) $(foreach MOCK,$(MOCKS),-Wl,--wrap=$(MOCK)) --coverage $(LDFLAGS_ADDTL)) + $(eval LDFLAGS := $(LDFLAGS) --coverage $(LDFLAGS_ADDTL)) $(eval UTEST_EXECUTABLE_NAME := unittest) $(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) @@ -50,7 +49,7 @@ flags_darwin: flags_win32: $(eval CFLAGS := -Os -s -std=c99 -m32 -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) - $(eval LDFLAGS := $(LDFLAGS) -s -std=c99 -m32 $(foreach MOCK,$(MOCKS),-Wl,--wrap=$(MOCK)) $(LDFLAGS_ADDTL)) + $(eval LDFLAGS := $(LDFLAGS) -s -std=c99 -m32 $(LDFLAGS_ADDTL)) $(eval UTEST_EXECUTABLE_NAME := unittest.exe) $(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) From f1bda7520d6fed47365b21e1e3292d69569bc6eb Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Fri, 1 Dec 2023 21:57:53 +0100 Subject: [PATCH 27/27] Fix some problems with LEX and YACC defaults on Linux Remove flags_darwin, which are the same as flags_unix now --- .github/workflows/boxes.yml | 4 ++-- Makefile | 40 ++++++++++--------------------------- src/Makefile | 4 ++-- utest/Makefile | 8 +------- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/.github/workflows/boxes.yml b/.github/workflows/boxes.yml index 61638153..7c767f13 100644 --- a/.github/workflows/boxes.yml +++ b/.github/workflows/boxes.yml @@ -51,8 +51,8 @@ jobs: build-macos: runs-on: macos-latest env: - LEX: /usr/local/opt/flex/bin/flex - YACC: /usr/local/opt/bison/bin/bison + BX_LEX: /usr/local/opt/flex/bin/flex + BX_YACC: /usr/local/opt/bison/bin/bison steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index a17eef06..78b759ad 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,9 @@ DOC_FILES = doc/boxes.1 doc/boxes.el PKG_NAME = boxes-$(BVERSION) OUT_DIR = out -# Set some defaults for LEX and YACC but allow env -# variables to override them. -LEX ?= flex -YACC ?= bison +# Set some defaults for BX_LEX and BX_YACC but allow env variables to override them. +BX_LEX ?= flex +BX_YACC ?= bison PCRE2_VERSION = 10.40 PCRE2_DIR = vendor/pcre2-$(PCRE2_VERSION) @@ -44,37 +43,20 @@ WIN_CMOCKA_DIR = vendor/cmocka-$(WIN_CMOCKA_VERSION) package win32.package package_common utest win32.utest static -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# Detect platform (Apple's linker does not support --wrap) -# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -BOXES_PLATFORM := "" -ifeq ($(OS),Windows_NT) - BOXES_PLATFORM := win32 -else - UNAME_S := $(shell sh -c 'uname -s 2>/dev/null || echo Unknown') - ifeq ($(UNAME_S),Darwin) - BOXES_PLATFORM := darwin - else - BOXES_PLATFORM := unix - endif -endif - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Build # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - build cov debug: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=$(BOXES_PLATFORM) LEX=$(LEX) YACC=$(YACC) $@ + $(MAKE) -C src BOXES_PLATFORM=unix LEX=$(BX_LEX) YACC=$(BX_YACC) $@ win32: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=$(BOXES_PLATFORM) C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ + $(MAKE) -C src BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ LEX=../$(WIN_FLEX_BISON_DIR)/win_flex.exe YACC=../$(WIN_FLEX_BISON_DIR)/win_bison.exe \ LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) build win32.debug: infomsg replaceinfos - $(MAKE) -C src BOXES_PLATFORM=$(BOXES_PLATFORM) C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ + $(MAKE) -C src BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src LDFLAGS=-L../$(PCRE2_DIR)/.libs \ LEX=../$(WIN_FLEX_BISON_DIR)/win_flex.exe YACC=../$(WIN_FLEX_BISON_DIR)/win_bison.exe \ LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) debug @@ -146,8 +128,8 @@ $(LIBNCURSES_DIR)/lib/libncurses.a: vendor/libncurses-$(LIBNCURSES_VERSION).tar. cd $(LIBNCURSES_DIR) ; ./configure --enable-static ; $(MAKE) static: infomsg replaceinfos $(LIBUNISTRING_DIR)/lib/.libs/libunistring.a $(PCRE2_DIR)/.libs/libpcre2-32.a $(LIBNCURSES_DIR)/lib/libncurses.a - $(MAKE) -C src BOXES_PLATFORM=static LEX=$(LEX) YACC=$(YACC) LIBUNISTRING_DIR=$(LIBUNISTRING_DIR) \ - PCRE2_DIR=$(PCRE2_DIR) LIBNCURSES_DIR=$(LIBNCURSES_DIR) LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) $@ + $(MAKE) -C src BOXES_PLATFORM=static LEX=$(BX_LEX) YACC=$(BX_YACC) LIBUNISTRING_DIR=$(LIBUNISTRING_DIR) \ + PCRE2_DIR=$(PCRE2_DIR) LIBNCURSES_DIR=$(LIBNCURSES_DIR) LIBNCURSES_WIN_INCLUDE=$(LIBNCURSES_WIN_INCLUDE) $@ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -176,7 +158,7 @@ $(OUT_DIR)/zip/$(PKG_NAME).zip: @echo Windows ZIP file created at $(OUT_DIR)/zip/$(PKG_NAME).zip package: build - $(MAKE) BOXES_PLATFORM=$(BOXES_PLATFORM) $(PKG_NAME).tar.gz + $(MAKE) BOXES_PLATFORM=unix $(PKG_NAME).tar.gz win32.package: win32 $(OUT_DIR)/zip/$(PKG_NAME).zip @@ -211,11 +193,11 @@ covtest: cd test; ./testrunner.sh --suite --coverage utest: - $(MAKE) -C utest BOXES_PLATFORM=$(BOXES_PLATFORM) utest + $(MAKE) -C utest BOXES_PLATFORM=unix utest win32.utest: $(OUT_DIR) cp $(WIN_CMOCKA_DIR)/bin/cmocka.dll $(OUT_DIR)/ - $(MAKE) -C utest BOXES_PLATFORM=$(BOXES_PLATFORM) C_INCLUDE_PATH=../$(PCRE2_DIR)/src:../$(WIN_CMOCKA_DIR)/include \ + $(MAKE) -C utest BOXES_PLATFORM=win32 C_INCLUDE_PATH=../$(PCRE2_DIR)/src:../$(WIN_CMOCKA_DIR)/include \ LDFLAGS_ADDTL="-L../$(PCRE2_DIR)/.libs -L../$(WIN_CMOCKA_DIR)/lib" utest diff --git a/src/Makefile b/src/Makefile index 0121b169..196d0dc2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -32,7 +32,7 @@ ORIG_SRC = $(ORIG_GEN) $(ORIG_NORM) ORIG_FILES = $(ORIG_SRC) $(ORIG_HDR) -.PHONY: boxes.static check_dir clean build cov debug package static flags_unix flags_darwin flags_static flags_win32 flags_ +.PHONY: boxes.static check_dir clean build cov debug package static flags_unix flags_static flags_win32 flags_ .NOTPARALLEL: @@ -76,7 +76,7 @@ boxes.exe: $(ALL_OBJ) | check_dir if [ "$(STRIP)" = "true" ] ; then strip $@ ; fi -flags_unix flags_darwin: +flags_unix: $(eval CFLAGS := -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) $(eval LDFLAGS := $(LDFLAGS) $(LDFLAGS_ADDTL)) $(eval BOXES_EXECUTABLE_NAME := boxes) diff --git a/utest/Makefile b/utest/Makefile index 5af764ee..4e74b736 100644 --- a/utest/Makefile +++ b/utest/Makefile @@ -22,7 +22,7 @@ VPATH = $(SRC_DIR):$(SRC_DIR)/misc:$(UTEST_DIR) UTEST_NORM = global_mock.c bxstring_test.o cmdline_test.c tools_test.c regulex_test.o main.o unicode_test.o \ utest_tools.o -.PHONY: check_dir flags_unix flags_darwin flags_win32 flags_ utest +.PHONY: check_dir flags_unix flags_win32 flags_ utest .NOTPARALLEL: @@ -41,12 +41,6 @@ flags_unix: $(eval UTEST_EXECUTABLE_NAME := unittest) $(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) -flags_darwin: - $(eval CFLAGS := -I. -I$(SRC_DIR) -O -Wall -W -Wno-stringop-overflow $(CFLAGS_ADDTL)) - $(eval LDFLAGS := $(LDFLAGS) --coverage $(LDFLAGS_ADDTL)) - $(eval UTEST_EXECUTABLE_NAME := unittest) - $(eval UTEST_OBJ := $(UTEST_NORM:.c=.o)) - flags_win32: $(eval CFLAGS := -Os -s -std=c99 -m32 -I. -I$(SRC_DIR) -Wall -W $(CFLAGS_ADDTL)) $(eval LDFLAGS := $(LDFLAGS) -s -std=c99 -m32 $(LDFLAGS_ADDTL))