dart.objectbox_flutter_libs: init

This commit is contained in:
emaryn
2025-05-03 11:47:04 +08:00
parent 7064665800
commit f062017c40
3 changed files with 97 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
media_kit_libs_linux = callPackage ./media_kit_libs_linux { };
metadata_god = callPackage ./metadata_god { };
olm = callPackage ./olm { };
objectbox_flutter_libs = callPackage ./objectbox_flutter_libs { };
pdfrx = callPackage ./pdfrx { };
printing = callPackage ./printing { };
rhttp = callPackage ./rhttp { };

View File

@@ -0,0 +1,46 @@
--- old/linux/CMakeLists.txt
+++ new/linux/CMakeLists.txt
@@ -41,35 +41,6 @@
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
-# ----------------------------------------------------------------------
-# Download and add objectbox-c prebuilt library.
-
-set(OBJECTBOX_VERSION 4.0.2)
-
-set(OBJECTBOX_ARCH ${CMAKE_SYSTEM_PROCESSOR})
-if (${OBJECTBOX_ARCH} MATCHES "x86_64")
- set(OBJECTBOX_ARCH x64)
-elseif (${OBJECTBOX_ARCH} MATCHES "^arm64" OR ${OBJECTBOX_ARCH} MATCHES "^armv8")
- set(OBJECTBOX_ARCH aarch64)
-elseif (${OBJECTBOX_ARCH} MATCHES "^armv7")
- set(OBJECTBOX_ARCH armv7hf)
-elseif (${OBJECTBOX_ARCH} MATCHES "^arm")
- set(OBJECTBOX_ARCH armv6hf)
-endif ()
-
-include(FetchContent)
-FetchContent_Declare(
- objectbox-download
- URL https://github.com/objectbox/objectbox-c/releases/download/v${OBJECTBOX_VERSION}/objectbox-linux-${OBJECTBOX_ARCH}.tar.gz
-)
-
-FetchContent_GetProperties(objectbox-download)
-if(NOT objectbox-download_POPULATED)
- FetchContent_Populate(objectbox-download)
-endif()
-
-# ----------------------------------------------------------------------
-
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
@@ -77,6 +48,6 @@
# Note: do not link the ObjectBox C library; the Dart library looks for it in a lib subfolder
# where flutter build puts it when added below.
set(objectbox_flutter_libs_bundled_libraries
- "${objectbox-download_SOURCE_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}objectbox${CMAKE_SHARED_LIBRARY_SUFFIX}"
+ "@OBJECTBOX_SHARED_LIBRARY@"
PARENT_SCOPE
)

View File

@@ -0,0 +1,50 @@
{
lib,
stdenv,
fetchzip,
replaceVars,
}:
{ version, src, ... }:
let
selectSystem =
attrs:
attrs.${stdenv.hostPlatform.system}
or (throw "objectbox_flutter_libs: ${stdenv.hostPlatform.system} is not supported");
arch = selectSystem {
x86_64-linux = "x64";
aarch64-linux = "aarch64";
};
objectbox-sync = fetchzip {
url = "https://github.com/objectbox/objectbox-c/releases/download/v4.0.2/objectbox-sync-linux-${arch}.tar.gz";
hash = selectSystem {
x86_64-linux = "sha256-VXTuCYg0ZItK+lAs7xkNlxO0rUPnbRZOP5RAXbcRyjM=";
aarch64-linux = "sha256-kNlrBRR/qDEhdU34f4eDQLgYkYAIfFC8/of4rgL+m6k=";
};
stripRoot = false;
};
in
stdenv.mkDerivation {
pname = "objectbox_flutter_libs";
inherit version src;
inherit (src) passthru;
patches = [
(replaceVars ./CMakeLists.patch {
OBJECTBOX_SHARED_LIBRARY = "${objectbox-sync}/lib/libobjectbox.so";
})
];
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
meta.sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
}