Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[{*.py,SConstruct,SCsub}]
[*.py]
indent_style = space

[{*.{yml,yaml},.clang{-format,-tidy,d}}]
Expand Down
103 changes: 47 additions & 56 deletions .github/actions/openvic-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
name: Build OpenVic
description: Setup and Build OpenVic with the provided options
description: Configure, build, and install OpenVic with CMake

inputs:
identifier:
description: Identifier of this build
target:
description: Target type to build for
description: Identifier of this build (artifact name)
preset:
description: CMake configure preset
required: true
platform:
description: Platform to build for
configuration:
description: Build configuration (Debug, Release, RelWithDebInfo)
required: true
arch:
description: Architecture to build for
required: true
api-version:
description: API version to build for
required: true
scons-flags:
description: Additional flags to send to SCons
cmake-args:
description: Additional -D flags passed to the CMake configure step
default: ''
cache-base-branch:
description: Branch to base the cache upon
default: 'master'
disable-cache:
description: Whether to disable the build cache
default: 'false'
tag-name:
description: Name of tag
default: ''
Expand All @@ -35,34 +23,40 @@ inputs:
runs:
using: composite
steps:
- name: Setup build cache
uses: OpenVicProject/openvic-cache@master
if: ${{ inputs.disable-cache != 'true' }}
with:
cache-name: ${{ inputs.identifier }}
base-branch: ${{ inputs.cache-base-branch }}
continue-on-error: true

- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.x"
- name: Setup MSVC environment
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$vsPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
Get-ChildItem env: | ForEach-Object { Add-Content -Path $env:GITHUB_ENV -Value "$($_.Name)=$($_.Value)" }

- name: Set up SCons
- name: Setup Ninja
shell: bash
run: |
python -c "import sys; print(sys.version)"
python -m pip install scons
scons --version
# Ninja is preinstalled on GitHub-hosted images; fall back to the
# image's package manager if a future image drops it.
if ! command -v ninja >/dev/null 2>&1; then
if [ "$RUNNER_OS" = "macOS" ]; then
brew install ninja
elif [ "$RUNNER_OS" = "Windows" ]; then
choco install ninja -y
else
sudo apt-get update -y && sudo apt-get install -y ninja-build
fi
fi
ninja --version

- name: Install APT dependencies
if: ${{ inputs.platform == 'linux' }}
if: ${{ runner.os == 'Linux' }}
uses: awalsh128/cache-apt-pkgs-action@681749ae568c81c2037cb9185e38b709b261bd2f # v1.6.1
with:
packages: build-essential pkg-config libtbb-dev

- name: Install and Set g++ to version 13
if: ${{ inputs.platform == 'linux' }}
if: ${{ runner.os == 'Linux' }}
shell: sh
run: |
g++ --version
Expand All @@ -73,26 +67,23 @@ runs:
sudo update-alternatives --set g++ /usr/bin/g++-13
g++ --version

- name: Setup MinGW for Windows/MinGW build
if: ${{ inputs.platform == 'windows' }}
uses: egor-tensin/setup-mingw@ef0952fadae6794e225c0c1654887408bcadbf64

- name: Compile with SCons
uses: OpenVicProject/openvic-build@master
- name: Configure
shell: bash
env:
GAME_TAG: ${{ inputs.tag-name }}
GAME_RELEASE: ${{ inputs.release-name }}
with:
platform: ${{ inputs.platform }}
target: ${{ inputs.target }}
bin-dir: "game/bin/"
sconsflags: arch=${{ inputs.arch }} api_version=${{ inputs.api-version }} ${{ inputs.scons-flags }}

