Add license checking (#1353)

It's stated in the Guidelines that all contributions must be under
the Apache License 2.0. To avoid potential mistakes from manual
reviews, this patch adds the check-license.py script to
automatically check all source files for license headers.

Travis CI is also configured to run the check.

Fallout: it turned out that some files already in the code base
either miss a license header or have some minor typo differences.
The patch fixes up some of these deficiences.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2016-09-21 16:15:57 +02:00
committed by GitHub
parent 454d3af951
commit 70cd3d3184
13 changed files with 165 additions and 13 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ dist: trusty
sudo: required
env:
- OPTS="--check-signed-off-travis --check-cppcheck --check-vera"
- OPTS="--check-signed-off-travis --check-cppcheck --check-vera --check-license"
- OPTS="--jerry-tests --jerry-test-suite"
- OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300 INSTALL_QEMU_ARM=yes
- OPTS=--buildoption-test
+1 -1
View File
@@ -1,6 +1,6 @@
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* 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
+16
View File
@@ -1,3 +1,19 @@
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* 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.
*/
var check = 1;
function blink ()
+15
View File
@@ -1,3 +1,18 @@
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
*
* 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.
*/
function sysloop (ticknow)
{
blink ();
+2 -3
View File
@@ -1,5 +1,4 @@
/*
* Copyright (c) 2016 Linaro
/* Copyright (c) 2016 Linaro
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -8,7 +7,7 @@
* 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,
* 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.
+2 -3
View File
@@ -1,5 +1,4 @@
/*
* Copyright (c) 2016 Linaro
/* Copyright (c) 2016 Linaro
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -8,7 +7,7 @@
* 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,
* 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.
+1 -1
View File
@@ -4,7 +4,7 @@
* 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
* 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
+3 -3
View File
@@ -1,14 +1,14 @@
// Copyright 2015 Samsung Electronics Co., Ltd.
// Copyright 2015 University of Szeged.
//
// Licensed under the Apache License, Version 2.0 (the License);
// 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
// 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
// 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.
+16
View File
@@ -1,3 +1,19 @@
/* Copyright 2016 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* 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.
*/
/*
* Generated by tools/gen-test-libm.sh
* DO NOT EDIT!!!
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env python
# Copyright 2015-2016 Samsung Electronics Co., Ltd.
# Copyright 2016 University of Szeged
#
# 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.
import os
import re
import sys
license = re.compile(
u"""((#|//|\*) Copyright .*
)+\s?\\2
\s?\\2 Licensed under the Apache License, Version 2.0 \(the "License"\);
\s?\\2 you may not use this file except in compliance with the License.
\s?\\2 You may obtain a copy of the License at
\s?\\2
\s?\\2 http://www.apache.org/licenses/LICENSE-2.0
\s?\\2
\s?\\2 Unless required by applicable law or agreed to in writing, software
\s?\\2 distributed under the License is distributed on an "AS IS" BASIS
\s?\\2 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\s?\\2 See the License for the specific language governing permissions and
\s?\\2 limitations under the License.""")
dirs = [
'cmake',
'jerry-core',
'jerry-libc',
'jerry-libm',
'jerry-main',
'targets',
'tests',
'tools',
]
exclude_dirs = [
'targets/esp8266'
]
exts = [
'.c',
'.cpp',
'.h',
'.S',
'.js',
'.py',
'.sh',
'.tcl',
'.cmake',
]
def main():
is_ok = True
for dname in dirs:
for root, _, files in os.walk(dname):
if any(root.startswith(exclude) for exclude in exclude_dirs):
continue
for fname in files:
if any(fname.endswith(ext) for ext in exts):
fpath = os.path.join(root, fname)
with open(fpath) as f:
if not license.search(f.read()):
print('%s: incorrect license' % fpath)
is_ok = False
if not is_ok:
sys.exit(1)
if __name__ == '__main__':
main()
+4
View File
@@ -31,6 +31,7 @@ parser.add_argument('--check-signed-off-tolerant', action='store_true', default=
parser.add_argument('--check-signed-off-travis', action='store_true', default=False, help='Run signed-off check in tolerant mode if on Travis CI and not checking a pull request')
parser.add_argument('--check-cppcheck', action='store_true', default=False, help='Run cppcheck')
parser.add_argument('--check-vera', action='store_true', default=False, help='Run vera check')
parser.add_argument('--check-license', action='store_true', default=False, help='Run license check')
parser.add_argument('--buildoption-test', action='store_true', default=False, help='Run buildoption-test')
parser.add_argument('--jerry-tests', action='store_true', default=False, help='Run jerry-tests')
parser.add_argument('--jerry-test-suite', action='store_true', default=False, help='Run jerry-test-suite')
@@ -197,6 +198,9 @@ def main():
if not ret and (script_args.all or script_args.check_vera):
ret = run_check(VERA_SCRIPT)
if not ret and (script_args.all or script_args.check_license):
ret = run_check(LICENSE_SCRIPT)
if not ret and (script_args.all or script_args.jerry_tests):
ret = run_jerry_tests()
+1
View File
@@ -27,5 +27,6 @@ BUILD_SCRIPT = path.join(TOOLS_DIR, 'build.py')
CPPCHECK_SCRIPT = path.join(TOOLS_DIR, 'check-cppcheck.sh')
SIGNED_OFF_SCRIPT = path.join(TOOLS_DIR, 'check-signed-off.sh')
VERA_SCRIPT = path.join(TOOLS_DIR, 'check-vera.sh')
LICENSE_SCRIPT = path.join(TOOLS_DIR, 'check-license.py')
TEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-test-suite.sh')
UNITTEST_RUNNER_SCRIPT = path.join(TOOLS_DIR, 'runners/run-unittests.sh')
+17 -1
View File
@@ -33,7 +33,23 @@
int
main (int argc, char **args)
{
printf ("/*\n"
printf ("/* Copyright 2016 Samsung Electronics Co., Ltd.\n"
" * Copyright 2016 University of Szeged.\n"
" *\n"
" * Licensed under the Apache License, Version 2.0 (the \"License\");\n"
" * you may not use this file except in compliance with the License.\n"
" * You may obtain a copy of the License at\n"
" *\n"
" * http://www.apache.org/licenses/LICENSE-2.0\n"
" *\n"
" * Unless required by applicable law or agreed to in writing, software\n"
" * distributed under the License is distributed on an \"AS IS\" BASIS\n"
" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
" * See the License for the specific language governing permissions and\n"
" * limitations under the License.\n"
" */\n"
"\n"
"/*\n"
" * Generated by tools/gen-test-libm.sh\n"
" * DO NOT EDIT!!!\n"
" */\n");