xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

如何方便去掉一些内置的编译参数 #5274

Closed TOMO-CAT closed 4 months ago

TOMO-CAT commented 4 months ago

你在什么场景下需要该功能?

举个例子,在 coverage 或者 debug 模式下,xmake 会自带很多编译参数,比如 nvcc 中会带上{"-G", "-g", "-lineinfo"} , 但是出于某些特殊需求,比如我们去掉里面的 -G 参数,在根目录的xmake.lua 全局作用域中写:

if is_mode("coverage") then
  remove_cuflags("-G")
end

这样是最便捷的,但是实际上无法生效。

即使我想在 after_load 中删掉 cuflags 也无法生效,因为打印 target:get("cuflags") 时 -G 并不在其中。

描述可能的解决方案

提供一种解决方法去掉 xmake 内部自带的编译参数。

描述你认为的候选方案

No response

其他信息

No response

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: How to easily remove some built-in compilation parameters

In what scenario do you need this feature?

For example, in coverage or debug mode, xmake will bring many compilation parameters. For example, nvcc will bring {"-G", "-g", "-lineinfo"}, but for some special reasons Requirements, for example, we remove the -G parameter and write in the global scope of xmake.lua in the root directory:

if is_mode("coverage") then
  remove_cuflags("-G")
end

This is the most convenient, but it doesn't actually work.

Even if I want to remove cuflags in after_load it doesn't work because when target:get("cuflags") is printed, -G is not among them.

Describe possible solutions

Provide a solution to remove the built-in compilation parameters of xmake.

Describe your alternatives

No response

other information

No response

xq114 commented 4 months ago

不写add_rules("mode.debug"),自己判断is_mode("debug")加相关flag试试?

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Instead of writing add_rules("mode.debug"), try judging is_mode("debug") and adding relevant flags yourself?

TOMO-CAT commented 4 months ago

不写add_rules("mode.debug"),自己判断is_mode("debug")加相关flag试试?

那相当于整个 mode.coverage 都得自己重新写,可以试试,但感觉比较麻烦,为了去掉一个参数将内置的一些 rule 整个重写了,还有一些 rule 更复杂比如 protobuf.cpp,不太好重写

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Instead of writing add_rules("mode.debug"), try judging is_mode("debug") and adding relevant flags yourself?

That's equivalent to having to rewrite the entire mode.coverage yourself. You can try it, but it seems troublesome. In order to remove a parameter, some built-in rules have been completely rewritten. There are also some rules that are more complicated, such as protobuf.cpp, which is not good. rewrite

waruqi commented 4 months ago

set_symbols("none") 或者自定义 debug mode

TOMO-CAT commented 4 months ago

"

好的

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


set_symbols("none") or customize debug mode

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


"

OK