多平台预制脚本

eri*_*xff 5 premake

我是 Node9 的作者,Node9 是一个托管的混合操作系统,它结合了 Inferno 和 LuaJIT,创建了一个交互式的分布式开发环境。请参阅此处的项目: https: //github.com/jvburnes/node9

我创建了一个基本的 4.x 预制脚本来编译 OSX 的所有依赖项和主要源代码,但现在人们要求 Linux、BSD 和 Windows 的构建配置。我有执行此操作的代码,并且我想创建预制配置以在这些操作系统上构建和运行 Node9。我需要设置库并包括搜索路径、编译器名称以及每个平台的定义。

  1. 谁能给我指出一个好的多平台预制脚本?
  2. 我是否使用“premake gmake”并以某种方式感知本机平台,或者我是否需要在命令行上显式放置目标平台并在 premake 配置和平台部分中引用该平台?
  3. 我听说 premake 4.x 是遗留版本,而 premake 5.x 是未来的解决方案。它是否足够稳定且可用,可以为所有这些平台构建?

我知道这有很多问题,但我想把这件事做好。

谢谢。

Cit*_*ron 3

我不是多平台编译方面的专家,但这里有一些可能对您有帮助的事情。首先,我强烈建议您切换到 Premake5。它很稳定,社区致力于它并且非常活跃,并且您支持模块(Android?:p)和许多很酷的其他功能。

至于你的问题:

  1. 我不能,但基本上它应该像这样简单:

    solution "multiplatform_solution"
        configurations { "debug", "release", "whatever" }
    
        -- now here, you define your supported platforms
        platforms {
            "win32",
            "win64",
            "macos",
            "linux86",
            "linux64",
            -- etc.
        }
    
        project "some_project"
    
            -- now you can configure some things per platform:
            filter { "platforms:win32" }
                -- some defines, some specific paths to libs, etc.
                -- specific to win 32
                defines { "WIN32" }
            filter { "platforms:macos" }
                -- macos specific configurations
                defines { "you_fool_" } -- yes, it's a troll :p
            -- etc.
    
            -- and configure the rest as usual
    
    Run Code Online (Sandbox Code Playgroud)
  2. 当你调用时,premake gmake你只需告诉 premake 为 gmake 构建一个 makefile。如果您在 Windows、MacOS 和 Linux 上有 gmake,则可以premake gmake在所有平台上使用。当您实际构建时,您只需要指定您的配置和平台。我不太了解 gmake,但这可能看起来像这样:gmake config=release platform=linux32

  3. 正如我所说,您可能想更新到 Premake 5。我认为它足够稳定,如果出现问题,您可以在这里提问:)