[Win][PAL] Move WebCoreHeaderDetection.h to PAL
https://bugs.webkit.org/show_bug.cgi?id=176990

Patch by Yoshiaki Jitsukawa <Yoshiaki.Jitsukawa@sony.com> on 2017-09-18
Reviewed by Alex Christensen.

.:

Create DerivedSources directory for PAL if WebCore build is enabled.

* Source/cmake/WebKitCommon.cmake:
* Source/cmake/WebKitFS.cmake:

Source/WebCore:

* PlatformWin.cmake:
Stop generating WebCoreHeaderDetection.h in WebCore.

* config.h:
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
* platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
Include PALHeaderDetection.h instead of WebCoreHeaderDetection.h

Source/WebCore/PAL:

* AVFoundationSupport.py: Renamed from Source/WebCore/AVFoundationSupport.py.
(lookFor):
(fileContains):

* pal/PlatformWin.cmake:
Add a custom target PAL_PreBuild to generate PALHeaderDetection.h

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@222148 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/ChangeLog b/ChangeLog
index f99085b..6ed92f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-09-18  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
+
+        [Win][PAL] Move WebCoreHeaderDetection.h to PAL
+        https://bugs.webkit.org/show_bug.cgi?id=176990
+
+        Reviewed by Alex Christensen.
+
+        Create DerivedSources directory for PAL if WebCore build is enabled.
+
+        * Source/cmake/WebKitCommon.cmake:
+        * Source/cmake/WebKitFS.cmake:
+
 2017-09-15  Konstantin Tokarev  <annulen@yandex.ru>
 
         Consider enabling -Wno-expansion-to-defined for gcc 7
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 47b80d0..b0a417e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2017-09-18  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
+
+        [Win][PAL] Move WebCoreHeaderDetection.h to PAL
+        https://bugs.webkit.org/show_bug.cgi?id=176990
+
+        Reviewed by Alex Christensen.
+
+        * PlatformWin.cmake:
+        Stop generating WebCoreHeaderDetection.h in WebCore.
+
+        * config.h:
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        * platform/graphics/ca/win/PlatformCALayerWinInternal.cpp:
+        Include PALHeaderDetection.h instead of WebCoreHeaderDetection.h
+
 2017-09-18  Basuke Suzuki  <Basuke.Suzuki@sony.com>
 
         [Curl] Create classes dedicated to handle SSL related tasks
diff --git a/Source/WebCore/AVFoundationSupport.py b/Source/WebCore/PAL/AVFoundationSupport.py
similarity index 100%
rename from Source/WebCore/AVFoundationSupport.py
rename to Source/WebCore/PAL/AVFoundationSupport.py
diff --git a/Source/WebCore/PAL/ChangeLog b/Source/WebCore/PAL/ChangeLog
index 2523b68..62995fa 100644
--- a/Source/WebCore/PAL/ChangeLog
+++ b/Source/WebCore/PAL/ChangeLog
@@ -1,3 +1,17 @@
+2017-09-18  Yoshiaki Jitsukawa  <Yoshiaki.Jitsukawa@sony.com>
+
+        [Win][PAL] Move WebCoreHeaderDetection.h to PAL
+        https://bugs.webkit.org/show_bug.cgi?id=176990
+
+        Reviewed by Alex Christensen.
+
+        * AVFoundationSupport.py: Renamed from Source/WebCore/AVFoundationSupport.py.
+        (lookFor):
+        (fileContains):
+
+        * pal/PlatformWin.cmake:
+        Add a custom target PAL_PreBuild to generate PALHeaderDetection.h
+
 2017-09-15  Tim Horton  <timothy_horton@apple.com>
 
         Fix the macOS CMake build
diff --git a/Source/WebCore/PAL/pal/PlatformWin.cmake b/Source/WebCore/PAL/pal/PlatformWin.cmake
index 6e13855..e8b1bb6 100644
--- a/Source/WebCore/PAL/pal/PlatformWin.cmake
+++ b/Source/WebCore/PAL/pal/PlatformWin.cmake
@@ -29,3 +29,12 @@
         file(COPY ${_file} DESTINATION ${FORWARDING_HEADERS_DIR}/WebCore/pal/${_directory})
     endforeach ()
 endforeach ()
