The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

scripts: Allow expressing "or" and "not" in conditions for exposing extensions.

+27 -1
+27 -1
scripts/generate_oxr_ext_support.py
··· 8 8 # Each extension that we implement gets an entry in this tuple. 9 9 # Each entry should be a list of defines that are checked for an extension: 10 10 # the first one must be the name of the extension itself. 11 + # The second and later items might be modified using or_() and not_(). 11 12 # Keep sorted, KHR, EXT, Vendor, experimental (same order). 12 13 EXTENSIONS = ( 13 14 ['XR_KHR_android_create_instance', 'XR_USE_PLATFORM_ANDROID'], ··· 40 41 ['XR_MNDX_force_feedback_curl'], 41 42 ) 42 43 44 + 45 + def or_(*args): 46 + """ 47 + Create an "OR" in the definition condition list. 48 + 49 + Takes any number of strings directly or through e.g. "not_". 50 + """ 51 + return "({})".format(" || ".join(_add_defined(s) for s in args)) 52 + 53 + 54 + def not_(s): 55 + """ 56 + Create a "NOT" in the condition list. 57 + 58 + Takes a single string, directly or through e.g. "or_". 59 + """ 60 + return "(!{})".format(_add_defined(s)) 61 + 62 + 63 + def _add_defined(s): 64 + if "defined" in s: 65 + return s 66 + return "defined({})".format(s) 67 + 68 + 43 69 ROOT = Path(__file__).resolve().parent.parent 44 70 FN = ROOT / 'src' / 'xrt'/'state_trackers' / 'oxr' / 'oxr_extension_support.h' 45 71 ··· 60 86 ext_name = data[0] 61 87 trimmed_name = trim_ext_name(ext_name) 62 88 upper_name = trimmed_name.upper() 63 - condition = " && ".join("defined({})".format(x) for x in data) 89 + condition = " && ".join(_add_defined(x) for x in data) 64 90 65 91 parts.append(f""" 66 92 /*