diff --git a/checks/check-static-exts-cross.nix b/checks/check-static-exts-cross.nix new file mode 100644 index 0000000..c8e9850 --- /dev/null +++ b/checks/check-static-exts-cross.nix @@ -0,0 +1,37 @@ +{ self, pkgs }: +let + pkgs' = pkgs.pkgsCross.aarch64-multiplatform; + + sqlite-example-exts-static = pkgs'.callPackage ./util/sqlite-example-exts-static.nix { }; + + sqlite-with-static-exts = self.mkSqlite { + pkgs = pkgs'; + + extensions = [ + { + library = "${sqlite-example-exts-static}/lib/libaddext.a"; + init = "sqlite3_addext_init"; + } + { + library = "${sqlite-example-exts-static}/lib/libsubext.a"; + init = "sqlite3_subext_init"; + } + { + library = "${sqlite-example-exts-static}/lib/libmultext.a"; + init = "sqlite3_multext_init"; + } + ]; + }; +in +pkgs'.runCommand "test-sqlite-with-static-exts-aarch64" { + nativeBuildInputs = [ sqlite-with-static-exts.sqlite-cli ]; + + passthru = { + inherit sqlite-example-exts-static; + inherit sqlite-with-static-exts; + }; +} '' + mkdir -p "$out" + sqlite3 :memory: <<<"SELECT myadd(1, 2), mysub(5, 3), mymult(4, 6);" | tee "$out/test.log" + grep -q -F "3|2|24" "$out/test.log" || (echo "Unexpected output from sqlite3 with static extensions" && exit 1) + '' diff --git a/checks/check-static-exts.nix b/checks/check-static-exts.nix new file mode 100644 index 0000000..10820b9 --- /dev/null +++ b/checks/check-static-exts.nix @@ -0,0 +1,35 @@ +{ self, pkgs }: +let + sqlite-example-exts-static = pkgs.callPackage ./util/sqlite-example-exts-static.nix { }; + + sqlite-with-static-exts = self.mkSqlite { + inherit pkgs; + + extensions = [ + { + library = "${sqlite-example-exts-static}/lib/libaddext.a"; + init = "sqlite3_addext_init"; + } + { + library = "${sqlite-example-exts-static}/lib/libsubext.a"; + init = "sqlite3_subext_init"; + } + { + library = "${sqlite-example-exts-static}/lib/libmultext.a"; + init = "sqlite3_multext_init"; + } + ]; + }; +in +pkgs.runCommand "test-sqlite-with-static-exts" { + nativeBuildInputs = [ sqlite-with-static-exts.sqlite-cli ]; + + passthru = { + inherit sqlite-example-exts-static; + inherit sqlite-with-static-exts; + }; +} '' + mkdir -p "$out" + sqlite3 :memory: <<<"SELECT myadd(1, 2), mysub(5, 3), mymult(4, 6);" | tee "$out/test.log" + grep -q -F "3|2|24" "$out/test.log" || (echo "Unexpected output from sqlite3 with static extensions" && exit 1) + '' diff --git a/sqlite-example-exts/addext.c b/checks/sqlite-example-exts/addext.c similarity index 100% rename from sqlite-example-exts/addext.c rename to checks/sqlite-example-exts/addext.c diff --git a/sqlite-example-exts/multext.c b/checks/sqlite-example-exts/multext.c similarity index 100% rename from sqlite-example-exts/multext.c rename to checks/sqlite-example-exts/multext.c diff --git a/sqlite-example-exts/subext.c b/checks/sqlite-example-exts/subext.c similarity index 100% rename from sqlite-example-exts/subext.c rename to checks/sqlite-example-exts/subext.c diff --git a/checks/util/sqlite-example-exts-static.nix b/checks/util/sqlite-example-exts-static.nix new file mode 100644 index 0000000..262dbc7 --- /dev/null +++ b/checks/util/sqlite-example-exts-static.nix @@ -0,0 +1,35 @@ +{ + sqlite, + stdenv, +}: +stdenv.mkDerivation { + name = "sqlite-example-exts-static"; + src = ../sqlite-example-exts; + + env.NIX_CFLAGS_COMPILE = "-DSQLITE_CORE"; + + buildInputs = [ sqlite.dev ]; + buildPhase = '' + runHook preBuild + + "$CC" -c addext.c + "$AR" rcs libaddext.a addext.o + + "$CC" -c subext.c + "$AR" rcs libsubext.a subext.o + + "$CC" -c multext.c + "$AR" rcs libmultext.a multext.o + + runHook postBuild + ''; + + + installPhase = '' + runHook preInstall + + install -Dm444 *.a -t "$out/lib" + + runHook postInstall + ''; +}