Skip to content

Commit 664eeb4

Browse files
committed
cmake: Add CLAP_TINT_BIN to specify external tint binary
Building tint-extract in a github worker three times is not ideal. Add an option to specify an external tint executable that foregoes fetching its source and building it. Signed-off-by: Alexander Shishkin <alex@ash.works>
1 parent fa61e47 commit 664eeb4

1 file changed

Lines changed: 35 additions & 23 deletions

File tree

CMakeLists.txt

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,42 @@ include(ExternalProject)
9292

9393
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
9494
if (CONFIG_RENDERER_WGPU)
95-
bootstrap_deps("bootstrap-wgpu.json")
96-
97-
include(scripts/host-compiler.cmake)
98-
99-
set(TINT_HOST_BUILD_DIR "${CMAKE_BINARY_DIR}/tint-host")
100-
set(TINT_BIN_PATH "${TINT_HOST_BUILD_DIR}/tint")
101-
102-
ExternalProject_Add(tint_host
103-
SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/src/tint-extract"
104-
BINARY_DIR "${TINT_HOST_BUILD_DIR}"
105-
CMAKE_ARGS
106-
-DCMAKE_C_COMPILER=${HOST_C_COMPILER}
107-
-DCMAKE_CXX_COMPILER=${HOST_CXX_COMPILER}
108-
-DCMAKE_BUILD_TYPE=Release
109-
-DCMAKE_TOOLCHAIN_FILE=
110-
BUILD_BYPRODUCTS "${TINT_BIN_PATH}"
111-
INSTALL_COMMAND ""
112-
USES_TERMINAL_BUILD TRUE
113-
STEP_TARGETS build
114-
)
95+
set(CLAP_TINT_BIN "" CACHE FILEPATH
96+
"Path to an external tint binary. If set, skips fetching/building tint-extract.")
97+
98+
if (CLAP_TINT_BIN)
99+
if (NOT EXISTS "${CLAP_TINT_BIN}")
100+
message(FATAL_ERROR
101+
"CLAP_TINT_BIN is set to '${CLAP_TINT_BIN}' but the file does not exist")
102+
endif ()
103+
set(TINT_BIN_PATH "${CLAP_TINT_BIN}")
104+
message(STATUS "tint: using external binary at ${TINT_BIN_PATH}")
105+
else ()
106+
bootstrap_deps("bootstrap-wgpu.json")
107+
108+
include(scripts/host-compiler.cmake)
109+
110+
set(TINT_HOST_BUILD_DIR "${CMAKE_BINARY_DIR}/tint-host")
111+
set(TINT_BIN_PATH "${TINT_HOST_BUILD_DIR}/tint")
112+
113+
ExternalProject_Add(tint_host
114+
SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/src/tint-extract"
115+
BINARY_DIR "${TINT_HOST_BUILD_DIR}"
116+
CMAKE_ARGS
117+
-DCMAKE_C_COMPILER=${HOST_C_COMPILER}
118+
-DCMAKE_CXX_COMPILER=${HOST_CXX_COMPILER}
119+
-DCMAKE_BUILD_TYPE=Release
120+
-DCMAKE_TOOLCHAIN_FILE=
121+
BUILD_BYPRODUCTS "${TINT_BIN_PATH}"
122+
INSTALL_COMMAND ""
123+
USES_TERMINAL_BUILD TRUE
124+
STEP_TARGETS build
125+
)
115126

116-
add_executable(tint IMPORTED GLOBAL)
117-
set_target_properties(tint PROPERTIES IMPORTED_LOCATION "${TINT_BIN_PATH}")
118-
add_dependencies(tint tint_host)
127+
add_executable(tint IMPORTED GLOBAL)
128+
set_target_properties(tint PROPERTIES IMPORTED_LOCATION "${TINT_BIN_PATH}")
129+
add_dependencies(tint tint_host)
130+
endif ()
119131
set(CLAP_EMSCRIPTEN_COMPILE_OPTIONS "--use-port=emdawnwebgpu")
120132
set(CLAP_EMSCRIPTEN_COMPILE_LIBRARIES "--use-port=emdawnwebgpu")
121133
endif ()

0 commit comments

Comments
 (0)