|
| 1 | +import os |
| 2 | + |
| 3 | +from conan import ConanFile |
| 4 | +from conan.errors import ConanInvalidConfiguration |
| 5 | +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps |
| 6 | +from conan.tools.files import apply_conandata_patches, copy, get |
| 7 | + |
| 8 | +required_conan_version = ">=2.0.6" |
| 9 | + |
| 10 | + |
| 11 | +class TmpfileConan(ConanFile): |
| 12 | + name = "tmpfile" |
| 13 | + package_type = "library" |
| 14 | + |
| 15 | + license = ["GPLv3"] |
| 16 | + homepage = "https://github.com/ViliusSutkus89/tmpfile-Android/" |
| 17 | + url = "https://github.com/opendocument-app/conan-odr-index" |
| 18 | + description = "tmpfile POSIX function fix for Android" |
| 19 | + topics = ("android", "posix", "workaround", "tmpfile", "bionic") |
| 20 | + |
| 21 | + # Binary configuration |
| 22 | + settings = "os", "compiler", "build_type", "arch" |
| 23 | + options = {"shared": [True, False], "fPIC": [True, False]} |
| 24 | + default_options = {"shared": False, "fPIC": True} |
| 25 | + |
| 26 | + def source(self): |
| 27 | + get(self, **self.conan_data["sources"][self.version], strip_root=True) |
| 28 | + apply_conandata_patches(self) |
| 29 | + |
| 30 | + def config_options(self): |
| 31 | + if self.settings.os == "Windows": |
| 32 | + self.options.rm_safe("fPIC") |
| 33 | + |
| 34 | + def configure(self): |
| 35 | + if self.options.shared: |
| 36 | + self.options.rm_safe("fPIC") |
| 37 | + |
| 38 | + def validate(self): |
| 39 | + if self.settings.os != "Android": |
| 40 | + raise ConanInvalidConfiguration("Only Android is supported") |
| 41 | + |
| 42 | + def layout(self): |
| 43 | + cmake_layout(self) |
| 44 | + |
| 45 | + def generate(self): |
| 46 | + deps = CMakeDeps(self) |
| 47 | + deps.generate() |
| 48 | + tc = CMakeToolchain(self) |
| 49 | + tc.variables["WITH_JNI"] = "OFF" |
| 50 | + tc.generate() |
| 51 | + |
| 52 | + def build(self): |
| 53 | + cmake = CMake(self) |
| 54 | + cmake.configure(build_script_folder='tmpfile/src/main/cpp') |
| 55 | + cmake.build() |
| 56 | + |
| 57 | + def package(self): |
| 58 | + copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) |
| 59 | + cmake = CMake(self) |
| 60 | + cmake.install() |
| 61 | + |
| 62 | + def package_info(self): |
| 63 | + self.cpp_info.libs = ["tmpfile"] |
| 64 | + self.cpp_info.system_libs = ["log"] |
| 65 | + self.cpp_info.includedirs = None |
| 66 | + self.cpp_info.bindirs = None |
0 commit comments