Premake issues with lua

61 views Asked by At

I using premake as a build system and I have my Lua script but for some reason when I open my vs2022 and run it some things don't get made right. some of the projects and items have a red circle with a minus sign. and my sandbox project isn't in my directories at all.

Im using premake5-beta beta2

heres my lua script.

workspace "Almond"
    architecture "x64"

    configurations
    {
        "Debug",
        "Release",
        "Dist"
    }

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

project "Almond"
    location "Almond"
    kind "SharedLib"
    language "C++"

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

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

    filter "system:windows"
        cppdialect "C++17"
        staticruntime "On"
        systemversion "latest"
        
        defines
        {
            "AM_PLATFORM_WINDOWS",
            "AM_BUILD_DLL"
        }

        postbuildcommands
        {
            ("{COPY} %{cfg.buildtarget.relpath} ../bin/" .. outputdir .. "/Sandbox")
        }
    
    filter "configurations:Debug"
        defines "AM_DEBUG"
        symbols "On"

    filter "configurations:Release"
        defines "AM_RELEASE"
        optimize "On"

    filter "configurations:Dist"
        defines "AM_DIST"
        optimize "On"

project "Sanbox"
        location "Sandbox"
        kind "ConsoleApp"
        language "C++"

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

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

        includedirs
        {
            "Almond/src"
        }

        links
        {
            "Almond"
        }

        filter "system:windows"
            cppdialect "C++17"
            staticruntime "On"
            systemversion "latest"
        
            defines
            {
            "AM_PLATFORM_WINDOWS"
            }

    filter "configurations:Debug"
        defines "AM_DEBUG"
        symbols "On"

    filter "configurations:Release"
        defines "AM_RELEASE"
        optimize "On"

    filter "configurations:Dist"
        defines "AM_DIST"
        optimize "On"

Ive never used premake before but ive heard its simpler than cmake for beginner. "-thecherno"

1

There are 1 answers

9
Jarod42 On

You have 3 issues:

  • typo in Sandbox project name (missing 'd')
  • 2 issues with postbuildcommands:
  • bin SandBox directory might not already exist, so create missing directory.
  • paths in buildcommand are not really directly relative to lua script :-/

Following postbuildcommands should fix the issue:

postbuildcommands
{
    "{MKDIR} %[bin/" .. outputdir .. "/Sandbox]",
    "{COPYFILE} %[%{!cfg.buildtarget.abspath}] %[bin/" .. outputdir .. "/Sandbox]"
}
  • %[..] is to make path relative to project correctly (take absolute path)
  • %{!..} is to force path to be absolute.