Search code examples
luapremake

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


So, I've started this new project and was writing my premake script, but generating it fails and generates

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

Usually when it's just a typo, the error message includes a line number in the script. I looked at the

error in the premake source files but couldn't figure it out.

Here is the script:

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"

What is actually wrong with this script and what causes this error to be generated?


Solution

  • Both targetdir and objdir expect single argument that indicates path. Premake usually handles paths as strings so that end-user can use syntactic sugar and omit parentheses. They usually present their examples in this simplified syntax which sometimes leads to misunderstandings.

    Switch:

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

    to:

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