-
-
Notifications
You must be signed in to change notification settings - Fork 491
bnm-android: add package #8374
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
Merged
Merged
bnm-android: add package #8374
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e596737
Create xmake.lua for BNM-Android package
std-microblock a6ae207
Change on_install function to specify 'android'
std-microblock 02c607e
Change config check from BNM_LINK_LOG to link_log
std-microblock c40734e
Implement unity_version configuration and parsing
std-microblock a43b593
Update xmake.lua
luadebug d778db5
Create xmake.lua
luadebug b632ec8
Update xmake.lua
luadebug 18d1639
Update xmake.lua
luadebug 4db0c64
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,142 @@ | ||
| package("bnm-android") | ||
| set_homepage("https://github.com/ByNameModding/BNM-Android") | ||
| set_description("Modding il2cpp games by classes, methods, fields names on Android.") | ||
|
|
||
| add_urls("https://github.com/ByNameModding/BNM-Android.git") | ||
| add_versions("2025.10.14", "502928771983d29e37f28c78f28823dfb775a3aa") | ||
|
|
||
| add_configs("link_log", {description = "Link against liblog.so", default = false, type = "boolean"}) | ||
| add_configs("hook_lib", { | ||
| description = "Choose the hooking library used (dobby or shadowhook).", | ||
| default = "shadowhook", | ||
| type = "string", | ||
| values = {"shadowhook", "dobby"}, | ||
| }) | ||
|
|
||
| on_load(function (package) | ||
| if package:config("hook_lib") == "dobby" then | ||
| package:add("deps", "dobby") | ||
| elseif package:config("hook_lib") == "shadowhook" then | ||
| package:add("deps", "shadowhook") | ||
| end | ||
| end) | ||
|
|
||
| on_install(function (package) | ||
| local dummy_impl = [[// Dummy | ||
| #include <cassert> | ||
|
|
||
| static_assert(false, "No hooking software!"); | ||
|
|
||
| template<typename PTR_T, typename NEW_T, typename T_OLD> | ||
| inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &oldBytes) { | ||
| if ((void *) ptr != nullptr) ((void)0); | ||
| return nullptr; | ||
| } | ||
|
|
||
| template<typename PTR_T, typename NEW_T, typename T_OLD> | ||
| inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &&oldBytes) { | ||
| if ((void *) ptr != nullptr) ((void)0); | ||
| return nullptr; | ||
| } | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| template<typename PTR_T> | ||
| inline void Unhook(PTR_T ptr) { | ||
| if ((void *) ptr != nullptr) ((void)0); | ||
| } | ||
| ]] | ||
|
|
||
| if package:config("hook_lib") == "dobby" then | ||
| io.replace("include/BNM/UserSettings/GlobalSettings.hpp", dummy_impl, [[ | ||
| #include <dobby.h> | ||
|
|
||
| template<typename PTR_T, typename NEW_T, typename T_OLD> | ||
| inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &oldBytes) { | ||
| if ((void *) ptr != nullptr) DobbyHook((void *)ptr, (void *) newMethod, (void **) &oldBytes); | ||
| return (void *) ptr; | ||
| } | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| template<typename PTR_T, typename NEW_T, typename T_OLD> | ||
| inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &&oldBytes) { | ||
| if ((void *) ptr != nullptr) DobbyHook((void *)ptr, (void *) newMethod, (void **) &oldBytes); | ||
| return (void *) ptr; | ||
| } | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| template<typename PTR_T> | ||
| inline void Unhook(PTR_T ptr) { | ||
| if ((void *) ptr != nullptr) DobbyDestroy((void *)ptr); | ||
| } | ||
| ]], {plain = true}) | ||
| elseif package:config("hook_lib") == "shadowhook" then | ||
| io.replace("include/BNM/UserSettings/GlobalSettings.hpp", dummy_impl, [[ | ||
| #include "shadowhook.h" | ||
| template<typename PTR_T, typename NEW_T, typename T_OLD> | ||
| inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &oldBytes) { | ||
| if ((void *) ptr != nullptr) return shadowhook_hook_func_addr((void *)ptr, (void *) newMethod, (void **) &oldBytes); | ||
| return nullptr; | ||
| } | ||
|
|
||
| template<typename PTR_T, typename NEW_T, typename T_OLD> | ||
| inline void *BasicHook(PTR_T ptr, NEW_T newMethod, T_OLD &&oldBytes) { | ||
| if ((void *) ptr != nullptr) return shadowhook_hook_func_addr((void *)ptr, (void *) newMethod, (void **) &oldBytes); | ||
| return nullptr; | ||
| } | ||
luadebug marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| template<typename PTR_T> | ||
| inline void Unhook(PTR_T ptr) { | ||
| if ((void *) ptr != nullptr) shadowhook_unhook((void *)ptr); | ||
| } | ||
| ]], {plain = true}) | ||
| else | ||
| raise("Unknown hooking library: " .. package:config("hook_lib")) | ||
|
Contributor
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. @gemini-code-assist Is this redundant block of code, as it is already limited to two options there would not be third options selected anyway nothing to worry about? |
||
| end | ||
|
|
||
| io.writefile("xmake.lua", [[ | ||
| set_project("BNM") | ||
| set_version("1.0.0") | ||
|
|
||
| set_languages("c++20") | ||
|
|
||
| add_rules("mode.debug", "mode.release") | ||
|
|
||
| if is_config("hook_lib", "dobby") then | ||
| add_requires("dobby") | ||
| elseif is_config("hook_lib", "shadowhook") then | ||
| add_requires("shadowhook") | ||
| end | ||
|
|
||
| option("link_log") | ||
| option("hook_lib") | ||
|
|
||
| target("BNM") | ||
| set_kind("static") | ||
| if is_config("hook_lib", "dobby") then | ||
| add_packages("dobby", {public = true}) | ||
| elseif is_config("hook_lib", "shadowhook") then | ||
| add_packages("shadowhook", {public = true}) | ||
| end | ||
|
|
||
| add_files("src/*.cpp") | ||
|
|
||
| add_headerfiles("include/(**.h)", "include/(**.hpp)") | ||
| add_headerfiles("external/include/(**.h)", "external/include/(**.hpp)") | ||
| add_includedirs("include", "external/include", "external", "external/utf8", "src/private") | ||
|
|
||
| if has_config("BNM_LINK_LOG") then | ||
| add_syslinks("log") | ||
| end | ||
luadebug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| set_configvar("BNM_INCLUDE_DIRECTORIES", "include;external/include") | ||
| ]]) | ||
| import("package.tools.xmake").install(package, { | ||
| link_log = package:config("link_log"), | ||
| hook_lib = package:config("hook_lib"), | ||
| }) | ||
| end) | ||
|
|
||
| on_test(function (package) | ||
| package:check_cxxsnippets({test = [[ | ||
| void test() { | ||
| BNM::Loading::TryLoadByUsersFinder(); | ||
| } | ||
| ]]}, {configs = {languages = "c++20"}, includes = {"BNM/Loading.hpp"}}) | ||
| end) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.