diff mx/commands.py @ 4184:fa6b78681c54

Added copyright check to the gate.
author Doug Simon <doug.simon@oracle.com>
date Tue, 03 Jan 2012 12:37:31 +0100
parents d1b26c17910a
children 4af146831ed6
line wrap: on
line diff
--- a/mx/commands.py	Mon Jan 02 17:39:20 2012 -0800
+++ b/mx/commands.py	Tue Jan 03 12:37:31 2012 +0100
@@ -43,6 +43,10 @@
     os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16')
     mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make'))
 
+def copyrightcheck(args):
+    """run copyright check on the Mercurial controlled source files"""
+    mx.run_java(['-cp', mx.classpath('com.oracle.max.base', resolve=False), 'com.sun.max.tools.CheckCopyright', '-cfp=' + join(mx.project('com.oracle.max.base').dir, '.copyright.regex')] + args)
+
 def export(args):
     """create a GraalVM zip file for distribution"""
     
@@ -545,15 +549,26 @@
     mx.log(time.strftime('%d %b %Y %H:%M:%S - Build...'))
     build([])
     
-    # 5. Bootstrap with system assertions enabled
+    # 5 Copyright check
+    mx.log(time.strftime('%d %b %Y %H:%M:%S - Running copyright check...'))
+    hgNode = mx.get_env('hg_node')
+    if hgNode is None:
+        copyrightcheck(['-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
+        copyrightcheck(['-last=' + str(changesetCount), '-reporterrors=true', '-continueonerror'])
+    
+    # 6. Bootstrap with system assertions enabled
     mx.log(time.strftime('%d %b %Y %H:%M:%S - Bootstrap with -esa...'))
     vm(['-esa', '-version'])
     
-    # 6. Run unittests
+    # 7. Run unittests
     mx.log(time.strftime('%d %b %Y %H:%M:%S - Running unit tests...'))
     unittest([])
     
-    # 7. Run selected DaCapo benchmarks
+    # 8. Run selected DaCapo benchmarks
     mx.log(time.strftime('%d %b %Y %H:%M:%S - Running DaCapo benchmarks...'))
     dacapo(['eclipse'])
     #dacapo(['tradesoap'])
@@ -569,6 +584,7 @@
     commands = {
         'build': [build, ''],
         'clean': [clean, ''],
+        'copyrightcheck': [copyrightcheck, ''],
         'dacapo': [dacapo, '[benchmark] [VM options|DaCapo options]'],
         'example': [example, '[-v] example names...'],
         'gate' : [gate, ''],