* add package: zycore-c

* zycore add v1.1.0

* add package zydis

* update zydis

* update zydis

* link libzycore under xmake

* zydis specific deps version

* version_map

* convert utf16le to utf8

* zydis sync with zycore

* disable build_shared flag for zydis

* add limits for plat
pull/1283/head
yszhou2019 3 years ago committed by GitHub
parent bcb63660fe
commit 41631312e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 84
      packages/z/zydis/patches/v3.2.1/cmake.patch
  2. 40
      packages/z/zydis/xmake.lua

@ -0,0 +1,84 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9898f42..788d371 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,41 +43,52 @@ option(ZYDIS_FUZZ_AFL_FAST
option(ZYDIS_LIBFUZZER
"Enables LLVM libfuzzer mode and reduces prints in ZydisFuzzIn"
OFF)
-set(ZYDIS_ZYCORE_PATH
- "${CMAKE_CURRENT_LIST_DIR}/dependencies/zycore"
- CACHE
- PATH
- "The path to look for Zycore")
# =============================================================================================== #
-# Dependencies #
+# Exported functions #
# =============================================================================================== #
-# Try to initialize the Zycore submodule using Git
-if (NOT EXISTS "${ZYDIS_ZYCORE_PATH}/CMakeLists.txt" AND
- "${ZYDIS_ZYCORE_PATH}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}/dependencies/zycore")
- find_package(Git QUIET)
- if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
- execute_process(
- COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
- endif()
+function (zyan_set_common_flags target)
+if (NOT MSVC)
+ target_compile_options("${target}" PRIVATE "-std=c99")
endif ()
-if (NOT EXISTS "${ZYDIS_ZYCORE_PATH}/CMakeLists.txt")
- message(
- FATAL_ERROR
- "Can't find zycore submodule. Please make sure to clone the repo recursively.\n"
- "You can fix this by running\n"
- " git submodule update --init\n"
- "or by cloning using\n"
- " git clone --recursive <url>\n"
- "Alternatively, you can manually clone zycore to some path and set ZYDIS_ZYCORE_PATH."
- )
+if (ZYAN_DEV_MODE)
+ # If in developer mode, be pedantic.
+ if (MSVC)
+ target_compile_options("${target}" PUBLIC "/WX" "/W4")
+ else ()
+ target_compile_options("${target}" PUBLIC "-Wall" "-pedantic" "-Wextra" "-Werror")
+ endif ()
+endif ()
+endfunction ()
+
+function (zyan_set_source_group target)
+if (ZYAN_DEV_MODE)
+ if (((CMAKE_MAJOR_VERSION GREATER 3) OR (CMAKE_MAJOR_VERSION EQUAL 3)) AND
+ ((CMAKE_MINOR_VERSION GREATER 8) OR (CMAKE_MINOR_VERSION EQUAL 8)))
+ # Mirror directory structure in project files
+ get_property("TARGET_SOURCE_FILES" TARGET "${target}" PROPERTY SOURCES)
+ source_group(TREE "${CMAKE_CURRENT_LIST_DIR}" FILES ${TARGET_SOURCE_FILES})
+ endif ()
endif ()
+endfunction ()
+
+function (zyan_maybe_enable_wpo target)
+if (ZYAN_WHOLE_PROGRAM_OPTIMIZATION AND MSVC)
+ set_target_properties("${target}" PROPERTIES COMPILE_FLAGS "/GL")
+ set_target_properties("${target}" PROPERTIES LINK_FLAGS_RELEASE "/LTCG")
+endif ()
+endfunction ()
+
+function (zyan_maybe_enable_wpo_for_lib target)
+if (ZYAN_WHOLE_PROGRAM_OPTIMIZATION AND MSVC)
+ set_target_properties("${target}" PROPERTIES COMPILE_FLAGS "/GL")
+ set_target_properties("${target}" PROPERTIES LINK_FLAGS_RELEASE "/LTCG")
+ set_target_properties("${target}" PROPERTIES STATIC_LIBRARY_FLAGS_RELEASE "/LTCG")
+endif ()
+endfunction ()
-add_subdirectory(${ZYDIS_ZYCORE_PATH} "zycore" EXCLUDE_FROM_ALL)
# =============================================================================================== #
# Library configuration #

@ -0,0 +1,40 @@
package("zydis")
set_homepage("https://zydis.re")
set_description("Fast and lightweight x86/x86-64 disassembler and code generation library")
set_license("MIT")
add_urls("https://github.com/zyantific/zydis/archive/refs/tags/$(version).tar.gz",
"https://github.com/zyantific/zydis.git")
add_versions("v3.2.1", "349a2d27270e54499b427051dd45f7b6064811b615588414b096cdeeaeb730ad")
add_patches("v3.2.1", path.join(os.scriptdir(), "patches", "v3.2.1", "cmake.patch"), "8464810921f507206b8c21618a20de0f5b96cbef7656ebc549079f941f8718fc")
add_deps("cmake")
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
on_load(function (package)
local zycore_c_vers = {
["v3.2.1"] = "v1.1.0",
["v4.0.0"] = "v1.2.0"
}
package:add("deps", "zycore-c " .. zycore_c_vers[package:version_str()])
end)
on_install("windows", "macosx", "linux", "bsd", "cross", "mingw", "android", function (package)
local configs = {}
table.insert(configs, "-DZYDIS_BUILD_EXAMPLES=OFF")
table.insert(configs, "-DZYDIS_BUILD_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
if package:config("shared") then
table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
end
import("package.tools.cmake").install(package, configs, {packagedeps = "zycore-c"})
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <Zydis/Zydis.h>
#include <Zycore/LibC.h>
void test() {
ZyanU8 encoded_instruction[ZYDIS_MAX_INSTRUCTION_LENGTH];
ZyanUSize encoded_length = sizeof(encoded_instruction);
}
]]}, {configs = {languages = "c++11"}}))
end)
Loading…
Cancel
Save