Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keystone: add new recipe #25968

Merged
merged 31 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bb26cd9
keystone port init
luadebug Nov 17, 2024
b9d91e7
fmt
luadebug Nov 17, 2024
223ed48
license file fix
luadebug Nov 17, 2024
51e0fb9
clean
luadebug Nov 17, 2024
0b79c8b
Update conanfile.py fix lic
luadebug Nov 17, 2024
571bff3
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
d917e08
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
121fae0
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
ce90ffc
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
72c08e5
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
8d0cd9d
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
f11a083
Update recipes/keystone/all/test_package/CMakeLists.txt
luadebug Nov 19, 2024
982ae51
Update recipes/keystone/all/test_package/CMakeLists.txt
luadebug Nov 19, 2024
f701a00
Delete recipes/keystone/all/test_v1_package directory
luadebug Nov 19, 2024
de402b7
bump to v2.0 min conan ver
luadebug Nov 19, 2024
76101a0
Rename test_package.c to test_package.cpp
luadebug Nov 19, 2024
7663797
Fix test_package.cpp
luadebug Nov 19, 2024
34f6255
C++ like style for test_package.cpp
luadebug Nov 19, 2024
4164526
Clean def package_info
luadebug Nov 19, 2024
a874527
Trigger build for PR-25968
uilianries Nov 19, 2024
07bf69b
Fix conanfile.py
luadebug Nov 19, 2024
f0fc64b
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
7c121f1
Import missing check_max_cppstd
uilianries Nov 19, 2024
3c1e4a3
Update recipes/keystone/all/conanfile.py
luadebug Nov 19, 2024
a03eb06
Topics change conanfile.py
luadebug Nov 19, 2024
a90728f
auto fpic conanfile.py
luadebug Nov 19, 2024
276a66b
fix lic conanfile.py
luadebug Nov 19, 2024
a2c975f
lic add conanfile.py
luadebug Nov 19, 2024
2c015f8
Update recipes/keystone/all/conanfile.py
luadebug Nov 20, 2024
7153a66
Update recipes/keystone/all/conanfile.py
luadebug Nov 20, 2024
5bf2f11
Update recipes/keystone/all/conanfile.py
luadebug Nov 20, 2024
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
4 changes: 4 additions & 0 deletions recipes/keystone/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
101 changes: 101 additions & 0 deletions recipes/keystone/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import (
copy,
get,
rmdir,
export_conandata_patches,
apply_conandata_patches,
)
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
uilianries marked this conversation as resolved.
Show resolved Hide resolved
from conan.tools.scm import Version
luadebug marked this conversation as resolved.
Show resolved Hide resolved
import os

required_conan_version = ">=1.53.0"


class KeystoneConan(ConanFile):
name = "keystone"
luadebug marked this conversation as resolved.
Show resolved Hide resolved
description = (
"Keystone assembler framework: Core (Arm, Arm64, Hexagon, "
"Mips, PowerPC, Sparc, SystemZ & X86) + bindings."
)
license = "GPL-2.0-or-later"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.keystone-engine.org"
topics = (
"reverse-engineering",
"disassembler",
"security",
"framework",
"arm",
"arm64",
"x86",
"sparc",
"powerpc",
"mips",
"x86-64",
"hexagon",
"systemz",
)
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"use_default_alloc": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"use_default_alloc": True,
luadebug marked this conversation as resolved.
Show resolved Hide resolved
}

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

luadebug marked this conversation as resolved.
Show resolved Hide resolved
def layout(self):
cmake_layout(self, src_folder="src")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

luadebug marked this conversation as resolved.
Show resolved Hide resolved
def generate(self):
tc = CMakeToolchain(self)
tc.variables["build_libs_only"] = True
tc.variables["KEYSTONE_BUILD_STATIC_RUNTIME"] = is_msvc_static_runtime(self)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()

def build(self):
apply_conandata_patches(self)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
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"),
)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
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):
suffix = "_dll" if is_msvc(self) and self.options.shared else ""
self.cpp_info.libs = [f"keystone{suffix}"]
if self.settings.os == "Windows":
self.cpp_info.system_libs = ["shell32", "ole32", "uuid"]
7 changes: 7 additions & 0 deletions recipes/keystone/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
project(test_package LANGUAGES C)

find_package(keystone REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
luadebug marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(${PROJECT_NAME} PRIVATE keystone::keystone)
26 changes: 26 additions & 0 deletions recipes/keystone/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
11 changes: 11 additions & 0 deletions recipes/keystone/all/test_package/test_package.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <keystone/keystone.h>

int main()
{
int major = 0, minor = 0;
ks_version(&major, &minor);
printf("keystone version %d.%d\n", major, minor);
return EXIT_SUCCESS;
}
8 changes: 8 additions & 0 deletions recipes/keystone/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
17 changes: 17 additions & 0 deletions recipes/keystone/all/test_v1_package/conanfile.py
luadebug marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
3 changes: 3 additions & 0 deletions recipes/keystone/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.9.2":
folder: "all"