Manuals
Manuals




This translation is community contributed and may not be up to date. We only maintain the English version of the documentation. Read this manual in English

构建器 Bob

Bob 是一个命令行工具,用于在正常编辑器工作流程之外构建 Defold 项目。

Bob 能够构建数据(对应于选择编辑器菜单项 Project ▸ Build 的构建步骤),创建数据存档,并创建独立的、可分发的应用程序包(对应于编辑器菜单项 Project ▸ Bundle ▸ ... 选项)。

Bob 作为 Java JAR 存档分发,其中包含构建所需的一切。您可以在 GitHub 发布页面 上找到最新的 bob.jar 分发版本。选择一个发布版本,然后下载 bob/bob.jar。您需要 OpenJDK 25 来运行它。

兼容的 OpenJDK 25 镜像:

如果您在 Windows 上,您需要 OpenJDK 的 .msi 文件安装程序。

用法

Bob 通过在 shell 或命令行中调用 java(在 Windows 上是 java.exe)并提供 bob java 存档作为参数来运行:

$ java -jar bob.jar --help
usage: bob [options] [commands]
 -a,--archive                            Build archive
 -ar,--architectures <arg>               Comma separated list of
                                         architectures to include for the
                                         platform
    --archive-resource-padding <arg>     The alignment of the resources in
                                         the game archive. Default is 4
 -bf,--bundle-format <arg>               Which formats to create the
                                         application bundle in. Comma
                                         separated list. (Android: 'apk'
                                         and 'aab')
    --binary-output <arg>                Location where built engine
                                         binary will be placed. Default is
                                         "<build-output>/<platform>/"
 -bo,--bundle-output <arg>               Bundle output directory
 -br,--build-report <arg>                DEPRECATED! Use
                                         --build-report-json instead
 -brhtml,--build-report-html <arg>       Filepath where to save a build
                                         report as HTML
 -brjson,--build-report-json <arg>       Filepath where to save a build
                                         report as JSON
    --build-artifacts <arg>              If left out, will default to
                                         build the engine. Choices:
                                         'engine', 'plugins', 'library'.
                                         Comma separated list
    --build-input <arg>                  Project resource path to build
                                         instead of game.project. May be
                                         specified more than once. More
                                         than one occurrence is allowed
    --build-input-file <arg>             File containing project resource
                                         paths to build instead of
                                         game.project. May be specified
                                         more than once. More than one
                                         occurrence is allowed
    --build-server <arg>                 The build server (when using
                                         native extensions)
    --build-server-header <arg>          Additional build server header to
                                         set. More than one occurrence is
                                         allowed
 -ce,--certificate <arg>                 DEPRECATED! Use --keystore
                                         instead
 -d,--debug                              DEPRECATED! Use --variant=debug
                                         instead
    --debug-ne-upload                    Outputs the files sent to build
                                         server as upload.zip
    --debug-output-glsl <arg>            Force build GLSL shaders
    --debug-output-hlsl <arg>            Force build HLSL shaders
    --debug-output-msl <arg>             Force build Metal shaders
    --debug-output-spirv <arg>           Force build SPIR-V shaders
    --debug-output-wgsl <arg>            Force build WGSL shaders
    --defoldsdk <arg>                    What version of the defold sdk
                                         (sha1) to use
 -e,--email <arg>                        User email
 -ea,--exclude-archive                   Exclude resource archives from
                                         application bundle. Use this to
                                         create an empty Defold
                                         application for use as a build
                                         target
    --exclude-build-folder <arg>         DEPRECATED! Use '.defignore' file
                                         instead
    --experimental-path-minification     Minimizes resource path names in
                                         order to save bundle size.
 -h,--help                               This help message
 -i,--input <arg>                        DEPRECATED! Use --root instead
    --identity <arg>                     Sign identity (iOS)
 -kp,--key-pass <arg>                    Password of the deployment key if
                                         different from the keystore
                                         password (Android)
 -ks,--keystore <arg>                    Deployment keystore used to sign
                                         APKs (Android)
 -ksa,--keystore-alias <arg>             The alias of the signing key+cert
                                         you want to use (Android)
 -ksp,--keystore-pass <arg>              Password of the deployment
                                         keystore (Android)
 -l,--liveupdate <arg>                   Yes if liveupdate content should
                                         be published
    --max-cpu-threads <arg>              Max count of threads that bob.jar
                                         can use
 -mp,--mobileprovisioning <arg>          mobileprovisioning profile (iOS)
    --ne-build-dir <arg>                 Specify a folder with includes or
                                         source, to build a specific
                                         library. More than one occurrence
                                         is allowed
    --ne-output-name <arg>               Specify a library target name
 -o,--output <arg>                       Output directory. Default is
                                         "build/default"
 -p,--platform <arg>                     Platform (when building and
                                         bundling)
 -pk,--private-key <arg>                 DEPRECATED! Use --keystore
                                         instead
 -r,--root <arg>                         Build root directory. Default is
                                         current directory
    --resource-cache-local <arg>         Path to local resource cache
    --resource-cache-remote <arg>        URL to remote resource cache
    --resource-cache-remote-pass <arg>   Password/token to authenticate
                                         access to the remote resource
                                         cache
    --resource-cache-remote-user <arg>   Username to authenticate access
                                         to the remote resource cache
    --settings <arg>                     Path to a game project settings
                                         file. The settings files are
                                         applied left to right. More than
                                         one occurrence is allowed
    --strip-executable                   Strip the dmengine of debug
                                         symbols (when bundling iOS or
                                         Android)
 -tc,--texture-compression               Use texture compression as
                                         specified in texture profiles
 -tp,--texture-profiles <arg>            DEPRECATED! Use
                                         --texture-compression instead
 -u,--auth <arg>                         User auth token
    --use-async-build-server             DEPRECATED! Asynchronous build is
                                         now the default
    --use-lua-bytecode-delta             Use byte code delta compression
                                         when building for multiple
                                         architectures
    --use-uncompressed-lua-source        Use uncompressed and unencrypted
                                         Lua source code instead of byte
                                         code
    --use-vanilla-lua                    DEPRECATED! Use
                                         --use-uncompressed-lua-source
                                         instead
 -v,--verbose                            Verbose output
    --variant <arg>                      Specify debug, release or
                                         headless version of dmengine
                                         (when bundling)
    --version                            Prints the version number to the
                                         output
    --with-sha1                          Generate (and verify) sha1
                                         signatures from build artifacts
                                         (when bunding for web)
    --with-symbols                       Generate the symbol file (if
                                         applicable)

