@novastera-oss/llamarn 0.1.1-alpha.6 → 0.1.1-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,27 +26,26 @@ else()
26
26
  message(STATUS "Vulkan not found - GPU acceleration will be limited")
27
27
  endif()
28
28
 
29
- # Add the prebuilt libraries as IMPORTED (64-bit architectures only: arm64-v8a, x86_64)
29
+ # Add the prebuilt libraries as IMPORTED with IMPORTED_NO_SONAME to avoid absolute path embedding
30
30
  add_library(llama SHARED IMPORTED)
31
- set_target_properties(llama PROPERTIES IMPORTED_LOCATION
32
- ${JNI_LIBS_DIR}/${ANDROID_ABI}/libllama.so)
31
+ set_target_properties(llama PROPERTIES
32
+ IMPORTED_LOCATION ${JNI_LIBS_DIR}/${ANDROID_ABI}/libllama.so
33
+ IMPORTED_NO_SONAME TRUE)
33
34
 
34
35
  add_library(ggml-base SHARED IMPORTED)
35
- set_target_properties(ggml-base PROPERTIES IMPORTED_LOCATION
36
- ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-base.so)
36
+ set_target_properties(ggml-base PROPERTIES
37
+ IMPORTED_LOCATION ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-base.so
38
+ IMPORTED_NO_SONAME TRUE)
37
39
 
38
40
  add_library(ggml SHARED IMPORTED)
39
- set_target_properties(ggml PROPERTIES IMPORTED_LOCATION
40
- ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml.so)
41
+ set_target_properties(ggml PROPERTIES
42
+ IMPORTED_LOCATION ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml.so
43
+ IMPORTED_NO_SONAME TRUE)
41
44
 
42
- # CPU backend is essential and always built
43
45
  add_library(ggml-cpu SHARED IMPORTED)
44
- set_target_properties(ggml-cpu PROPERTIES IMPORTED_LOCATION
45
- ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-cpu.so)
46
-
47
- # With GGML_BACKEND_DL, GPU backends are loaded dynamically at runtime
48
- # So we don't need to link against them directly - they'll be separate .so files
49
- # that get loaded when available
46
+ set_target_properties(ggml-cpu PROPERTIES
47
+ IMPORTED_LOCATION ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-cpu.so
48
+ IMPORTED_NO_SONAME TRUE)
50
49
 
51
50
  # Create a minimal common library with only essential files that don't require missing GGML symbols
52
51
  add_library(
@@ -75,13 +74,10 @@ add_library(
75
74
  target_compile_options(common PRIVATE -Wno-unused-function)
76
75
  target_compile_options(RNLlamaCpp PRIVATE -Wno-unused-function)
77
76
 
78
- # Enable dynamic backend loading to match external build configuration
77
+ # Enable dynamic backend loading for GPU acceleration
79
78
  target_compile_definitions(common PRIVATE -DGGML_BACKEND_DL)
80
79
  target_compile_definitions(RNLlamaCpp PRIVATE -DGGML_BACKEND_DL)
81
80
 
82
- # With GGML_BACKEND_DL, GPU backends are loaded dynamically, so we don't need to disable them
83
- # The runtime will detect and load available backends automatically
84
-
85
81
  # Include directories
86
82
  target_include_directories(common PRIVATE
87
83
  ${CPP_DIR}
@@ -104,15 +100,15 @@ target_include_directories(RNLlamaCpp PRIVATE
104
100
  ${MODULE_ROOT}/android/generated/jni/react/renderer/components/RNLlamaCppSpec
105
101
  )
106
102
 
107
- # Link libraries
103
+ # Link libraries with proper dependencies
108
104
  target_link_libraries(
109
105
  RNLlamaCpp
110
106
  common
111
107
  react_codegen_RNLlamaCppSpec # Link against the generated TurboModule code
112
108
  llama # Link against the imported prebuilt core llama library
113
- ggml-base # Link against the imported GGML base library (contains ggml_abort, ggml_time_us, gguf_*)
114
- ggml # Link against the imported GGML library (contains ggml_backend_load_all for dynamic loading)
115
- ggml-cpu # Link against the CPU backend (essential for basic functionality)
109
+ ggml-base # Link against the imported GGML base library
110
+ ggml # Link against the imported GGML library
111
+ ggml-cpu # Link against the imported GGML CPU library
116
112
  jsi
117
113
  reactnative
118
114
  fbjni
@@ -121,6 +117,51 @@ target_link_libraries(
121
117
  dl # Required for dynamic loading of backend libraries
122
118
  )
123
119
 
120
+ # Copy dependency libraries to build output directory so they get packaged into APK
121
+ add_custom_command(TARGET RNLlamaCpp POST_BUILD
122
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
123
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libllama.so
124
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libllama.so
125
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
126
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-base.so
127
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libggml-base.so
128
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
129
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml.so
130
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libggml.so
131
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
132
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-cpu.so
133
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libggml-cpu.so
134
+ COMMENT "Copying dependency libraries to build output directory"
135
+ )
136
+
137
+ # Also copy any optional GPU libraries if they exist
138
+ if(EXISTS ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-vulkan.so)
139
+ add_custom_command(TARGET RNLlamaCpp POST_BUILD
140
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
141
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-vulkan.so
142
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libggml-vulkan.so
143
+ COMMENT "Copying Vulkan library to build output directory"
144
+ )
145
+ endif()
146
+
147
+ if(EXISTS ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-opencl.so)
148
+ add_custom_command(TARGET RNLlamaCpp POST_BUILD
149
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
150
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libggml-opencl.so
151
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libggml-opencl.so
152
+ COMMENT "Copying OpenCL library to build output directory"
153
+ )
154
+ endif()
155
+
156
+ if(EXISTS ${JNI_LIBS_DIR}/${ANDROID_ABI}/libOpenCL.so)
157
+ add_custom_command(TARGET RNLlamaCpp POST_BUILD
158
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
159
+ ${JNI_LIBS_DIR}/${ANDROID_ABI}/libOpenCL.so
160
+ $<TARGET_FILE_DIR:RNLlamaCpp>/libOpenCL.so
161
+ COMMENT "Copying OpenCL loader library to build output directory"
162
+ )
163
+ endif()
164
+
124
165
  # Expose our headers to consuming targets (for autolinking)
125
166
  target_include_directories(RNLlamaCpp INTERFACE
126
167
  ${CPP_DIR}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@novastera-oss/llamarn",
3
- "version": "0.1.1-alpha.6",
3
+ "version": "0.1.1-alpha.8",
4
4
  "description": "An attempt at a pure cpp turbo module library",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",