From b80bde34ba5e99eeb003838c7ce95cb70c60a776 Mon Sep 17 00:00:00 2001 From: leleliu008 Date: Fri, 1 Dec 2023 13:06:01 +0800 Subject: [PATCH] GitHub Actions: add cross compile for FreeBSD, OpenBSD, NetBSD workflows This allows users get our executable for FreeBSD, OpenBSD, NetBSD in a different maner. Signed-off-by: leleliu008 --- .../cross-compile-for--netbsd-on-ubuntu.yml | 119 +++++++++++++++++ .../cross-compile-for-freebsd-on-ubuntu.yml | 110 +++++++++++++++ .../cross-compile-for-openbsd-on-ubuntu.yml | 125 ++++++++++++++++++ 3 files changed, 354 insertions(+) create mode 100644 .github/workflows/cross-compile-for--netbsd-on-ubuntu.yml create mode 100644 .github/workflows/cross-compile-for-freebsd-on-ubuntu.yml create mode 100644 .github/workflows/cross-compile-for-openbsd-on-ubuntu.yml diff --git a/.github/workflows/cross-compile-for--netbsd-on-ubuntu.yml b/.github/workflows/cross-compile-for--netbsd-on-ubuntu.yml new file mode 100644 index 0000000000..eb4524c561 --- /dev/null +++ b/.github/workflows/cross-compile-for--netbsd-on-ubuntu.yml @@ -0,0 +1,119 @@ +name: cross compile for NetBSD on Ubuntu + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + netbsd-release-version: [9.3] + + runs-on: ubuntu-latest + + env: + CC: clang --target=amd64-unknown-netbsd --sysroot=${{ github.workspace }}/amd64-unknown-netbsd-sysroot + CFLAGS: -I${{ github.workspace }}/amd64-unknown-netbsd-3rdroot/include -v -fPIC + LDFLAGS: -L${{ github.workspace }}/amd64-unknown-netbsd-3rdroot/lib -Wl,-v + PKG_CONFIG_PATH: ${{ github.workspace }}/amd64-unknown-netbsd-3rdroot/lib/pkgconfig + + steps: + - uses: actions/checkout@v4 + with: + repository: universal-ctags/ctags + + - run: sudo apt-get -y update + - run: sudo apt-get -y install clang cmake make automake autoconf pkg-config curl file + + - run: install -d amd64-unknown-netbsd-sysroot + - run: install -d amd64-unknown-netbsd-3rdroot + + - name: install amd64-unknown-netbsd-sysroot + run: | + major="$(printf '%s\n' ${{ matrix.netbsd-release-version }} | cut -d. -f1)" + minor="$(printf '%s\n' ${{ matrix.netbsd-release-version }} | cut -d. -f2)" + + for item in base comp + do + FILENAME="$item.tar.xz" + curl -LO "https://ftp.netbsd.org/pub/NetBSD/NetBSD-${{ matrix.netbsd-release-version }}/amd64/binary/sets/$FILENAME" + tar vxf "$FILENAME" -C amd64-unknown-netbsd-sysroot + done + + - name: build zlib + run: | + install -d src/zlib + cd src/zlib + curl -L -o src.tar.gz https://zlib.net/fossils/zlib-1.3.tar.gz + tar vxf src.tar.gz --strip-components=1 + sed -i 's|/share/pkgconfig|/lib/pkgconfig|' CMakeLists.txt + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-netbsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF + cmake --build build.d + cmake --install build.d + + - name: build libiconv + run: | + install -d src/libiconv + cd src/libiconv + curl -L -o src.tar.gz https://ftp.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-netbsd --prefix=${{ github.workspace }}/amd64-unknown-netbsd-3rdroot --enable-extra-encodings --enable-static --disable-shared + make V=1 + make install + + - name: build libxml2 + run: | + install -d src/libxml2 + cd src/libxml2 + curl -L -o src.tar.gz https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.6.tar.xz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-netbsd --prefix=${{ github.workspace }}/amd64-unknown-netbsd-3rdroot --with-zlib --without-lzma --without-python --without-readline --without-coverage --enable-ipv6 --enable-static --disable-shared LIBS=-liconv + make V=1 + make install + + - name: build libyaml + run: | + install -d src/libyaml + cd src/libyaml + curl -L -o src.tar.gz https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-netbsd --prefix=${{ github.workspace }}/amd64-unknown-netbsd-3rdroot + make V=1 + make install + + - name: build jansson + run: | + install -d src/jansson + cd src/jansson + curl -L -o src.tar.gz https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz + tar vxf src.tar.gz --strip-components=1 + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-netbsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF -DJANSSON_BUILD_SHARED_LIBS=OFF -DJANSSON_BUILD_DOCS=OFF -DJANSSON_COVERAGE=OFF -DJANSSON_EXAMPLES=OFF -DJANSSON_WITHOUT_TESTS=ON + cmake --build build.d + cmake --install build.d + + - name: build libpcre2 + run: | + install -d src/libpcre2 + cd src/libpcre2 + curl -L -o src.tar.gz https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.bz2 + tar vxf src.tar.gz --strip-components=1 + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-netbsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF -DJANSSON_BUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=99 -DCMAKE_C_STANDARD_REQUIRED=ON -DPCRE2_BUILD_PCRE2_8=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF -DPCRE2_SUPPORT_VALGRIND=OFF -DPCRE2_SUPPORT_UNICODE=ON + cmake --build build.d + cmake --install build.d + + - run: ./autogen.sh + - run: | + ./configure --host=amd64-unknown-netbsd --prefix=${{ github.workspace }}/uctags-netbsd-amd64 --enable-static || { + cat config.log + exit 1 + } + - run: make V=1 + - run: make install + + - run: readelf -h ctags + - run: readelf -d ctags + - run: file ctags | grep NetBSD diff --git a/.github/workflows/cross-compile-for-freebsd-on-ubuntu.yml b/.github/workflows/cross-compile-for-freebsd-on-ubuntu.yml new file mode 100644 index 0000000000..8b41e1adc1 --- /dev/null +++ b/.github/workflows/cross-compile-for-freebsd-on-ubuntu.yml @@ -0,0 +1,110 @@ +name: cross compile for FreeBSD on Ubuntu + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + freebsd-release-version: [13.2] + + runs-on: ubuntu-latest + + env: + CC: clang --target=amd64-unknown-freebsd --sysroot=${{ github.workspace }}/amd64-unknown-freebsd-sysroot + CFLAGS: -I${{ github.workspace }}/amd64-unknown-freebsd-3rdroot/include -v -fPIC + LDFLAGS: -L${{ github.workspace }}/amd64-unknown-freebsd-3rdroot/lib -Wl,-v + PKG_CONFIG_PATH: ${{ github.workspace }}/amd64-unknown-freebsd-3rdroot/lib/pkgconfig + + steps: + - uses: actions/checkout@v4 + with: + repository: universal-ctags/ctags + + - run: sudo apt-get -y update + - run: sudo apt-get -y install clang cmake make automake autoconf curl file + + - run: install -d amd64-unknown-freebsd-sysroot + - run: install -d amd64-unknown-freebsd-3rdroot + + - run: curl -L -o amd64-unknown-freebsd-sysroot.txz https://archive.freebsd.org/old-releases/amd64/${{ matrix.freebsd-release-version }}-RELEASE/base.txz + - run: tar vxf amd64-unknown-freebsd-sysroot.txz -C amd64-unknown-freebsd-sysroot + + - name: build zlib + run: | + install -d src/zlib + cd src/zlib + curl -L -o src.tar.gz https://zlib.net/fossils/zlib-1.3.tar.gz + tar vxf src.tar.gz --strip-components=1 + sed -i 's|/share/pkgconfig|/lib/pkgconfig|' CMakeLists.txt + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-freebsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF + cmake --build build.d + cmake --install build.d + + - name: build libiconv + run: | + install -d src/libiconv + cd src/libiconv + curl -L -o src.tar.gz https://ftp.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-freebsd --prefix=${{ github.workspace }}/amd64-unknown-freebsd-3rdroot --enable-extra-encodings --enable-static --disable-shared + make V=1 + make install + + - name: build libxml2 + run: | + install -d src/libxml2 + cd src/libxml2 + curl -L -o src.tar.gz https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.6.tar.xz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-freebsd --prefix=${{ github.workspace }}/amd64-unknown-freebsd-3rdroot --with-zlib --without-lzma --without-python --without-readline --without-coverage --enable-ipv6 --enable-static --disable-shared LIBS=-liconv + make V=1 + make install + + - name: build libyaml + run: | + install -d src/libyaml + cd src/libyaml + curl -L -o src.tar.gz https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-freebsd --prefix=${{ github.workspace }}/amd64-unknown-freebsd-3rdroot + make V=1 + make install + + - name: build jansson + run: | + install -d src/jansson + cd src/jansson + curl -L -o src.tar.gz https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz + tar vxf src.tar.gz --strip-components=1 + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-freebsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF -DJANSSON_BUILD_SHARED_LIBS=OFF -DJANSSON_BUILD_DOCS=OFF -DJANSSON_COVERAGE=OFF -DJANSSON_EXAMPLES=OFF -DJANSSON_WITHOUT_TESTS=ON + cmake --build build.d + cmake --install build.d + + - name: build libpcre2 + run: | + install -d src/libpcre2 + cd src/libpcre2 + curl -L -o src.tar.gz https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.bz2 + tar vxf src.tar.gz --strip-components=1 + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-freebsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF -DJANSSON_BUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=99 -DCMAKE_C_STANDARD_REQUIRED=ON -DPCRE2_BUILD_PCRE2_8=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF -DPCRE2_SUPPORT_VALGRIND=OFF -DPCRE2_SUPPORT_UNICODE=ON + cmake --build build.d + cmake --install build.d + + - run: ./autogen.sh + - run: | + ./configure --host=amd64-unknown-freebsd --prefix=${{ github.workspace }}/uctags-freebsd-amd64 --enable-static || { + cat config.log + exit 1 + } + - run: make V=1 + - run: make install + + - run: readelf -h ctags + - run: readelf -d ctags + - run: file ctags | grep FreeBSD diff --git a/.github/workflows/cross-compile-for-openbsd-on-ubuntu.yml b/.github/workflows/cross-compile-for-openbsd-on-ubuntu.yml new file mode 100644 index 0000000000..5cefe7084e --- /dev/null +++ b/.github/workflows/cross-compile-for-openbsd-on-ubuntu.yml @@ -0,0 +1,125 @@ +name: cross compile for OpenBSD on Ubuntu + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + strategy: + fail-fast: false + matrix: + openbsd-release-version: [7.4] + + runs-on: ubuntu-latest + + env: + CC: clang --target=amd64-unknown-openbsd --sysroot=${{ github.workspace }}/amd64-unknown-openbsd-sysroot + CFLAGS: -I${{ github.workspace }}/amd64-unknown-openbsd-3rdroot/include -v -fPIC + LDFLAGS: -L${{ github.workspace }}/amd64-unknown-openbsd-3rdroot/lib -Wl,-v + PKG_CONFIG_PATH: ${{ github.workspace }}/amd64-unknown-openbsd-3rdroot/lib/pkgconfig + + steps: + - uses: actions/checkout@v4 + with: + repository: universal-ctags/ctags + + - run: sudo apt-get -y update + - run: sudo apt-get -y install clang cmake make automake autoconf pkg-config curl file + + - run: install -d amd64-unknown-openbsd-sysroot + - run: install -d amd64-unknown-openbsd-3rdroot + + - name: install amd64-unknown-openbsd-sysroot + run: | + major="$(printf '%s\n' ${{ matrix.openbsd-release-version }} | cut -d. -f1)" + minor="$(printf '%s\n' ${{ matrix.openbsd-release-version }} | cut -d. -f2)" + + for item in base comp + do + FILENAME="$item$major$minor.tgz" + curl -LO "https://cdn.openbsd.org/pub/OpenBSD/${{ matrix.openbsd-release-version }}/amd64/$FILENAME" + tar vxf "$FILENAME" -C amd64-unknown-openbsd-sysroot + done + + - name: build zlib + run: | + install -d src/zlib + cd src/zlib + curl -L -o src.tar.gz https://zlib.net/fossils/zlib-1.3.tar.gz + tar vxf src.tar.gz --strip-components=1 + sed -i 's|/share/pkgconfig|/lib/pkgconfig|' CMakeLists.txt + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-openbsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF + cmake --build build.d + cmake --install build.d + + - name: build libiconv + run: | + install -d src/libiconv + cd src/libiconv + curl -L -o src.tar.gz https://ftp.gnu.org/gnu/libiconv/libiconv-1.17.tar.gz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-openbsd --prefix=${{ github.workspace }}/amd64-unknown-openbsd-3rdroot --enable-extra-encodings --enable-static --disable-shared + make V=1 + make install + + - name: build libxml2 + run: | + install -d src/libxml2 + cd src/libxml2 + curl -L -o src.tar.gz https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.6.tar.xz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-openbsd --prefix=${{ github.workspace }}/amd64-unknown-openbsd-3rdroot --with-zlib --without-lzma --without-python --without-readline --without-coverage --enable-ipv6 --enable-static --disable-shared LIBS=-liconv + make V=1 + make install + cd ${{ github.workspace }}/amd64-unknown-openbsd-3rdroot/lib/pkgconfig + sed -i '/^Requires: /d' libxml-2.0.pc + printf 'Requires: zlib\n' >> libxml-2.0.pc + + - name: build libyaml + run: | + install -d src/libyaml + cd src/libyaml + curl -L -o src.tar.gz https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz + tar vxf src.tar.gz --strip-components=1 + ./configure --host=amd64-unknown-openbsd --prefix=${{ github.workspace }}/amd64-unknown-openbsd-3rdroot + make V=1 + make install + + - name: build jansson + run: | + install -d src/jansson + cd src/jansson + curl -L -o src.tar.gz https://github.com/akheron/jansson/releases/download/v2.14/jansson-2.14.tar.gz + tar vxf src.tar.gz --strip-components=1 + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-openbsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF -DJANSSON_BUILD_SHARED_LIBS=OFF -DJANSSON_BUILD_DOCS=OFF -DJANSSON_COVERAGE=OFF -DJANSSON_EXAMPLES=OFF -DJANSSON_WITHOUT_TESTS=ON + cmake --build build.d + cmake --install build.d + + - name: build libpcre2 + run: | + install -d src/libpcre2 + cd src/libpcre2 + curl -L -o src.tar.gz https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.bz2 + tar vxf src.tar.gz --strip-components=1 + cmake -S . -B build.d -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/amd64-unknown-openbsd-3rdroot -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTING=OFF -DJANSSON_BUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=99 -DCMAKE_C_STANDARD_REQUIRED=ON -DPCRE2_BUILD_PCRE2_8=ON -DPCRE2_BUILD_PCRE2_16=ON -DPCRE2_BUILD_PCRE2_32=ON -DPCRE2_BUILD_PCRE2GREP=OFF -DPCRE2_BUILD_TESTS=OFF -DPCRE2_SUPPORT_VALGRIND=OFF -DPCRE2_SUPPORT_UNICODE=ON + cmake --build build.d + cmake --install build.d + + - run: rm ${{ github.workspace }}/amd64-unknown-openbsd-3rdroot/lib/lib*.so + + - run: ./autogen.sh + - run: | + ./configure --host=amd64-unknown-openbsd --prefix=${{ github.workspace }}/uctags-openbsd-amd64 || { + cat config.log + exit 1 + } + - run: cat config.log + - run: make V=1 + - run: make install + + - run: readelf -h ctags + - run: readelf -d ctags + - run: file ctags | grep OpenBSD