diff --git a/.azure-pipelines/build_jobs.yml b/.azure-pipelines/build_jobs.yml index 3bbb25d20..1f2276e06 100644 --- a/.azure-pipelines/build_jobs.yml +++ b/.azure-pipelines/build_jobs.yml @@ -116,7 +116,7 @@ jobs: # Use the specified version of Python from the tool cache - task: UsePythonVersion@0 inputs: - versionSpec: '3.9' + versionSpec: '3.9' - task: PythonScript@0 displayName: Move artifact contents inputs: diff --git a/.azure-pipelines/check_file_format.yml b/.azure-pipelines/check_file_format.yml new file mode 100644 index 000000000..8b5d1ace7 --- /dev/null +++ b/.azure-pipelines/check_file_format.yml @@ -0,0 +1,24 @@ +# Copyright (c) 2020 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 +jobs: +- job: check_file_format + displayName: 'Check file formatting' + pool: + vmImage: 'ubuntu-20.04' + container: khronosgroup/docker-images:openxr-sdk + steps: + - script: sudo apt-get install -qq dos2unix recode + displayName: Install dependencies + - script: ./file_format.sh + displayName: File formatting checks (file_format.sh) + + - script: git diff --patch --exit-code > file_format.patch + displayName: Save changes as diff + - script: echo "The following files need file formatting:"; sed -n -e "s/^diff.* b\///p" file_format.patch + condition: failed() + - task: PublishPipelineArtifact@1 + displayName: Publish diff + condition: failed() + inputs: + path: $(System.DefaultWorkingDirectory)/file_format.patch + artifact: file_format_changes diff --git a/file_format.sh b/file_format.sh new file mode 100755 index 000000000..7d5394aaf --- /dev/null +++ b/file_format.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Copyright (c) 2020 The Khronos Group Inc. +# SPDX-License-Identifier: Apache-2.0 + +# This script ensures proper POSIX text file formatting and a few other things. +# This is supplementary to clang-format. + +# We need dos2unix and recode. +if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then + printf "Install 'dos2unix' and 'recode' to use this script.\n" +fi + +set -e -uo pipefail +IFS=$'\n\t' + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude some files. + if [[ "$f" == "external"* ]]; then + continue + elif [[ "$f" == "src/external"* ]]; then + continue + fi + # Ensure that files are UTF-8 formatted. + recode UTF-8 "$f" 2> /dev/null + # Ensure that files have LF line endings and do not contain a BOM. + dos2unix "$f" 2> /dev/null + # Remove trailing space characters and ensures that files end + # with newline characters. -l option handles newlines conveniently. + perl -i -ple 's/\s*$//g' "$f" +done + +# If no patch has been generated all is OK, clean up, and exit. +if git diff --exit-code > patch.patch; then + printf "Files in this commit comply with the formatting 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 '\n" +rm -f patch.patch +exit 1 diff --git a/specification/registry/xr.xml b/specification/registry/xr.xml index 6b4b1bd09..59b68a589 100644 --- a/specification/registry/xr.xml +++ b/specification/registry/xr.xml @@ -3528,7 +3528,7 @@ maintained in the default branch of the Khronos OpenXR GitHub project. - + @@ -3570,14 +3570,14 @@ maintained in the default branch of the Khronos OpenXR GitHub project. - + - + diff --git a/specification/scripts/docgenerator.py b/specification/scripts/docgenerator.py index 5bd5345f2..3ce4d1e25 100644 --- a/specification/scripts/docgenerator.py +++ b/specification/scripts/docgenerator.py @@ -291,7 +291,7 @@ def genStructBody(self, typeinfo, typeName): body += ';\n' body += '} ' + typeName + ';' return body - + def genStruct(self, typeinfo, typeName, alias): """Generate struct.""" OutputGenerator.genStruct(self, typeinfo, typeName, alias) diff --git a/src/scripts/validation_layer_generator.py b/src/scripts/validation_layer_generator.py index 308fd5f1b..6f9ca4dcc 100644 --- a/src/scripts/validation_layer_generator.py +++ b/src/scripts/validation_layer_generator.py @@ -501,7 +501,7 @@ def outputValidationSourceNextChainFunc(self): continue if struct_tuple.protect_value: next_chain_info += '#if %s\n' % struct_tuple.protect_string - + next_chain_info += self.writeIndent(2) next_chain_info += 'case %s:\n' % cur_value.name next_chain_info += self.writeIndent(3)