what is PREMAKE error: Error: [string "src/base/api.lua"]:592: bad argument #2 to 'deferredjoin' (string expected, got table)?

what is PREMAKE error: Error: [string "src/base/api.lua"]:592: bad argument #2 to 'deferredjoin' (string expected, got table)?

所以,我开始了这个新项目并正在编写我的预制脚本,但生成它失败并生成了

此错误:[字符串“src/base/api.lua”]:592:'deferredjoin' 的错误参数 #2(应为字符串, 得到了 table)

通常当它只是一个拼写错误时,错误消息会在脚本中包含一个行号。我看了

premake 源文件中有错误,但无法弄清楚。

这是脚本:

workspace "DX12"
    architecture "x86_64"
    startproject "Demo"

    configurations
    {
        "Debug",
        "Release"
    }

    flags
    {
        "MultiProcessorCompile"
    }

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

project "Demo"
    location "Demo"
    kind "WindowedApp"
    language "C++"
    cppdialect "C++17"
    staticruntime "on"

    targetdir {"bin/" .. outputdir .. "/%{prj.name}"}
    objdir    {"bin-int/" .. outputdir .. "/%{prj.name}"}

    files
    {
        "%{prj.name}/src/**.h",
        "%{prj.name}/src/**.cpp"
    }

    includedirs
    {
        "%{prj.name}/src"
    }

    

    links
    {
        "d3d12.lib",
        "dxgi.lib",
        "d3dcompiler.lib"
    }

    filter "system:windows"
        systemversion "latest"

    filter "configurations:Debug"
        defines "DEBUG"
        runtime "Debug"
        symbols "on"

    filter "configurations:Release"
        defines "RELEASE"
        runtime "Release"
        optimize "on"

这个脚本到底有什么问题,是什么导致了这个错误的产生?

两者 targetdir and objdir 都需要指示路径的单个参数。 Premake 通常将路径作为字符串处理,以便最终用户可以使用语法糖并省略括号。他们通常以这种有时会导致误解的简化语法来展示他们的示例。

切换:

    targetdir {"bin/" .. outputdir .. "/%{prj.name}"}
    objdir    {"bin-int/" .. outputdir .. "/%{prj.name}"}

至:

    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir    ("bin-int/" .. outputdir .. "/%{prj.name}")