diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df1afea..e93346b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,41 @@ jobs: - name: Lint run: deno lint --ignore=sqlite + cross-build-linux-aarch64: + runs-on: ubuntu-latest + steps: + - name: Setup repo + uses: actions/checkout@v2 + with: + submodules: true + + - name: Setup Deno + uses: denoland/setup-deno@main + with: + deno-version: 'v1.x' + + - name: Install Dependencies + run: | + sudo apt update + sudo apt install gcc-9-aarch64-linux-gnu + + - name: Build + env: + CC: aarch64-linux-gnu-gcc-9 + TARGET_ARCH: aarch64 + run: deno task build + + - name: Release + if: ${{ github.ref == 'refs/heads/main' }} + uses: softprops/action-gh-release@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: "Release Draft" + draft: true + files: | + build/libsqlite3_aarch64.so + test: strategy: matrix: diff --git a/scripts/build.ts b/scripts/build.ts index 8dc406a..785792a 100644 --- a/scripts/build.ts +++ b/scripts/build.ts @@ -1,3 +1,5 @@ +const ARCH = Deno.env.get("TARGET_ARCH") || Deno.build.arch; + const COMPILE_OPTIONS: Record = { SQLITE_DQS: "0", SQLITE_DEFAULT_MEMSTATUS: "0", @@ -36,7 +38,7 @@ const ext = Deno.build.os === "windows" : "so"; const lib = `${prefix}sqlite3.${ext}`; const libWithArch = `${prefix}sqlite3${ - Deno.build.arch !== "x86_64" ? `_${Deno.build.arch}` : "" + ARCH !== "x86_64" ? `_${ARCH}` : "" }.${ext}`; const SLICE_WIN = Deno.build.os === "windows" ? 1 : 0; @@ -67,7 +69,7 @@ if (Deno.build.os !== "windows") { const CFLAGS = `${ Deno.build.os === "windows" ? "OPT_FEATURE_FLAGS" : "CFLAGS" -}=${Deno.build.os === "windows" ? "" : "-g -O3 "}${ +}=${Deno.build.os === "windows" ? "" : "-g -O3 -fPIC "}${ Object.entries( COMPILE_OPTIONS, ) @@ -94,6 +96,7 @@ if (Deno.build.os === "windows") { $( new URL("../sqlite/configure", import.meta.url), "--enable-releasemode", + ...(Deno.build.arch === ARCH ? [] : ["--disable-tcl", "--host=arm-linux"]), ); $( "make", diff --git a/src/ffi.ts b/src/ffi.ts index 42938b3..df68b0f 100644 --- a/src/ffi.ts +++ b/src/ffi.ts @@ -615,10 +615,7 @@ try { throw e; } - const error = new Error("Failed to load SQLite3 Dynamic Library"); - error.cause = e; - - throw error; + throw new Error("Failed to load SQLite3 Dynamic Library", { cause: e }); } const init = lib.sqlite3_initialize();