2

我的项目是一个游戏,由几个源文件和几个资源如图像、地图、模型等组成。其中一些需要由程序处理,例如我想将所有图像从png转换为dds。由于我的构建是源外构建,因此我希望将所有资源都构建到构建文件夹中,以便为了运输,我只需要打包构建文件夹。

我怎么做?

4

1 回答 1

3

如果您使用的是 Premake 的 4.x 版本,恐怕没有简单的解决方案。您可以嵌入数据(将它们复制到输出目录)

configuration "**.png"
   buildaction "Copy"

如果你想构建它们,我会做的是复制它们,然后使用“post-build”命令来处理文件的转换和清理。例如 :

configuration ""
    postbuildcommands { "premake --file=build_resources.lua build" }

当然,您输入的build_resources.lua内容取决于您,您甚至可以使用与创建项目时使用的脚本相同的脚本。您只需要定义build操作及其作用(基本上解析输出文件夹,并将每个 png 编译为 dds',然后清理 png。您可能还必须添加选项以指定您的平台/配置到构建脚本。

现在,如果您使用的是最新版本的 premake(可在此处找到:http: //sourceforge.net/projects/premake/files/Premake/nightlies/),您可以更轻松地实现这一点:

-- filter is the equivalent of 'configuration' in Premake 5.
-- configuration is still supported for backward compatibility, but it
-- will be removed eventually, so better start using 'filter' :)
filter "files:**.png"

    -- this is simply a message shown in the Visual Studio output
    buildmessage "converting %{file.relpath} to dds ..."

    -- this is the actual custom compilation command
    buildcommands {
        "ddsconverter --input=%{file.abspath} --output=%{cfg.linktarget.directory}"
    }

有关更多信息,请参见此处: https ://bitbucket.org/premake/premake-dev/wiki/buildcommands

以及有关令牌的信息(%{xxx}允许您使用已知路径而不编写它们的东西): https ://bitbucket.org/premake/premake-dev/wiki/Tokens

于 2015-01-19T09:28:59.670 回答