Skip to content
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

Merged
merged 6 commits into from
Jun 24, 2024

Conversation

CofeCofe
Copy link
Contributor

@@ -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)
Copy link
Member

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 去进行语义版本判断

Copy link
Contributor Author

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进行语义判断有没有具体的例子可以参考下

Copy link
Member

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"
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

这种,默认应该也是支持的。。你可以先什么都不改 ,试试。。我觉得原本的实现 就已经能提取到 version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

用原本的方式获取到的是MDK的版本号,因为 armclang --version 的输出是这样的
屏幕截图 2024-06-24 170914

Copy link
Contributor Author

Choose a reason for hiding this comment

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

默认方式获取到的是5.38,不是6.19

Copy link
Member

Choose a reason for hiding this comment

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

哦,那就加上 parse 好了

toolchain:add("asflags", "--cpu=" .. arch_cpu)
toolchain:add("ldflags", "--cpu " .. arch_cpu_ld)

import("lib.detect.find_tool")
Copy link
Member

Choose a reason for hiding this comment

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

import 放最开头

Copy link
Member

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() 取出来直接用


import("lib.detect.find_tool")
import("core.base.semver")
local armclang = find_tool("armclang", {version = true})
Copy link
Member

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()})

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
Copy link
Member

Choose a reason for hiding this comment

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

armclang 要判空,不是一定就能找到的

@waruqi
Copy link
Member

waruqi commented Jun 24, 2024

我改了下,再试试

@Issues-translate-bot
Copy link

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


I changed it and try again

@CofeCofe
Copy link
Contributor Author

我改了下,再试试

没问题了,感谢大佬

@Issues-translate-bot
Copy link

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


I changed it and try again

No problem, thank you sir

@waruqi waruqi merged commit de48240 into xmake-io:dev Jun 24, 2024
19 checks passed
@waruqi waruqi added this to the v2.9.4 milestone Jun 24, 2024
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