Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions builtin-adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ include_directories(${JNI_INCLUDE_DIRS} ${REINDEXER_INCLUDE_DIRS})

target_link_libraries(${TARGET} reindexer_server_library reindexer_server_resources ${REINDEXER_LIBRARIES})

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(JNI_EXPORTS "${CMAKE_CURRENT_SOURCE_DIR}/jni.exports")
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS
" -Wl,--version-script=\"${JNI_EXPORTS}\" -Wl,--gc-sections")
set_property(TARGET ${TARGET} APPEND PROPERTY LINK_DEPENDS "${JNI_EXPORTS}")

# Keep the regular symbol table for native backtraces, but omit DWARF data.
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND "${CMAKE_STRIP}" --strip-debug "$<TARGET_FILE:${TARGET}>"
VERBATIM
)
endif()

# Workaround for macOS to propagate a correct OpenSSL lib path to Reindexer.
if(APPLE)
find_package(OpenSSL)
Expand Down
7 changes: 7 additions & 0 deletions builtin-adapter/jni.exports
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
global:
Java_ru_rt_restream_reindexer_binding_builtin_BuiltinAdapter_*;
Java_ru_rt_restream_reindexer_util_NativeUtils_*;
local:
*;
};
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<excludes>
<exclude>**/*.so</exclude>
<exclude>**/*.dylib</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,23 @@ public class BuiltinAdapter {

private static void loadLibrary(String fileName) throws IOException {
Path tempFile = Files.createTempFile("rx-connector-", fileName);
boolean loaded = false;
LOGGER.debug("rx: loading {}", tempFile);
try (InputStream is = BuiltinAdapter.class.getClassLoader().getResourceAsStream(fileName)) {
if (is == null) {
throw new IllegalArgumentException("File: '" + fileName + "' is not found");
}
Files.copy(is, tempFile, StandardCopyOption.REPLACE_EXISTING);
// Native backtrace resolution needs the ELF file after the library is loaded.
tempFile.toFile().deleteOnExit();
System.load(tempFile.toAbsolutePath().toString());
loaded = true;
LOGGER.debug("rx: loaded {}", tempFile);
} finally {
Files.delete(tempFile);
LOGGER.debug("rx: deleted {}", tempFile);
if (!loaded) {
Files.deleteIfExists(tempFile);
LOGGER.debug("rx: deleted {}", tempFile);
}
}
}

Expand Down
Loading