Skip to content

Commit

Permalink
SCons: Unify tools/target build type configuration
Browse files Browse the repository at this point in the history
Implements godotengine/godot-proposals#3371.

New `target` presets
====================

The `tools` option is removed and `target` changes to use three new presets,
which match the builds users are familiar with. These targets control the
default optimization level and enable editor-specific and debugging code:

- `editor`: Replaces `tools=yes target=release_debug`.
  * Defines: `TOOLS_ENABLED`, `DEBUG_ENABLED`, `-O2`/`/O2`
- `template_debug`: Replaces `tools=no target=release_debug`.
  * Defines: `DEBUG_ENABLED`, `-O2`/`/O2`
- `template_release`: Replaces `tools=no target=release`.
  * Defines: `-O3`/`/O2`

New `dev_build` option
======================

The previous `target=debug` is now replaced by a separate `dev_build=yes`
option, which can be used in combination with either of the three targets,
and changes the following:

- `dev_build`: Defines `DEV_ENABLED`, disables optimization (`-O0`/`/0d`),
  enables generating debug symbols, does not define `NDEBUG` so `assert()`
  works in thirdparty libraries, adds a `.dev` suffix to the binary name.

Note: Unlike previously, `dev_build` defaults to off so that users who
compile Godot from source get an optimized and small build by default.
Engine contributors should now set `dev_build=yes` in their build scripts or
IDE configuration manually.

Changed binary names
====================

The name of generated binaries and object files are changed too, to follow
this format:

`godot.<platform>.<target>[.dev][.double].<arch>[.<extra_suffix>][.<ext>]`

For example:
- `godot.linuxbsd.editor.dev.arm64`
- `godot.windows.template_release.double.x86_64.mono.exe`

Be sure to update your links/scripts/IDE config accordingly.

More flexible `optimize` and `debug_symbols` options
====================================================

The optimization level and whether to generate debug symbols can be further
specified with the `optimize` and `debug_symbols` options. So the default
values listed above for the various `target` and `dev_build` combinations
are indicative and can be replaced when compiling, e.g.:

`scons p=linuxbsd target=template_debug dev_build=yes optimize=debug`
will make a "debug" export template with dev-only code enabled, `-Og`
optimization level for GCC/Clang, and debug symbols. Perfect for debugging
complex crashes at runtime in an exported project.
  • Loading branch information
akien-mga committed Sep 26, 2022
1 parent b9a64c7 commit 39facb3
Show file tree
Hide file tree
Showing 42 changed files with 216 additions and 339 deletions.
17 changes: 7 additions & 10 deletions .github/actions/godot-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ name: Build Godot
description: Build Godot with the provided options.
inputs:
target:
description: The scons target (debug/release_debug/release).
default: "debug"
tools:
description: If tools are to be built.
default: false
description: Build target (editor, template_release, template_debug).
default: "editor"
tests:
description: If tests are to be built.
description: Unit tests.
default: false
platform:
description: The Godot platform to build.
description: Target platform.
required: false
sconsflags:
default: ""
Expand All @@ -33,7 +30,7 @@ runs:
SCONS_CACHE: ${{ inputs.scons-cache }}
SCONS_CACHE_LIMIT: ${{ inputs.scons-cache-limit }}
run: |
echo "Building with flags:" ${{ env.SCONSFLAGS }}
if ! ${{ inputs.tools }}; then rm -rf editor; fi # Ensure we don't include editor code.
scons p=${{ inputs.platform }} target=${{ inputs.target }} tools=${{ inputs.tools }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
echo "Building with flags:" platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
if [ "${{ inputs.target }}" != "editor" ]; then rm -rf editor; fi # Ensure we don't include editor code.
scons platform=${{ inputs.platform }} target=${{ inputs.target }} tests=${{ inputs.tests }} ${{ env.SCONSFLAGS }}
ls -l bin/
8 changes: 3 additions & 5 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
jobs:
android-template:
runs-on: "ubuntu-20.04"
name: Template (target=release, tools=no)
name: Template (target=template_release)

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -44,17 +44,15 @@ jobs:
with:
sconsflags: ${{ env.SCONSFLAGS }} arch=arm32
platform: android
target: release
tools: false
target: template_release
tests: false

- name: Compilation (arm64)
uses: ./.github/actions/godot-build
with:
sconsflags: ${{ env.SCONSFLAGS }} arch=arm64
platform: android
target: release
tools: false
target: template_release
tests: false

- name: Generate Godot templates
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/ios_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
jobs:
ios-template:
runs-on: "macos-latest"
name: Template (target=release, tools=no)
name: Template (target=template_release)

steps:
- uses: actions/checkout@v3
Expand All @@ -31,8 +31,7 @@ jobs:
with:
sconsflags: ${{ env.SCONSFLAGS }}
platform: ios
target: release
tools: false
target: template_release
tests: false

- name: Upload artifact
Expand Down
42 changes: 18 additions & 24 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: false
DOTNET_CLI_TELEMETRY_OPTOUT: true

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-linux
Expand All @@ -21,57 +21,52 @@ jobs:
fail-fast: false
matrix:
include:
- name: Editor w Mono (target=release_debug, tools=yes, tests=yes)
- name: Editor w/ Mono (target=editor)
cache-name: linux-editor-mono
target: release_debug
tools: true
target: editor
tests: false # Disabled due freeze caused by mix Mono build and CI
sconsflags: module_mono_enabled=yes
doc-test: true
bin: "./bin/godot.linuxbsd.opt.tools.x86_64.mono"
bin: "./bin/godot.linuxbsd.editor.x86_64.mono"
build-mono: true
proj-conv: true
artifact: true

- name: Editor with doubles and GCC sanitizers (target=debug, tools=yes, float=64, tests=yes, use_asan=yes, use_ubsan=yes, linker=gold)
- name: Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, float=64, use_asan=yes, use_ubsan=yes, linker=gold)
cache-name: linux-editor-double-sanitizers
target: debug
tools: true
target: editor
tests: true
sconsflags: float=64 use_asan=yes use_ubsan=yes linker=gold
sconsflags: dev_build=yes float=64 use_asan=yes use_ubsan=yes linker=gold
proj-test: true
# Can be turned off for PRs that intentionally break compat with godot-cpp,
# until both the upstream PR and the matching godot-cpp changes are merged.
godot-cpp-test: true
bin: "./bin/godot.linuxbsd.double.tools.x86_64.san"
bin: "./bin/godot.linuxbsd.editor.dev.double.x86_64.san"
build-mono: false
# Skip 2GiB artifact speeding up action.
artifact: false

