From 51c3240c2369b7259acf17b0c34baf605a4e38db Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Tue, 3 Dec 2019 11:53:31 -0600 Subject: [PATCH] st/oxr: Improve extension support header. --- scripts/generate_oxr_ext_support.py | 6 +++--- src/xrt/state_trackers/oxr/oxr_extension_support.h | 14 +++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/generate_oxr_ext_support.py b/scripts/generate_oxr_ext_support.py index f4c28868b..cf513ed41 100755 --- a/scripts/generate_oxr_ext_support.py +++ b/scripts/generate_oxr_ext_support.py @@ -23,8 +23,8 @@ ROOT = Path(__file__).resolve().parent.parent FN = ROOT / 'src' / 'xrt'/'state_trackers' / 'oxr' / 'oxr_extension_support.h' INVOCATION_PREFIX = 'OXR_EXTENSION_SUPPORT' - -END_OF_PER_EXTENSION = '// end of per-extension defines - do not modify this comment - used by scripts' +BEGIN_OF_PER_EXTENSION = '// beginning of GENERATED defines - do not modify - used by scripts' +END_OF_PER_EXTENSION = '// end of GENERATED per-extension defines - do not modify - used by scripts' CLANG_FORMAT_OFF = '// clang-format off' CLANG_FORMAT_ON = '// clang-format on' @@ -73,7 +73,7 @@ def generate_second_chunk(): if __name__ == "__main__": with open(str(FN), 'r', encoding='utf-8') as fp: orig = [line.rstrip() for line in fp.readlines()] - beginning = orig[:orig.index('#pragma once')+1] + beginning = orig[:orig.index(BEGIN_OF_PER_EXTENSION)+1] middle_start = orig.index(END_OF_PER_EXTENSION) middle_end = orig.index(CLANG_FORMAT_OFF) middle = orig[middle_start:middle_end] diff --git a/src/xrt/state_trackers/oxr/oxr_extension_support.h b/src/xrt/state_trackers/oxr/oxr_extension_support.h index bc8106811..da596f450 100644 --- a/src/xrt/state_trackers/oxr/oxr_extension_support.h +++ b/src/xrt/state_trackers/oxr/oxr_extension_support.h @@ -5,14 +5,19 @@ * @brief Macros for generating extension-related tables and code and * inspecting Monado's extension support. * - * Add an extension here first to support it. To correctly update this easily, - * edit and run generate_oxr_ext_support.py, then run clang-format on this file. + * MOSTLY GENERATED CODE - see below! + * + * To add support for a new extension, edit and run generate_oxr_ext_support.py, + * then run clang-format on this file. Two entire chunks of this file get + * replaced by that script: comments indicate where they are. * * @author Ryan Pavlik */ #pragma once +// beginning of GENERATED defines - do not modify - used by scripts + /* * XR_EXT_debug_utils */ @@ -95,7 +100,7 @@ #define OXR_EXTENSION_SUPPORT_MND_headless(_) #endif -// end of per-extension defines - do not modify this comment - used by scripts +// end of GENERATED per-extension defines - do not modify - used by scripts /*! * Call this, passing a macro taking two parameters, to @@ -113,6 +118,9 @@ * Implementation note: This macro calls another macro for each extension: that * macro is either defined to call your provided macro, or defined to nothing, * depending on if the extension is supported in this build. + * + * @note Do not edit anything between `clang-format off` and `clang-format on` - + * it will be replaced next time this file is generated! */ // clang-format off #define OXR_EXTENSION_SUPPORT_GENERATE(_) \