From 185406439fda58a4e6e0dc3534f8e6abb9772826 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 5 Jun 2018 21:36:50 -0400 Subject: [PATCH] Setup gclient and presubmit file. This CL adds the necessary files to use gclient and the depot_tools with the SPIRV-Tools directory. This allows doing things like `git cl format` to format code pre-upload and `git cl presubmit -uf` to run presubmit checks over the code. The dependencies are all added to the DEPS file and will be auto-downloaded. They are all pin'd to specific revisions so everyone has the same checkout. Clang is included in the checkout so it will be consistent over usages. Use clang-format --- .clang-format | 1 + .gitignore | 6 ++-- CMakeLists.txt | 2 +- DEPS | 85 +++++++++++++++++++++++++++++++++++++++++++++ PRESUBMIT.py | 49 ++++++++++++++++++++++++++ codereview.settings | 2 ++ 6 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 DEPS create mode 100644 PRESUBMIT.py create mode 100644 codereview.settings diff --git a/.clang-format b/.clang-format index 2b5d4a50..1d43c4ed 100644 --- a/.clang-format +++ b/.clang-format @@ -2,4 +2,5 @@ Language: Cpp BasedOnStyle: Google DerivePointerAlignment: false +SortIncludes: true ... diff --git a/.gitignore b/.gitignore index e5d8db4b..aa12fcc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,15 @@ -/build* +.clang_complete .ycm_extra_conf.py* compile_commands.json +/build* /external/googletest /external/SPIRV-Headers /external/spirv-headers /external/effcee /external/re2 /TAGS -/.clang_complete +/third_party/llvm-build/ +/tools/clang/ /utils/clang-format-diff.py # Vim diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e61db1e..665cf7c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MAT set(COMPILER_IS_LIKE_GNU TRUE) endif() if(${COMPILER_IS_LIKE_GNU}) - set(SPIRV_WARNINGS -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers) + set(SPIRV_WARNINGS -Wall -Wextra -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-self-assign) option(SPIRV_WARN_EVERYTHING "Enable -Weverything" ${SPIRV_WARN_EVERYTHING}) if(${SPIRV_WARN_EVERYTHING}) diff --git a/DEPS b/DEPS new file mode 100644 index 00000000..f2146886 --- /dev/null +++ b/DEPS @@ -0,0 +1,85 @@ +use_relative_paths = True + +vars = { + 'chromium_git': 'https://chromium.googlesource.com', + 'github': 'https://github.com', + + 'buildtools_revision': 'ab7b6a7b350dd15804c87c20ce78982811fdd76f', + 'clang_revision': 'abe5e4f9dc0f1df848c7a0efa05256253e77a7b7', + 'effcee_revision': '04b624799f5a9dbaf3fa1dbed2ba9dce2fc8dcf2', + 'googletest_revision': '98a0d007d7092b72eea0e501bb9ad17908a1a036', + 're2_revision': '6cf8ccd82dbaab2668e9b13596c68183c9ecd13f', + 'spirv_headers_revision': '3ce3e49d73b8abbf2ffe33f829f941fb2a40f552', +} + +deps = { + 'buildtools': + Var('chromium_git') + '/chromium/buildtools.git@' + + Var('buildtools_revision'), + + 'external/spirv-headers': + Var('github') + '/KhronosGroup/SPIRV-Headers.git@' + + Var('spirv_headers_revision'), + + 'external/googletest': + Var('github') + '/google/googletest.git@' + Var('googletest_revision'), + + 'external/effcee': + Var('github') + '/google/effcee.git@' + Var('effcee_revision'), + + 'external/re2': + Var('github') + '/google/re2.git@' + Var('re2_revision'), + + 'tools/clang': + Var('chromium_git') + '/chromium/src/tools/clang@' + Var('clang_revision') +} + +recursedeps = [ + # buildtools provides clang_format, libc++, and libc++api + 'buildtools', +] + +hooks = [ + # Pull clang-format binaries using checked-in hashes. + { + 'name': 'clang_format_win', + 'pattern': '.', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=win32', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', 'SPIRV-Tools/buildtools/win/clang-format.exe.sha1', + ], + }, + { + 'name': 'clang_format_mac', + 'pattern': '.', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=darwin', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', 'SPIRV-Tools/buildtools/mac/clang-format.sha1', + ], + }, + { + 'name': 'clang_format_linux', + 'pattern': '.', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=linux*', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', 'SPIRV-Tools/buildtools/linux64/clang-format.sha1', + ], + }, + { + # Pull clang + 'name': 'clang', + 'pattern': '.', + 'action': ['python', + 'SPIRV-Tools/tools/clang/scripts/update.py' + ], + }, +] diff --git a/PRESUBMIT.py b/PRESUBMIT.py new file mode 100644 index 00000000..2ccee9bb --- /dev/null +++ b/PRESUBMIT.py @@ -0,0 +1,49 @@ +# Copyright (c) 2018 The Khronos Group Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Presubmit script for SPIRV-Tools. + +See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts +for more details about the presubmit API built into depot_tools. +""" + +LINT_FILTERS = [ + "-build/include", + "-build/include_order", + "-build/include_what_you_use", + "-build/namespaces", + "-readability/braces", + "-readability/casting", + "-readability/fn_size", + "-readability/todo", + "-runtime/explicit", + "-runtime/references", + "-whitespace/blank_line", + "-whitespace/ending_newline", + "-whitespace/line_length", + "-whitespace/newline", + "-whitespace/operators", + "-whitespace/parens", + "-whitespace/semicolon", + "-whitespace/todo" +] + + +def CheckChangeOnUpload(input_api, output_api): + results = [] + results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) + results += input_api.canned_checks.CheckChangeLintsClean( + input_api, output_api, None, LINT_FILTERS) + + return results diff --git a/codereview.settings b/codereview.settings new file mode 100644 index 00000000..ef84cf85 --- /dev/null +++ b/codereview.settings @@ -0,0 +1,2 @@ +# This file is used by git cl to get repository specific information. +CODE_REVIEW_SERVER: github.com