if(NOT DEFINED METACORE_RUNTIME_CONFIG_TOOL) message(FATAL_ERROR "METACORE_RUNTIME_CONFIG_TOOL is required") endif() if(NOT DEFINED METACORE_RUNTIME_CONFIG_OUTPUT_ROOT) message(FATAL_ERROR "METACORE_RUNTIME_CONFIG_OUTPUT_ROOT is required") endif() function(metacore_expect_exists path description) if(NOT EXISTS "${path}") message(FATAL_ERROR "${description} does not exist: ${path}") endif() endfunction() function(metacore_expect_not_exists path description) if(EXISTS "${path}") message(FATAL_ERROR "${description} should not exist: ${path}") endif() endfunction() function(metacore_expect_contains path pattern description) file(READ "${path}" content) string(FIND "${content}" "${pattern}" pattern_index) if(pattern_index EQUAL -1) message(FATAL_ERROR "${description} missing '${pattern}' in ${path}") endif() endfunction() file(REMOVE_RECURSE "${METACORE_RUNTIME_CONFIG_OUTPUT_ROOT}") set(file_project_root "${METACORE_RUNTIME_CONFIG_OUTPUT_ROOT}/file_replay") set(file_runtime_dir "${file_project_root}/Runtime") execute_process( COMMAND "${METACORE_RUNTIME_CONFIG_TOOL}" "${file_runtime_dir}" RESULT_VARIABLE file_result OUTPUT_VARIABLE file_stdout ERROR_VARIABLE file_stderr ) if(NOT file_result EQUAL 0) message(FATAL_ERROR "MetaCoreRuntimeConfigTool file_replay failed: ${file_stderr}") endif() string(FIND "${file_stdout}" "mode=file_replay" file_mode_index) if(file_mode_index EQUAL -1) message(FATAL_ERROR "MetaCoreRuntimeConfigTool file_replay output did not report mode=file_replay: ${file_stdout}") endif() metacore_expect_exists("${file_runtime_dir}/ProjectRuntime.mcruntimecfg" "Runtime project document") metacore_expect_exists("${file_runtime_dir}/DataSources.mcruntime" "Runtime data sources document") metacore_expect_exists("${file_runtime_dir}/Bindings.mcruntime" "Runtime bindings document") metacore_expect_exists("${file_runtime_dir}/RuntimeReplay.mcstream" "Runtime replay stream") metacore_expect_exists("${file_project_root}/MetaCore.project.json" "Project descriptor") metacore_expect_exists("${file_project_root}/Scenes/Main.mcscene.json" "Startup scene") metacore_expect_exists("${file_project_root}/Assets/UI/Hud.mcui.json" "Startup UI") metacore_expect_contains("${file_project_root}/MetaCore.project.json" "\"runtime_directory\": \"Runtime\"" "Project descriptor") metacore_expect_contains("${file_project_root}/MetaCore.project.json" "\"startup_scene\": \"Scenes/Main.mcscene.json\"" "Project descriptor") metacore_expect_contains("${file_runtime_dir}/RuntimeReplay.mcstream" "runtime.status string RuntimeData replay started" "Replay stream") metacore_expect_contains("${file_project_root}/Assets/UI/Hud.mcui.json" "runtime.status" "Startup UI") set(custom_project_root "${METACORE_RUNTIME_CONFIG_OUTPUT_ROOT}/custom_runtime") set(custom_runtime_dir "${custom_project_root}/ConfigRuntime") execute_process( COMMAND "${METACORE_RUNTIME_CONFIG_TOOL}" "${custom_runtime_dir}" RESULT_VARIABLE custom_result OUTPUT_VARIABLE custom_stdout ERROR_VARIABLE custom_stderr ) if(NOT custom_result EQUAL 0) message(FATAL_ERROR "MetaCoreRuntimeConfigTool custom runtime failed: ${custom_stderr}") endif() metacore_expect_exists("${custom_runtime_dir}/ProjectRuntime.mcruntimecfg" "Custom runtime project document") metacore_expect_exists("${custom_runtime_dir}/DataSources.mcruntime" "Custom runtime data sources document") metacore_expect_exists("${custom_runtime_dir}/Bindings.mcruntime" "Custom runtime bindings document") metacore_expect_exists("${custom_runtime_dir}/RuntimeReplay.mcstream" "Custom runtime replay stream") metacore_expect_exists("${custom_project_root}/MetaCore.project.json" "Custom project descriptor") metacore_expect_exists("${custom_project_root}/Scenes/Main.mcscene.json" "Custom startup scene") metacore_expect_contains("${custom_project_root}/MetaCore.project.json" "\"runtime_directory\": \"ConfigRuntime\"" "Custom project descriptor") metacore_expect_contains("${custom_project_root}/MetaCore.project.json" "\"startup_scene\": \"Scenes/Main.mcscene.json\"" "Custom project descriptor") set(tcp_project_root "${METACORE_RUNTIME_CONFIG_OUTPUT_ROOT}/tcp") set(tcp_runtime_dir "${tcp_project_root}/Runtime") execute_process( COMMAND "${METACORE_RUNTIME_CONFIG_TOOL}" "${tcp_runtime_dir}" "--tcp" RESULT_VARIABLE tcp_result OUTPUT_VARIABLE tcp_stdout ERROR_VARIABLE tcp_stderr ) if(NOT tcp_result EQUAL 0) message(FATAL_ERROR "MetaCoreRuntimeConfigTool tcp failed: ${tcp_stderr}") endif() string(FIND "${tcp_stdout}" "mode=tcp" tcp_mode_index) if(tcp_mode_index EQUAL -1) message(FATAL_ERROR "MetaCoreRuntimeConfigTool tcp output did not report mode=tcp: ${tcp_stdout}") endif() metacore_expect_exists("${tcp_runtime_dir}/ProjectRuntime.mcruntimecfg" "TCP runtime project document") metacore_expect_exists("${tcp_runtime_dir}/DataSources.mcruntime" "TCP runtime data sources document") metacore_expect_exists("${tcp_runtime_dir}/Bindings.mcruntime" "TCP runtime bindings document") metacore_expect_not_exists("${tcp_runtime_dir}/RuntimeReplay.mcstream" "TCP runtime replay stream") metacore_expect_exists("${tcp_project_root}/MetaCore.project.json" "TCP project descriptor") metacore_expect_exists("${tcp_project_root}/Scenes/Main.mcscene.json" "TCP startup scene") metacore_expect_exists("${tcp_project_root}/Assets/UI/Hud.mcui.json" "TCP startup UI") metacore_expect_contains("${tcp_project_root}/MetaCore.project.json" "\"runtime_directory\": \"Runtime\"" "TCP project descriptor") metacore_expect_contains("${tcp_project_root}/MetaCore.project.json" "\"startup_scene\": \"Scenes/Main.mcscene.json\"" "TCP project descriptor") metacore_expect_contains("${tcp_project_root}/Assets/UI/Hud.mcui.json" "runtime.status" "TCP startup UI")