-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
libmem: add package #5430
Open
luadebug
wants to merge
7
commits into
xmake-io:dev
Choose a base branch
from
luadebug:dev
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+148
−0
Open
libmem: add package #5430
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
797807a
Added libmem.
luadebug 5ac6151
Merge branch 'xmake-io:dev' into dev
luadebug c52b158
Update xmake.lua
luadebug eaed43b
Update xmake.lua
luadebug 33b6d0d
Update xmake.lua
luadebug bff94dc
Update xmake.lua
luadebug 72d8d1d
Update xmake.lua
luadebug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package("libmem") | ||
|
||
set_homepage("https://github.com/rdbo/libmem") | ||
set_description("Cross-platform game hacking library for C, C++, Rust, and Python, supporting process/memory hacking, hooking, detouring, and DLL/SO injection.") | ||
set_license("AGPL-3.0") | ||
|
||
add_urls("https://github.com/rdbo/libmem/archive/refs/tags/$(version).tar.gz", "https://github.com/rdbo/libmem.git", {submodules = true}) | ||
add_versions("5.0.2", "99adea3e86bd3b83985dce9076adda16968646ebd9d9316c9f57e6854aeeab9c") | ||
add_deps("cmake") | ||
|
||
|
||
on_install(function (package) | ||
|
||
local configs = {} | ||
|
||
io.writefile("xmake.lua", [[ | ||
set_languages("c17", "c++20") | ||
|
||
if is_plat("windows") then | ||
set_toolset("make", "nmake") -- Use NMAKE as the make tool | ||
end | ||
|
||
-- Set options | ||
option("build_tests", {description = "Build tests", default = false, showmenu = true}) | ||
option("deep_tests", {description = "Enable deep testing", default = false, showmenu = true}) | ||
option("build_static", {description = "Build static library", default = true, showmenu = true}) | ||
|
||
set_arch(os.arch()) | ||
|
||
-- Set Capstone, Keystone, and LLVM directories (adjust as needed) | ||
local external_dependencies_dir = path.join(os.projectdir(), "external") | ||
local capstone_dir = path.join(external_dependencies_dir, "capstone") | ||
local keystone_dir = path.join(external_dependencies_dir, "keystone") | ||
local llvm_dir = path.join(external_dependencies_dir, "llvm") | ||
|
||
-- Set external dependencies | ||
add_includedirs(path.join(capstone_dir, "include")) | ||
add_includedirs(path.join(keystone_dir, "include")) | ||
add_includedirs(path.join(llvm_dir, "include")) | ||
|
||
-- Define source directories | ||
local libmem_dir = os.projectdir() | ||
local internal_dir = path.join(libmem_dir, "internal") | ||
local common_dir = path.join(libmem_dir, "src", "common") | ||
|
||
-- Add source files based on platform | ||
local libmem_src = {} | ||
|
||
if is_plat("windows") then | ||
libmem_src = { | ||
path.join(libmem_dir, "src/win/*.c"), | ||
path.join(common_dir, "*.c"), | ||
path.join(common_dir, "*.cpp"), | ||
path.join(internal_dir, "winutils/*.c"), | ||
path.join(internal_dir, "demangler/*.cpp") | ||
} | ||
elseif is_plat("linux") then | ||
if is_arch("x86_64") then | ||
libmem_src = { | ||
path.join(common_dir, "arch/x86.c"), | ||
path.join(libmem_dir, "src/linux/ptrace/x64/*.c"), | ||
path.join(libmem_dir, "src/linux/*.c"), | ||
path.join(common_dir, "*.c"), | ||
path.join(common_dir, "*.cpp"), | ||
path.join(internal_dir, "posixutils/*.c"), | ||
path.join(internal_dir, "elfutils/*.c"), | ||
path.join(internal_dir, "demangler/*.cpp") | ||
} | ||
elseif is_arch("i386") then | ||
libmem_src = { | ||
path.join(common_dir, "arch/x86.c"), | ||
path.join(libmem_dir, "src/linux/ptrace/x86/*.c"), | ||
path.join(libmem_dir, "src/linux/*.c"), | ||
path.join(common_dir, "*.c"), | ||
path.join(common_dir, "*.cpp"), | ||
path.join(internal_dir, "posixutils/*.c"), | ||
path.join(internal_dir, "elfutils/*.c"), | ||
path.join(internal_dir, "demangler/*.cpp") | ||
} | ||
end | ||
elseif is_plat("freebsd") then | ||
if is_arch("x86_64") then | ||
libmem_src = { | ||
path.join(common_dir, "arch/x86.c"), | ||
path.join(libmem_dir, "src/freebsd/ptrace/x64/*.c"), | ||
path.join(libmem_dir, "src/freebsd/*.c"), | ||
path.join(common_dir, "*.c"), | ||
path.join(common_dir, "*.cpp"), | ||
path.join(internal_dir, "posixutils/*.c"), | ||
path.join(internal_dir, "elfutils/*.c"), | ||
path.join(internal_dir, "demangler/*.cpp") | ||
} | ||
elseif is_arch("i386") then | ||
libmem_src = { | ||
path.join(common_dir, "arch/x86.c"), | ||
path.join(libmem_dir, "src/freebsd/ptrace/x86/*.c"), | ||
path.join(libmem_dir, "src/freebsd/*.c"), | ||
path.join(common_dir, "*.c"), | ||
path.join(common_dir, "*.cpp"), | ||
path.join(internal_dir, "posixutils/*.c"), | ||
path.join(internal_dir, "elfutils/*.c"), | ||
path.join(internal_dir, "demangler/*.cpp") | ||
} | ||
end | ||
end | ||
|
||
-- Add target for libmem | ||
target("libmem") | ||
if has_config("build_static") then | ||
set_kind("static") | ||
else | ||
set_kind("shared") | ||
end | ||
|
||
add_files(libmem_src) | ||
|
||
-- Correct the include directory to point to "include" | ||
add_includedirs(path.join(libmem_dir, "include"), { public = true }) | ||
add_includedirs(path.join(libmem_dir, "src")) | ||
add_includedirs(internal_dir) | ||
add_includedirs(common_dir) | ||
|
||
-- Link against external libraries | ||
add_links("capstone", "keystone", "llvm") | ||
|
||
-- Platform-specific dependencies | ||
if is_plat("windows") then | ||
add_syslinks("user32", "psapi", "ntdll", "shell32") | ||
elseif is_plat("linux") then | ||
add_syslinks("dl", "stdc++", "m") | ||
elseif is_plat("freebsd") then | ||
add_syslinks("dl", "kvm", "procstat", "elf", "stdc++", "m") | ||
end | ||
|
||
-- Define for export symbol | ||
add_defines("LM_EXPORT") | ||
|
||
-- Optionally build tests | ||
if has_config("build_tests") then | ||
target("libmem_tests") | ||
set_kind("binary") | ||
add_files(path.join(libmem_dir, "tests/*.cpp")) | ||
add_deps("libmem") | ||
end | ||
]]) | ||
|
||
import("package.tools.xmake").install(package, configs) | ||
end) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缺少 on_test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🏳️🏳️🏳️ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
复杂的配置,挪到 port/xmake.lua 独立文件维护,参考其他包
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏳️🏳️🏳️
I wish I could do that, but libmem s repository refers to non-existing repositories branches I believe. Legacy
It will take a lot of time to port complete meaningless dependencies onto xrepo in that case.
Maybe I have misunderstood your review, idea behind context is to make some file to store stuff that is being used by io.writefile???