summaryrefslogtreecommitdiffstats
path: root/misc/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'misc/scripts')
-rwxr-xr-xmisc/scripts/header_guards.py37
-rwxr-xr-xmisc/scripts/validate_extension_api.sh5
2 files changed, 32 insertions, 10 deletions
diff --git a/misc/scripts/header_guards.py b/misc/scripts/header_guards.py
index b554be5159..fed418db1e 100755
--- a/misc/scripts/header_guards.py
+++ b/misc/scripts/header_guards.py
@@ -8,22 +8,38 @@ if len(sys.argv) < 2:
print("Invalid usage of header_guards.py, it should be called with a path to one or multiple files.")
sys.exit(1)
-HEADER_CHECK_OFFSET = 30
-HEADER_BEGIN_OFFSET = 31
-HEADER_END_OFFSET = -1
-
changed = []
invalid = []
for file in sys.argv[1:]:
- with open(file, "rt", encoding="utf-8", newline="\n") as f:
+ header_start = -1
+ HEADER_CHECK_OFFSET = -1
+
+ with open(file.strip(), "rt", encoding="utf-8", newline="\n") as f:
lines = f.readlines()
- if len(lines) <= HEADER_BEGIN_OFFSET:
- continue # Most likely a dummy file.
+ for idx, line in enumerate(lines):
+ sline = line.strip()
+
+ if header_start < 0:
+ if sline == "": # Skip empty lines at the top.
+ continue
+
+ if sline.startswith("/**********"): # Godot header starts this way.
+ header_start = idx
+ else:
+ HEADER_CHECK_OFFSET = 0 # There is no Godot header.
+ break
+ else:
+ if not sline.startswith("*") and not sline.startswith("/*"): # Not in the Godot header anymore.
+ HEADER_CHECK_OFFSET = idx + 1 # The include should be two lines below the Godot header.
+ break
+
+ if HEADER_CHECK_OFFSET < 0:
+ continue
- if lines[HEADER_CHECK_OFFSET].startswith("#import"):
- continue # Early catch obj-c file.
+ HEADER_BEGIN_OFFSET = HEADER_CHECK_OFFSET + 1
+ HEADER_END_OFFSET = len(lines) - 1
split = file.split("/") # Already in posix-format.
@@ -82,6 +98,9 @@ for file in sys.argv[1:]:
objc = False
for idx, line in enumerate(lines):
+ if line.startswith("// #import"): # Some dummy obj-c files only have commented out import lines.
+ objc = True
+ break
if not line.startswith("#"):
continue
elif line.startswith("#ifndef") and header_check == -1:
diff --git a/misc/scripts/validate_extension_api.sh b/misc/scripts/validate_extension_api.sh
index cde7a8574d..1d64883541 100755
--- a/misc/scripts/validate_extension_api.sh
+++ b/misc/scripts/validate_extension_api.sh
@@ -8,6 +8,7 @@ fi
if [ $# != 1 ]; then
echo "Usage: @0 <path-to-godot-executable>"
+ exit 1
fi
api_validation_dir="$( dirname -- "$( dirname -- "${BASH_SOURCE[0]//\.\//}" )" )/extension_api_validation/"
@@ -70,7 +71,9 @@ while read -r file; do
obsolete_validation_error="$(comm -13 "$validation_output" "$allowed_errors")"
if [ -n "$obsolete_validation_error" ] && [ "$warn_extra" = "1" ]; then
- make_annotation "The following validation errors no longer occur (compared to $reference_tag):" "$obsolete_validation_error" warning "$file"
+ #make_annotation "The following validation errors no longer occur (compared to $reference_tag):" "$obsolete_validation_error" warning "$file"
+ echo "The following validation errors no longer occur (compared to $reference_tag):"
+ echo "$obsolete_validation_error"
fi
if [ -n "$new_validation_error" ]; then
make_annotation "Compatibility to $reference_tag is broken in the following ways:" "$new_validation_error" error "$file"