xmake-io / xmake-vscode

🍩 A XMake integration in Visual Studio Code
https://xmake.io
Apache License 2.0
223 stars 55 forks source link

Target里on_load打印消息,会导致run或debug无法运行 #261

Open Wzshun opened 3 months ago

Wzshun commented 3 months ago

Xmake 版本

2.8.8

操作系统版本和架构

windows11

描述问题

add_rules("mode.debug", "mode.release")

target("basenameIssue")
    set_kind("binary")
    add_files("src/*.cpp")
    on_load(function (target) 
        local venderInfo = {appName = "hello"}
        print("venderInfo:", venderInfo)

        --target:set("basename", venderInfo.appName)
    end)

编译通过,但是点击vscode状态栏的run或者debug,无法运行。

此外终端里,调用xmake run,运行正常。

期待的结果

vscode状态栏run或debug,能正常工作,在on load打印消息时。

工程配置

附加信息和错误日志

正在执行任务: xmake run 'venderInfo: { 
  appName = "hello" 
}

basenameIssue' 

venderInfo: { 
  appName = "hello" 
}

error: venderInfo: { 
 appName = hello 
}

basenameIssue is not a valid target name for this project

 *  终端进程“C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command xmake run 'venderInfo: { 
  appName = "hello" 
}

basenameIssue'”已终止,退出代码: 1。 
 *  终端将被任务重用,按任意键关闭。 
waruqi commented 3 months ago

不要加 print ,会干扰插件对 target file 的获取。。

如果你想过滤这部分 print 的干扰,就自己提 pr 过来改进下,我最近也没空细改这块。

https://github.com/xmake-io/xmake-vscode/blob/master/assets/targetpath.lua https://github.com/xmake-io/xmake-vscode/blob/165343dfb209198f9d2c899a5ab288679302d49b/src/xmake.ts#L1012