|
1 | 1 | # GenerateMnxSchemaXxd.cmake
|
2 | 2 |
|
3 | 3 | # Define the paths
|
4 |
| -set(MNX_SCHEMA_JSON "${CMAKE_BINARY_DIR}/third_party/mnx-schema.json") |
| 4 | +set(MNX_SCHEMA_DIR "${CMAKE_SOURCE_DIR}/schema") |
| 5 | +set(MNX_SCHEMA_JSON "${MNX_SCHEMA_DIR}/mnx-schema.json") |
5 | 6 | set(GENERATED_MNX_XXD "${GENERATED_DIR}/mnx_schema.xxd")
|
6 |
| -set(MNX_SCHEMA_URL "https://w3c.github.io/mnx/docs/mnx-schema.json") |
7 |
| - |
8 |
| -file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/third_party") |
9 |
| - |
10 |
| -# Only download if the file doesn't exist |
11 |
| -if(NOT EXISTS "${MNX_SCHEMA_JSON}") |
12 |
| - message(STATUS "Downloading ${MNX_SCHEMA_URL}...") |
13 |
| - execute_process( |
14 |
| - COMMAND curl --fail --location --output "${MNX_SCHEMA_JSON}" "${MNX_SCHEMA_URL}" |
15 |
| - RESULT_VARIABLE download_result |
16 |
| - OUTPUT_QUIET |
17 |
| - ERROR_QUIET |
18 |
| - ) |
19 |
| - |
20 |
| - if(NOT download_result EQUAL 0) |
21 |
| - message(FATAL_ERROR "Failed to download ${MNX_SCHEMA_URL}") |
22 |
| - else() |
23 |
| - message(STATUS "Downloaded ${MNX_SCHEMA_URL} to ${MNX_SCHEMA_JSON}") |
24 |
| - endif() |
25 |
| -else() |
26 |
| - message(STATUS "Schema file already exists; skipping download.") |
27 |
| -endif() |
28 | 7 |
|
29 | 8 | # Step 2: Convert mnx-schema.json to mnx_schema.xxd
|
30 | 9 | add_custom_command(
|
31 | 10 | OUTPUT "${CMAKE_BINARY_DIR}/generated/mnx_schema.xxd"
|
32 | 11 | COMMAND ${CMAKE_COMMAND} -E echo "Generating mnx_schema.xxd..."
|
33 | 12 | COMMAND ${CMAKE_COMMAND} -E make_directory "${GENERATED_DIR}"
|
34 |
| - COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_BINARY_DIR}/third_party" |
| 13 | + COMMAND ${CMAKE_COMMAND} -E chdir "${MNX_SCHEMA_DIR}" |
35 | 14 | xxd -i "mnx-schema.json" > "${GENERATED_MNX_XXD}"
|
36 | 15 | DEPENDS "${MNX_SCHEMA_JSON}"
|
37 | 16 | COMMENT "Converting mnx-schema.json to mnx_schema.xxd"
|
|
0 commit comments