comparison mx/mx_graal.py @ 16022:3f350b0d93c9

pass make variables on the command line instead of in environment variables to simplify running the make on the command line without mx
author Doug Simon <doug.simon@oracle.com>
date Wed, 04 Jun 2014 22:58:14 +0200
parents c60362c5150f
children cd2209d3af46 e497100e1fbf
comparison
equal deleted inserted replaced
16021:0926a952ba55 16022:3f350b0d93c9
735 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile): 735 if not _runInDebugShell(winBuildCmd, _graal_home, compilelogfile):
736 mx.log('Error building project') 736 mx.log('Error building project')
737 return 737 return
738 else: 738 else:
739 cpus = multiprocessing.cpu_count() 739 cpus = multiprocessing.cpu_count()
740 runCmd = [mx.gmake_cmd()] 740 makeDir = join(_graal_home, 'make')
741 runCmd.append(build + buildSuffix) 741 runCmd = [mx.gmake_cmd(), '-C', makeDir]
742
742 env = os.environ.copy() 743 env = os.environ.copy()
744
745 # These must be passed as environment variables
746 env.setdefault('LANG', 'C')
747 env['JAVA_HOME'] = jdk
748
749 def setMakeVar(name, default, env=None):
750 """Sets a make variable on the command line to the value
751 of the variable in 'env' with the same name if defined
752 and 'env' is not None otherwise to 'default'
753 """
754 runCmd.append(name + '=' + (env.get(name, default) if env else default))
743 755
744 if opts2.D: 756 if opts2.D:
745 for nv in opts2.D: 757 for nv in opts2.D:
746 name, value = nv.split('=', 1) 758 name, value = nv.split('=', 1)
747 env[name.strip()] = value 759 setMakeVar(name.strip(), value)
748 760
749 env.setdefault('ARCH_DATA_MODEL', '64') 761 setMakeVar('ARCH_DATA_MODEL', '64', env=env)
750 env.setdefault('LANG', 'C') 762 setMakeVar('HOTSPOT_BUILD_JOBS', str(cpus), env=env)
751 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) 763 setMakeVar('ALT_BOOTDIR', mx.java().jdk, env=env)
752 env.setdefault('ALT_BOOTDIR', mx.java().jdk) 764
753 765 setMakeVar('MAKE_VERBOSE', 'y' if mx._opts.verbose else '')
754 if not mx._opts.verbose:
755 runCmd.append('MAKE_VERBOSE=')
756 env['JAVA_HOME'] = jdk
757 if vm.endswith('nograal'): 766 if vm.endswith('nograal'):
758 env['INCLUDE_GRAAL'] = 'false' 767 setMakeVar('INCLUDE_GRAAL', 'false')
759 env.setdefault('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os())) 768 setMakeVar('ALT_OUTPUTDIR', join(_graal_home, 'build-nograal', mx.get_os()), env=env)
760 else: 769 else:
761 # extract latest release tag for graal 770 # extract latest release tag for graal
762 try: 771 try:
763 tags = [x.split(' ')[0] for x in subprocess.check_output(['hg', '-R', _graal_home, 'tags']).split('\n') if x.startswith("graal-")] 772 tags = [x.split(' ')[0] for x in subprocess.check_output(['hg', '-R', _graal_home, 'tags']).split('\n') if x.startswith("graal-")]
764 except: 773 except:
766 tags = None 775 tags = None
767 776
768 if tags: 777 if tags:
769 # extract the most recent tag 778 # extract the most recent tag
770 tag = sorted(tags, key=lambda e: [int(x) for x in e[len("graal-"):].split('.')], reverse=True)[0] 779 tag = sorted(tags, key=lambda e: [int(x) for x in e[len("graal-"):].split('.')], reverse=True)[0]
771 env.setdefault('USER_RELEASE_SUFFIX', tag) 780 setMakeVar('USER_RELEASE_SUFFIX', tag)
772 env.setdefault('GRAAL_VERSION', tag[len("graal-"):]) 781 setMakeVar('GRAAL_VERSION', tag[len("graal-"):])
773 else: 782 else:
774 version = 'unknown-{}-{}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z')) 783 version = 'unknown-{}-{}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z'))
775 env.setdefault('USER_RELEASE_SUFFIX', 'graal-' + version) 784 setMakeVar('USER_RELEASE_SUFFIX', 'graal-' + version)
776 env.setdefault('GRAAL_VERSION', version) 785 setMakeVar('GRAAL_VERSION', version)
777 env['INCLUDE_GRAAL'] = 'true' 786 setMakeVar('INCLUDE_GRAAL', 'true')
778 env.setdefault('INSTALL', 'y') 787 setMakeVar('INSTALL', 'y', env=env)
779 if mx.get_os() == 'solaris': 788 if mx.get_os() == 'solaris':
780 # If using sparcWorks, setup flags to avoid make complaining about CC version 789 # If using sparcWorks, setup flags to avoid make complaining about CC version
781 cCompilerVersion = subprocess.Popen('CC -V', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stderr.readlines()[0] 790 cCompilerVersion = subprocess.Popen('CC -V', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stderr.readlines()[0]
782 if cCompilerVersion.startswith('CC: Sun C++'): 791 if cCompilerVersion.startswith('CC: Sun C++'):
783 compilerRev = cCompilerVersion.split(' ')[3] 792 compilerRev = cCompilerVersion.split(' ')[3]
784 env.setdefault('ENFORCE_COMPILER_REV', compilerRev) 793 setMakeVar('ENFORCE_COMPILER_REV', compilerRev, env=env)
785 env.setdefault('ENFORCE_CC_COMPILER_REV', compilerRev) 794 setMakeVar('ENFORCE_CC_COMPILER_REV', compilerRev, env=env)
786 if build == 'jvmg': 795 if build == 'jvmg':
787 # I want ALL the symbols when I'm debugging on Solaris 796 # We want ALL the symbols when debugging on Solaris
788 # Some Makefile variable are overloaded by environment variable so we need to explicitely 797 setMakeVar('STRIP_POLICY', 'no_strip')
789 # pass them down in the command line. This one is an example of that.
790 runCmd.append('STRIP_POLICY=no_strip')
791 # This removes the need to unzip the *.diz files before debugging in gdb 798 # This removes the need to unzip the *.diz files before debugging in gdb
792 env.setdefault('ZIP_DEBUGINFO_FILES', '0') 799 setMakeVar('ZIP_DEBUGINFO_FILES', '0', env=env)
793 800
794 # Clear these 2 variables as having them set can cause very confusing build problems 801 # Clear these 2 variables as having them set can cause very confusing build problems
795 env.pop('LD_LIBRARY_PATH', None) 802 env.pop('LD_LIBRARY_PATH', None)
796 env.pop('CLASSPATH', None) 803 env.pop('CLASSPATH', None)
797 804
798 mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env) 805 if mx._opts.verbose:
806 # Issue an env prefix that can be used to run the make on the command line
807 envPrefix = ' '.join([key + '=' + env[key] for key in env.iterkeys() if not os.environ.has_key(key) or env[key] != os.environ[key]])
808 if len(envPrefix):
809 mx.log('env ' + envPrefix + ' \\')
810
811 runCmd.append(build + buildSuffix)
812 mx.run(runCmd, err=filterXusage, env=env)
799 813
800 jvmCfg = _vmCfgInJdk(jdk) 814 jvmCfg = _vmCfgInJdk(jdk)
801 if not exists(jvmCfg): 815 if not exists(jvmCfg):
802 mx.abort(jvmCfg + ' does not exist') 816 mx.abort(jvmCfg + ' does not exist')
803 817