Skip to content

Conversation

std-microblock
Copy link
Contributor

Add xmake.lua for BNM-Android package with configuration options.

  • Before adding new features and new modules, please go to issues to submit the relevant feature description first.
  • Write good commit messages and use the same coding conventions as the rest of the project.
  • Please commit code to dev branch and we will merge into master branch in feature
  • Ensure your edited codes with four spaces instead of TAB.

  • 增加新特性和新模块之前,请先到issues提交相关特性说明,经过讨论评估确认后,再进行相应的代码提交,避免做无用工作。
  • 编写友好可读的提交信息,并使用与工程代码相同的代码规范,代码请用4个空格字符代替tab缩进。
  • 请提交代码到dev分支,如果通过,我们会在特定时间合并到master分支上。
  • 为了规范化提交日志的格式,commit消息,不要用中文,请用英文描述。

Add xmake.lua for BNM-Android package with configuration options.
Copy link
Contributor

Summary of Changes

Hello @std-microblock, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces comprehensive xmake support for the bnm-android package, streamlining its integration and build process within xmake-based projects. It provides flexible configuration options, allowing developers to customize key aspects such as the hooking library and logging integration, ensuring adaptability to various project requirements. The changes facilitate easier management of dependencies and build configurations for Android modding development.

Highlights

  • New xmake package definition: A new xmake.lua file has been added to define the bnm-android package, making it discoverable and buildable within xmake projects.
  • Configurable hooking library: The package introduces a hook_lib configuration option, allowing users to choose between dobby and shadowhook as the underlying hooking library for Android modding.
  • Conditional logging library linking: An optional link_log configuration is provided, enabling conditional linking against the Android liblog.so library based on user preference.
  • Dynamic header modification: During the installation process, the package dynamically modifies include/BNM/UserSettings/GlobalSettings.hpp to integrate the function calls specific to the chosen hooking library (Dobby or Shadowhook).
  • Project-specific xmake.lua generation: The on_install function generates a dedicated xmake.lua for the BNM project itself, configuring its build settings, dependencies, and include paths based on the selected package options.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new xmake package for BNM-Android, which is a great addition for managing this dependency. The package is well-structured, providing options for selecting different hooking libraries. My review focuses on improving the correctness and robustness of the implementation. I've found a bug in the generated xmake.lua file related to a configuration check, and also identified some incorrect C++ template overloads in the code that gets injected during the installation process. The suggested changes will fix the bug and make the C++ API less confusing. Overall, this is a good contribution.

@luadebug
Copy link
Contributor

luadebug commented Oct 14, 2025

Nice package, could you please create file xmake.lua inside of port folder instead of io.writefile("xmake.lua",[[

Maybe #include <cmath> is missing in source headerfile or cpp file.

@star-hengxing star-hengxing changed the title Create xmake.lua for BNM-Android package bnm-android: add package Oct 14, 2025
Add unity_version configuration and parsing logic
@std-microblock
Copy link
Contributor Author

Maybe #include <cmath> is missing in source headerfile or cpp file.

Yes, I've created a pr in the origin repo for that, so I think we can ignore it now: ByNameModding/BNM-Android#150

@std-microblock
Copy link
Contributor Author

Nice package, could you please create file xmake.lua inside of port folder instead of io.writefile("xmake.lua",[[

Can you do the change? idk how to read the file from the port file

@luadebug
Copy link
Contributor

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new xmake package for bnm-android. The changes look good overall, introducing the necessary package definition and build scripts. I've identified a couple of potential bugs related to configuration checking and error handling in the hooking logic. I've also included some suggestions to improve code clarity and maintainability in the xmake scripts. Please see my detailed comments below.

Comment on lines +47 to +49
if has_config("link_log") then
add_syslinks("log")
end
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The use of has_config("link_log") is incorrect for checking a boolean option. has_config checks if the option was set by the user, not its value. This means that if a user explicitly sets link_log=false, this condition would be true, which is not the intended behavior.

You should use get_config("link_log") to correctly check the boolean value of the option.

    if get_config("link_log") then
        add_syslinks("log")
    end

Comment on lines +29 to +118
local parse_unity_version = function (version)
local major, minor, patch = version:match("^(%d+)%.(%d+)%.(%d+)")
if not major then
major, minor = version:match("^(%d+)%.(%d+)%.%w+")
if not major then
return 222, 32
end
patch = nil
end

major = tonumber(major)
minor = tonumber(minor)
patch = patch and tonumber(patch) or nil

local unity_ver
local unity_patch_ver

if major == 5 then
if minor == 6 then
unity_ver = 56
end
elseif major == 2017 then
if minor == 1 then
unity_ver = 171
elseif minor >= 2 and minor <= 4 then
unity_ver = 172
end
elseif major == 2018 then
if minor == 1 then
unity_ver = 181
elseif minor == 2 then
unity_ver = 182
elseif minor >= 3 then
unity_ver = 183
end
elseif major == 2019 then
if minor <= 2 then
unity_ver = 191
elseif minor == 3 then
unity_ver = 193
elseif minor == 4 then
unity_ver = 194
end
elseif major == 2020 then
if minor == 1 then
unity_ver = 201
elseif minor == 2 then
unity_ver = 202
elseif minor == 3 then
if patch and patch >= 20 then
unity_ver = 203
else
unity_ver = 202
end
end
elseif major == 2021 then
if minor == 1 then
unity_ver = 211
-- Need to set UNITY_PATCH_VER to 24 if x (2021.1.x) >= 24
if patch and patch >= 24 then
unity_patch_ver = patch
end
elseif minor == 2 then
unity_ver = 212
elseif minor == 3 then
unity_ver = 213
end
elseif major == 2022 then
if minor == 1 then
unity_ver = 221
elseif minor >= 2 then
unity_ver = 222
unity_patch_ver = patch or 32
end
elseif major == 2023 then
if minor == 1 then
unity_ver = 231
elseif minor >= 2 then
unity_ver = 232
end
end

-- Fallback to default if no match found
if not unity_ver then
unity_ver = 222
unity_patch_ver = 32
end

return unity_ver, unity_patch_ver
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This function is quite long and contains a large chain of if/elseif statements, which can be difficult to read and maintain. Consider refactoring this logic to be more data-driven. You could use a table of rules to define the version mappings, or break the logic into smaller helper functions. This would make the function shorter, and adding support for new Unity versions in the future would be simpler.

}
]], {plain = true})
else
raise("Unknown hooking library: " .. package:config("hook_lib"))
Copy link
Contributor

@luadebug luadebug Oct 14, 2025

Choose a reason for hiding this comment

The 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?

@waruqi waruqi merged commit cc6bf55 into xmake-io:dev Oct 16, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants