[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / openmp / runtime / tools / libomputils.py
blobc38b81dbe7e607615485189170da6891e727c1c7
2 # //===----------------------------------------------------------------------===//
3 # //
4 # // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 # // See https://llvm.org/LICENSE.txt for license information.
6 # // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 # //
8 # //===----------------------------------------------------------------------===//
11 import os
12 import subprocess
13 import sys
16 class ScriptError(Exception):
17 """Convenience class for user errors generated"""
19 def __init__(self, msg):
20 super(Exception, self).__init__(msg)
23 def error(msg):
24 raise ScriptError(msg)
27 def print_line(msg, form="i"):
28 print("{}: ({}) {}".format(os.path.basename(sys.argv[0]), form, msg))
31 def print_info_line(msg):
32 print_line(msg)
35 def print_error_line(msg):
36 print_line(msg, form="x")
39 class RunResult:
40 """
41 Auxiliary class for execute_command() containing the
42 results of running a command
43 """
45 def __init__(self, args, stdout, stderr, returncode):
46 self.executable = args[0]
47 self.stdout = stdout.decode("utf-8")
48 self.stderr = stderr.decode("utf-8")
49 self.returncode = returncode
50 self.command = " ".join(args)
53 def execute_command(args):
54 """
55 Run a command with arguments: args
57 Return RunResult containing stdout, stderr, returncode
58 """
59 handle = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
60 stdout, stderr = handle.communicate()
61 returncode = handle.wait()
62 return RunResult(args, stdout, stderr, returncode)
65 # end of file