diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..2674cf1b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +**/.git +cb/bld/bin +cb/bld/obj \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7953a18..22ff9b42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,10 +11,10 @@ on: - 'bld/bin/**' jobs: - build: + build-win-mac: strategy: matrix: - os: [ubuntu-20.04, macos-13, windows-2019] + os: [macos-13, windows-2019] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -25,14 +25,6 @@ jobs: repository: libtom/libtomcrypt path: "libtomcrypt" ref: "v1.18.2" - - name: Setup cross compilers - if: startsWith(matrix.os, 'ubuntu') - run: ./cb/bld/setup_linux.sh - - name: Setup NDK - if: startsWith(matrix.os, 'ubuntu') - uses: nttld/setup-ndk@v1 - with: - ndk-version: r21e - name: Setup .NET uses: actions/setup-dotnet@v4 with: @@ -44,29 +36,77 @@ jobs: run: chmod +x *.sh working-directory: cb/bld - name: Clean output directory - if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos') + if: startsWith(matrix.os, 'macos') run: rm -fr bin working-directory: cb/bld - name: Clean output directory if: startsWith(matrix.os, 'windows') run: rm bin -r -fo working-directory: cb/bld - - name: Build (Linux) - if: startsWith(matrix.os, 'ubuntu') + - name: Build (macOS, iOS, tvOS) + if: startsWith(matrix.os, 'macos') run: | - #!/bin/bash - export PATH="$PWD/../../crosscompilers/bin:$PATH" set -e - for f in linux_*.sh; do - if [[ "$f" == *_cross.sh ]] || [[ "$f" == *_regular.sh ]] - then - continue - fi + for f in mac_*.sh maccatalyst_*.sh ios_*.sh tvos_*.sh; do bash "$f" done working-directory: cb/bld + - name: Build (Windows) + if: startsWith(matrix.os, 'windows') + run: | + $files = Get-ChildItem *.bat -Exclude "win_e_sqlite3.bat","win_e_sqlite3mc.bat","win_e_sqlcipher.bat","win_sqlite3mc.bat" + foreach ($f in $files) { + cmd /C $f + } + working-directory: cb/bld + - uses: actions/upload-artifact@v4 + with: + name: bin-${{ matrix.os }} + path: cb/bld/bin + + build-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + path: "cb" + - uses: actions/checkout@v4 + with: + repository: libtom/libtomcrypt + path: "libtomcrypt" + ref: "v1.18.2" + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + - name: Setup NDK + uses: nttld/setup-ndk@v1 + with: + ndk-version: r21e + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0 + - name: Generate script + run: dotnet run + working-directory: cb/bld + - name: Update permissions + run: chmod +x *.sh + working-directory: cb/bld + - name: Clean output directory + run: rm -fr bin + working-directory: cb/bld + - name: Build (Linux) + run: > + mv ./cb/.dockerignore . && + docker buildx build + --output=type=local,dest=. + --cache-to type=gha + --cache-from type=gha + --build-arg TOOLCHAIN_RELEASE_BASE_URL=https://github.com/${{ github.repository }}/releases/download/crosscompilers + -f ./cb/Dockerfile + . - name: Build (Android) - if: startsWith(matrix.os, 'ubuntu') run: | set -e cd android_e_sqlite3 @@ -86,25 +126,9 @@ jobs: mkdir -p ../bin/sqlite3mc/android cp -r libs/* ../bin/sqlite3mc/android working-directory: cb/bld - - name: Build (macOS, iOS, tvOS) - if: startsWith(matrix.os, 'macos') - run: | - set -e - for f in mac_*.sh maccatalyst_*.sh ios_*.sh tvos_*.sh; do - bash "$f" - done - working-directory: cb/bld - - name: Build (Windows) - if: startsWith(matrix.os, 'windows') - run: | - $files = Get-ChildItem *.bat -Exclude "win_e_sqlite3.bat","win_e_sqlite3mc.bat","win_e_sqlcipher.bat","win_sqlite3mc.bat" - foreach ($f in $files) { - cmd /C $f - } - working-directory: cb/bld - uses: actions/upload-artifact@v4 with: - name: bin-${{ matrix.os }} + name: bin-linux path: cb/bld/bin build-wasm: @@ -116,7 +140,7 @@ jobs: - '{ "tfm": "net7.0", "emsdk": "3.1.12" }' # eol: 2024-05-14 - '{ "tfm": "net8.0", "emsdk": "3.1.34" }' # eol: 2026-11-14 - '{ "tfm": "net9.0", "emsdk": "3.1.56" }' # eol: 2026-05-12 - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -157,7 +181,7 @@ jobs: path: cb/bld/bin test: - needs: [ build, build-wasm] + needs: [ build-linux, build-win-mac, build-wasm] if: ${{ github.event_name == 'pull_request' }} strategy: matrix: @@ -183,7 +207,7 @@ jobs: working-directory: cb/bld - uses: actions/download-artifact@v4 with: - name: bin-ubuntu-20.04 + name: bin-linux path: cb/bld/bin - uses: actions/download-artifact@v4 with: @@ -235,9 +259,9 @@ jobs: dotnet run publish: - needs: [ build, build-wasm ] + needs: [ build-linux, build-win-mac, build-wasm ] if: ${{ github.event_name == 'push' }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -251,7 +275,7 @@ jobs: working-directory: bld - uses: actions/download-artifact@v4 with: - name: bin-ubuntu-20.04 + name: bin-linux path: bld/bin - uses: actions/download-artifact@v4 with: diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a09b0ee2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bld/obj \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..81843d2b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +FROM ubuntu:18.04 AS build + +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ=Etc/UTC +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +# Setup cross compilers +RUN dpkg --add-architecture i386 && \ + apt-get -y update && \ + apt-get install --allow-downgrades -y \ + wget \ + linux-libc-dev:i386 \ + gcc-7-multilib \ + gcc-arm-linux-gnueabi \ + gcc-arm-linux-gnueabihf \ + musl-dev musl-tools \ + gcc-aarch64-linux-gnu \ + gcc-mips64el-linux-gnuabi64 \ + gcc-s390x-linux-gnu \ + # gcc-powerpc64le-linux-gnu \ + gcc-riscv64-linux-gnu + +WORKDIR /a/crosscompilers + +ARG TOOLCHAIN_RELEASE_BASE_URL + +RUN wget -q ${TOOLCHAIN_RELEASE_BASE_URL}/arm-linux-musleabihf-cross.tgz && \ + # wget https://musl.cc/arm-linux-musleabihf-cross.tgz + # wget https://ericsink.com/arm-linux-musleabihf-cross.tgz + tar --strip-components=1 -zxf ./arm-linux-musleabihf-cross.tgz && \ + wget -q ${TOOLCHAIN_RELEASE_BASE_URL}/aarch64-linux-musl-cross.tgz && \ + # wget https://musl.cc/aarch64-linux-musl-cross.tgz + # wget https://ericsink.com/aarch64-linux-musl-cross.tgz + tar --strip-components=1 -zxf aarch64-linux-musl-cross.tgz && \ + wget -q ${TOOLCHAIN_RELEASE_BASE_URL}/s390x-linux-musl-cross.tgz && \ + # wget https://musl.cc/s390x-linux-musl-cross.tgz + tar --strip-components=1 -zxf s390x-linux-musl-cross.tgz && \ + wget -q ${TOOLCHAIN_RELEASE_BASE_URL}/riscv64-linux-musl-cross.tgz && \ + # wget https://musl.cc/riscv64-linux-musl-cross.tgz + tar --strip-components=1 -zxf riscv64-linux-musl-cross.tgz && \ + wget -q ${TOOLCHAIN_RELEASE_BASE_URL}/powerpc64le-power8--glibc--stable-2024.05-1.tar.xz && \ + # wget https://toolchains.bootlin.com/downloads/releases/toolchains/powerpc64le-power8/tarballs/powerpc64le-power8--glibc--stable-2024.05-1.tar.xz + tar --strip-components=1 -xJf powerpc64le-power8--glibc--stable-2024.05-1.tar.xz + +WORKDIR /a + +COPY --link . . + +WORKDIR /a/cb/bld + +SHELL ["/bin/bash", "-c"] + +# run build scripts +RUN export PATH="$PWD/../../crosscompilers/bin:$PATH" && \ + set -e && \ + for f in linux_*.sh; do \ + if [[ "$f" == *_cross.sh ]] || [[ "$f" == *_regular.sh ]]; \ + then \ + continue; \ + fi; \ + bash "$f"; \ + done + +# pull end build products out into scratch image to simplify extraction +FROM scratch + +COPY --from=build /a/cb/bld /cb/bld diff --git a/bld/cb.cs b/bld/cb.cs index eb496e35..db66807a 100644 --- a/bld/cb.cs +++ b/bld/cb.cs @@ -166,7 +166,7 @@ IList libs break; case "ppc64le": - compiler = "powerpc64le-linux-gnu-gcc"; + compiler = "powerpc64le-linux-gcc"; break; case "armhf": diff --git a/bld/setup_linux.sh b/bld/setup_linux.sh deleted file mode 100755 index 1369cd08..00000000 --- a/bld/setup_linux.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -sudo dpkg --add-architecture i386 -sudo apt-get update -sudo apt-get install linux-libc-dev:i386 -sudo apt-get install gcc-multilib - -sudo apt-get install gcc-arm-linux-gnueabi -sudo apt-get install gcc-arm-linux-gnueabihf -sudo apt-get install musl-dev musl-tools -sudo apt-get install gcc-aarch64-linux-gnu -sudo apt-get install gcc-mips64el-linux-gnuabi64 -sudo apt-get install gcc-s390x-linux-gnu -sudo apt-get install gcc-powerpc64le-linux-gnu -sudo apt-get install gcc-riscv64-linux-gnu - -mkdir crosscompilers -cd crosscompilers -wget https://musl.cc/arm-linux-musleabihf-cross.tgz -#wget https://ericsink.com/arm-linux-musleabihf-cross.tgz -tar --strip-components=1 -zxf ./arm-linux-musleabihf-cross.tgz -wget https://musl.cc/aarch64-linux-musl-cross.tgz -#wget https://ericsink.com/aarch64-linux-musl-cross.tgz -tar --strip-components=1 -zxf aarch64-linux-musl-cross.tgz -wget https://musl.cc/s390x-linux-musl-cross.tgz -tar --strip-components=1 -zxf s390x-linux-musl-cross.tgz -wget https://musl.cc/riscv64-linux-musl-cross.tgz -tar --strip-components=1 -zxf riscv64-linux-musl-cross.tgz -cd ..