From a5923a5d4d3741069122d8008bedd1c90e2480b9 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Thu, 20 Oct 2022 00:54:31 +0200 Subject: [PATCH] scripts: Move add_defined above extension list --- scripts/generate_oxr_ext_support.py | 46 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index 40137f795..752fea21e 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -5,6 +5,28 @@ from pathlib import Path +def _add_defined(s): + if "defined" in s: + return s + return "defined({})".format(s) + +def or_(*args): + """ + Create an "OR" in the definition condition list. + + Takes any number of strings directly or through e.g. "not_". + """ + return "({})".format(" || ".join(_add_defined(s) for s in args)) + + +def not_(s): + """ + Create a "NOT" in the condition list. + + Takes a single string, directly or through e.g. "or_". + """ + return "(!{})".format(_add_defined(s)) + # Each extension that we implement gets an entry in this tuple. # Each entry should be a list of defines that are checked for an extension: # the first one must be the name of the extension itself. @@ -42,30 +64,6 @@ EXTENSIONS = ( ) -def or_(*args): - """ - Create an "OR" in the definition condition list. - - Takes any number of strings directly or through e.g. "not_". - """ - return "({})".format(" || ".join(_add_defined(s) for s in args)) - - -def not_(s): - """ - Create a "NOT" in the condition list. - - Takes a single string, directly or through e.g. "or_". - """ - return "(!{})".format(_add_defined(s)) - - -def _add_defined(s): - if "defined" in s: - return s - return "defined({})".format(s) - - ROOT = Path(__file__).resolve().parent.parent FN = ROOT / 'src' / 'xrt'/'state_trackers' / 'oxr' / 'oxr_extension_support.h'