Skip to content
Myr

Cross compile for Linux, MacOS and Windows on CI (#2665)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Owen Ou · committed by GitHub · parent 193f432 · Browse files · 3 files+138 added−47 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+138 added−47 removed

  • other:+138 added−47 removed

3 files+138 added−47 removed

modified:.github/workflows/ci.yml+130 added-47 removed
10 unmodified lines
11 linux:12 strategy:13 fail-fast: false14 matrix:15 compiler: [gcc, clang]16 image: [ubuntu-20.04, ubuntu-22.04]15 arch:16 [17 amd64,18 arm64,19 armel,20 armhf,21 i386,22 mips,23 mips64,24 mips64el,25 mips64r6,26 mips64r6el,27 mipsel,28 mipsr6,29 mipsr6el,30 powerpc,31 ppc64el,32 s390x,33 riscv64,34 ]35 include:18 - compiler: gcc19 image: ubuntu-20.0420 configure_flag: ''21 - compiler: gcc22 image: ubuntu-22.0423 configure_flag: --enable-static --enable-all-static24 - compiler: clang25 image: ubuntu-20.0426 configure_flag: ''27 - compiler: clang28 image: ubuntu-22.0429 configure_flag: --enable-static --enable-all-static30 runs-on: ${{ matrix.image }}36 - arch: amd6437 CC: "x86_64-linux-gnu"38 - arch: arm6439 CC: "aarch64-linux-gnu"40 - arch: armel41 CC: "arm-linux-gnueabi"42 - arch: armhf43 CC: "arm-linux-gnueabihf"44 - arch: i38645 CC: "i686-linux-gnu"46 - arch: mips47 CC: "mips-linux-gnu"48 - arch: mips6449 CC: "mips64-linux-gnuabi64"50 - arch: mips64el51 CC: "mips64el-linux-gnuabi64"52 - arch: mips64r653 CC: "mipsisa64r6-linux-gnuabi64"54 - arch: mips64r6el55 CC: "mipsisa64r6el-linux-gnuabi64"56 - arch: mipsel57 CC: "mipsel-linux-gnu"58 - arch: mipsr659 CC: "mipsisa32r6-linux-gnu"60 - arch: mipsr6el61 CC: "mipsisa32r6el-linux-gnu"62 - arch: powerpc63 CC: "powerpc-linux-gnu"64 - arch: ppc64el65 CC: "powerpc64le-linux-gnu"66 - arch: s390x67 CC: "s390x-linux-gnu"68 - arch: riscv6469 CC: "riscv64-linux-gnu"70 runs-on: ubuntu-22.0471 env:32 CC: ${{ matrix.compiler }}33 SUFFIX: linux-${{ matrix.image }}-${{ matrix.compiler }}72 AR: ${{ matrix.CC }}-ar73 CHOST: ${{ matrix.cc }}74 CC: ${{ matrix.cc }}-gcc75 CPP: ${{ matrix.cc }}-cpp76 CXX: ${{ matrix.cc }}-g++77 LDFLAGS: -s78 SUFFIX: linux-${{ matrix.arch }}79 steps:80 - name: Clone repository81 uses: actions/checkout@v382 with:83 submodules: true84 - name: Install packages85 run: |41 sudo apt-get update -qq42 sudo apt-get install -y automake autoconf86 sudo apt-get update87 sudo apt-get upgrade88 sudo apt-get install -y automake autoconf libtool crossbuild-essential-${{ matrix.arch }}89 - name: Build90 run: |91 autoreconf -i92 ./configure \93 --host=${{ matrix.CC }} \94 --disable-docs \95 --disable-maintainer-mode \96 --disable-valgrind \97 --with-oniguruma=builtin \51 ${{ matrix.configure_flag }}52 make53 strip jq98 --enable-static \99 --enable-all-static100 make -j$(nproc)101 file ./jq102 cp ./jq jq-${{ env.SUFFIX }}103 - name: Test104 # Only run tests for amd64 matching the CI machine arch105 if: ${{ matrix.arch == 'amd64' }}106 run: |107 make check108 git diff --exit-code109 - name: Upload Test Logs
8 unmodified lines
118 - name: Upload Artifacts119 uses: actions/upload-artifact@v3120 with:121 name: jq-${{ env.SUFFIX }}122 path: jq-${{ env.SUFFIX }}123 if-no-files-found: error124 retention-days: 773 path: jq125126 macos:127 strategy:128 fail-fast: false129 matrix:79 compiler: [gcc, clang]80 image: [macos-11, macos-12, macos-13]81 runs-on: ${{ matrix.image }}130 arch:131 [132 amd64,133 arm64,134 ]135 include:136 - arch: amd64137 target: "x86_64-apple-darwin"138 - arch: arm64139 target: "arm64-apple-darwin"140 runs-on: macos-13141 env:83 CC: ${{ matrix.compiler }}84 SUFFIX: macos-${{ matrix.image }}-${{ matrix.compiler }}142 LDFLAGS: -s143 SUFFIX: macos-${{ matrix.arch }}144 steps:145 - name: Clone repository146 uses: actions/checkout@v3147 with:
2 unmodified lines
150 run: |151 # brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!"152 brew update || brew update-reset153 brew install autoconf automake libtool154 - name: "Set CC"155 run: |156 echo "CC=clang -target ${{ matrix.target }}$(uname -r)" >> $GITHUB_ENV157 - name: Build158 run: |159 autoreconf -i160 ./configure \161 --host=${{ matrix.target }}$(uname -r) \162 --disable-docs \163 --disable-maintainer-mode \164 --disable-valgrind \165 --with-oniguruma=builtin \166 --enable-static \167 --enable-all-static105 make106 strip jq168 make -j$(nproc)169 file ./jq170 cp ./jq jq-${{ env.SUFFIX }}171 - name: Test172 # Only run tests for amd64 matching the CI machine arch173 if: ${{ matrix.arch == 'amd64' }}174 run: |175 make check176 git diff --exit-code177 - name: Upload Test Logs
8 unmodified lines
186 - name: Upload Artifacts187 uses: actions/upload-artifact@v3188 with:189 name: jq-${{ env.SUFFIX }}190 path: jq-${{ env.SUFFIX }}191 if-no-files-found: error192 retention-days: 7126 path: jq193194 windows:195 strategy:196 fail-fast: false197 matrix:132 compiler: [gcc]133 image: [windows-2019, windows-2022]134 runs-on: ${{ matrix.image }}198 arch:199 [200 amd64,201 i386,202 ]203 include:204 - arch: amd64205 CC: "x86_64-pc-msys"206 toolchain: "gcc"207 msystem: msys208 - arch: i386209 CC: "i686-w64-mingw32"210 toolchain: "mingw-w64-i686-toolchain"211 msystem: mingw32212 runs-on: windows-2022213 env:136 CC: ${{ matrix.compiler }}137 SUFFIX: windows-${{ matrix.image }}-${{ matrix.compiler }}214 CHOST: ${{ matrix.CC }}215 CC: ${{ matrix.CC }}-gcc216 LDFLAGS: -s217 SUFFIX: windows-${{ matrix.arch }}218 steps:219 - name: Clone repository220 uses: actions/checkout@v3221 with:222 submodules: true223 - uses: msys2/setup-msys2@v2224 with:225 update: true226 msystem: ${{ matrix.msystem }}227 install: >-228 base-devel229 git149 clang230 autoconf231 automake232 libtool233 ${{ matrix.toolchain }}234 - name: Build235 shell: msys2 {0}236 run: |237 autoreconf -i238 ./configure \239 --host=${{ matrix.CC }} \240 --disable-docs \241 --disable-maintainer-mode \242 --disable-valgrind \243 --with-oniguruma=builtin \244 --disable-shared \245 --enable-static \246 --enable-all-static165 make166 strip jq.exe247 make -j$(nproc)248 file ./jq.exe249 cp ./jq.exe jq-${{ env.SUFFIX }}.exe250 - name: Test251 # Only run tests for amd64 matching the CI machine arch252 if: ${{ matrix.arch == 'amd64' }}253 shell: msys2 {0}254 run: |255 make check256 git diff --exit-code --ignore-submodules
9 unmodified lines
266 - name: Upload Artifacts267 uses: actions/upload-artifact@v3268 with:269 name: jq-${{ env.SUFFIX }}270 path: jq-${{ env.SUFFIX }}.exe271 if-no-files-found: error272 retention-days: 7187 path: jq.exe273274 dist:275 runs-on: ubuntu-latest276 if: startsWith(github.ref, 'refs/tags/jq-')
72 unmodified lines
349 - name: Clone repository350 uses: actions/checkout@v3351 - name: Merge built artifacts352 uses: actions/download-artifact@v3268 with:269 path: artifacts353 - name: Upload release354 env:355 TAG_NAME: ${{ github.ref_name }}356 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}357 run: |275 mkdir release276 cp artifacts/jq-linux-ubuntu-22.04-gcc/jq release/jq-linux-amd64277 cp artifacts/jq-macos-macos-13-gcc/jq release/jq-macos-amd64278 cp artifacts/jq-windows-windows-2022-gcc/jq.exe release/jq-windows-amd64.exe279 cp artifacts/jq-dist/jq-* release/358 mkdir -p "release"359 for files in jq-*; do360 cp -rf "${files}/"* "release/"361 done362363 gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes364 gh release upload "$TAG_NAME" --clobber release/jq-*
modified:src/jv_thread.h+4 added
1#ifndef JV_THREAD_H2#define JV_THREAD_H34#ifdef WIN325#ifndef __MINGW32__6#include <windows.h>7#include <winnt.h>8#include <errno.h>9
59 unmodified lines
69void *pthread_getspecific(pthread_key_t);70#else71#include <pthread.h>72#endif73#else74#include <pthread.h>75#endif76#endif /* JV_THREAD_H */
modified:src/jv.c+4 added
220 unmodified lines
221#define DEC_NUMBER_STRING_GUARD (14)222223#include "jv_thread.h"224#ifdef WIN32225#ifndef __MINGW32__226/* Copied from Heimdal: thread-specific keys; see lib/base/dll.c in Heimdal */227228/*229 * This is an implementation of thread-specific storage with
256 unmodified lines
486}487#else488#include <pthread.h>489#endif490#else491#include <pthread.h>492#endif493494static pthread_key_t dec_ctx_key;495static pthread_key_t dec_ctx_dbl_key;496#ifndef WIN32
1495 unmodified lines