获取源代码

下载 Godot 源代码

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

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

如果你是为了做贡献或拉动请求而进行编译,你应该遵循拉取请求工作流中的说明。

如果你还不太了解 git,在各种网站上都有大量的 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

The maintenance branches are used to release further patches on each minor version.

You can get the source code for each release and pre-release in .tar.xz format from godotengine/godot-builds on GitHub. This lacks version control information but has a slightly smaller download size.

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