From 0e2330238c7707e6bf8e20cdbb13a1cd349209b8 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Thu, 21 Apr 2022 17:08:48 +0100 Subject: [PATCH] Fixed GCC preinclude always present in build fixes https://github.com/TryGhost/node-sqlite3/issues/1584 - I'd previously added the `gcc-preinclude.h` file into `deps/sqlite3.gyp`, which would include it for every build - this was technically incorrect because we only want to use this in CI to build backwards compatible binaries - I tried this before, but couldn't get the syntax right - this commit switches to only including the preinclude in CI and removes it from every build, so FreeBSD etc can compile as per the issue --- .github/workflows/ci.yml | 7 +++++++ deps/sqlite3.gyp | 4 ---- tools/BinaryBuilder.Dockerfile | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dac6fd565..d3debfb24 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,6 +54,13 @@ jobs: - name: Install dependencies run: yarn install --ignore-scripts + - name: Add Linux env vars + if: contains(matrix.os, 'ubuntu') + run: | + echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV + echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV + echo "V=1" >> $GITHUB_ENV + - name: Configure build run: yarn node-pre-gyp configure diff --git a/deps/sqlite3.gyp b/deps/sqlite3.gyp index bc99b20c7..660b3b07e 100755 --- a/deps/sqlite3.gyp +++ b/deps/sqlite3.gyp @@ -92,11 +92,7 @@ 'SQLITE_ENABLE_MATH_FUNCTIONS' ], }, - 'cflags': [ - '-include ../src/gcc-preinclude.h' - ], 'cflags_cc': [ - '-include ../src/gcc-preinclude.h', '-Wno-unused-value' ], 'defines': [ diff --git a/tools/BinaryBuilder.Dockerfile b/tools/BinaryBuilder.Dockerfile index 9c8b33f1e..0404dd8f2 100644 --- a/tools/BinaryBuilder.Dockerfile +++ b/tools/BinaryBuilder.Dockerfile @@ -17,6 +17,8 @@ RUN cd node_modules/\@mapbox/node-pre-gyp \ && npm install fs-extra@10.0.1 \ && sed -i -e s/\'fs/\'fs-extra/ -e s/fs\.renameSync/fs.moveSync/ ./lib/util/napi.js +ENV CFLAGS="${CFLAGS:-} -include ../src/gcc-preinclude.h" +ENV CXXFLAGS="${CXXFLAGS:-} -include ../src/gcc-preinclude.h" RUN npx node-pre-gyp configure RUN npx node-pre-gyp build