-
-
Notifications
You must be signed in to change notification settings - Fork 785
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
Add armclang version judgement and automatically select assembler based on the result #5247
Conversation
CofeCofe
commented
Jun 23, 2024
- 增加对armclang版本的检测
- 根据不同armclang版本自动选择不同版本的汇编器(armasm/armclang),并选用不同的asflags(--cpu/-mcpu) armclang汇编警告 #5071
- 修改了armclang自动添加的cxflags为"--target=",使其自动生成的compile_commands.json在clangd中不会报错 xmake自动生成的 compile_commands.json有问题 #5244
…election of different assembler
@@ -73,6 +73,8 @@ function _find_mdk(sdkdir) | |||
-- armclang sdk directory | |||
local sdkdir_armclang = path.join(sdkdir, "armclang") | |||
if os.isdir(sdkdir_armclang) and os.isfile(path.join(sdkdir_armclang, "bin", "armclang.exe")) then | |||
local sdk_armclang_ver = os.iorun(path.join(sdkdir_armclang, "bin", "armclang.exe").." --version_number") | |||
result.sdk_armclang_vernum = tonumber(sdk_armclang_ver) |
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.
不应该改这里。。https://github.com/xmake-io/xmake/blob/master/xmake/modules/detect/tools/find_armclang.lua 改进这里获取版本,然后直接调用 local armclang = find_tool("armclang", {version = true})
去获取版本 armclang.version
,这里面默认走的 --version
应该也能获取到版本号,然后走 semver 去进行语义版本判断
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.
好的,感谢大佬说明。前面这个通过更改find_armclang.lua这个,我这边大概知道要怎么改(类似https://github.com/xmake-io/xmake/blob/master/xmake/modules/detect/tools/find_gdc.lua 正则改一下),后面说的走semver进行语义判断有没有具体的例子可以参考下
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.
获取到的版本字符串,如果是标准的语义化版本。x.y.z
走 sermver 模块去比较判断版本就行了
-- semver.compare('1.2.3', '1.3.0') > 0? |
@@ -39,7 +39,9 @@ import("detect.sdks.find_mdk") | |||
function main(opt) | |||
|
|||
-- init options | |||
opt = opt or {} | |||
opt = opt or {} | |||
opt.command = opt.command or "--version" |
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.
默认就是 --version
不用加
opt = opt or {} | ||
opt = opt or {} | ||
opt.command = opt.command or "--version" | ||
opt.parse = opt.parse or function (output) return output:match("Arm Compiler for Embedded (%d+%.?%d+%.?%d+)%s") end |
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.
这种,默认应该也是支持的。。你可以先什么都不改 ,试试。。我觉得原本的实现 就已经能提取到 version
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.
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.
默认方式获取到的是5.38,不是6.19
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.
哦,那就加上 parse 好了
xmake/toolchains/armclang/xmake.lua
Outdated
toolchain:add("asflags", "--cpu=" .. arch_cpu) | ||
toolchain:add("ldflags", "--cpu " .. arch_cpu_ld) | ||
|
||
import("lib.detect.find_tool") |
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.
import 放最开头
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.
不要在 on_load 里面去找 armclang ,应该放到 on_check 里面找,然后通过 toolchain:config_set/toolchain_save 保存到一个 key/value 中,在 on_load 里面通过 toolchain:config() 取出来直接用
xmake/toolchains/armclang/xmake.lua
Outdated
|
||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
local armclang = find_tool("armclang", {version = true}) |
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.
传递 toolchain:bindir()
到 find_tool
local armclang = find_tool("armclang", {version = true, force = true, paths = toolchain:bindir()})
xmake/toolchains/armclang/xmake.lua
Outdated
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
local armclang = find_tool("armclang", {version = true}) | ||
if semver.compare(armclang.version, "6.13")>0 then |
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.
armclang 要判空,不是一定就能找到的
我改了下,再试试 |
I changed it and try again |
没问题了,感谢大佬 |
No problem, thank you sir |