Merge pull request #502 from Zylann/clang_format_ci
Re-added clang-format checks to the CIpull/507/head
commit
925a47f65b
|
@ -124,3 +124,18 @@ jobs:
|
||||||
name: godot-cpp-macos-x86_64-release
|
name: godot-cpp-macos-x86_64-release
|
||||||
path: bin/libgodot-cpp.osx.release.64.a
|
path: bin/libgodot-cpp.osx.release.64.a
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
static-checks:
|
||||||
|
name: Static Checks (clang-format)
|
||||||
|
runs-on: ubuntu-16.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2.3.4
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get install clang-format-8
|
||||||
|
|
||||||
|
- name: Style checks via clang-format
|
||||||
|
run: |
|
||||||
|
bash ./misc/scripts/clang_format.sh
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#define CAMERA_MATRIX_H
|
#define CAMERA_MATRIX_H
|
||||||
|
|
||||||
#include "Defs.hpp"
|
#include "Defs.hpp"
|
||||||
|
#include "Math.hpp"
|
||||||
#include "Plane.hpp"
|
#include "Plane.hpp"
|
||||||
#include "Rect2.hpp"
|
#include "Rect2.hpp"
|
||||||
#include "Transform.hpp"
|
#include "Transform.hpp"
|
||||||
#include "Math.hpp"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -39,12 +39,10 @@ struct CameraMatrix {
|
||||||
void set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov = false);
|
void set_frustum(real_t p_size, real_t p_aspect, Vector2 p_offset, real_t p_near, real_t p_far, bool p_flip_fov = false);
|
||||||
|
|
||||||
static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
|
static real_t get_fovy(real_t p_fovx, real_t p_aspect) {
|
||||||
|
|
||||||
return Math::rad2deg(atan(p_aspect * tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0);
|
return Math::rad2deg(atan(p_aspect * tan(Math::deg2rad(p_fovx) * 0.5)) * 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline double absd(double g) {
|
static inline double absd(double g) {
|
||||||
|
|
||||||
union {
|
union {
|
||||||
double d;
|
double d;
|
||||||
uint64_t i;
|
uint64_t i;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "OS.hpp"
|
#include "OS.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
|
||||||
class FunctionProfiling {
|
class FunctionProfiling {
|
||||||
|
@ -23,7 +22,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace godot
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
#define GODOT_PROFILING_FUNCTION FunctionProfiling __function_profiling(__FUNCTION__, __LINE__);
|
#define GODOT_PROFILING_FUNCTION FunctionProfiling __function_profiling(__FUNCTION__, __LINE__);
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# This script runs clang-format on all relevant files in the repo.
|
||||||
|
# This is the primary script responsible for fixing style violations.
|
||||||
|
|
||||||
|
set -uo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
CLANG_FORMAT_FILE_EXTS=(".c" ".h" ".cpp" ".hpp" ".cc" ".hh" ".cxx" ".m" ".mm" ".inc" ".java" ".glsl")
|
||||||
|
|
||||||
|
# Loops through all text files tracked by Git.
|
||||||
|
git grep -zIl '' |
|
||||||
|
while IFS= read -rd '' f; do
|
||||||
|
# Exclude some files.
|
||||||
|
if [[ "$f" == "thirdparty"* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do
|
||||||
|
if [[ "$f" == *"$extension" ]]; then
|
||||||
|
# Run clang-format.
|
||||||
|
clang-format -i "$f"
|
||||||
|
continue 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
git diff > patch.patch
|
||||||
|
|
||||||
|
# If no patch has been generated all is OK, clean up, and exit.
|
||||||
|
if [ ! -s patch.patch ] ; then
|
||||||
|
printf "Files in this commit comply with the clang-format style rules.\n"
|
||||||
|
rm -f patch.patch
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# A patch has been created, notify the user, clean up, and exit.
|
||||||
|
printf "\n*** The following differences were found between the code "
|
||||||
|
printf "and the formatting rules:\n\n"
|
||||||
|
cat patch.patch
|
||||||
|
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
||||||
|
rm -f patch.patch
|
||||||
|
exit 1
|
|
@ -1,48 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
CLANG_FORMAT=clang-format-8
|
|
||||||
|
|
||||||
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
|
||||||
# Travis only clones the PR branch and uses its HEAD commit as detached HEAD,
|
|
||||||
# so it's problematic when we want an exact commit range for format checks.
|
|
||||||
# We fetch upstream to ensure that we have the proper references to resolve.
|
|
||||||
# Ideally we would use $TRAVIS_COMMIT_RANGE but it doesn't play well with PR
|
|
||||||
# updates, as it only includes changes since the previous state of the PR.
|
|
||||||
if [ -z "$(git remote | grep upstream)" ]; then
|
|
||||||
git remote add upstream https://github.com/godotengine/godot-cpp \
|
|
||||||
--no-tags -f -t $TRAVIS_BRANCH
|
|
||||||
fi
|
|
||||||
RANGE="upstream/$TRAVIS_BRANCH HEAD"
|
|
||||||
else
|
|
||||||
# Test only the last commit, since $TRAVIS_COMMIT_RANGE wouldn't support
|
|
||||||
# force pushes.
|
|
||||||
RANGE=HEAD
|
|
||||||
fi
|
|
||||||
|
|
||||||
FILES=$(git diff-tree --no-commit-id --name-only -r $RANGE | grep -E "\.(c|h|cpp|hpp|cc|hh|cxx|m|mm|inc|java|glsl)$")
|
|
||||||
echo "Checking files:\n$FILES"
|
|
||||||
|
|
||||||
# create a random filename to store our generated patch
|
|
||||||
prefix="static-check-clang-format"
|
|
||||||
suffix="$(date +%s)"
|
|
||||||
patch="/tmp/$prefix-$suffix.patch"
|
|
||||||
|
|
||||||
for file in $FILES; do
|
|
||||||
"$CLANG_FORMAT" -style=file "$file" | \
|
|
||||||
diff -u "$file" - | \
|
|
||||||
sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
|
|
||||||
done
|
|
||||||
|
|
||||||
# if no patch has been generated all is ok, clean up the file stub and exit
|
|
||||||
if [ ! -s "$patch" ] ; then
|
|
||||||
printf "Files in this commit comply with the clang-format rules.\n"
|
|
||||||
rm -f "$patch"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# a patch has been created, notify the user and exit
|
|
||||||
printf "\n*** The following differences were found between the code to commit "
|
|
||||||
printf "and the clang-format rules:\n\n"
|
|
||||||
cat "$patch"
|
|
||||||
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
|
|
||||||
exit 1
|
|
Loading…
Reference in New Issue