Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

获取源代码

下载 Godot 源代码

进入 SCons 构建系统并编译 Godot 之前,你需要将 Godot 的源代码下载到本地。

源代码位于 GitHub 上, 虽然你可以通过网站手动下载它, 但是通常你希望通过 git 版本控制系统来下载.

如果你是为了贡献代码或提交拉取请求(Pull Request)而进行编译,那么你应该按照 Pull Request workflow 中的说明来进行操作。

如果你还不太了解 git,在各种网站上都有大量的 Git 教程

通常,你需要安装 git 和/或各种 GUI 客户端中的一个。

之后,要获得最新版本的 Godot 源代码(不稳定的 master 分支),可以使用 git clone

如果你使用 git 命令行,可以通过在终端输入下列命令来完成:

git clone https://github.com/godotengine/godot.git
# You can add the --depth 1 argument to omit the commit history (shallow clone).
# A shallow clone is faster, but not all Git operations (like blame) will work.

要获取稳定版本的源代码,请访问源代码发布页面然后单击所需发行版的链接。然后,你可以从页面上的下载链接下载并解压源代码。

使用 git 时,你也可以通过在 --branch (或者简写为 -b )参数后面指定对应的分支或标签,来克隆一个稳定的发行版本。

# Clone the continuously maintained stable branch (`4.4` as of writing).
git clone https://github.com/godotengine/godot.git -b 4.4

# Clone the `4.4-stable` tag. This is a fixed revision that will never change.
git clone https://github.com/godotengine/godot.git -b 4.4-stable

# After cloning, optionally go to a specific commit.
# This can be used to access the source code at a specific point in time,
# e.g. for development snapshots, betas and release candidates.
cd godot
git checkout f4af8201bac157b9d47e336203d3e8a8ef729de2

维护分支 maintenance branches 用于在每个小版本上发布后续的补丁。

你可以从 GitHub 上的 godotengine/godot-builds on GitHub, 以 .tar.xz 压缩包格式获取每一个正式版本和预发布版本的源码。这种方式下载的文件体积会稍微小一点,但缺点是里面不包含版本控制(Git)的相关信息。

获取到 Godot 的源代码之后,你就可以继续编译 Godot 了。