lua 的 Premake 问题

问题描述 投票:0回答:1

我使用 premake 作为构建系统,并且我有 Lua 脚本,但由于某种原因,当我打开 vs2022 并运行它时,有些事情没有做好。一些项目和项目有一个带有减号的红色圆圈。而且我的沙盒项目根本不在我的目录中。

我正在使用 premake5-beta beta2

这是我的lua脚本。

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"

我以前从未使用过 premake,但我听说对于初学者来说它比 cmake 更简单。 “-thecherno”

c++17 build-system premake build-script
1个回答
0
投票

您有 3 个问题:

  • Sandbox 项目名称中的拼写错误(缺少
    'd'
  • postbuildcommands
    有 2 个问题:
  • bin SandBox 目录可能尚不存在,因此创建缺失的目录。
  • buildcommand 中的路径并不真正直接与 lua 脚本相关:-/

以下

postbuildcommands
应该可以解决问题:

postbuildcommands
{
    "{MKDIR} %[bin/" .. outputdir .. "/Sandbox]",
    "{COPYFILE} %[%{!cfg.buildtarget.abspath}] %[bin/" .. outputdir .. "/Sandbox]"
}
  • %[..]
    就是正确制作相对于项目的路径(取绝对路径)
  • %{!..}
    是强制路径为绝对路径。
© www.soinside.com 2019 - 2024. All rights reserved.