+
+# Generate PALHeaderDetection.h by PAL_PreBuild
+add_custom_target(PAL_PreBuild SOURCES "${DERIVED_SOURCES_PAL_DIR}/PALHeaderDetection.h")
+add_custom_command(
+    OUTPUT "${DERIVED_SOURCES_PAL_DIR}/PALHeaderDetection.h"
+    WORKING_DIRECTORY "${DERIVED_SOURCES_PAL_DIR}"
+    COMMAND ${PYTHON_EXECUTABLE} ${PAL_DIR}/AVFoundationSupport.py ${WEBKIT_LIBRARIES_DIR} > PALHeaderDetection.h
+    VERBATIM)
+add_dependencies(PAL PAL_PreBuild)
diff --git a/Source/WebCore/PlatformWin.cmake b/Source/WebCore/PlatformWin.cmake
index d3ca315..250b890 100644
--- a/Source/WebCore/PlatformWin.cmake
+++ b/Source/WebCore/PlatformWin.cmake
@@ -36,6 +36,7 @@
     "${WEBCORE_DIR}/platform/win"
     "${THIRDPARTY_DIR}/ANGLE/include"
     "${THIRDPARTY_DIR}/ANGLE/include/egl"
+    "${DERIVED_SOURCES_PAL_DIR}"
 )
 
 list(APPEND WebCore_SOURCES
@@ -140,10 +141,6 @@
     ${WEBCORE_DIR}/css/themeWinQuirks.css
 )
 
-list(APPEND WebCore_DERIVED_SOURCES
-    "${DERIVED_SOURCES_WEBCORE_DIR}/WebCoreHeaderDetection.h"
-)
-
 set(WebCore_FORWARDING_HEADERS_DIRECTORIES
     .
     accessibility
@@ -287,12 +284,6 @@
     include(PlatformAppleWin.cmake)
 endif ()
 
-add_custom_command(
-    OUTPUT "${DERIVED_SOURCES_WEBCORE_DIR}/WebCoreHeaderDetection.h"
-    WORKING_DIRECTORY "${DERIVED_SOURCES_WEBCORE_DIR}"
-    COMMAND ${PYTHON_EXECUTABLE} ${WEBCORE_DIR}/AVFoundationSupport.py ${WEBKIT_LIBRARIES_DIR} > WebCoreHeaderDetection.h
-    VERBATIM)
-
 make_directory(${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/WebKit.resources/en.lproj)
 file(COPY
     "${WEBCORE_DIR}/English.lproj/Localizable.strings"
diff --git a/Source/WebCore/config.h b/Source/WebCore/config.h
index e0b51d4..d3dee99 100644
--- a/Source/WebCore/config.h
+++ b/Source/WebCore/config.h
@@ -30,7 +30,7 @@
 #endif
 
 #if PLATFORM(WIN)
-#include "WebCoreHeaderDetection.h"
+#include <PALHeaderDetection.h>
 #endif
 
 #include "PlatformExportMacros.h"
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
index f0f9623..ca1da9f 100644
--- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
@@ -37,7 +37,6 @@
 #include "PlatformCALayerWinInternal.h"
 #include "TextRun.h"
 #include "TileController.h"
-#include "WebCoreHeaderDetection.h"
 #include "WebTiledBackingLayerWin.h"
 #include <QuartzCore/CoreAnimationCF.h>
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
diff --git a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
index 584ff91..3f43a05 100644
--- a/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
+++ b/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp
@@ -34,7 +34,6 @@
 #include "PlatformCALayer.h"
 #include "TileController.h"
 #include "TiledBacking.h"
-#include "WebCoreHeaderDetection.h"
 #include <QuartzCore/CACFLayer.h>
 #include <wtf/MainThread.h>
 
diff --git a/Source/cmake/WebKitCommon.cmake b/Source/cmake/WebKitCommon.cmake
index 79717b4..f919af7 100644
--- a/Source/cmake/WebKitCommon.cmake
+++ b/Source/cmake/WebKitCommon.cmake
@@ -63,6 +63,7 @@
     # -----------------------------------------------------------------------------
 
     if (ENABLE_WEBCORE)
+        file(MAKE_DIRECTORY ${DERIVED_SOURCES_PAL_DIR})
         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBCORE_DIR})
     endif ()
 
diff --git a/Source/cmake/WebKitFS.cmake b/Source/cmake/WebKitFS.cmake
index a5d585c..be96f16 100644
--- a/Source/cmake/WebKitFS.cmake
+++ b/Source/cmake/WebKitFS.cmake
@@ -31,6 +31,7 @@
 
 set(DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources")
 set(DERIVED_SOURCES_JAVASCRIPTCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/JavaScriptCore")
+set(DERIVED_SOURCES_PAL_DIR "${CMAKE_BINARY_DIR}/DerivedSources/PAL")
 set(DERIVED_SOURCES_WEBCORE_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebCore")
 set(DERIVED_SOURCES_WEBDRIVER_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebDriver")
 set(DERIVED_SOURCES_WEBKITLEGACY_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebKitLegacy")