[Win][CMake] Use add_custom_command to copy each forwarding header files
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Dec 2017 22:06:35 +0000 (22:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Dec 2017 22:06:35 +0000 (22:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180921

Patch by Fujii Hironori <Hironori.Fujii@sony.com> on 2017-12-28
Reviewed by Brent Fulgham.

.:

Modifying WTF header files didn't trigger the recompilation of
TestWTF because Ninja doesn't know which command generates the
forwarding header.

Use add_custom_command to copy each forwarding header files.

* Source/cmake/WebKitMacros.cmake: Added a new function WEBKIT_MAKE_FORWARDING_HEADERS.

Source/JavaScriptCore:

* PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.

Source/WebCore:

No new tests because there is no behavior change.

* PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.

Source/WebKitLegacy:

* PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.

Source/WTF:

* wtf/PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.

Tools:

TestWTFLib needs forwarding headers of WebCore. Use
add_dependencies instead of invoking the DerivedSources/WebCore/preBuild.cmd.

* TestWebKitAPI/PlatformWin.cmake:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226306 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/PlatformWin.cmake
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformWin.cmake
Source/WebCore/ChangeLog
Source/WebCore/PlatformWin.cmake
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/PlatformWin.cmake
Source/cmake/WebKitMacros.cmake
Tools/ChangeLog
Tools/TestWebKitAPI/PlatformWin.cmake

index 611c708..b50c864 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [Win][CMake] Use add_custom_command to copy each forwarding header files
+        https://bugs.webkit.org/show_bug.cgi?id=180921
+
+        Reviewed by Brent Fulgham.
+
+        Modifying WTF header files didn't trigger the recompilation of
+        TestWTF because Ninja doesn't know which command generates the
+        forwarding header.
+
+        Use add_custom_command to copy each forwarding header files.
+
+        * Source/cmake/WebKitMacros.cmake: Added a new function WEBKIT_MAKE_FORWARDING_HEADERS.
+
 2017-12-22  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [GTK] Duplicated symbols in libjavascriptcoregtk and libwebkit2gtk can cause crashes in production builds
index b2e3d94..6dde26b 100644 (file)
@@ -1,3 +1,12 @@
+2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [Win][CMake] Use add_custom_command to copy each forwarding header files
+        https://bugs.webkit.org/show_bug.cgi?id=180921
+
+        Reviewed by Brent Fulgham.
+
+        * PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.
+
 2017-12-28  Saam Barati  <sbarati@apple.com>
 
         Assertion used to determine if something is an async generator is wrong
index b348eae..efc8ee7 100644 (file)
@@ -33,16 +33,10 @@ file(COPY
     ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
 )
 
-file(MAKE_DIRECTORY ${FORWARDING_HEADERS_DIR}/JavaScriptCore)
-
-set(JavaScriptCore_PRE_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore/preBuild.cmd")
-file(REMOVE "${JavaScriptCore_PRE_BUILD_COMMAND}")
-foreach (_directory ${JavaScriptCore_FORWARDING_HEADERS_DIRECTORIES})
-    file(APPEND "${JavaScriptCore_PRE_BUILD_COMMAND}" "@xcopy /y /d /f \"${JAVASCRIPTCORE_DIR}/${_directory}/*.h\" \"${FORWARDING_HEADERS_DIR}/JavaScriptCore\" >nul 2>nul\n")
-endforeach ()
-
-set(JavaScriptCore_POST_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore/postBuild.cmd")
-file(WRITE "${JavaScriptCore_POST_BUILD_COMMAND}" "@xcopy /y /d /f \"${DERIVED_SOURCES_DIR}/JavaScriptCore/*.h\" \"${FORWARDING_HEADERS_DIR}/JavaScriptCore\" >nul 2>nul\n")
-file(APPEND "${JavaScriptCore_POST_BUILD_COMMAND}" "@xcopy /y /d /f \"${DERIVED_SOURCES_DIR}/JavaScriptCore/inspector/*.h\" \"${FORWARDING_HEADERS_DIR}/JavaScriptCore\" >nul 2>nul\n")
+WEBKIT_MAKE_FORWARDING_HEADERS(JavaScriptCore
+    DIRECTORIES ${JavaScriptCore_FORWARDING_HEADERS_DIRECTORIES}
+    DERIVED_SOURCE_DIRECTORIES ${DERIVED_SOURCES_DIR}/JavaScriptCore ${DERIVED_SOURCES_DIR}/JavaScriptCore/inspector
+    FLATTENED
+)
 
 set(JavaScriptCore_OUTPUT_NAME JavaScriptCore${DEBUG_SUFFIX})
index 4c7eb3b..cb74198 100644 (file)
@@ -1,3 +1,12 @@
+2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [Win][CMake] Use add_custom_command to copy each forwarding header files
+        https://bugs.webkit.org/show_bug.cgi?id=180921
+
+        Reviewed by Brent Fulgham.
+
+        * wtf/PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.
+
 2017-12-27  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [WTF] Add clock_gettime based monotonicallyIncreasingTime implementation for Linux and BSDs
index 14d9d34..6e080f2 100644 (file)
@@ -26,8 +26,20 @@ if (USE_CF)
     list(APPEND WTF_LIBRARIES ${COREFOUNDATION_LIBRARY})
 endif ()
 
-set(WTF_PRE_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/WTF/preBuild.cmd")
-file(WRITE "${WTF_PRE_BUILD_COMMAND}" "@xcopy /y /s /d /f \"${WTF_DIR}/wtf/*.h\" \"${FORWARDING_HEADERS_DIR}/wtf\" >nul 2>nul\n@xcopy /y /s /d /f \"${DERIVED_SOURCES_DIR}/WTF/*.h\" \"${FORWARDING_HEADERS_DIR}/wtf\" >nul 2>nul\n")
-file(MAKE_DIRECTORY ${FORWARDING_HEADERS_DIR}/wtf)
+set(WTF_FORWARDING_HEADERS_DIRECTORIES
+    .
+    cf
+    dtoa
+    generic
+    persistence
+    spi
+    text
+    threads
+    unicode
+    win
+)
+WEBKIT_MAKE_FORWARDING_HEADERS(WTF
+    DESTINATION ${FORWARDING_HEADERS_DIR}/wtf
+    DIRECTORIES ${WTF_FORWARDING_HEADERS_DIRECTORIES})
 
 set(WTF_OUTPUT_NAME WTF${DEBUG_SUFFIX})
index 265c2cf..6938b94 100644 (file)
@@ -1,3 +1,14 @@
+2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [Win][CMake] Use add_custom_command to copy each forwarding header files
+        https://bugs.webkit.org/show_bug.cgi?id=180921
+
+        Reviewed by Brent Fulgham.
+
+        No new tests because there is no behavior change.
+
+        * PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.
+
 2017-12-27  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         Build fix after r226299
index daa5b35..f335739 100644 (file)
@@ -313,17 +313,12 @@ if (WTF_PLATFORM_WIN_CAIRO AND EXISTS ${WEBKIT_LIBRARIES_DIR}/etc/ssl/cert.pem)
     )
 endif ()
 
-file(MAKE_DIRECTORY ${FORWARDING_HEADERS_DIR}/WebCore)
-
-set(WebCore_DERIVED_SOURCES_PRE_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/WebCore/preBuild.cmd")
-file(WRITE "${WebCore_DERIVED_SOURCES_PRE_BUILD_COMMAND}" "@xcopy /y /s /d /f \"${WEBCORE_DIR}/ForwardingHeaders/*.h\" \"${FORWARDING_HEADERS_DIR}/WebCore\" >nul 2>nul\n")
-foreach (_directory ${WebCore_FORWARDING_HEADERS_DIRECTORIES})
-    file(APPEND "${WebCore_DERIVED_SOURCES_PRE_BUILD_COMMAND}" "@xcopy /y /d /f \"${WEBCORE_DIR}/${_directory}/*.h\" \"${FORWARDING_HEADERS_DIR}/WebCore\" >nul 2>nul\n")
-endforeach ()
-
-set(WebCore_POST_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/WebCore/postBuild.cmd")
-file(WRITE "${WebCore_POST_BUILD_COMMAND}" "@xcopy /y /s /d /f \"${DERIVED_SOURCES_WEBCORE_DIR}/*.h\" \"${FORWARDING_HEADERS_DIR}/WebCore\" >nul 2>nul\n")
-file(APPEND "${WebCore_POST_BUILD_COMMAND}" "@xcopy /y /s /d /f \"${DERIVED_SOURCES_PAL_DIR}/*.h\" \"${FORWARDING_HEADERS_DIR}/WebCore\" >nul 2>nul\n")
+WEBKIT_MAKE_FORWARDING_HEADERS(WebCore
+    DIRECTORIES ${WebCore_FORWARDING_HEADERS_DIRECTORIES}
+    EXTRA_DIRECTORIES ForwardingHeaders
+    DERIVED_SOURCE_DIRECTORIES ${DERIVED_SOURCES_WEBCORE_DIR} ${DERIVED_SOURCES_PAL_DIR}
+    FLATTENED
+)
 
 set(WebCore_OUTPUT_NAME
     WebCore${DEBUG_SUFFIX}
index 31fab84..4292832 100644 (file)
@@ -1,3 +1,12 @@
+2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [Win][CMake] Use add_custom_command to copy each forwarding header files
+        https://bugs.webkit.org/show_bug.cgi?id=180921
+
+        Reviewed by Brent Fulgham.
+
+        * PlatformWin.cmake: Use WEBKIT_MAKE_FORWARDING_HEADERS.
+
 2017-12-14  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Drop Thread::tryCreate
index b30dd39..2bfa637 100644 (file)
@@ -476,14 +476,12 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MSVC_RUNTIME_LINKE
 file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBKITLEGACY_DIR}/Interfaces)
 
-set(WebKitLegacyGUID_PRE_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/WebKitLegacy/preBuild.cmd")
-file(WRITE "${WebKitLegacyGUID_PRE_BUILD_COMMAND}" "@xcopy /y /d /f \"${CMAKE_CURRENT_SOURCE_DIR}/win/WebKitCOMAPI.h\" \"${FORWARDING_HEADERS_DIR}/WebKitLegacy\" >nul 2>nul\n@xcopy /y /d /f \"${CMAKE_CURRENT_SOURCE_DIR}/win/CFDictionaryPropertyBag.h\" \"${FORWARDING_HEADERS_DIR}/WebKitLegacy\" >nul 2>nul\n")
-file(MAKE_DIRECTORY ${FORWARDING_HEADERS_DIR}/WebKitLegacy)
-add_custom_command(TARGET WebKitLegacyGUID PRE_BUILD COMMAND ${WebKitLegacyGUID_PRE_BUILD_COMMAND} VERBATIM)
-
-set(WebKitLegacyGUID_POST_BUILD_COMMAND "${CMAKE_BINARY_DIR}/DerivedSources/WebKitLegacy/postBuild.cmd")
-file(WRITE "${WebKitLegacyGUID_POST_BUILD_COMMAND}" "@xcopy /y /d /f \"${DERIVED_SOURCES_WEBKITLEGACY_DIR}/Interfaces/*.h\" \"${FORWARDING_HEADERS_DIR}/WebKitLegacy\" >nul 2>nul")
-add_custom_command(TARGET WebKitLegacyGUID POST_BUILD COMMAND ${WebKitLegacyGUID_POST_BUILD_COMMAND} VERBATIM)
+WEBKIT_MAKE_FORWARDING_HEADERS(WebKitLegacyGUID
+    DESTINATION ${FORWARDING_HEADERS_DIR}/WebKitLegacy
+    FILES win/WebKitCOMAPI.h win/CFDictionaryPropertyBag.h
+    DERIVED_SOURCE_DIRECTORIES ${DERIVED_SOURCES_WEBKITLEGACY_DIR}/Interfaces
+    FLATTENED
+)
 
 set(WebKitLegacy_OUTPUT_NAME
     WebKit${DEBUG_SUFFIX}
index 370b82f..f0981eb 100644 (file)
@@ -215,6 +215,79 @@ macro(WEBKIT_CREATE_FORWARDING_HEADERS _framework)
     endif ()
 endmacro()
 
+function(WEBKIT_MAKE_FORWARDING_HEADERS framework)
+    set(options FLATTENED)
+    set(oneValueArgs DESTINATION)
+    set(multiValueArgs DIRECTORIES EXTRA_DIRECTORIES DERIVED_SOURCE_DIRECTORIES FILES)
+    cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+    set(headers ${opt_FILES})
+    if (opt_DESTINATION)
+        set(destination ${opt_DESTINATION})
+    else ()
+        set(destination ${FORWARDING_HEADERS_DIR}/${framework})
+    endif ()
+    file(MAKE_DIRECTORY ${destination})
+    foreach (dir IN LISTS opt_DIRECTORIES)
+        file(GLOB files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${dir}/*.h)
+        list(APPEND headers ${files})
+    endforeach ()
+    set(fwd_headers)
+    foreach (header IN LISTS headers)
+        if (opt_FLATTENED)
+            get_filename_component(header_filename ${header} NAME)
+            set(fwd_header ${destination}/${header_filename})
+        else ()
+            get_filename_component(header_dir ${header} DIRECTORY)
+            file(MAKE_DIRECTORY ${destination}/${header_dir})
+            set(fwd_header ${destination}/${header})
+        endif ()
+        add_custom_command(OUTPUT ${fwd_header}
+            COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${header} ${fwd_header}
+            MAIN_DEPENDENCY ${header}
+            VERBATIM
+        )
+        list(APPEND fwd_headers ${fwd_header})
+    endforeach ()
+    foreach (dir IN LISTS opt_EXTRA_DIRECTORIES)
+        set(dir ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
+        file(GLOB_RECURSE files RELATIVE ${dir} ${dir}/*.h)
+        foreach (header IN LISTS files)
+            get_filename_component(header_dir ${header} DIRECTORY)
+            file(MAKE_DIRECTORY ${destination}/${header_dir})
+            set(fwd_header ${destination}/${header})
+            add_custom_command(OUTPUT ${fwd_header}
+                COMMAND ${CMAKE_COMMAND} -E copy ${dir}/${header} ${fwd_header}
+                MAIN_DEPENDENCY ${dir}/${header}
+                VERBATIM
+            )
+            list(APPEND fwd_headers ${fwd_header})
+        endforeach ()
+    endforeach ()
+    add_custom_target(${framework}ForwardingHeaders DEPENDS ${fwd_headers})
+    add_dependencies(${framework} ${framework}ForwardingHeaders)
+    if (opt_DERIVED_SOURCE_DIRECTORIES)
+        set(script ${CMAKE_CURRENT_BINARY_DIR}/makeForwardingHeaders.cmake)
+        set(content "")
+        foreach (dir IN LISTS opt_DERIVED_SOURCE_DIRECTORIES)
+            string(CONCAT content ${content}
+                "file(GLOB headers \"${dir}/*.h\")\n"
+                "foreach (header IN LISTS headers)\n"
+                "    get_filename_component(header_filename \${header} NAME)\n"
+                "    execute_process(COMMAND \${CMAKE_COMMAND} -E copy \${header} ${destination}/\${header_filename} RESULT_VARIABLE result)\n"
+                "    if (NOT \${result} EQUAL 0)\n"
+                "        message(FATAL_ERROR \"Failed to copy \${header}: \${result}\")\n"
+                "    endif ()\n"
+                "endforeach ()\n"
+            )
+        endforeach ()
+        file(WRITE ${script} ${content})
+        add_custom_command(TARGET ${framework} POST_BUILD
+            COMMAND ${CMAKE_COMMAND} -P ${script}
+            VERBATIM
+        )
+    endif ()
+endfunction()
+
 # Helper macros for debugging CMake problems.
 macro(WEBKIT_DEBUG_DUMP_COMMANDS)
     set(CMAKE_VERBOSE_MAKEFILE ON)
index f081b44..850e220 100644 (file)
@@ -1,3 +1,15 @@
+2017-12-28  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [Win][CMake] Use add_custom_command to copy each forwarding header files
+        https://bugs.webkit.org/show_bug.cgi?id=180921
+
+        Reviewed by Brent Fulgham.
+
+        TestWTFLib needs forwarding headers of WebCore. Use
+        add_dependencies instead of invoking the DerivedSources/WebCore/preBuild.cmd.
+
+        * TestWebKitAPI/PlatformWin.cmake:
+
 2017-12-22  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         Unreviewed, try to fix the Sierra build again after r226277.
index 7142194..0d24e0e 100644 (file)
@@ -2,11 +2,6 @@ set(TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
 set(TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY_WTF "${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}")
 add_definitions(-DUSE_CONSOLE_ENTRY_POINT)
 
-add_custom_target(forwarding-headersWinForTestWebKitAPI
-    COMMAND ${CMAKE_BINARY_DIR}/DerivedSources/WebCore/preBuild.cmd VERBATIM
-)
-set(ForwardingHeadersForTestWebKitAPI_NAME forwarding-headersWinForTestWebKitAPI)
-
 if (${WTF_PLATFORM_WIN_CAIRO})
     add_definitions(-DWIN_CAIRO)
 endif ()
@@ -110,7 +105,7 @@ add_library(TestWTFLib SHARED
 )
 set_target_properties(TestWTFLib PROPERTIES OUTPUT_NAME "TestWTFLib")
 target_link_libraries(TestWTFLib ${test_wtf_LIBRARIES})
-add_dependencies(TestWTFLib ${ForwardingHeadersForTestWebKitAPI_NAME})
+add_dependencies(TestWTFLib WebCoreForwardingHeaders)
 
 set(test_wtf_LIBRARIES
     shlwapi
@@ -129,7 +124,6 @@ add_executable(TestWebCore
     ${TOOLS_DIR}/win/DLLLauncher/DLLLauncherMain.cpp
 )
 target_link_libraries(TestWebCore shlwapi)
-add_dependencies(TestWebCore ${ForwardingHeadersForTestWebKitAPI_NAME})
 
 
 add_test(TestWebCore ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/TestWebCore)
@@ -160,7 +154,6 @@ add_executable(TestWebKitLegacy
     ${TOOLS_DIR}/win/DLLLauncher/DLLLauncherMain.cpp
 )
 target_link_libraries(TestWebKitLegacy shlwapi)
-add_dependencies(TestWebKitLegacy ${ForwardingHeadersForTestWebKitAPI_NAME})
 
 add_test(TestWebKitLegacy ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/TestWebKitLegacy)
 set_tests_properties(TestWebKitLegacy PROPERTIES TIMEOUT 60)