Allow setting markupsafe directory in CMake.

This CL updates the configuration to allow providing the markupsafe
folder in the CMake configuration. The generator is updated in order to
in set the folder into the path so `jinja2` can find markupsafe.

Change-Id: I3b79deba0d8c2af9c751ddb63c4febc542e904df
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126661
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
dan sinclair 2023-04-07 07:52:36 +00:00 committed by Dawn LUCI CQ
parent d23059b0bf
commit 6b67a90d8b
3 changed files with 20 additions and 0 deletions

View File

@ -181,6 +181,7 @@ set_if_not_defined(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" "Direct
set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil")
set_if_not_defined(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" "Directory in which to find GLFW")
set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2")
set_if_not_defined(DAWN_MARKUPSAFE_DIR "${DAWN_THIRD_PARTY_DIR}/markupsafe" "Directory in which to find MarkupSafe")
set_if_not_defined(DAWN_KHRONOS_DIR "${DAWN_THIRD_PARTY_DIR}/khronos" "Directory in which to find Khronos GL headers")
set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-headers/src" "Directory in which to find SPIRV-Headers")
set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/src" "Directory in which to find SPIRV-Tools")

View File

@ -27,6 +27,7 @@ if (NOT DAWN_JINJA2_DIR)
endif()
else()
message(STATUS "Dawn: using jinja2 at ${DAWN_JINJA2_DIR}")
message(STATUS "Dawn: using markupsafe at ${DAWN_MARKUPSAFE_DIR}")
endif()
# Function to invoke a generator_lib.py generator.
@ -54,6 +55,9 @@ function(DawnGenerator)
if (DAWN_JINJA2_DIR)
list(APPEND BASE_ARGS --jinja2-path ${DAWN_JINJA2_DIR})
endif()
if (DAWN_MARKUPSAFE_DIR)
list(APPEND BASE_ARGS --markupsafe-path ${DAWN_MARKUPSAFE_DIR})
endif()
# Call the generator to get the list of its dependencies.
execute_process(

View File

@ -90,6 +90,16 @@ except ValueError:
# --jinja2-path isn't passed, ignore the exception and just import Jinja2
# assuming it already is in the Python PATH.
pass
kMarkupSafePath = '--markupsafe-path'
try:
markupsafe_path_argv_index = sys.argv.index(kMarkupSafePath)
# Add parent path for the import to succeed.
path = os.path.join(sys.argv[markupsafe_path_argv_index + 1], os.pardir)
sys.path.insert(1, path)
except ValueError:
# --markupsafe-path isn't passed, ignore the exception and just import
# assuming it already is in the Python PATH.
pass
import jinja2
@ -236,6 +246,11 @@ def run_generator(generator):
default=None,
type=str,
help='Additional python path to set before loading Jinja2')
parser.add_argument(
kMarkupSafePath,
default=None,
type=str,
help='Additional python path to set before loading MarkupSafe')
parser.add_argument(
'--output-json-tarball',
default=None,