art-standalone: add pkg-config support

This commit is contained in:
Jonas Heinrich
2025-09-01 13:04:59 +02:00
parent 17c24ab075
commit 6f2a943d4f
2 changed files with 49 additions and 0 deletions
@@ -35,6 +35,10 @@ stdenv.mkDerivation (finalAttrs: {
patches = [
# Do not hardocde addr2line binary path
./no-hardcode-path-addr2line.patch
# Add support for pkg-config
# See: https://gitlab.com/android_translation_layer/art_standalone/-/merge_requests/37
./pkg-config-support.patch
];
postPatch = ''
@@ -0,0 +1,45 @@
diff --git a/Makefile b/Makefile
index 42df5b18..3321adae 100644
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,8 @@ ____dalvikvm_bin_64 := $(____TOPDIR)/out/host/linux-x86/bin/dalvikvm64
__RPATH_BIN := \$${ORIGIN}/../$(____LIBDIR)/art/:\$${ORIGIN}/../$(____LIBDIR)/java/dex/art/natives
__RPATH_LIB := \$${ORIGIN}
+__VERSION ?= 0.0.0
+
# Jack compiler was google's first attempt at a solution for desugaring Java 8 and newer bytecode into bytecode compatible with older dex file formats.
# Thankfully, google realized that this was a bad idea, and in a typical google fashion, axed the project.
# They experimented with other approaches, but currently (2022) the way to do this is to use d8/r8 instead of dx;
@@ -112,6 +114,15 @@ install:
# our stable C API for libandroidfw, used by ATL
install -Dt $(____INSTALL_INCLUDEDIR)/androidfw $(____TOPDIR)/libandroidfw/include/androidfw/androidfw_c_api.h
+ # install pkg-config file
+ mkdir -p $(____INSTALL_LIBDIR)/pkgconfig
+ sed -e 's|@prefix@|$(____PREFIX)|g' \
+ -e 's|@libdir@|$(____LIBDIR)|g' \
+ -e 's|@includedir@|$(____INCLUDEDIR)|g' \
+ -e 's|@version@|$(__VERSION)|g' \
+ art-standalone.pc.in > $(____INSTALL_LIBDIR)/pkgconfig/art-standalone.pc
+
+
# TODO: figure out sharing dependencies and have this in a separate repo
install_adbd:
install -Dt $(____INSTALL_BINDIR) $(____TOPDIR)/out/host/linux-x86/bin/adbd
diff --git a/art-standalone.pc.in b/art-standalone.pc.in
new file mode 100644
index 00000000..210cd031
--- /dev/null
+++ b/art-standalone.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=${prefix}/@libdir@
+includedir=${prefix}/@includedir@
+
+Name: art-standalone
+Description: Android ART runtime (standalone build, minimal ATL deps)
+Version: @version@
+Libs: -L${libdir}/art -lart -lnativebridge -landroidfw
+Cflags: -I${includedir} -I${includedir}/androidfw