Skip to content

Commit a4f9d22

Browse files
authored
Merge pull request #1529 from dsnopek/4.1-cherrypicks-12
Cherry-picks for the godot-cpp 4.1 branch - 12th batch
2 parents 2e7f551 + 7dd2d24 commit a4f9d22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+739
-1101
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = tab
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[{*.py,SConstruct}]
12+
indent_style = space
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2
16+
indent_style = space

.gitattributes

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
1-
*.c eol=lf
2-
*.cpp eol=lf
3-
*.gd eol=lf
4-
*.tscn eol=lf
5-
*.cfg eol=lf
6-
*.godot eol=lf
1+
# Normalize EOL for all files that Git considers text files
2+
* text=auto eol=lf

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
cache-name: windows-x86_64-mingw
5555

5656
- name: 🍎 macOS (universal)
57-
os: macos-11
57+
os: macos-latest
5858
platform: macos
5959
artifact-name: godot-cpp-macos-universal-release
6060
artifact-path: bin/libgodot-cpp.macos.template_release.universal.a
@@ -72,7 +72,7 @@ jobs:
7272
cache-name: android-arm64
7373

7474
- name: 🍏 iOS (arm64)
75-
os: macos-11
75+
os: macos-latest
7676
platform: ios
7777
artifact-name: godot-cpp-ios-arm64-release
7878
artifact-path: bin/libgodot-cpp.ios.template_release.arm64.a

.github/workflows/static_checks.yml

+21-42
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,27 @@ concurrency:
77

88
jobs:
99
static-checks:
10-
name: Format (clang-format, black format, file format)
11-
runs-on: ubuntu-20.04
10+
name: Format (clang-format, ruff format, file format)
11+
runs-on: ubuntu-22.04
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v4
15-
16-
# Azure repositories are not reliable, we need to prevent Azure giving us packages.
17-
- name: Make apt sources.list use the default Ubuntu repositories
18-
run: |
19-
sudo rm -f /etc/apt/sources.list.d/*
20-
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
21-
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
22-
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"
23-
sudo apt-get update
24-
25-
- name: Install dependencies
26-
run: |
27-
sudo apt-get install -qq dos2unix recode clang-format-15 libxml2-utils python3-pip moreutils
28-
sudo update-alternatives --remove-all clang-format || true
29-
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100
30-
sudo pip3 install black==22.3.0 pygments pytest==7.1.2 mypy==0.971
31-
32-
- name: File formatting checks (file_format.sh)
33-
run: |
34-
bash ./misc/scripts/file_format.sh
35-
36-
- name: Header guards formatting checks (header_guards.sh)
37-
run: |
38-
bash ./misc/scripts/header_guards.sh
39-
40-
- name: Python style checks via black (black_format.sh)
41-
run: |
42-
bash ./misc/scripts/black_format.sh
43-
44-
- name: Python scripts static analysis (mypy_check.sh)
45-
run: |
46-
bash ./misc/scripts/mypy_check.sh
47-
48-
- name: Bindings generation checks (ensures get_file_list returns all generated files)
49-
run: |
50-
python ./misc/scripts/check_get_file_list.py
51-
52-
- name: Style checks via clang-format (clang_format.sh)
53-
run: |
54-
bash ./misc/scripts/clang_format.sh
15+
with:
16+
fetch-depth: 2
17+
18+
- name: Get changed files
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: |
22+
if [ "${{ github.event_name }}" == "pull_request" ]; then
23+
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
24+
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
25+
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
26+
fi
27+
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
28+
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
29+
30+
- name: Style checks via pre-commit
31+
uses: pre-commit/action@v3.0.1
32+
with:
33+
extra_args: --verbose --hook-stage manual --files ${{ env.CHANGED_FILES }}

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
include/gen
99
src/gen
1010

11-
# Build configuarion.
11+
# Build configuration.
1212
/custom.py
1313

1414
# Misc

.pre-commit-config.yaml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
default_language_version:
2+
python: python3
3+
4+
exclude: |
5+
(?x)^(
6+
gdextension/extension_api\.json|
7+
gdextension/gdextension_interface\.h
8+
)$
9+
10+
repos:
11+
- repo: https://github.com/pre-commit/mirrors-clang-format
12+
rev: v17.0.6
13+
hooks:
14+
- id: clang-format
15+
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.4.4
18+
hooks:
19+
- id: ruff
20+
args: [--fix]
21+
- id: ruff-format
22+
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v0.971
25+
hooks:
26+
- id: mypy
27+
files: \.py$
28+
types_or: [text]
29+
30+
- repo: https://github.com/codespell-project/codespell
31+
rev: v2.3.0
32+
hooks:
33+
- id: codespell
34+
additional_dependencies: [tomli]
35+
36+
- repo: local
37+
hooks:
38+
- id: copyright-headers
39+
name: copyright-headers
40+
language: python
41+
entry: python misc/scripts/copyright_headers.py
42+
files: \.(c|h)pp$
43+
exclude: ^test/
44+
45+
- id: header-guards
46+
name: header-guards
47+
language: python
48+
entry: python misc/scripts/header_guards.py
49+
files: \.hpp$
50+
exclude: ^test/
51+
52+
- id: file-format
53+
name: file-format
54+
language: python
55+
entry: python misc/scripts/file_format.py
56+
types_or: [text]
57+
58+
- id: check-get-file-list
59+
name: check-get-file-list
60+
language: python
61+
entry: python misc/scripts/check_get_file_list.py
62+
pass_filenames: false
63+
always_run: true
64+
stages: [manual]

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# godot-cpp cmake arguments
55
# GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file
6-
# GODOT_CPP_SYSTEM_HEADERS Mark the header files as SYSTEM. This may be useful to supress warnings in projects including this one.
6+
# GODOT_CPP_SYSTEM_HEADERS Mark the header files as SYSTEM. This may be useful to suppress warnings in projects including this one.
77
# GODOT_CPP_WARNING_AS_ERROR Treat any warnings as errors
88
# GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)
99
# FLOAT_PRECISION: Floating-point precision level ("single", "double")

SConstruct

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
#!/usr/bin/env python
22

33
import os
4-
import platform
5-
import sys
6-
import subprocess
7-
from binding_generator import scons_generate_bindings, scons_emit_files
8-
94

105
EnsureSConsVersion(4, 0)
116

127

138
try:
149
Import("env")
15-
except:
10+
except Exception:
1611
# Default tools with no platform defaults to gnu toolchain.
1712
# We apply platform specific toolchains via our custom tools.
1813
env = Environment(tools=["default"], PLATFORM="")
@@ -23,7 +18,7 @@ env.PrependENVPath("PATH", os.getenv("PATH"))
2318
customs = ["custom.py"]
2419
try:
2520
customs += Import("customs")
26-
except:
21+
except Exception:
2722
pass
2823
profile = ARGUMENTS.get("profile", "")
2924
if profile:

0 commit comments

Comments
 (0)