--texture-compression 是一个不带值的开关。包含它以启用纹理配置文件中选定的压缩;省略它则禁用纹理压缩。旧式 --texture-compression=true 写法仍然可用。旧式 --texture-compression=false 写法会被忽略并产生警告;请改为省略该开关。

可用命令:

clean
删除构建目录中已构建的文件。
distclean
删除构建目录中的所有文件。
build
构建从所选构建根可达的依赖图。默认的根是 game.project--build-input--build-input-file 可以指定其他根。文件不会仅因为它们位于项目根目录下就被构建。当 game.project 是构建根时,添加 --archive 以在构建目录中生成游戏数据存档。
bundle
创建特定于平台的应用程序包。打包需要存在已构建的存档(使用 --archive 选项的 build)并指定目标平台(使用 --platform 选项)。除非使用 --bundle-output 选项指定不同的目录,否则 Bob 会在输出目录中创建包。包根据 game.project 中的项目名称设置命名。--variant 指定打包时构建哪种类型的可执行文件,它与 --strip-executable 选项一起取代了 --debug 选项。如果没有指定 --variant,您将获得引擎的发布版本(在 Android 和 iOS 上剥离符号)。将 --variant 设置为 debug 并省略 --strip-executable 会产生与 --debug 过去相同的可执行文件类型。
resolve
解析所有外部库依赖项。

可用平台和架构:

x86_64-macos
macOS 64 位
arm64-macos
macOS Apple Silicon (ARM)
x86_64-win32
Windows 64 位
x86-win32
Windows 32 位
x86_64-linux
Linux 64 位
arm64-linux
用于树莓派和基于 Linux 的掌上设备的 Linux ARM64。
x86_64-ios
iOS macOS 64 位 (iOS 模拟器)
arm64-ios
iOS 64 位。默认情况下,--architectures 参数值为 arm64-ios
armv7-android
Android,具有可用的 32 位 armv7-android 和 64 位 arm64-android 架构。默认情况下,--architectures 参数值为 armv7-android,arm64-android
wasm-web
HTML5,具有可用的 wasm-webwasm_pthread-web 架构。默认情况下,--architectures 参数值为 wasm-web

默认情况下,Bob 在当前目录中寻找项目,并将从 game.project 可达的资源构建到 build/default 中。未被引用的资源不会编译。如果代码在运行时按路径加载原始文件,请通过自定义资源项目设置将其包含进来;其他 Defold 资源需要有从某个构建根可达的引用。

$ cd /Applications/Defold-beta/branches/14/4/main
$ java -jar bob.jar
100%
$

您可以将命令串联在一起以一次性执行一系列任务。以下示例解析库,清除构建目录,构建存档数据并将 macOS 应用程序捆绑(命名为 My Game.app):

$ java -jar bob.jar --archive --platform x86_64-macos resolve distclean build bundle
100%
$ ls -al build/default/
total 70784
drwxr-xr-x   13 sicher  staff       442  1 Dec 10:15 .
drwxr-xr-x    3 sicher  staff       102  1 Dec 10:15 ..
drwxr-xr-x    3 sicher  staff       102  1 Dec 10:15 My Game.app
drwxr-xr-x    8 sicher  staff       272  1 Dec 10:15 builtins
-rw-r--r--    1 sicher  staff    140459  1 Dec 10:15 digest_cache
drwxr-xr-x    4 sicher  staff       136  1 Dec 10:15 fonts
-rw-r--r--    1 sicher  staff  35956340  1 Dec 10:15 game.darc
-rw-r--r--    1 sicher  staff       735  1 Dec 10:15 game.projectc
drwxr-xr-x  223 sicher  staff      7582  1 Dec 10:15 graphics
drwxr-xr-x    3 sicher  staff       102  1 Dec 10:15 input
drwxr-xr-x   20 sicher  staff       680  1 Dec 10:15 logic
drwxr-xr-x   27 sicher  staff       918  1 Dec 10:15 sound
-rw-r--r--    1 sicher  staff    131926  1 Dec 10:15 state
$