|
18 | 18 | STATE_CONDITION = 1
|
19 | 19 | STATE_SKIP = 2
|
20 | 20 | FILE_OPEN_PERMISSIONS = 0o600
|
| 21 | +DEFAULT_UNIFIED_RUNTIME_PUBLIC_HEADERS = ["ur_api.h", "sycl/ur_api.h"] |
21 | 22 |
|
22 | 23 |
|
23 | 24 | # https://docs.python.org/3/library/functions.html#open
|
@@ -47,6 +48,38 @@ def get_ocl_api_list(ocl_path):
|
47 | 48 | return func_list
|
48 | 49 |
|
49 | 50 |
|
| 51 | +def get_ur_api_file_path(include_file_path, include_file=None): |
| 52 | + """ |
| 53 | + Given include file path (typically passed to the compiler and found by the |
| 54 | + build system), find where the unified runtime public API header file is. |
| 55 | + """ |
| 56 | + |
| 57 | + # Invalid directory. |
| 58 | + if os.path.exists(include_file_path) == False: |
| 59 | + raise Exception("Passed non-existent file path for UR headers") |
| 60 | + |
| 61 | + ur_file_path = include_file_path |
| 62 | + |
| 63 | + # Assume passed the full path to file. |
| 64 | + if os.path.isfile(ur_file_path) == True: |
| 65 | + return ur_file_path |
| 66 | + |
| 67 | + if include_file != None: |
| 68 | + ur_file_path = os.path.join(ur_file_path, include_file) |
| 69 | + |
| 70 | + if os.path.exists(ur_file_path) == False: |
| 71 | + raise Exception("Passed non-existent file path for UR headers") |
| 72 | + |
| 73 | + return ur_file_path |
| 74 | + |
| 75 | + for header in DEFAULT_UNIFIED_RUNTIME_PUBLIC_HEADERS: |
| 76 | + if os.path.isfile(os.path.join(ur_file_path, header)): |
| 77 | + ur_file_path = os.path.join(ur_file_path, header) |
| 78 | + break |
| 79 | + |
| 80 | + return ur_file_path |
| 81 | + |
| 82 | + |
50 | 83 | #
|
51 | 84 | # Extracts api function names from ur_api.h and returns as list.
|
52 | 85 | # Note: The ur_api.h contains predefined ids for each api -- assumption is no recycle on deprecation.
|
@@ -924,9 +957,13 @@ def main():
|
924 | 957 |
|
925 | 958 | pti_inc_path = sys.argv[4]
|
926 | 959 | ur_path = sys.argv[5]
|
927 |
| - ur_file_path = os.path.join(ur_path, "sycl/ur_api.h") |
| 960 | + ur_file_path = get_ur_api_file_path(ur_path) |
| 961 | + |
| 962 | + if os.path.isfile(ur_file_path) == True: |
| 963 | + print("Found UR Path: ", ur_file_path) |
| 964 | + else: |
| 965 | + sys.exit("UR file not found: " + ur_file_path) |
928 | 966 |
|
929 |
| - print("Found UR Path: ", ur_path) |
930 | 967 | regen_api_files = False # Should we regenerate and update api_id_files as well?
|
931 | 968 | if sys.argv[6] == "ON":
|
932 | 969 | print("Regeneration of api files requested!")
|
|
0 commit comments