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

set_filename导致 1. mingw 平台 xmake run 找不到构建好的目标 2. windows 平台构建产物无 .exe 后缀 #5120

Closed
Doekin opened this issue May 20, 2024 · 5 comments
Labels

Comments

@Doekin
Copy link

Doekin commented May 20, 2024

Xmake 版本

xmake v2.9.1+HEAD.0c79f6162

操作系统版本和架构

Windows 10 22H2

描述问题

如果在 target 中调用 set_filename(),那么

  1. 当目标平台为windows时,产物无 .exe后缀
  2. 当目标平台为mingw时,运行 xmake run 报错 error: please run `$xmake build [target]` to build the following targets first

期待的结果

目标产物后缀名正常,且能通过 xmake run 运行

工程配置

xmake create -l c++ -t console helloworld 生成示例工程,添加set_filename("a")

附加信息和错误日志

目标平台为mingw时,xmake build 成功构建后,执行 xmake run -vD 报错如下

error: @programdir\core\main.lua:329: @programdir\actions\run\main.lua:195: please run `$xmake build [target]` to build the following targets first:
  -> xmake-exp
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:973]:
    [@programdir\actions\run\main.lua:195]: in function '_check_targets'
    [@programdir\actions\run\main.lua:229]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:275]:
    [@programdir\core\base\task.lua:491]: in function 'run'
    [@programdir\core\main.lua:327]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:406]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:973: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:329: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>
@Doekin Doekin added the bug label May 20, 2024
@Issues-translate-bot
Copy link

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


Title: set_filename results in 1. The mingw platform xmake run cannot find the built target 2. The windows platform build product has no .exe suffix

@waruqi
Copy link
Member

waruqi commented May 20, 2024

当目标平台为windows时,产物无 .exe后缀

set_filename 是完整改写文件名,包括后缀,你 set_filename("a") 都把 .exe 去了,当然就没有了。。不想去后缀,得用 set_basename

@Issues-translate-bot
Copy link

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


When the target platform is windows, the product does not have an .exe suffix

set_filename completely rewrites the file name, including the suffix. If you use set_filename("a") to remove the .exe, of course it will be gone. . If you don’t want to remove the suffix, you have to use set_basename

@Doekin
Copy link
Author

Doekin commented May 20, 2024

是我误解相关 api 的使用了,经测试,set_filename("a.exe") 和 set_basename("a") 都能实现预期效果

而 set_filename("a") 在 mingw 平台上的构建产物为 a.exe ,可能是 llvm-mingw 工具链自身导致的。运行 xmake -vD build ,相关命令为 D:\Applications\Scoop\apps\mingw-mstorsjo-llvm-ucrt\current\bin\x86_64-w64-mingw32-g++ -o build\mingw\x86_64\debug\a build\.objs\xmake-exp\mingw\x86_64\debug\src\main.cpp.obj -m64,然而输出产物仍为 a.exe

@Doekin Doekin closed this as completed May 20, 2024
@Issues-translate-bot
Copy link

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


I misunderstood the use of related APIs. After testing, set_filename("a.exe") and set_basename("a") can achieve the expected results.

The build product of set_filename("a") on the mingw platform is a.exe, which may be caused by the llvm-mingw tool chain itself. Run xmake -vD build, the relevant command is D:\Applications\Scoop\apps\mingw-mstorsjo-llvm-ucrt\current\bin\x86_64-w64-mingw32-g++ -o build\mingw\x86_64\debug\a build \.objs\xmake-exp\mingw\x86_64\debug\src\main.cpp.obj -m64, but the output product is still a.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants