17 if sys.platform.startswith(
'linux'):
19 if sys.platform.startswith(
'win'):
21 if sys.platform.startswith(
'darwin'):
23 raise Exception(
'Confused, can not determine OS, aborting.')
27 stdout_has_errors=False,
28 exit_status_on_error=None):
29 """Run a command as a subprocess.
31 Errors in that subprocess are printed out if it returns an error exit code.
34 cmd: Command to run as a list of strings.
35 stdout_has_errors: Whether to print stdout instead of stderr on an error
37 exit_status_on_error: If specified, upon an error in the subprocess the
38 caller script exits immediately with the given status.
40 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
41 output, err = p.communicate()
44 PrintErr(
'\nError when invoking "%s"' %
' '.join(cmd))
50 if exit_status_on_error
is not None:
51 sys.exit(exit_status_on_error)
59 '''A class for finding directories and paths under either a standalone
60 checkout or a chromium checkout of PDFium.'''
65 self.
testing_dir = os.path.join(root_finder.pdfium_root,
'testing')
73 '''Finds compiled binaries under the build path.'''
74 result = os.path.join(self.
build_dir, name)
76 result = result +
'.exe'
80 '''Finds other scripts in the same directory as this one.'''
81 return os.path.join(self.
my_dir, name)
84 '''Places generated files under the build directory, not source dir.'''
85 result = os.path.join(self.
build_dir,
'gen',
'pdfium')
87 result = os.path.join(result, other_components)
91 '''Finds test files somewhere under the testing directory.'''
94 result = os.path.join(result, other_components)
98 '''Finds directory with the test fonts.'''
99 return os.path.join(self.
base_dir,
'third_party',
'test_fonts')
103 '''Extract the value of a boolean flag in args.gn'''
106 gn_args_output = subprocess.check_output(
107 [
'gn',
'args',
'.',
'--list=%s' % arg_name,
'--short']).
decode(
'utf8')
109 arg_match_output = re.search(
'%s = (.*)' % arg_name, gn_args_output).group(1)
112 "Found '%s' for value of %s" % (arg_match_output, arg_name),
114 return arg_match_output ==
'true'
118 """Prints s prepended by a timestamp."""
119 print(
'[%s] %s' % (datetime.datetime.now().strftime(
"%Y%m%d %H:%M:%S"), s))
123 """Prints s to stderr."""
124 print(s, file=sys.stderr)
QDebug print(QDebug debug, QSslError::SslError error)