This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#5063) Add djinni-support-lib
* dAdd djinni-support-lib * add url attribute * add zulu-openjdk as dependency * handle PIfC config * fix testing * patch for windows build * add final line end * Add support for stone-age python Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * Remove default include folder Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * Remove ctest artifact Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * Use lowercase options * Join Path instead of provide/them Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * Join Path instead of provide/them Co-authored-by: Chris Mc <prince.chrismc@gmail.com> * adopt include to generator output Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
- Loading branch information
1 parent
b8bcdb0
commit a56405f
Showing
8 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(conan_cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
if(WIN32 AND BUILD_SHARED_LIBS) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif() | ||
|
||
add_subdirectory("source_subfolder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"0.0.1": | ||
url: https://github.com/cross-language-cpp/djinni-support-lib/archive/v0.0.1.tar.gz | ||
sha256: "ddef30a95a8bd325446d3a76ea9c11f198f3b33f66157217bd46fb13d75c43d2" | ||
patches: | ||
"0.0.1": | ||
- patch_file: "patches/cmake_install.patch" | ||
base_path: "source_subfolder" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import os | ||
|
||
from conans import ConanFile, CMake, tools | ||
|
||
class DjinniSuppotLib(ConanFile): | ||
name = "djinni-support-lib" | ||
homepage = "https://djinni.xlcpp.dev" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
description = "Djinni is a tool for generating cross-language type declarations and interface bindings" | ||
topics = ("java", "Objective-C", "Android", "iOS") | ||
license = "Apache-2.0" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = {"shared": [True, False], | ||
"fPIC": [True, False], | ||
"target": ["jni", "objc", "auto"], | ||
"system_java": [True, False] | ||
} | ||
default_options = {"shared": False, | ||
"fPIC": True , | ||
"target": "auto", | ||
"system_java": False | ||
} | ||
exports_sources = ["patches/**", "CMakeLists.txt"] | ||
generators = "cmake", "cmake_find_package" | ||
|
||
_cmake = None | ||
|
||
@property | ||
def objc_support(self): | ||
if self.options.target == "auto": | ||
return self.settings.os in ["iOS", "Macos"] | ||
else: | ||
return self.options.target == "objc" | ||
|
||
@property | ||
def jni_support(self): | ||
if self.options.target == "auto": | ||
return self.settings.os != "iOS" | ||
else: | ||
return self.options.target == "jni" | ||
|
||
|
||
def configure(self): | ||
if self.settings.compiler == 'Visual Studio': | ||
del self.options.fPIC | ||
|
||
@property | ||
def _source_subfolder(self): | ||
return "source_subfolder" | ||
|
||
def build_requirements(self): | ||
if not self.options.system_java: | ||
self.build_requires("zulu-openjdk/11.0.8@") | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
os.rename(self.name + "-" + self.version, self._source_subfolder) | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
self._cmake = CMake(self) | ||
if not self.options.shared: | ||
self._cmake.definitions["DJINNI_STATIC_LIB"] = True | ||
self._cmake.definitions["DJINNI_WITH_OBJC"] = self.objc_support | ||
self._cmake.definitions["DJINNI_WITH_JNI"] = self.jni_support | ||
if self.jni_support: | ||
self._cmake.definitions["JAVA_AWT_LIBRARY"] = "NotNeeded" | ||
self._cmake.definitions["JAVA_AWT_INCLUDE_PATH"] = "NotNeeded" | ||
self._cmake.configure() | ||
return self._cmake | ||
|
||
def build(self): | ||
for patch in self.conan_data.get("patches", {}).get(self.version, []): | ||
tools.patch(**patch) | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def package(self): | ||
cmake = self._configure_cmake() | ||
cmake.install() | ||
self.copy("LICENSE", dst="licenses", src=self._source_subfolder) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = tools.collect_libs(self) | ||
# these should not be here, but to support old generated files .... | ||
if self.objc_support: | ||
self.cpp_info.includedirs.append(os.path.join("include", "djinni", "objc")) | ||
if self.jni_support: | ||
self.cpp_info.includedirs.append(os.path.join("include", "djinni", "jni")) |
16 changes: 16 additions & 0 deletions
16
recipes/djinni-support-lib/all/patches/cmake_install.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 53c3ed1..f48be06 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -42,8 +42,9 @@ set_target_properties(djinni_support_lib PROPERTIES | ||
|
||
install( | ||
TARGETS djinni_support_lib | ||
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) | ||
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
class TestPackageConan(ConanFile): | ||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "cmake" | ||
|
||
def _configure_cmake(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
return cmake | ||
|
||
def build(self): | ||
cmake = self._configure_cmake() | ||
cmake.build() | ||
|
||
def test(self): | ||
if not tools.cross_building(self.settings): | ||
bin_path = os.path.join("bin", "test_package") | ||
self.run(bin_path, run_environment=True) |
11 changes: 11 additions & 0 deletions
11
recipes/djinni-support-lib/all/test_package/test_package.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <djinni/djinni_common.hpp> | ||
#include <cstdlib> | ||
|
||
// since we would either need objective C++ or Java (jni) there is not a lot to test | ||
// just that we have the hearders and can link | ||
int main() { | ||
return EXIT_SUCCESS ; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.0.1": | ||
folder: "all" |