Commit f35f1110 by Jiacheng Lu Committed by Commit Bot

Add script to apply clang-format on all sources

1. python script wrapper to call clang-format over the whole code base 2. Add clang-format rule `IncludeBlocks: Preserve` to tell clang-format do not merge include blocks 3. Fix existed clang-format issue in code base Bug: angleproject:3532 Change-Id: I289292dc62c2784ff21688065c87c3f3f5538f17 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1709720Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent fb5c581d
...@@ -15,6 +15,8 @@ ColumnLimit: 100 ...@@ -15,6 +15,8 @@ ColumnLimit: 100
# Always break before braces # Always break before braces
BreakBeforeBraces: Custom BreakBeforeBraces: Custom
BraceWrapping: BraceWrapping:
# TODO(lujc) wait for clang-format-9 support in Chromium tools
# AfterCaseLabel: true
AfterClass: true AfterClass: true
AfterControlStatement: true AfterControlStatement: true
AfterEnum: true AfterEnum: true
...@@ -53,3 +55,6 @@ KeepEmptyLinesAtTheStartOfBlocks: true ...@@ -53,3 +55,6 @@ KeepEmptyLinesAtTheStartOfBlocks: true
# Indent nested PP directives. # Indent nested PP directives.
IndentPPDirectives: AfterHash IndentPPDirectives: AfterHash
# Include blocks style
IncludeBlocks: Preserve
#!/usr/bin/env python
# Copyright 2019 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# apply_clang_format_on_all_sources.py:
# Script to apply clang-format recursively on directory,
# example usage:
# ./scripts/apply_clang_format_on_all_sources.py src
from __future__ import print_function
import os
import sys
import platform
import subprocess
# inplace change and use style from .clang-format
CLANG_FORMAT_ARGS = ['-i', '-style=file']
def main(directory):
system = platform.system()
clang_format_exe = 'clang-format'
if system == 'Windows':
clang_format_exe += '.bat'
partial_cmd = [clang_format_exe] + CLANG_FORMAT_ARGS
for subdir, _, files in os.walk(directory):
if 'third_party' in subdir:
continue
for f in files:
if f.endswith(('.c', '.h', '.cpp', '.hpp')):
f_abspath = os.path.join(subdir, f)
print("Applying clang-format on ", f_abspath)
subprocess.check_call(partial_cmd + [f_abspath])
if __name__ == '__main__':
if len(sys.argv) > 2:
print('Too mang args', file=sys.stderr)
elif len(sys.argv) == 2:
main(os.path.join(os.getcwd(), sys.argv[1]))
else:
main(os.getcwd())
...@@ -13,7 +13,8 @@ template <typename outType> ...@@ -13,7 +13,8 @@ template <typename outType>
inline outType *DynamicCastComObject(IUnknown *object) inline outType *DynamicCastComObject(IUnknown *object)
{ {
outType *outObject = nullptr; outType *outObject = nullptr;
HRESULT result = object->QueryInterface(__uuidof(outType), reinterpret_cast<void**>(&outObject)); HRESULT result =
object->QueryInterface(__uuidof(outType), reinterpret_cast<void **>(&outObject));
if (SUCCEEDED(result)) if (SUCCEEDED(result))
{ {
return outObject; return outObject;
......
...@@ -14,21 +14,13 @@ ...@@ -14,21 +14,13 @@
using namespace angle; using namespace angle;
SphereGeometry::SphereGeometry() SphereGeometry::SphereGeometry() {}
{
}
SphereGeometry::~SphereGeometry() SphereGeometry::~SphereGeometry() {}
{
}
CubeGeometry::CubeGeometry() CubeGeometry::CubeGeometry() {}
{
}
CubeGeometry::~CubeGeometry() CubeGeometry::~CubeGeometry() {}
{
}
void CreateSphereGeometry(size_t sliceCount, float radius, SphereGeometry *result) void CreateSphereGeometry(size_t sliceCount, float radius, SphereGeometry *result)
{ {
......
...@@ -70,7 +70,7 @@ bool StabilizeCPUForBenchmarking() ...@@ -70,7 +70,7 @@ bool StabilizeCPUForBenchmarking()
"default priority"); "default priority");
success = false; success = false;
} }
#if ANGLE_PLATFORM_LINUX # if ANGLE_PLATFORM_LINUX
cpu_set_t affinity; cpu_set_t affinity;
CPU_SET(0, &affinity); CPU_SET(0, &affinity);
errno = 0; errno = 0;
...@@ -81,9 +81,9 @@ bool StabilizeCPUForBenchmarking() ...@@ -81,9 +81,9 @@ bool StabilizeCPUForBenchmarking()
"default affinity"); "default affinity");
success = false; success = false;
} }
#else # else
// TODO(jmadill): Implement for non-linux. http://anglebug.com/2923 // TODO(jmadill): Implement for non-linux. http://anglebug.com/2923
#endif # endif
return success; return success;
#else // defined(ANGLE_PLATFORM_FUCHSIA) #else // defined(ANGLE_PLATFORM_FUCHSIA)
......
...@@ -24,13 +24,9 @@ RNG::RNG() ...@@ -24,13 +24,9 @@ RNG::RNG()
} }
// Seed from fixed number. // Seed from fixed number.
RNG::RNG(unsigned int seed) : mGenerator(seed) RNG::RNG(unsigned int seed) : mGenerator(seed) {}
{
}
RNG::~RNG() RNG::~RNG() {}
{
}
void RNG::reseed(unsigned int newSeed) void RNG::reseed(unsigned int newSeed)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment