diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 08cc93e0c94..37f8983a07d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -59,7 +59,7 @@ jobs: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' sudo apt-get update - sudo apt-get install -y clang-format-16 ccache e2fsprogs gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip + sudo apt-get install -y clang-format-16 ccache e2fsprogs gcc-12 g++-12 libstdc++-12-dev libmpfr-dev libmpc-dev ninja-build optipng qemu-utils qemu-system-i386 unzip generate-ninja if ${{ matrix.arch == 'aarch64' }}; then # FIXME: Remove this when we no longer build our own Qemu binary. sudo apt-get install libgtk-3-dev libpixman-1-dev libsdl2-dev libslirp-dev @@ -72,7 +72,7 @@ jobs: python -m pip install --upgrade pip pip install flake8 requests - name: Check versions - run: set +e; g++ --version; g++-12 --version; clang-format --version; clang-format-16 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version + run: set +e; g++ --version; g++-12 --version; clang-format --version; clang-format-16 --version; prettier --version; python --version; python3 --version; ninja --version; flake8 --version; ccache --version; qemu-system-i386 --version; gn --version # === PREPARE FOR BUILDING === diff --git a/Meta/lint-ci.sh b/Meta/lint-ci.sh index ee5938d0ec4..e60aa774f35 100755 --- a/Meta/lint-ci.sh +++ b/Meta/lint-ci.sh @@ -29,6 +29,7 @@ for cmd in \ Meta/check-style.py \ Meta/lint-executable-resources.sh \ Meta/lint-gml-format.sh \ + Meta/lint-gn.sh \ Meta/lint-keymaps.py \ Meta/lint-prettier.sh \ Meta/lint-python.sh \ diff --git a/Meta/lint-gn.sh b/Meta/lint-gn.sh new file mode 100755 index 00000000000..bf43fbb5704 --- /dev/null +++ b/Meta/lint-gn.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P) +cd "${script_path}/.." || exit 1 + +if [ "$#" -eq "0" ]; then + mapfile -t files < <( + git ls-files '*.gn' '*.gni' + ) +else + files=() + for file in "$@"; do + if [[ "${file}" == *".gn" ]] || [[ "${file}" == *".gni" ]]; then + files+=("${file}") + fi + done +fi + +if (( ${#files[@]} )); then + if ! command -v gn >/dev/null 2>&1 ; then + echo "gn is not available, but gn files need linting! Either skip this script, or install gn." + exit 1 + fi + gn format "${files[@]}" +else + echo "No .gn or .gni files to check." +fi