- name: Delete compilation files
if: ${{ inputs.platform == 'windows' }}
shell: pwsh
# Baked into the commit-info header at configure time.
OPENVIC_TAG: ${{ inputs.tag-name }}
OPENVIC_RELEASE: ${{ inputs.release-name }}
run: |
Remove-Item game/bin/openvic/* -Include *.exp,*.lib,*.pdb -Force
cmake --preset ${{ inputs.preset }} \
${{ inputs.cmake-args }}

- name: Build
shell: bash
run: cmake --build out/build/${{ inputs.preset }} --config ${{ inputs.configuration }}

- name: Install
shell: bash
run: cmake --install out/build/${{ inputs.preset }} --config ${{ inputs.configuration }}

- name: Upload extension artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand Down
14 changes: 7 additions & 7 deletions .github/changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ everything: &everything
- "**"

# Determines if build actions should occur after static checks are ran. Broadly speaking, these
# files changing would result in SCons rebuilding the engine, or are otherwise pertinent to the
# files changing would result in CMake rebuilding, or are otherwise pertinent to the
# buildsystem itself.
sources:
- .github/{actions/*,workflows}/*.yml
- "**/{SConstruct,SCsub,*.py}"
- "**/CMakeLists.txt"
- "**/*.cmake"
- "**/CMakePresets.json"
- "**/*.py"
- "**/*.{hpp,cpp,inc,gd,tscn,scn,tres,res}"
- "**/*.{cfg,godot,gdextension,uid,import}"
- "**/*.{svg,ico,icns,png,ogv,ogg,mp3,csv,xml}"
- scripts
- godot-cpp
- extension/deps/**

pre-commit:
- *everything
- '!scripts/**'
- '!godot-cpp/**'
- '!extension/deps/*/**'
# The first-party submodule (openvic-simulation) runs its own checks.
- '!extension/deps/openvic-simulation/**'

# Determines which files are appropriate for running clangd-tidy checks on.
clangd:
Expand Down
62 changes: 32 additions & 30 deletions .github/workflows/build-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ name: 🔢 Build Matrix

on:
workflow_call:
inputs:
godot-api-version:
type: string
required: true
workflow_dispatch:
inputs:
godot-api-version:
type: string
required: true

jobs:
build-matrix:
Expand All @@ -25,44 +17,56 @@ jobs:
- identifier: windows-debug
os: windows-latest
name: 🏁 Windows Debug
target: template_debug
platform: windows
arch: x86_64
preset: windows-x64-template_debug
configuration: Debug

- identifier: windows-release
os: windows-latest
name: 🏁 Windows Release
target: template_release
platform: windows
arch: x86_64
preset: windows-x64-template_release
configuration: Release

- identifier: windows-editor
os: windows-latest
name: 🏁 Windows Editor
preset: windows-x64-editor
configuration: RelWithDebInfo

- identifier: macos-debug
os: macos-latest
name: 🍎 macOS (universal) Debug
target: template_debug
platform: macos
arch: universal
preset: macos-universal-template_debug
configuration: Debug

- identifier: macos-release
os: macos-latest
name: 🍎 macOS (universal) Release
target: template_release
platform: macos
arch: universal
preset: macos-universal-template_release
configuration: Release

- identifier: macos-editor
os: macos-latest
name: 🍎 macOS (universal) Editor
preset: macos-universal-editor
configuration: RelWithDebInfo

- identifier: linux-debug
os: ubuntu-22.04
name: 🐧 Linux Debug
target: template_debug
platform: linux
arch: x86_64
preset: linux-x64-template_debug
configuration: Debug

- identifier: linux-release
os: ubuntu-22.04
name: 🐧 Linux Release
target: template_release
platform: linux
arch: x86_64
preset: linux-x64-template_release
configuration: Release

- identifier: linux-editor
os: ubuntu-22.04
name: 🐧 Linux Editor
preset: linux-x64-editor
configuration: RelWithDebInfo

