xmake-io / xmake

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

set_group bug in vsxmake #3303

Closed Extra-Creativity closed 1 year ago

Extra-Creativity commented 1 year ago

Xmake Version

2.7.5

Operating System Version and Architecture

Win10 22H2, x86_64

Describe Bug

The minimal project that causes this bug has been uploaded to my temporary repository.

In this project, set_group here will:

In the second problem, running with -D will prompt error information as :

checking for Microsoft Visual Studio (x64) version ... 2019
error: @programdir\core\main.lua:280: @programdir\plugins\project\vsxmake\getinfo.lua:294: attempt to index a nil value 
(field '?')
stack traceback:
    [@programdir\plugins\project\vsxmake\getinfo.lua:294]: in function '_make_vsinfo_groups'
    [@programdir\plugins\project\vsxmake\getinfo.lua:442]:  
    [@programdir\plugins\project\vsxmake\vsxmake.lua:224]: in function '?'
    [@programdir\plugins\project\main.lua:79]: in function '_make'
    [@programdir\plugins\project\main.lua:92]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]:
    [@programdir\core\base\task.lua:501]: in function 'run' 
    [@programdir\core\main.lua:278]: in function 'cotask'   
    [@programdir\core\base\scheduler.lua:404]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:898: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:280: in upvalue 'cotask'  
        @programdir\core\base\scheduler.lua:404: in function <@programdir\core\base\scheduler.lua:397>

Expected Behavior

Project Configuration

No response

Additional Information and Error Logs

No response

waruqi commented 1 year ago

These are two questions, please refer to the vscode question, separately to https://github.com/xmake-io/xmake-vscode/issues

cause incorrect groups in vscode.

waruqi commented 1 year ago
local relativeDir = string.sub(scriptDir, #projectDir + 2)

try

local relativeDir = path.relative(scriptDir, projectDir)

https://github.com/Extra-Creativity/TestCode/blob/0fdf0e3374fa044be1fe32dae5e4e68585d8a77e/xmake.lua#L12

Extra-Creativity commented 1 year ago

Two questions:

  1. Why will this work but the other will not?
  2. It seems that the groups are still incorrect, like this: image
waruqi commented 1 year ago

Why will this work but the other will not?

string.sub(scriptDir, #projectDir + 2)

If projectDir is the same as scriptDir (GlobalTest target), it will return the empty string.

I've improved it on the dev branch, but it's still an invalid group name and xmake/dev will still ignore this group, but at least it won't throw an exception error

path.relative(scriptDir, projectDir)

it will return "."

waruqi commented 1 year ago

It seems that the groups are still incorrect, like this:

It works for me.

image

Extra-Creativity commented 1 year ago

Okay, works for me now when I omit the root directory, apologize for my carelessness.