changeset 4147:55376d8953a6

Improved 'build' and 'clean' commands.
author Doug Simon <doug.simon@oracle.com>
date Mon, 19 Dec 2011 22:22:56 +0100
parents 4eb5b2469b6f
children bf5efc22fb3f
files mx/commands.py mxtool/mx.py
diffstat 2 files changed, 36 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/mx/commands.py	Mon Dec 19 21:48:32 2011 +0100
+++ b/mx/commands.py	Mon Dec 19 22:22:56 2011 +0100
@@ -35,6 +35,7 @@
 
 def clean(args):
     """cleans the GraalVM source tree"""
+    mx.clean(args)
     os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16')
     mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make'))
 
@@ -181,11 +182,11 @@
     The optional argument specifies what type of VM to build."""
 
     build = 'product'
-    if len(args) != 0 and not args[len(args) - 1].startswith('-'):
-        build = args.pop()
+    if len(args) != 0 and not args[0].startswith('-'):
+        build = args.pop(0)
 
     # Call mx.build to compile the Java sources        
-    mx.build(args)
+    mx.build(args + ['--source', '1.7'])
 
     def fix_jvm_cfg(jdk):
         jvmCfg = join(jdk, 'jre', 'lib', 'amd64', 'jvm.cfg')
--- a/mxtool/mx.py	Mon Dec 19 21:48:32 2011 +0100
+++ b/mxtool/mx.py	Mon Dec 19 22:22:56 2011 +0100
@@ -479,10 +479,6 @@
     
         os.environ['JAVA_HOME'] = opts.java_home
         os.environ['HOME'] = opts.user_home
- 
-        opts.java = join(opts.java_home, 'bin', 'java')
-        opts.javac = join(opts.java_home, 'bin', 'javac')
-        opts.javap = join(opts.java_home, 'bin', 'javap')
         
         commandAndArgs = opts.__dict__.pop('commandAndArgs')
         
@@ -511,7 +507,7 @@
     return _java
 
 def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None):
-    return run(_java.format_cmd(args), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd)
+    return run(java().format_cmd(args), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd)
 
 def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None):
     """
@@ -728,8 +724,8 @@
     javaSource = join(myDir, 'URLConnectionDownload.java')
     javaClass = join(myDir, 'URLConnectionDownload.class')
     if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource):
-        subprocess.check_call([_opts.javac, '-d', myDir, javaSource])
-    if run([_opts.java, '-cp', myDir, 'URLConnectionDownload', path] + urls) != 0:
+        subprocess.check_call([java().javac, '-d', myDir, javaSource])
+    if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls) != 0:
         abort('Could not download to ' + path + ' from any of the following URLs:\n\n    ' +
                   '\n    '.join(urls) + '\n\nPlease use a web browser to do the download manually')
 
@@ -767,7 +763,9 @@
     parser = ArgumentParser(prog='mx build');
     parser.add_argument('-f', action='store_true', dest='force', help='force compilation even if class files are up to date')
     parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output')
-    parser.add_argument('--no-native', action='store_false', dest='native', help='do not build com.oracle.max.vm.native')
+    parser.add_argument('--source', dest='compliance', help='Java compliance level', default='1.6')
+    parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
+    parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects')
     parser.add_argument('--jdt', help='Eclipse installation or path to ecj.jar for using the Eclipse batch compiler instead of javac', metavar='<path>')
 
     args = parser.parse_args(args)
@@ -786,7 +784,7 @@
     for p in sorted_deps():
         
         if p.native:
-            log('Compiling C sources in {0}...'.format(p.dir))
+            log('Calling GNU make {0}...'.format(p.dir))
 
             if args.clean:
                 run([gmake_cmd(), 'clean'], cwd=p.dir)
@@ -844,32 +842,36 @@
             try:
                 if jdtJar is None:
                     log('Compiling Java sources in {0} with javac...'.format(sourceDir))
-                    
-                    class Filter:
-                        """
-                        Class to filter the 'is Sun proprietary API and may be removed in a future release'
-                        warning when compiling the VM classes.
-                        
-                        """
-                        def __init__(self):
-                            self.c = 0
+                    errFilt = None
+                    if not args.warnAPI:
+                        class Filter:
+                            """
+                            Class to errFilt the 'is Sun proprietary API and may be removed in a future release'
+                            warning when compiling the VM classes.
+                            
+                            """
+                            def __init__(self):
+                                self.c = 0
+                            
+                            def eat(self, line):
+                                if 'proprietary API':
+                                    self.c = 2
+                                elif self.c != 0:
+                                    self.c -= 1
+                                else:
+                                    print line.rstrip()
+                        errFilt=Filter().eat
                         
-                        def eat(self, line):
-                            if 'Sun proprietary API' in line:
-                                self.c = 2
-                            elif self.c != 0:
-                                self.c -= 1
-                            else:
-                                print line.rstrip()
-                        
-                    run([_opts.javac, '-g', '-J-Xmx1g', '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=Filter().eat)
+                    run([java().javac, '-g', '-J-Xmx1g', '-source', args.compliance, '-classpath', cp, '-d', outputDir, '@' + argfile.name], err=errFilt)
                 else:
                     log('Compiling Java sources in {0} with JDT...'.format(sourceDir))
                     jdtProperties = join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')
                     if not exists(jdtProperties):
                         raise SystemError('JDT properties file {0} not found'.format(jdtProperties))
-                    run([_opts.java, '-Xmx1g', '-jar', jdtJar, '-1.6', '-cp', cp, '-g',
-                             '-properties', jdtProperties, 
+                    run([java().java, '-Xmx1g', '-jar', jdtJar,
+                             '-properties', jdtProperties,
+                             '-' + args.compliance,
+                             '-cp', cp, '-g',
                              '-warn:-unusedImport,-unchecked',
                              '-d', outputDir, '@' + argfile.name])
             finally:
@@ -1075,7 +1077,7 @@
 
         -private -verbose -classpath <path to project classes>"""
         
-    javap = _opts.javap
+    javap = java().javap
     if not exists(javap):
         abort('The javap executable does not exists: ' + javap)
     else: