用Visual Studio编译
py -m pip install --upgrade pip
py -m pip install --upgrade scons
py -m pip install --upgrade pywin32
- 编译
假设Python安装在目录D:\Python3,Godot代码库在目录D:\prj\godotengine\godot。 如果是在x64平台上编译x64游戏,那么启动"x64 Native Tools Command Prompt for VS"并执行:
set PATH="D:\Python3";"D:\Python3\Scripts";%PATH%
cd /d D:\prj\godotengine\godot
scons -h
scons -H
scons -c
:: 编译运行项目的可执行程序
scons -j6 p=windows tools=no target=release production=yes use_lto=yes deprecated=no vsproj=yes debug_symbols=no
:: 编译导出模板(及编辑器和项目管理器)
scons -j6 p=windows tools=yes target=release_debug use_lto=yes deprecated=no vsproj=yes debug_symbols=no
将在目录D:\prj\godotengine\godot\bin下分别生成两个可执行文件:
godot.windows.opt.64.exe
godot.windows.opt.tools.64.exe
用MinGW-w64编译
- 启动MSYS2 MinGW 64-bit shell(D:\msys64\msys2_shell.cmd -mingw64)
- 准备编译环境
pacman -S --needed mingw-w64-x86_64-python-pip mingw-w64-x86_64-gcc make
pip install --upgrade scons
cd /d/prj/godotengine/godot
scons -c
scons -j6 p=windows tools=no target=release production=yes use_lto=yes deprecated=no debug_symbols=no use_mingw=yes
scons -j6 p=windows tools=yes target=release_debug use_lto=yes deprecated=no debug_symbols=no use_mingw=yes
strip bin/*.exe
输出的可执行文件名和用Visual Studio编译的相同。
- 安装Python
- 安装SCons
- 安装Android Studio或Android SDK命令行工具
- 下载Gradle
- 安装JDK
- 修改distributionUrl
修改D:\prj\godotengine\godot\platform\android\java\gradle\wrapper\gradle-wrapper.properties,将distributionUrl指向已下载的gradle包,例如:
distributionUrl=file:///D:/android/gradle/gradle-7.3.1-all.zip
- 编译
假设Android SDK安装在目录D:\android\android-sdk,JDK在目录D:\Program Files\Java\jdk-17.0.1。 在命令行窗口执行:
set ANDROID_SDK_ROOT=D:\android\android-sdk
set JAVA_HOME=D:\Program Files\Java\jdk-17.0.1
cd /d D:\prj\godotengine\godot
scons -c p=android target=release_debug use_lto=yes deprecated=no debug_symbols=no android_arch=arm64v8
scons -j6 p=android target=release production=yes use_lto=yes deprecated=no debug_symbols=no android_arch=arm64v8
cd platform/android/java
gradlew generateGodotTemplates
将在目录D:\prj\godotengine\godot\bin下生成三个文件:
android_release.apk
android_source.zip
godot-lib.release.aar
scons对于Android平台缺省有tools=no,无须指定。 另,编译调试用模板:
:: 注意:cleanGodotTemplates会删除目录D:\prj\godotengine\godot\bin下的文件
gradlew cleanGodotTemplates
cd /d D:\prj\godotengine\godot
scons -c p=android target=release production=yes use_lto=yes deprecated=no debug_symbols=no android_arch=arm64v8
scons -j6 p=android target=release_debug use_lto=yes deprecated=no debug_symbols=no android_arch=arm64v8
cd platform/android/java
gradlew generateGodotTemplates
将在目录D:\prj\godotengine\godot\bin下生成三个文件:
android_debug.apk
android_source.zip
godot-lib.debug.aar
|