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

add keystone #5459

Merged
merged 9 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
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
51 changes: 51 additions & 0 deletions packages/k/keystone/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package("keystone")
set_homepage("http://www.keystone-engine.org")
set_description("Keystone assembler framework: Core (Arm, Arm64, Hexagon, Mips, PowerPC, Sparc, SystemZ & X86) + bindings")
set_license("GPL-2.0")

add_urls("https://github.com/keystone-engine/keystone/archive/refs/tags/$(version).tar.gz",
"https://github.com/keystone-engine/keystone.git")

add_versions("0.9.2", "c9b3a343ed3e05ee168d29daf89820aff9effb2c74c6803c2d9e21d55b5b7c24")

add_deps("cmake")
add_deps("python 3.x", {kind = "binary"})

if is_plat("windows", "mingw") then
add_syslinks("shell32", "ole32", "uuid")
end

on_load(function (package)
if package:is_cross() or package:is_plat("mingw") or (package:is_plat("windows") and package:config("shared")) then
package:data_set("build_libs_only", true)
end
if not package:data("build_libs_only") then
package:addenv("PATH", "bin")
end
end)

on_install(function (package)
local configs = {}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if package:data("build_libs_only") then
table.insert(configs, "-DBUILD_LIBS_ONLY=ON")
end
if package:is_plat("windows") then
table.insert(configs, "-DKEYSTONE_BUILD_STATIC_RUNTIME=" .. (package:has_runtime("MT", "MTd") and "ON" or "OFF"))
elseif package:is_plat("android") then
Copy link
Contributor

@luadebug luadebug Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Github CI ignored it for some reason?

CMake Warning (dev) at /home/runner/work/xmake-repo/xmake-repo/android-ndk-r27/build/cmake/flags.cmake:46 (if):
Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake
--help-policy CMP0057" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

IN_LIST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
/home/runner/.xmake/packages/c/cmake/3.30.2/924bf70cd2964eea80fdac45c84f12e4/share/cmake-3.30/Modules/Platform/Android-Clang.cmake:23 (include)
/home/runner/.xmake/packages/c/cmake/3.30.2/924bf70cd2964eea80fdac45c84f12e4/share/cmake-3.30/Modules/Platform/Android-Clang-C.cmake:1 (include)
/home/runner/.xmake/packages/c/cmake/3.30.2/924bf70cd2964eea80fdac45c84f12e4/share/cmake-3.30/Modules/CMakeCInformation.cmake:48 (include)
CMakeLists.txt:5 (project)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error at /home/runner/work/xmake-repo/xmake-repo/android-ndk-r27/build/cmake/flags.cmake:46 (if):
if given arguments:

"hwaddress" "IN_LIST" "ANDROID_SANITIZE"

Unknown arguments specified
Call Stack (most recent call first):
/home/runner/.xmake/packages/c/cmake/3.30.2/924bf70cd2964eea80fdac45c84f12e4/share/cmake-3.30/Modules/Platform/Android-Clang.cmake:23 (include)
/home/runner/.xmake/packages/c/cmake/3.30.2/924bf70cd2964eea80fdac45c84f12e4/share/cmake-3.30/Modules/Platform/Android-Clang-C.cmake:1 (include)
/home/runner/.xmake/packages/c/cmake/3.30.2/924bf70cd2964eea80fdac45c84f12e4/share/cmake-3.30/Modules/CMakeCInformation.cmake:48 (include)
CMakeLists.txt:5 (project)

https://github.com/search?q=repo%3Axmake-io%2Fxmake-repo%20MAKE_POLICY_DEFAULT_CMP0057&type=code

cmake_policy(SET CMP0057 NEW)

android-NDK-r37.patch

--- CMakeLists.txt.orig 2024-10-10 08:00:00.000000000 +0000
+++ CMakeLists.txt      2024-10-10 08:10:00.000000000 +0000
@@ -19,6 +19,10 @@
   cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
 endif()

+if (POLICY CMP0057)
+  cmake_policy(SET CMP0057 NEW)
+endif()

 if (POLICY CMP0051)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@luadebug luadebug Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it did not work out.
https://github.com/xmake-io/xmake-repo/actions/runs/11276235247/job/31359534078?pr=5459

error: @programdir\core\sandbox\modules\os.lua:273: -- Android: Targeting API '30' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 18.0.1
-- The CXX compiler identification is Clang 18.0.1
-- Configuring incomplete, errors occurred!
 older versions.


CMake Warning (dev) at D:/a/xmake-repo/xmake-repo/ndk/android-ndk-r27/build/cmake/flags.cmake:46 (if):
  Policy CMP0057 is not set: Support new IN_LIST if() operator.  Run "cmake
  --help-policy CMP0057" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  IN_LIST will be interpreted as an operator when the policy is set to NEW.
  Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Android-Clang.cmake:23 (include)
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Android-Clang-C.cmake:1 (include)
  C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:5 (project)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at D:/a/xmake-repo/xmake-repo/ndk/android-ndk-r27/build/cmake/flags.cmake:46 (if):
  if given arguments:

    "hwaddress" "IN_LIST" "ANDROID_SANITIZE"

  Unknown arguments specified
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Android-Clang.cmake:23 (include)
  C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Android-Clang-C.cmake:1 (include)
  C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:5 (project)

We could rely over cmake.flags file like this:
https://android-review.googlesource.com/c/platform/ndk/+/3211647/1/build/cmake/flags.cmake
according to:
android/ndk#2032 (comment)
Please note it there old versions are being used:
https://github.com/search?q=repo%3Akeystone-engine%2Fkeystone%20cmake_minimum_required&type=code
Reference: https://cmake.org/cmake/help/latest/policy/CMP0057.html

The policy CMP0057 was introduced in CMake 3.3.

This policy adds support for the IN_LIST operator in if() conditions, which allows you to check if a value exists in a list more easily.

Here’s the relevant information:

    CMake Version: 3.3
    Policy: CMP0057
    Description: This policy governs the use of the IN_LIST operator in if() statements. When the policy is set to NEW, the IN_LIST operator is enabled, allowing list membership checks.

If you're using a version of CMake older than 3.3, the condition if(POLICY CMP0057) will fail because the policy does not exist in those versions. You need to upgrade to CMake 3.3 or later to use this policy.

-- support for ndk >= r27
-- https://github.com/android/ndk/issues/2032
table.insert(configs, "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW")
end
io.replace("CMakeLists.txt", "add_subdirectory(suite/fuzz)", "", {plain = true})
import("package.tools.cmake").install(package, configs)
os.cp("include", package:installdir())
end)

on_test(function (package)
if not package:data("build_libs_only") then
os.vrun('kstool -b x64 "mov rax, 1; ret"')
end
assert(package:has_cfuncs("ks_version", {includes = "keystone/keystone.h"}))
end)
Loading