mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Merge pull request #2806 from Ms2ger/tidy
Improve and extend tidy.py, and run it on Travis.
This commit is contained in:
commit
8cf004e28a
14 changed files with 138 additions and 136 deletions
|
@ -14,24 +14,18 @@ license0="""\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
license1="""\
|
license1="""\
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
license2="""\
|
license2="""\
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
"""
|
|
||||||
|
|
||||||
license3="""\
|
|
||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
license4 = """\
|
license3 = """\
|
||||||
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
||||||
// file at the top-level directory of this distribution.
|
// file at the top-level directory of this distribution.
|
||||||
//
|
//
|
||||||
|
@ -42,7 +36,7 @@ license4 = """\
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
license5 = """\
|
license4 = """\
|
||||||
# Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
# Copyright 2013 The Servo Project Developers. See the COPYRIGHT
|
||||||
# file at the top-level directory of this distribution.
|
# file at the top-level directory of this distribution.
|
||||||
#
|
#
|
||||||
|
@ -53,7 +47,7 @@ license5 = """\
|
||||||
# except according to those terms.
|
# except according to those terms.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
licenses = [license0, license1, license2, license3, license4, license5]
|
licenses = [license0, license1, license2, license3, license4]
|
||||||
|
|
||||||
exceptions = [
|
exceptions = [
|
||||||
"rust-http-client/http_parser.c", # BSD, Joyent
|
"rust-http-client/http_parser.c", # BSD, Joyent
|
||||||
|
|
|
@ -9,37 +9,54 @@
|
||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import fileinput, sys, os
|
import os
|
||||||
from licenseck import *
|
import sys
|
||||||
|
from licenseck import check_license
|
||||||
|
|
||||||
err = 0
|
err = 0
|
||||||
|
|
||||||
|
|
||||||
def report_error_name_no(name, no, s):
|
def report_error_name_no(name, no, s):
|
||||||
global err
|
global err
|
||||||
print("%s:%d: %s" % (name, no, s))
|
print("%s:%d: %s" % (name, no, s))
|
||||||
err = 1
|
err = 1
|
||||||
|
|
||||||
def report_err(s):
|
|
||||||
report_error_name_no(fileinput.filename(), fileinput.filelineno(), s)
|
|
||||||
|
|
||||||
def report_warn(s):
|
|
||||||
print("%s:%d: %s" % (fileinput.filename(),
|
|
||||||
fileinput.filelineno(),
|
|
||||||
s))
|
|
||||||
|
|
||||||
def do_license_check(name, contents):
|
def do_license_check(name, contents):
|
||||||
if not check_license(name, contents):
|
if not check_license(name, contents):
|
||||||
report_error_name_no(name, 1, "incorrect license")
|
report_error_name_no(name, 1, "incorrect license")
|
||||||
|
|
||||||
|
|
||||||
|
def do_whitespace_check(name, contents):
|
||||||
|
for idx, line in enumerate(contents):
|
||||||
|
if line[-1] == "\n":
|
||||||
|
line = line[:-1]
|
||||||
|
else:
|
||||||
|
report_error_name_no(name, idx + 1, "No newline at EOF")
|
||||||
|
|
||||||
|
if line.endswith(' '):
|
||||||
|
report_error_name_no(name, idx + 1, "trailing whitespace")
|
||||||
|
|
||||||
|
if '\t' in line:
|
||||||
|
report_error_name_no(name, idx + 1, "tab on line")
|
||||||
|
|
||||||
|
if '\r' in line:
|
||||||
|
report_error_name_no(name, idx + 1, "CR on line")
|
||||||
|
|
||||||
|
|
||||||
exceptions = [
|
exceptions = [
|
||||||
"src/support", # Upstream
|
# Upstream
|
||||||
"src/platform", # Upstream
|
"src/support",
|
||||||
"src/compiler", # Upstream
|
"src/platform",
|
||||||
"src/components/main/dom/bindings/codegen", # Generated and upstream code combined with our own. Could use cleanup
|
"src/compiler",
|
||||||
"src/components/script/dom/bindings/codegen", # Generated and upstream code combined with our own. Could use cleanup
|
"src/test/wpt/web-platform-tests",
|
||||||
"src/test/wpt/web-platform-tests", # Upstream
|
|
||||||
|
# Generated and upstream code combined with our own. Could use cleanup
|
||||||
|
"src/components/script/dom/bindings/codegen",
|
||||||
|
"src/components/style/properties/mod.rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def should_check(name):
|
def should_check(name):
|
||||||
if ".#" in name:
|
if ".#" in name:
|
||||||
return False
|
return False
|
||||||
|
@ -55,6 +72,7 @@ def should_check(name):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
file_names = []
|
file_names = []
|
||||||
for root, dirs, files in os.walk(sys.argv[1]):
|
for root, dirs, files in os.walk(sys.argv[1]):
|
||||||
for myfile in files:
|
for myfile in files:
|
||||||
|
@ -62,20 +80,10 @@ for root, dirs, files in os.walk(sys.argv[1]):
|
||||||
if should_check(file_name):
|
if should_check(file_name):
|
||||||
file_names.append(file_name)
|
file_names.append(file_name)
|
||||||
|
|
||||||
current_name = ""
|
for path in file_names:
|
||||||
current_contents = ""
|
with open(path, "r") as fp:
|
||||||
|
lines = fp.readlines()
|
||||||
for line in fileinput.input(file_names):
|
do_license_check(path, "".join(lines))
|
||||||
if fileinput.isfirstline() and current_name != "":
|
do_whitespace_check(path, lines)
|
||||||
do_license_check(current_name, current_contents)
|
|
||||||
|
|
||||||
if fileinput.isfirstline():
|
|
||||||
current_name = fileinput.filename()
|
|
||||||
current_contents = ""
|
|
||||||
|
|
||||||
current_contents += line
|
|
||||||
|
|
||||||
if current_name != "":
|
|
||||||
do_license_check(current_name, current_contents)
|
|
||||||
|
|
||||||
sys.exit(err)
|
sys.exit(err)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
import sys, os, argparse
|
import sys, os, argparse
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
cd build
|
cd build
|
||||||
../configure
|
../configure
|
||||||
make -j2 && make check-servo
|
make tidy && make -j2 && make check-servo
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
cd build
|
cd build
|
||||||
../configure
|
../configure
|
||||||
make -j2 && make check-servo && make check-content && make check-ref-cpu
|
make tidy && make -j2 && make check-servo && make check-content && make check-ref-cpu
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue