# Copyright (c) 2019 The Khronos Group Inc. # Use of this source code is governed by an MIT-style license that can be # found in the LICENSE.txt file.
# Author: Mobica LTD
import sys import re import os import subprocess import threading from sys import stdout, stderr, argv
# Running this script # 1. To rebuild all dependencies: # $ build.py deps # 2. To build all targets without rebuilding dependencies # $ build.py build # 3. To build a single target without rebuilding dependencies # $ build.py build <target> # See the table below for available targets # 4. To rebuild all dependencies and targets # $ build.py # 5. To build dependencies for a single target # $ build.py deps <target> # 6. To build dependencies for and compile a single target # $ build.py <target>
with open(outfile, "w") as out_file:
proc = subprocess.Popen(cmdLine, shell=True, stdout=subprocess.PIPE, stderr=stderr) while proc.poll() isNone:
line = proc.stdout.readline()
out_file.write(line)
def build_all_deps(): for target in targets.keys():
build_deps(target, targets[target])
def buildDepsFile(): # the parameter "--root_with_prefix" is the relative path from the file goog/base.js to the root of the .js files we # are working on.
cmdBuildDeps = 'python ../closure-library/closure/bin/build/depswriter.py --root_with_prefix=". ../../../deqp" > deqp-deps.js'
# Calls the python program that generates the google closure dependencies # write_to_file('deqp-deps.js', cmdBuildDeps, False)
proc = subprocess.Popen(cmdBuildDeps, shell=True, stdout=subprocess.PIPE, stderr=None)
proc.wait()
def build_target(target, namespace): global total_errors global total_warnings
deps = read_file(dep_filename(target))
cmdLine = 'java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE --jscomp_warning undefinedVars --externs compiler_additional_extern.js' for dep in deps.split('\n'):
dep = dep.strip() if len(dep) > 0:
cmdLine += ' --js ' + dep
cmdLine += ' --closure_entry_point=' + namespace
print cmdLine
filename = compiled_filename(target)
write_to_file(filename, cmdLine, True)
compiled = read_file(filename)
result = re.search(r'(\d*)\s*error\(s\),\s*(\d*)\s*warning\(s\)', compiled)
errors = 0
warnings = 0 if result:
print target + ': ' + result.group(0)
errors = int(result.group(1))
warnings = int(result.group(2))
total_errors += errors
total_warnings += warnings
results[target] = [errors, warnings]
def build_all_targets(): for target in targets.keys():
build_target(target, targets[target])
def format_target(target):
deps = read_file(dep_filename(target))
fixjsstyle = 'fixjsstyle.py'
reformat = 'reformatting_tool.py' for dep in deps.split('\n'):
dep = dep.strip() if len(dep) > 0 andnot re.search('closure-library.*base\.js', dep):
print fixjsstyle + ' ' + dep
subprocess.call(['python', fixjsstyle, dep])
print reformat + ' -f ' + dep
subprocess.call(['python', reformat, '-f', dep])
def format_all_targets(): for target in targets.keys():
format_target(target)
def pass_or_fail(): if total_errors + total_warnings == 0:
print "Passed" elif len(results) > 1: #display the summary only when building more than one target
passed = [k for k, v in results.iteritems() if v[0] + v[1] == 0]
failed = dict((k, v) for k, v in results.iteritems() if v[0] + v[1] != 0)
print "\nBuild Summary:" # Print first the tests that passed for target in passed:
print "{0:>30}\tPassed".format(target+":")
# Print tests that failed. Fixed-width to improve readability for target in failed:
errors = failed[target][0]
warnings = failed[target][1]
print "{0:>30}\tErrors: {1:4}\tWarnings: {2:4}".format(target+":", errors, warnings)
print "Compilation failed: {} error(s), {} warning(s).".format(total_errors, total_warnings)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.