From f47439feaeee20f33601b95459bafba7721ac888 Mon Sep 17 00:00:00 2001 From: Nathan Franke Date: Sat, 2 Nov 2024 02:43:49 -0500 Subject: [PATCH] scons cache --- .github/workflows/build.yml | 33 +++++++++++++++--------------- SConstruct | 14 ++++++------- project/demo/scene.tscn | 8 -------- project/demo/{scene.gd => test.gd} | 0 project/demo/test.tscn | 8 ++++++++ project/project.godot | 2 +- 6 files changed, 32 insertions(+), 33 deletions(-) delete mode 100644 project/demo/scene.tscn rename project/demo/{scene.gd => test.gd} (100%) create mode 100644 project/demo/test.tscn diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7288ba0..c4c0dc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,27 +91,26 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 -# TODO: Cache doesn't work yet. SCons rebuilds the objects even if they already exist. Could be caused by modification dates or extension_api.json. -# fetch-depth: 0 May be needed for cache. See: . -# - name: Set up SCons cache -# uses: actions/cache@v3 -# with: -# path: | -# ${{ github.workspace }}/.scons-cache/ -# ${{ github.workspace }}/**/.sconsign.dblite -# ${{ github.workspace }}/godot-cpp/gen/ -# key: ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} -# restore-keys: | -# ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} -# ${{ matrix.identifier }}-${{ github.ref }} -# ${{ matrix.identifier }} + - name: Set up SCons cache + uses: actions/cache@v3 + with: + path: | + ${{ github.workspace }}/.scons-cache/ + ${{ github.workspace }}/**/.sconsign.dblite + ${{ github.workspace }}/godot-cpp/gen/ + key: ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} + restore-keys: | + ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }} + ${{ matrix.identifier }}-${{ github.ref }} + ${{ matrix.identifier }} - name: Compile extension shell: sh -# env: -# SCONS_CACHE: '${{ github.workspace }}/.scons-cache/' -# SCONS_CACHE_LIMIT: 8192 + env: + SCONS_CACHE: '${{ github.workspace }}/.scons-cache/' + SCONS_CACHE_LIMIT: 4096 run: | scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' -j2 ls -l project/addons/*/bin/ diff --git a/SConstruct b/SConstruct index 8222b88..3254acb 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,5 @@ #!/usr/bin/env python +import os from glob import glob from pathlib import Path @@ -12,17 +13,16 @@ sources = Glob("src/*.cpp") # Find gdextension path even if the directory or extension is renamed (e.g. project/addons/example/example.gdextension). (extension_path,) = glob("project/addons/*/*.gdextension") -# Find the addon path (e.g. project/addons/example). +# Get the addon path (e.g. project/addons/example). addon_path = Path(extension_path).parent -# Find the project name from the gdextension file (e.g. example). +# Get the project name from the gdextension file (e.g. example). project_name = Path(extension_path).stem -# TODO: Cache is disabled currently. -# scons_cache_path = os.environ.get("SCONS_CACHE") -# if scons_cache_path != None: -# CacheDir(scons_cache_path) -# print("Scons cache enabled... (path: '" + scons_cache_path + "')") +scons_cache_path = os.environ.get("SCONS_CACHE") +if scons_cache_path != None: + CacheDir(scons_cache_path) + print("Scons cache enabled... (path: '" + scons_cache_path + "')") # Create the library target (e.g. libexample.linux.debug.x86_64.so). debug_or_release = "release" if env["target"] == "template_release" else "debug" diff --git a/project/demo/scene.tscn b/project/demo/scene.tscn deleted file mode 100644 index e5622f0..0000000 --- a/project/demo/scene.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://c7u64tpv6byvb"] - -[ext_resource type="Script" path="res://demo/scene.gd" id="1_lih0m"] - -[node name="Scene" type="Node"] -script = ExtResource("1_lih0m") - -[node name="MyNode" type="MyNode" parent="."] diff --git a/project/demo/scene.gd b/project/demo/test.gd similarity index 100% rename from project/demo/scene.gd rename to project/demo/test.gd diff --git a/project/demo/test.tscn b/project/demo/test.tscn new file mode 100644 index 0000000..031820a --- /dev/null +++ b/project/demo/test.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7u64tpv6byvb"] + +[ext_resource type="Script" path="res://demo/test.gd" id="1_b04qc"] + +[node name="Test" type="Node"] +script = ExtResource("1_b04qc") + +[node name="MyNode" type="MyNode" parent="."] diff --git a/project/project.godot b/project/project.godot index d38bd08..1709084 100644 --- a/project/project.godot +++ b/project/project.godot @@ -11,5 +11,5 @@ config_version=5 [application] config/name="project" -run/main_scene="res://demo/scene.tscn" +run/main_scene="res://demo/test.tscn" config/features=PackedStringArray("4.3", "Forward Plus")