steps:
- name: Checkout project
Expand All @@ -75,7 +79,5 @@ jobs:
uses: ./.github/actions/openvic-build
with:
identifier: ${{ matrix.identifier }}
target: ${{ matrix.target }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
api-version: ${{ inputs.godot-api-version }}
preset: ${{ matrix.preset }}
configuration: ${{ matrix.configuration }}
3 changes: 0 additions & 3 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
sources-changed: ${{ steps.changed-files.outputs.sources_any_changed }}
godot-executable-url: ${{ steps.godot-env.outputs.godot-linux-url }}
godot-templates-url: ${{ steps.godot-env.outputs.godot-template-url }}
godot-api-version: ${{ steps.godot-env.outputs.godot-api-version }}
steps:
- name: Checkout project
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
Expand Down Expand Up @@ -68,8 +67,6 @@ jobs:
permissions:
contents: read
uses: ./.github/workflows/build-matrix.yml
with:
godot-api-version: ${{ needs.static-checks-builds.outputs.godot-api-version }}

godot-debug-checks:
runs-on: ubuntu-latest
Expand Down
45 changes: 19 additions & 26 deletions .github/workflows/nightly-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
commit: ${{ steps.check_for_new_commits.outputs.commit }}
godot-executable-url: ${{ steps.godot-env.outputs.godot-linux-url }}
godot-templates-url: ${{ steps.godot-env.outputs.godot-template-url }}
godot-api-version: ${{ steps.godot-env.outputs.godot-api-version }}
latest-tag: ${{ steps.default-values.outputs.latest-tag || steps.master-values.outputs.latest-tag || steps.nightly-values.outputs.latest-tag }}
commit-hash: ${{ steps.default-values.outputs.commit-hash || steps.master-values.outputs.commit-hash || steps.nightly-values.outputs.commit-hash }}
from-ref: ${{ steps.default-values.outputs.from-ref || steps.master-values.outputs.from-ref || steps.nightly-values.outputs.from-ref }}
Expand Down Expand Up @@ -100,15 +99,14 @@ jobs:
run: |
relevant_files=(
"extension/deps/*"
"scripts"
"godot-cpp"
"extension/src/*.hpp"
"extension/src/*.cpp"
"game/*"
':!extension/src/openvic-extension/pch.hpp'
':!extension/src/openvic-extension/pch.cpp'
"pyproject.toml"
"SConstruct"
"CMakeLists.txt"
"CMakePresets.json"
".github/workflows/builds.yml"
".github/actions/openvic-build/action.yml"
".github/actions/openvic-release/action.yml"
Expand Down Expand Up @@ -227,39 +225,37 @@ jobs:
fail-fast: false
matrix:
include:
# RelWithDebInfo = optimized with debug symbols (the old
# optimize=speed_trace debug_symbols=yes flavor).
- identifier: windows-release
os: windows-latest
name: 🏁 Windows Release
target: template_release
platform: windows
arch: x86_64
scons-flags: optimize=speed_trace
preset: windows-x64-template_release
configuration: RelWithDebInfo
cmake-args: ''

- identifier: macos-release
os: macos-latest
name: 🍎 macOS (universal) Release
target: template_release
platform: macos
arch: universal
scons-flags: "optimize=speed_trace lto=full"
preset: macos-universal-template_release
configuration: RelWithDebInfo
cmake-args: -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

- identifier: linux-release
os: ubuntu-latest
name: 🐧 Linux Release
runner: ubuntu-22.04
target: template_release
platform: linux
arch: x86_64
scons-flags: "optimize=speed_trace lto=full use_static_cpp=yes"
preset: linux-x64-template_release
configuration: RelWithDebInfo
cmake-args: -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON

- identifier: linux-debug
os: ubuntu-latest
name: 🐧 Linux Debug
runner: ubuntu-latest
target: template_debug
platform: linux
arch: x86_64
scons-flags: optimize=none
preset: linux-x64-template_debug
configuration: Debug
cmake-args: ''

steps:
- name: Checkout project
Expand All @@ -272,13 +268,10 @@ jobs:
uses: ./.github/actions/openvic-build
with:
identifier: ${{ matrix.identifier }}
target: ${{ matrix.target }}
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
api-version: ${{ needs.nightly-check.outputs.godot-api-version }}
preset: ${{ matrix.preset }}
configuration: ${{ matrix.configuration }}
tag-name: ${{ needs.nightly-check.outputs.tag-name }}
disable-cache: true
scons-flags: use_hot_reload=no debug_symbols=yes ${{ matrix.scons-flags }}
cmake-args: ${{ matrix.cmake-args }}

publish-nightly-release:
name: Publish Release
Expand Down
Loading
Loading