|
@@ -1,6 +1,7 @@
|
|
|
cmake_minimum_required(VERSION 3.30)
|
|
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/json.cmake)
|
|
|
+include(${CMAKE_CURRENT_LIST_DIR}/verify-snippet.cmake)
|
|
|
# Test CALLBACK script. Prints output information and verifies index file
|
|
|
# Called as: cmake -P hook.cmake [CheckForStaticQuery?] [index.json]
|
|
|
set(index ${CMAKE_ARGV4})
|
|
@@ -19,7 +20,7 @@ function(add_error error)
|
|
|
return(PROPAGATE ERROR_MESSAGE)
|
|
|
endfunction()
|
|
|
|
|
|
-function(has_key key json)
|
|
|
+function(has_key_index key json)
|
|
|
cmake_parse_arguments(ARG "UNEXPECTED" "" "" ${ARGN})
|
|
|
unset(missingKey)
|
|
|
string(JSON ${key} ERROR_VARIABLE missingKey GET "${json}" ${key})
|
|
@@ -28,13 +29,13 @@ function(has_key key json)
|
|
|
elseif(ARG_UNEXPECTED AND missingKey MATCHES NOTFOUND)
|
|
|
add_error("\nUnexpected key \"${key}\" in index:\n${json}")
|
|
|
endif()
|
|
|
- return(PROPAGATE RunCMake_TEST_FAILED ${key})
|
|
|
+ return(PROPAGATE ERROR_MESSAGE ${key})
|
|
|
endfunction()
|
|
|
|
|
|
-has_key(version "${contents}")
|
|
|
-has_key(buildDir "${contents}")
|
|
|
-has_key(dataDir "${contents}")
|
|
|
-has_key(snippets "${contents}")
|
|
|
+has_key_index(version "${contents}")
|
|
|
+has_key_index(buildDir "${contents}")
|
|
|
+has_key_index(dataDir "${contents}")
|
|
|
+has_key_index(snippets "${contents}")
|
|
|
|
|
|
if (NOT version EQUAL 1)
|
|
|
add_error("Version must be 1, got: ${version}")
|
|
@@ -47,32 +48,34 @@ foreach(i RANGE ${length})
|
|
|
if (NOT EXISTS ${dataDir}/${filename})
|
|
|
add_error("Listed snippet: ${dataDir}/${filename} does not exist")
|
|
|
endif()
|
|
|
+ read_json(${dataDir}/${filename} snippet_contents)
|
|
|
+ verify_snippet(${dataDir}/${filename} "${snippet_contents}")
|
|
|
endforeach()
|
|
|
|
|
|
-has_key(staticSystemInformation "${contents}" ${hasStaticInfo})
|
|
|
-has_key(OSName "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(OSPlatform "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(OSRelease "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(OSVersion "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(familyId "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(hostname "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(is64Bits "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(modelId "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(numberOfLogicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(numberOfPhysicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(processorAPICID "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(processorCacheSize "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(processorClockFrequency "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(processorName "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(totalPhysicalMemory "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(totalVirtualMemory "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(vendorID "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
-has_key(vendorString "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(staticSystemInformation "${contents}" ${hasStaticInfo})
|
|
|
+has_key_index(OSName "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(OSPlatform "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(OSRelease "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(OSVersion "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(familyId "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(hostname "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(is64Bits "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(modelId "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(numberOfLogicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(numberOfPhysicalCPU "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(processorAPICID "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(processorCacheSize "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(processorClockFrequency "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(processorName "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(totalPhysicalMemory "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(totalVirtualMemory "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(vendorID "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+has_key_index(vendorString "${staticSystemInformation}" ${hasStaticInfo})
|
|
|
+
|
|
|
+get_filename_component(dataDir ${index} DIRECTORY)
|
|
|
+get_filename_component(v1 ${dataDir} DIRECTORY)
|
|
|
+file(WRITE ${v1}/${hook}.hook "${ERROR_MESSAGE}")
|
|
|
|
|
|
if (NOT ERROR_MESSAGE MATCHES "^$")
|
|
|
message(FATAL_ERROR ${ERROR_MESSAGE})
|
|
|
endif()
|
|
|
-
|
|
|
-get_filename_component(dataDir ${index} DIRECTORY)
|
|
|
-get_filename_component(v1 ${dataDir} DIRECTORY)
|
|
|
-file(TOUCH ${v1}/${hook}.hook)
|