本文整理汇总了Python中mx.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: c1visualizer
def c1visualizer(args):
"""run the Cl Compiler Visualizer"""
libpath = join(_suite.dir, 'lib')
if mx.get_os() == 'windows':
executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer.exe')
else:
executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer')
# Check whether the current C1Visualizer installation is the up-to-date
if exists(executable) and not exists(mx.library('C1VISUALIZER_DIST').get_path(resolve=False)):
mx.log('Updating C1Visualizer')
shutil.rmtree(join(libpath, 'c1visualizer'))
archive = mx.library('C1VISUALIZER_DIST').get_path(resolve=True)
if not exists(executable):
zf = zipfile.ZipFile(archive, 'r')
zf.extractall(libpath)
if not exists(executable):
mx.abort('C1Visualizer binary does not exist: ' + executable)
if mx.get_os() != 'windows':
# Make sure that execution is allowed. The zip file does not always specfiy that correctly
os.chmod(executable, 0777)
mx.run([executable])
示例2: _update_JDK9_STUBS_library
def _update_JDK9_STUBS_library():
"""
Sets the "path" and "sha1" attributes of the "JDK9_STUBS" library.
"""
jdk9InternalLib = _suite.suiteDict['libraries']['JDK9_STUBS']
jarInputDir = join(_suite.get_output_root(), 'jdk9-stubs')
jarPath = join(_suite.get_output_root(), 'jdk9-stubs.jar')
stubs = [
('jdk.internal.misc', 'VM', """package jdk.internal.misc;
public class VM {
public static String getSavedProperty(String key) {
throw new InternalError("should not reach here");
}
}
""")
]
if not exists(jarPath):
sourceFiles = []
for (package, className, source) in stubs:
sourceFile = join(jarInputDir, package.replace('.', os.sep), className + '.java')
mx.ensure_dir_exists(os.path.dirname(sourceFile))
with open(sourceFile, 'w') as fp:
fp.write(source)
sourceFiles.append(sourceFile)
jdk = mx.get_jdk(tag='default')
mx.run([jdk.javac, '-d', jarInputDir] + sourceFiles)
mx.run([jdk.jar, 'cf', jarPath, '.'], cwd=jarInputDir)
jdk9InternalLib['path'] = jarPath
jdk9InternalLib['sha1'] = mx.sha1OfFile(jarPath)
示例3: _run_netbeans_app
def _run_netbeans_app(app_name, env=None, args=None):
args = [] if args is None else args
dist = app_name.upper() + '_DIST'
name = app_name.lower()
extractPath = join(_suite.get_output_root())
if mx.get_os() == 'windows':
executable = join(extractPath, name, 'bin', name + '.exe')
else:
executable = join(extractPath, name, 'bin', name)
# Check whether the current installation is up-to-date
if exists(executable) and not exists(mx.library(dist).get_path(resolve=False)):
mx.log('Updating ' + app_name)
shutil.rmtree(join(extractPath, name))
archive = mx.library(dist).get_path(resolve=True)
if not exists(executable):
zf = zipfile.ZipFile(archive, 'r')
zf.extractall(extractPath)
if not exists(executable):
mx.abort(app_name + ' binary does not exist: ' + executable)
if mx.get_os() != 'windows':
# Make sure that execution is allowed. The zip file does not always specfiy that correctly
os.chmod(executable, 0777)
mx.run([executable]+args, env=env)
示例4: helloworld_internal
def helloworld_internal(native_image, path=svmbuild_dir(), javac_command=None, args=None):
if javac_command is None:
javac_command = ['javac']
args = [] if args is None else args
mkpath(path)
hello_file = join(path, 'HelloWorld.java')
output = 'Hello from Substrate VM'
with open(hello_file, 'w') as fp:
fp.write('public class HelloWorld { public static void main(String[] args) { System.out.println("' + output + '"); } }')
# Run javac. We sometimes run with an image so annotation processing must be disabled because it requires dynamic
# class loading, and we need to set the bootclasspath manually because our build directory does not contain any
# .jar files.
mx.run(javac_command + [hello_file])
native_image(["-H:Path=" + path, '-cp', path, 'HelloWorld'] + args)
expectedOutput = [output + '\n']
actualOutput = []
def _collector(x):
actualOutput.append(x)
mx.log(x)
mx.run([join(path, 'helloworld')], out=_collector)
if actualOutput != expectedOutput:
raise Exception('Wrong output: ' + str(actualOutput) + " != " + str(expectedOutput))
示例5: cinterfacetutorial
def cinterfacetutorial(native_image, args=None):
"""Build and run the tutorial for the C interface"""
args = [] if args is None else args
tutorial_proj = mx.dependency('com.oracle.svm.tutorial')
cSourceDir = join(tutorial_proj.dir, 'native')
buildDir = join(svmbuild_dir(), tutorial_proj.name, 'build')
# clean / create output directory
if exists(buildDir):
remove_tree(buildDir)
mkpath(buildDir)
# Build the shared library from Java code
native_image(['--shared', '-H:Path=' + buildDir, '-H:Name=libcinterfacetutorial',
'-H:CLibraryPath=' + tutorial_proj.dir, '-cp', tutorial_proj.output_dir()] + args)
# Build the C executable
mx.run(['cc', '-g', join(cSourceDir, 'cinterfacetutorial.c'),
'-I' + buildDir,
'-L' + buildDir, '-lcinterfacetutorial',
'-ldl', '-Wl,-rpath,' + buildDir,
'-o', join(buildDir, 'cinterfacetutorial')])
# Start the C executable
mx.run([buildDir + '/cinterfacetutorial'])
示例6: _gnur_install_test
def _gnur_install_test(pkgs, gnur_libinstall, gnur_install_tmp):
gnur_packages = join(_fastr_suite_dir(), 'gnur.packages')
with open(gnur_packages, 'w') as f:
for pkg in pkgs:
f.write(pkg)
f.write('\n')
env = os.environ.copy()
env["TMPDIR"] = gnur_install_tmp
env['R_LIBS_USER'] = gnur_libinstall
env["TZDIR"] = "/usr/share/zoneinfo/"
args = []
if _graalvm():
args += [_gnur_rscript()]
args += [_installpkgs_script()]
args += ['--pkg-filelist', gnur_packages]
args += ['--run-tests']
# GNU R will abort the entire run otherwise if a failure occurs
# args += ['--run-mode', 'internal']
args += ['--ignore-blacklist']
args += ['--testdir', 'test.gnur']
_log_step('BEGIN', 'install/test', 'GnuR')
if _graalvm():
mx.run(args, nonZeroIsFatal=False, env=env)
else:
mx_fastr.gnu_rscript(args, env=env)
_log_step('END', 'install/test', 'GnuR')
示例7: pullInstallDragonEgg
def pullInstallDragonEgg(args=None):
"""downloads and installs dragonegg (assumes that compatible GCC and G++ versions are installed)"""
toolDir = join(_toolDir, "tools/dragonegg")
mx.ensure_dir_exists(toolDir)
url = "https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/dragonegg-3.2.src.tar.gz"
localPath = pullsuite(toolDir, [url])
tar(localPath, toolDir)
os.remove(localPath)
if mx.get_os() == "darwin":
gccToolDir = join(_toolDir, "tools/gcc")
url = "https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/gcc-4.6.4.tar.gz"
localPath = pullsuite(gccToolDir, [url])
tar(localPath, gccToolDir)
os.remove(localPath)
mx.run(
["patch", "-p1", _toolDir + "tools/dragonegg/dragonegg-3.2.src/Makefile", "mx.sulong/dragonegg-mac.patch"]
)
os.environ["GCC"] = getGCC()
os.environ["CXX"] = getGPP()
os.environ["CC"] = getGCC()
pullLLVMBinaries()
os.environ["LLVM_CONFIG"] = findLLVMProgram("llvm-config")
print os.environ["LLVM_CONFIG"]
compileCommand = ["make"]
return mx.run(compileCommand, cwd=_toolDir + "tools/dragonegg/dragonegg-3.2.src")
示例8: genInlineAssemblyParser
def genInlineAssemblyParser(args=None, out=None):
"""generate inline assembly parser and scanner if corresponding grammer is new"""
generatedParserDir = _inlineAssemblySrcDir + _inlineAssemblyPackageName.replace(".", "/") + "/"
generatedFiles = [generatedParserDir + "Parser.java", generatedParserDir + "Scanner.java"]
configFiles = [
_inlineAssemblySrcDir + "InlineAssembly.atg",
_inlineAssemblySrcDir + "Parser.frame",
_inlineAssemblySrcDir + "Scanner.frame",
_inlineAssemblySrcDir + "Copyright.frame",
]
isAllGeneratedFilesExists = all([isfile(fileName) for fileName in generatedFiles])
latestGeneratedFile = (
sorted(generatedFiles, key=os.path.getmtime, reverse=True)[0] if isAllGeneratedFilesExists else ""
)
latestConfigFile = sorted(configFiles, key=os.path.getmtime, reverse=True)[0]
# If any auto-generated file is missing or any config file is updated after last auto-generation then regenerate the files
if not isAllGeneratedFilesExists or os.path.getmtime(latestConfigFile) >= os.path.getmtime(latestGeneratedFile):
localCocoJarFile = _suite.dir + "/lib/Coco.jar"
if not isfile(localCocoJarFile):
jarFileUrls = ["https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/Coco.jar"]
mx.download(localCocoJarFile, jarFileUrls)
command = [
mx.get_jdk(tag="jvmci").java,
"-jar",
localCocoJarFile,
"-package",
_inlineAssemblyPackageName,
"-o",
generatedParserDir,
_inlineAssemblyGrammer,
]
mx.run(command)
# Files get generated in Windows file format. Convert them to avoid style check failure during regression testing
dos2unix(generatedFiles)
示例9: _runmake
def _runmake(args):
"""run the JDK make process
To build hotspot and import it into the JDK: "mx make hotspot import-hotspot"
{0}"""
jdkBuildDir = _get_jdk_build_dir()
if not exists(jdkBuildDir):
# JDK9 must be bootstrapped with a JDK8
compliance = mx.JavaCompliance('8')
jdk8 = mx.get_jdk(compliance.exactMatch, versionDescription=compliance.value)
cmd = ['sh', 'configure', '--with-debug-level=' + _vm.debugLevel, '--with-native-debug-symbols=external', '--disable-precompiled-headers', '--with-jvm-features=graal',
'--with-jvm-variants=' + _vm.jvmVariant, '--disable-warnings-as-errors', '--with-boot-jdk=' + jdk8.home, '--with-jvm-features=graal']
mx.run(cmd, cwd=_jdkSourceRoot)
cmd = [mx.gmake_cmd(), 'CONF=' + _vm.debugLevel]
if mx.get_opts().verbose:
cmd.append('LOG=debug')
cmd.extend(args)
if mx.get_opts().use_jdk_image and 'images' not in args:
cmd.append('images')
if not mx.get_opts().verbose:
mx.log('--------------- make execution ----------------------')
mx.log('Working directory: ' + _jdkSourceRoot)
mx.log('Command line: ' + ' '.join(cmd))
mx.log('-----------------------------------------------------')
mx.run(cmd, cwd=_jdkSourceRoot)
示例10: jdkartifactstats
def jdkartifactstats(args):
"""show stats about JDK deployed Graal artifacts"""
artifacts = {}
jdkDir = get_jvmci_jdk().home
def _getDeployedJars():
if JVMCI_VERSION < 9:
for root, _, filenames in os.walk(join(jdkDir, 'jre', 'lib')):
for f in filenames:
if f.endswith('.jar') and not f.endswith('.stripped.jar'):
yield join(root, f)
else:
for jdkDist in jdkDeployedDists:
dist = jdkDist.dist()
if isinstance(jdkDist, JvmciJDKDeployedDist):
yield dist.path
for jar in _getDeployedJars():
f = basename(jar)
if 'truffle' in f:
if 'enterprise' in f:
artifacts.setdefault('GraalEnterpriseTruffle', []).append(jar)
else:
artifacts.setdefault('GraalTruffle', []).append(jar)
elif 'enterprise' in f:
artifacts.setdefault('GraalEnterprise', []).append(jar)
elif 'jvmci' in f:
artifacts.setdefault('JVMCI', []).append(jar)
elif 'graal' in f:
artifacts.setdefault('Graal', []).append(jar)
else:
mx.logv('ignored: ' + jar)
print '{:>10} {:>10} {:>10} {}'.format('All', 'NoVars', 'None', 'Jar')
for category in sorted(artifacts.viewkeys()):
jars = artifacts[category]
if jars:
totals = (0, 0, 0)
print
for j in jars:
gSize = os.path.getsize(j)
stripped = j[:-len('.jar')] + '.stripped.jar'
mx.run([mx.get_jdk().pack200, '--repack', '--quiet', '-J-Djava.util.logging.config.file=', '-DLocalVariableTypeTable=strip', '-DLocalVariableTable=strip', stripped, j])
gLinesSourceSize = os.path.getsize(stripped)
mx.run([mx.get_jdk().pack200, '--repack', '--quiet', '-J-Djava.util.logging.config.file=', '-G', stripped, j])
gNoneSize = os.path.getsize(stripped)
os.remove(stripped)
print '{:10,} {:10,} {:10,} {}:{}'.format(gSize, gLinesSourceSize, gNoneSize, category, basename(j))
t1, t2, t3 = totals
totals = (t1 + gSize, t2 + gLinesSourceSize, t3 + gNoneSize)
t1, t2, t3 = totals
print '{:10,} {:10,} {:10,} {}'.format(t1, t2, t3, category)
jvmLib = join(jdkDir, relativeVmLibDirInJdk(), get_vm(), mx.add_lib_suffix(mx.add_lib_prefix('jvm')))
print
if exists(jvmLib):
print '{:10,} {}'.format(os.path.getsize(jvmLib), jvmLib)
else:
print '{:>10} {}'.format('<missing>', jvmLib)
示例11: build
def build(self):
cwd = _suite.dir
maven_repo_arg, env = mavenSetup()
mx.log("Building jruby-core with Maven")
mx.run_maven(['-q', '-DskipTests', maven_repo_arg, '-pl', 'core,lib'], cwd=cwd, env=env)
# Install Bundler
gem_home = join(_suite.dir, 'lib', 'ruby', 'gems', 'shared')
env['GEM_HOME'] = gem_home
env['GEM_PATH'] = gem_home
mx.run(['bin/jruby', 'bin/gem', 'install', 'bundler', '-v', '1.10.6'], cwd=cwd, env=env)
示例12: gccBench
def gccBench(args=None):
""" executes a benchmark with the system default GCC version"""
_, inputFiles = extract_compiler_args(args)
_, ext = os.path.splitext(inputFiles[0])
if ext == '.c':
mx.run(['gcc', '-std=gnu99'] + args + standardLinkerCommands())
elif ext == '.cpp':
mx.run(['g++'] + args + standardLinkerCommands())
else:
exit(ext + " is not supported!")
return mx.run(['./a.out'])
示例13: _configs
def _configs():
class Configs:
def __init__(self):
self.configs = dict()
def eat(self, line):
(k, v) = line.split('#')
self.configs[k] = v.rstrip()
c = Configs()
mx.run([mx.java().java, '-client', '-Xmx40m', '-Xms40m', '-XX:NewSize=30m', '-cp', mx.classpath(resolve=False), 'test.com.sun.max.vm.MaxineTesterConfiguration'], out=c.eat)
return c.configs
示例14: clangBench
def clangBench(args=None):
""" Executes a benchmark with the system default Clang"""
_, inputFiles = extract_compiler_args(args)
_, ext = os.path.splitext(inputFiles[0])
if ext == '.c':
mx.run(['clang'] + args + standardLinkerCommands())
elif ext == '.cpp':
mx.run(['clang++'] + args + standardLinkerCommands())
else:
exit(ext + " is not supported!")
return mx.run(['./a.out'])
示例15: build
def build(self):
cwd = _suite.dir
maven_repo_arg, env = mavenSetup()
mx.log("Building jruby-core with Maven")
quiet = [] if mx.get_opts().verbose else ['-q']
mx.run_maven(quiet + ['-DskipTests', maven_repo_arg, '-Dcreate.sources.jar', '-pl', 'core,lib'], cwd=cwd, env=env)
# Install Bundler
gem_home = join(_suite.dir, 'lib', 'ruby', 'gems', 'shared')
env['GEM_HOME'] = gem_home
env['GEM_PATH'] = gem_home
mx.run(['bin/jruby', 'bin/gem', 'install', 'bundler', '-v', '1.10.6'], cwd=cwd, env=env)