diff --git a/recipes/keystone/all/conandata.yml b/recipes/keystone/all/conandata.yml new file mode 100644 index 0000000000000..293bb6907aa2e --- /dev/null +++ b/recipes/keystone/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.9.2": + url: "https://github.com/keystone-engine/keystone/archive/refs/tags/0.9.2.tar.gz" + sha256: "c9b3a343ed3e05ee168d29daf89820aff9effb2c74c6803c2d9e21d55b5b7c24" diff --git a/recipes/keystone/all/conanfile.py b/recipes/keystone/all/conanfile.py new file mode 100644 index 0000000000000..a4075c2b51be6 --- /dev/null +++ b/recipes/keystone/all/conanfile.py @@ -0,0 +1,93 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rmdir +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime +from conan.tools.build import check_max_cppstd +import os + +required_conan_version = ">=2.0" + + +class KeystoneConan(ConanFile): + name = "keystone" + description = ( + "Keystone assembler framework: Core (Arm, Arm64, Hexagon, " + "Mips, PowerPC, Sparc, SystemZ & X86) + bindings." + ) + license = ( "GPL-2.0-only", "DocumentRef-EXCEPTIONS-CLIENT:LicenseRef-FOSS-License-Exception" ) + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://www.keystone-engine.org" + topics = ( + "security", + "arm", + "framework", + "mips", + "x86-64", + "reverse-engineering", + "assembler", + "x86", + "hexagon", + "arm64", + "sparc", + "powerpc", + "systemz" + ) + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + implements = ["auto_shared_fpic"] + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def validate(self): + # INFO: include/llvm/ADT/STLExtras.h:54:34: error: no template named 'binary_function' in namespace 'std' + # The std::binary_function was removed in C++17 + check_max_cppstd(self, 14) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["BUILD_LIBS_ONLY"] = True + tc.cache_variables["KEYSTONE_BUILD_STATIC_RUNTIME"] = is_msvc_static_runtime(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy( + self, + "COPYING", + src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses"), + ) + copy( + self, + "EXCEPTIONS-CLIENT", + src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses"), + ) + copy(self, "LICENSE*", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_info(self): + self.cpp_info.libs = ["keystone"] + if is_msvc(self) and self.options.shared: + self.cpp_info.bindirs = ["lib"] + if self.settings.os == "Windows": + self.cpp_info.system_libs = ["shell32", "ole32", "uuid"] diff --git a/recipes/keystone/all/test_package/CMakeLists.txt b/recipes/keystone/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..fa5c67fc76107 --- /dev/null +++ b/recipes/keystone/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(keystone REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE keystone::keystone) diff --git a/recipes/keystone/all/test_package/conanfile.py b/recipes/keystone/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/keystone/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/keystone/all/test_package/test_package.cpp b/recipes/keystone/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..979bb61f8423f --- /dev/null +++ b/recipes/keystone/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() +{ + unsigned int major = 0, minor = 0; + ks_version(&major, &minor); + std::cout << "Keystone version: " << major << "." << minor << std::endl; + return EXIT_SUCCESS; +} diff --git a/recipes/keystone/config.yml b/recipes/keystone/config.yml new file mode 100644 index 0000000000000..6adb5bb604435 --- /dev/null +++ b/recipes/keystone/config.yml @@ -0,0 +1,3 @@ +versions: + "0.9.2": + folder: "all"