diff --git a/.tool-versions b/.tool-versions index 8a67de1..ad57b0f 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -djinni 0.5.0 +djinni 1.0.0 java zulu-11.41.23 diff --git a/CMakeLists.txt b/CMakeLists.txt index 105ca1e..1847013 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,8 @@ set(SRC_JNI "djinni/jni/djinni_support.hpp" "djinni/jni/Marshal.hpp" "djinni/jni/djinni_support.cpp" + "djinni/jni/djinni_jni_main.hpp" + "djinni/jni/djinni_jni_main.cpp" ) set(SRC_OBJC @@ -62,7 +64,6 @@ set_target_properties(djinni_support_lib PROPERTIES CXX_EXTENSIONS false ) - install( TARGETS djinni_support_lib LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" @@ -70,14 +71,11 @@ install( RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) - install( FILES ${SRC_SHARED} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/djinni/ ) - - # Objective-C support option(DJINNI_WITH_OBJC "Include the Objective-C support code in Djinni support library." off) if(DJINNI_WITH_OBJC) @@ -104,11 +102,9 @@ target_include_directories(djinni_support_lib PUBLIC "$") target_sources(djinni_support_lib PRIVATE ${SRC_JNI}) source_group("jni" FILES ${SRC_JNI}) @@ -117,6 +113,7 @@ if(DJINNI_WITH_JNI) FILES "djinni/jni/djinni_support.hpp" "djinni/jni/Marshal.hpp" + "djinni/jni/djinni_jni_main.hpp" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/djinni/jni ) diff --git a/djinni/jni/djinni_jni_main.cpp b/djinni/jni/djinni_jni_main.cpp new file mode 100644 index 0000000..3fd861a --- /dev/null +++ b/djinni/jni/djinni_jni_main.cpp @@ -0,0 +1,17 @@ +// +// Copyright 2021 cross-language-cpp +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "djinni_jni_main.hpp" diff --git a/djinni/jni/djinni_main.cpp b/djinni/jni/djinni_jni_main.hpp similarity index 85% rename from djinni/jni/djinni_main.cpp rename to djinni/jni/djinni_jni_main.hpp index f655695..6c9bca1 100644 --- a/djinni/jni/djinni_main.cpp +++ b/djinni/jni/djinni_jni_main.hpp @@ -1,5 +1,6 @@ // // Copyright 2014 Dropbox, Inc. +// Copyright 2021 cross-language-cpp // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,9 +14,9 @@ // See the License for the specific language governing permissions and // limitations under the License. // - -// This provides a minimal JNI_OnLoad and JNI_OnUnload implementation - include it if your -// app doesn't use JNI except through Djinni. +// This provides a minimal JNI_OnLoad and JNI_OnUnload implementation. +// Don't include it if your library does require a custom JNI_OnLoad implementation with custom initialization logic. +#pragma once #include "djinni_support.hpp" diff --git a/djinni/jni/djinni_support.hpp b/djinni/jni/djinni_support.hpp index ddae504..759c935 100644 --- a/djinni/jni/djinni_support.hpp +++ b/djinni/jni/djinni_support.hpp @@ -23,8 +23,8 @@ #include #include -#include "../proxy_cache_interface.hpp" -#include "../djinni_common.hpp" +#include "djinni/proxy_cache_interface.hpp" +#include "djinni/djinni_common.hpp" #include /* diff --git a/mkdocs-requirements.txt b/mkdocs-requirements.txt index c6f31b5..f3a0250 100644 --- a/mkdocs-requirements.txt +++ b/mkdocs-requirements.txt @@ -1,3 +1,3 @@ # dependencies for mkdocs documentation mkdocs>=1.1 -mkdocs-material>=7.1.3 \ No newline at end of file +mkdocs-material>=7.1.3 diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index dac28f4..530c3a8 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -67,6 +67,7 @@ add_djinni_target(DjinniWCharTests JAVA_NONNULL_ANNOTATION "javax.annotation.Nonnull" IDENT_JAVA_FIELD "mFooBar" JNI_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/jni" + JNI_GENERATE_MAIN false IDENT_JNI_CLASS "NativeFooBar" IDENT_JNI_FILE "NativeFooBar" OBJC_OUT "${CMAKE_CURRENT_BINARY_DIR}/generated-src/objc" @@ -133,10 +134,7 @@ source_group("generated-objcpp" FILES ${WCHAR_OBJCPP_GENERATED_SRCS}) source_group("generated-yaml" FILES ${WCHAR_YAML_GENERATED_SRCS}) if(DJINNI_WITH_JNI) - file(GLOB_RECURSE SUPPORT_LIB_JNI_SRCS "${CMAKE_SOURCE_DIR}/djinni/jni/*") - add_library(DjinniTestNative SHARED - ${SUPPORT_LIB_JNI_SRCS} ${JNI_GENERATED_SRCS} ${CPP_GENERATED_SRCS} ${WCHAR_JNI_GENERATED_SRCS} @@ -150,6 +148,7 @@ if(DJINNI_WITH_JNI) ${CMAKE_CURRENT_BINARY_DIR}/generated-src/cpp ${JNI_INCLUDE_DIRS} ) + target_link_libraries(DjinniTestNative PUBLIC djinni-support-lib::djinni-support-lib) find_package(Java REQUIRED) include(UseJava) diff --git a/test-suite/Djinni.cmake b/test-suite/Djinni.cmake index 082acb5..ea73238 100644 --- a/test-suite/Djinni.cmake +++ b/test-suite/Djinni.cmake @@ -105,6 +105,7 @@ function(add_djinni_target) JNI_INCLUDE_CPP_PREFIX JNI_NAMESPACE JNI_BASE_LIB_INCLUDE_PREFIX + JNI_GENERATE_MAIN IDENT_JNI_CLASS IDENT_JNI_FILE @@ -233,6 +234,7 @@ function(add_djinni_target) append_if_defined(DJINNI_GENERATION_COMMAND "--jni-include-cpp-prefix" ${DJINNI_JNI_INCLUDE_CPP_PREFIX}) append_if_defined(DJINNI_GENERATION_COMMAND "--jni-namespace" ${DJINNI_JNI_NAMESPACE}) append_if_defined(DJINNI_GENERATION_COMMAND "--jni-base-lib-include-prefix" ${DJINNI_JNI_BASE_LIB_INCLUDE_PREFIX}) + append_if_defined(DJINNI_GENERATION_COMMAND "--jni-generate-main" ${DJINNI_JNI_GENERATE_MAIN}) append_if_defined(DJINNI_GENERATION_COMMAND "--ident-jni-class" ${DJINNI_IDENT_JNI_CLASS}) append_if_defined(DJINNI_GENERATION_COMMAND "--ident-jni-file" ${DJINNI_IDENT_JNI_FILE}) diff --git a/test/jni_list.txt b/test/jni_list.txt index a952cef..9407b9e 100644 --- a/test/jni_list.txt +++ b/test/jni_list.txt @@ -6,6 +6,7 @@ ./usr/local/include/djinni/djinni_common.hpp ./usr/local/include/djinni/jni ./usr/local/include/djinni/jni/Marshal.hpp +./usr/local/include/djinni/jni/djinni_jni_main.hpp ./usr/local/include/djinni/jni/djinni_support.hpp ./usr/local/include/djinni/proxy_cache_impl.hpp ./usr/local/include/djinni/proxy_cache_interface.hpp