- name: Editor with clang sanitizers (target=debug, tools=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)
- name: Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)
cache-name: linux-editor-llvm-sanitizers
target: debug
tools: true
target: editor
tests: true
sconsflags: use_asan=yes use_ubsan=yes use_llvm=yes linker=lld
bin: "./bin/godot.linuxbsd.tools.x86_64.llvm.san"
sconsflags: dev_build=yes use_asan=yes use_ubsan=yes use_llvm=yes linker=lld
bin: "./bin/godot.linuxbsd.editor.dev.x86_64.llvm.san"
build-mono: false
# Skip 2GiB artifact speeding up action.
artifact: false

- name: Template w/ Mono (target=release, tools=no)
- name: Template w/ Mono (target=template_release)
cache-name: linux-template-mono
target: release
tools: false
target: template_release
tests: false
sconsflags: module_mono_enabled=yes debug_symbols=no
sconsflags: module_mono_enabled=yes
build-mono: false
artifact: true

- name: Minimal Template (target=release, tools=no, everything disabled)
- name: Minimal template (target=template_release, everything disabled)
cache-name: linux-template-minimal
target: release
tools: false
target: template_release
tests: false
sconsflags: modules_enabled_by_default=no disable_3d=yes disable_advanced_gui=yes deprecated=no minizip=no
artifact: true
Expand Down Expand Up @@ -113,7 +108,6 @@ jobs:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: linuxbsd
target: ${{ matrix.target }}
tools: ${{ matrix.tools }}
tests: ${{ matrix.tests }}

- name: Generate C# glue
Expand Down Expand Up @@ -221,7 +215,7 @@ jobs:
if: ${{ matrix.godot-cpp-test }}
run: |
cd godot-cpp/test
scons target=${{ matrix.target }}
scons target=debug
cd ../..
- name: Prepare artifact
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ jobs:
fail-fast: false
matrix:
include:
- name: Editor (target=release_debug, tools=yes, tests=yes)
- name: Editor (target=editor, tests=yes)
cache-name: macos-editor
target: release_debug
tools: true
target: editor
tests: true
bin: "./bin/godot.macos.opt.tools.x86_64"
bin: "./bin/godot.macos.editor.x86_64"

- name: Template (target=release, tools=no)
- name: Template (target=template_release)
cache-name: macos-template
target: release
tools: false
target: template_release
tests: false
sconsflags: debug_symbols=no

Expand All @@ -55,7 +53,6 @@ jobs:
sconsflags: ${{ env.SCONSFLAGS }}
platform: macos
target: ${{ matrix.target }}
tools: ${{ matrix.tools }}
tests: ${{ matrix.tests }}

# Execute unit tests for the editor
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/web_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:
jobs:
web-template:
runs-on: "ubuntu-20.04"
name: Template (target=release, tools=no)
name: Template (target=template_release)

steps:
- uses: actions/checkout@v3
Expand All @@ -43,8 +43,7 @@ jobs:
with:
sconsflags: ${{ env.SCONSFLAGS }}
platform: web
target: release
tools: false
target: template_release
tests: false

- name: Upload artifact
Expand Down
13 changes: 5 additions & 8 deletions .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ jobs:
fail-fast: false
matrix:
include:
- name: Editor (target=release_debug, tools=yes, tests=yes)
- name: Editor (target=editor, tests=yes)
cache-name: windows-editor
target: release_debug
tools: true
target: editor
tests: true
# Skip debug symbols, they're way too big with MSVC.
sconsflags: debug_symbols=no
bin: "./bin/godot.windows.opt.tools.x86_64.exe"
bin: "./bin/godot.windows.editor.x86_64.exe"

- name: Template (target=release, tools=no)
- name: Template (target=template_release, tools=no)
cache-name: windows-template
target: release
tools: false
target: template_release
tests: false
sconsflags: debug_symbols=no

Expand All @@ -57,7 +55,6 @@ jobs:
sconsflags: ${{ env.SCONSFLAGS }} ${{ matrix.sconsflags }}
platform: windows
target: ${{ matrix.target }}
tools: ${{ matrix.tools }}
tests: ${{ matrix.tests }}

# Execute unit tests for the editor
Expand Down
Loading

0 comments on commit 39facb3

Please sign in to comment.