Ninja: Update BuildDepends test to verify cmcldeps depfiles.

This commit is contained in:
Robert Maynard 2013-07-23 14:53:00 -04:00 committed by Brad King
parent 6fa9d0ab40
commit 9275554496
3 changed files with 58 additions and 0 deletions

View File

@ -53,6 +53,8 @@ write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in
"static const char* zot = \"zot\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/dir/header.txt
"#define HEADER_STRING \"ninja\"\n" )
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in
"static const char* zot_custom = \"zot_custom\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
@ -93,6 +95,26 @@ if(NOT RESULT)
message(SEND_ERROR "Could not build test project (1)!")
endif()
# find and save the ninjadep executable
set(ninjadep ${BuildDepends_BINARY_DIR}/Project/ninjadep${CMAKE_EXECUTABLE_SUFFIX})
if(EXISTS
"${BuildDepends_BINARY_DIR}/Project/Debug/ninjadep${CMAKE_EXECUTABLE_SUFFIX}" )
message("found debug")
set(ninjadep
"${BuildDepends_BINARY_DIR}/Project/Debug/ninjadep${CMAKE_EXECUTABLE_SUFFIX}")
endif()
message("Running ${ninjadep} ")
execute_process(COMMAND ${ninjadep} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("Run result: ${runResult} Output: \"${out}\"")
if("${out}" STREQUAL "HEADER_STRING: ninja ")
message("Worked!")
else()
message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n"
" expected [HEADER_STRING: ninja]")
endif()
set(bar ${BuildDepends_BINARY_DIR}/Project/bar${CMAKE_EXECUTABLE_SUFFIX})
if(EXISTS
"${BuildDepends_BINARY_DIR}/Project/Debug/bar${CMAKE_EXECUTABLE_SUFFIX}" )
@ -151,6 +173,8 @@ execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
message("Modifying Project/foo.cxx")
write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx
"const char* foo() { return \"foo changed\";}" )
file(WRITE "${BuildDepends_BINARY_DIR}/Project/dir/header.txt"
"#define HEADER_STRING \"ninja changed\"\n" )
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in
"static const char* zot = \"zot changed\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in
@ -204,6 +228,18 @@ if(EXISTS
message("found debug")
endif()
message("Running ${ninjadep} ")
execute_process(COMMAND ${ninjadep} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("Run result: ${runResult} Output: \"${out}\"")
if("${out}" STREQUAL "HEADER_STRING: ninja changed ")
message("Worked!")
else()
message(SEND_ERROR "Project did not rebuild properly. Output[${out}]\n"
" expected [HEADER_STRING: ninja changed]")
endif()
message("Running ${bar} ")
execute_process(COMMAND ${bar} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
string(REGEX REPLACE "[\r\n]" " " out "${out}")

View File

@ -123,3 +123,19 @@ add_custom_target(link_depends_no_shared_check ALL
-P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake
)
add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.txt
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_BINARY_DIR}/dir/header.txt
${CMAKE_CURRENT_BINARY_DIR}/dir/header.h
)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dir/header.h
PROPERTIES GENERATED 1)
add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(ninjadep ninjadep.cpp)
add_dependencies(ninjadep header_tgt)

View File

@ -0,0 +1,6 @@
#include <stdio.h>
#include "dir/header.h"
int main() {
printf("HEADER_STRING: %s\n", HEADER_STRING);
}