Skip to content

Commit

Permalink
[fix] mx checkcopyrights
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Oct 10, 2018
1 parent 8364999 commit be4b153
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 522 deletions.
1 change: 0 additions & 1 deletion com.oracle.max.base/.copyright.regex.hash

This file was deleted.

1 change: 0 additions & 1 deletion com.oracle.max.base/.copyright.regex.star

This file was deleted.

504 changes: 0 additions & 504 deletions com.oracle.max.base/src/com/sun/max/tools/CheckCopyright.java

This file was deleted.

6 changes: 6 additions & 0 deletions git/hooks/pre-commit
Expand Up @@ -26,5 +26,11 @@ if [ $result -ne 0 ]; then
echo "There are some style errors in your files, please fix them before committing"
quit $result
fi
mx --suite=maxine checkcopyrights --modified
result=$?
if [ $result -ne 0 ]; then
echo "There are some copyright issues in your files, please fix them before committing"
quit $result
fi

quit 0
19 changes: 19 additions & 0 deletions mx.maxine/copyrights/oracle.copyright.hash
@@ -0,0 +1,19 @@
#
# Copyright (c) 2018, APT Group, School of Computer Science,
# The University of Manchester. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
1 change: 1 addition & 0 deletions mx.maxine/copyrights/oracle.copyright.regex.hash
@@ -0,0 +1 @@
(?:#!.*\n#\n#\ -*\n)?#\n# Copyright \(c\) (?:20[0-9][0-9], )?(20[0-9][0-9]), [\w\s/,.*]+. All rights reserved.\n(?:# Copyright \(c\) (?:20[0-9][0-9], )+[\w\s/,.*]+. All rights reserved.\n)*# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n#\n# This code is free software; you can redistribute it and/or modify it\n# under the terms of the GNU General Public License version 2 only, as\n# published by the Free Software Foundation.\n#\n# This code is distributed in the hope that it will be useful, but WITHOUT\n# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n# version 2 for more details \(a copy is included in the LICENSE file that\n# accompanied this code\).\n#\n.*\n
1 change: 1 addition & 0 deletions mx.maxine/copyrights/oracle.copyright.regex.star
@@ -0,0 +1 @@
/\*\n \* Copyright \(c\) (?:20[0-9][0-9], )?(20[0-9][0-9]), [\w\s/,.*]+. All rights reserved.\n(?: \* Copyright \(c\) (?:20[0-9][0-9], )+[\w\s/,.*]+. All rights reserved.\n)* \* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.\n \*\n \* This code is free software; you can redistribute it and/or modify it\n \* under the terms of the GNU General Public License version 2 only, as\n \* published by the Free Software Foundation.\n \*\n \* This code is distributed in the hope that it will be useful, but WITHOUT\n \* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n \* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n \* version 2 for more details \(a copy is included in the LICENSE file that\n \* accompanied this code\).\n \*\n \* You should have received a copy of the GNU General Public License version\n \* 2 along with this work; if not, write to the Free Software Foundation,\n \* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.\n(?: \*\n \* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n \* or visit www.oracle.com if you need additional information or have any\n \* questions.\n)? \*/\n.*\n
19 changes: 19 additions & 0 deletions mx.maxine/copyrights/oracle.copyright.star
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2018, APT Group, School of Computer Science,
* The University of Manchester. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
29 changes: 13 additions & 16 deletions mx.maxine/mx_maxine.py
Expand Up @@ -75,10 +75,13 @@ def configs(arg):
for k, v in sorted(c.iteritems()):
mx.log(' @{0:<16} {1}'.format(k, v.replace('@', ' ')))

def copycheck(args):
"""run copyright check on the Maxine sources (defined as being under hg control)"""
mx.build(['--projects', 'com.oracle.max.base'])
mx.run_java(['-cp', mx.classpath('com.oracle.max.base', resolve=False), 'com.sun.max.tools.CheckCopyright'] + args)
def checkcopyrights(args):
"""run copyright check on the Maxine sources"""
for i in args:
if i == '-h' or i == '-help' or i == '--help':
print '"for help run mx :checkcopyrights -h"'
return
mx.checkcopyrights(['--', '--copyright-dir', 'mx.maxine'] + args)

def eclipse(args):
"""launch Eclipse with the Maxine VM
Expand Down Expand Up @@ -127,17 +130,11 @@ def gate(args):
if mx.checkstyle([]):
mx.abort('Checkstyle warnings were found')

if exists(join(_maxine_home, '.hg')):
# Copyright check depends on the sources being in a Mercurial repo
mx.log('Running copycheck')
hgNode = os.getenv('hg_node')
if hgNode is None:
copycheck(['-modified', '-reporterrors=true', '-continueonerror'])
else:
revTip = int(subprocess.check_output(['hg', 'tip', '--template', "'{rev}'"]).strip("'"))
revLast = int(subprocess.check_output(['hg', 'log', '-r', hgNode, '--template', "'{rev}'"]).strip("'"))
changesetCount = revTip - revLast + 1
copycheck(['-last=' + str(changesetCount), '-reporterrors=true', '-continueonerror'])
if exists(join(_maxine_home, '.git')):
# Copyright check depends on the sources being in a git repo
mx.log('Running checkcopyrights')
if checkcopyrights(['--modified', '--report-errors']):
mx.abort('Copyright issues were found')

mx.log('Ensuring JavaTester harness is up to date')
try:
Expand Down Expand Up @@ -733,7 +730,7 @@ def mx_init(suite):
commands = {
'c1x': [c1x, '[options] patterns...'],
'configs': [configs, ''],
'copycheck': [copycheck, ''],
'checkcopyrights': [checkcopyrights, '"for help run mx :checkcopyrights -h"'],
'eclipse': [eclipse, '[VM options]'],
'gate': [gate, '[options]'],
'gitinit': [gitinit, ''],
Expand Down

0 comments on commit be4b153

Please sign in to comment.