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

vsxmake 生成工程出现 table index is nil 错误 #2334

Closed
VirFunc opened this issue May 5, 2022 · 2 comments
Closed

vsxmake 生成工程出现 table index is nil 错误 #2334

VirFunc opened this issue May 5, 2022 · 2 comments

Comments

@VirFunc
Copy link

VirFunc commented May 5, 2022

Xmake 版本

2.6.5

操作系统版本和架构

Windows 10 version 21H1

描述问题

在有多层目录的项目中使用 vsxmake 生成 vs 2019 的工程文件会出现 error: table index is nil 错误

期待的结果

能够正常生成 Visual Studio 工程文件

工程配置

目录结构

vsxmake_test
│
├─ src
│  └─ core
│     ├─ lib.cpp
│     └─ xmake.lua
└─ xmake.lua

根目录中的 xmake.lua

set_xmakever("2.6.5")
    set_project("vsxmake_test")
    includes("src/core")

src/core 中的 xmake.lua

target("core")
    set_kind("static")
    add_files("lib.cpp")

src/core/lib.cpp 中包含一个简单的测试函数

#include <stdio.h>

int core_print() {
    printf("test test");
    return 0;
}

附加信息和错误日志

生成 vs 2019 工程时的输出

PS D:\Projects\temp\vsxmake_test> xmake project -vD -k vsxmake2019  
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2019
checkinfo: cannot runv(dmd.exe --version), No such file or directory 
checking for dmd ... no
checkinfo: cannot runv(ldc2.exe --version), No such file or directory
checking for ldc2 ... no
checkinfo: cannot runv(gdc.exe --version), No such file or directory 
checking for gdc ... no
checkinfo: cannot runv(zig.exe version), No such file or directory   
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
configure
{
    host = windows   
    mode = release   
    ndk_stdcxx = true
    kind = static
    vs = 2019
    buildir = build
    plat = windows
    ccache = true
    arch = x64
}
using project kind vs2019
checking for release.x86 ...
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\cl.exe
checking for Microsoft Visual Studio (x86) version ... 2019
checkinfo: cannot runv(dmd.exe --version), No such file or directory
checking for dmd ... no
checkinfo: cannot runv(ldc2.exe --version), No such file or directory
checking for ldc2 ... no
checkinfo: cannot runv(gdc.exe --version), No such file or directory
checking for gdc ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe
checking for the static library archiver (ar) ... link.exe
checking for release.x64 ...
checking for cl.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2019
checkinfo: cannot runv(dmd.exe --version), No such file or directory
checking for dmd ... no
checkinfo: cannot runv(ldc2.exe --version), No such file or directory
checking for ldc2 ... no
checkinfo: cannot runv(gdc.exe --version), No such file or directory
checking for gdc ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig.exe version), No such file or directory
checking for zig ... no
checking for link.exe ... C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe
checking for the static library archiver (ar) ... link.exe
error: @programdir\core\main.lua:280: @programdir\plugins\project\vsxmake\getinfo.lua:544: table index is nil
stack traceback:
    [@programdir\plugins\project\vsxmake\getinfo.lua:544]:
    [@programdir\plugins\project\vsxmake\vsxmake.lua:223]: in function '?'
    [@programdir\plugins\project\main.lua:79]: in function '_make'
    [@programdir\plugins\project\main.lua:89]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]:
    [@programdir\core\base\task.lua:519]: in function 'run'
    [@programdir\core\main.lua:278]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:371]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:854: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:280: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:371: in function <@programdir\core\base\scheduler.lua:368>
@VirFunc VirFunc added the bug label May 5, 2022
@VirFunc
Copy link
Author

VirFunc commented May 5, 2022

如果对工程稍作修改,改成下面这样

src/core/xmake.lua 移动到 src/xmake.lua

vsxmake_test
│
├─ src
│  ├─ core
│  │  └─ lib.cpp
│  └─ xmake.lua
└─ xmake.lua

根目录中的 xmake.lua

set_xmakever("2.6.5")
    set_project("vsxmake_test")
    includes("src")

src/core 中的 xmake.lua

target("core")
    set_kind("static")
    add_files("core/lib.cpp")

这样可以正常生成 vs 的工程文件

@waruqi
Copy link
Member

waruqi commented May 5, 2022

见:#2328

@waruqi waruqi closed this as completed May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants