[CMake] Replace AVFoundationSupport.py using CMake
authordon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 23:28:10 +0000 (23:28 +0000)
committerdon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 23:28:10 +0000 (23:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182891

Reviewed by Per Arne Vollan.

.:

Adds CMake checks for AVFoundation support replacing the functionality
of AVFoundationSupport.py.

CMake is used to detect the symbols expected with the HAVE_* checks for
AVFoundation support. This involves creating source files that will be
built which verifies the presence of symbols. For Apple frameworks it
is customary to include the main framework file which includes the
other associated headers.

The check for HAVE_AVCFPLAYERITEM_CALLBACK_VERSION_2 involves looking
for an enumeration which a symbol check cannot detect. Instead a small
program is used which will compile and link when the version 2
enumeration is present.

* Source/cmake/OptionsAppleWin.cmake:
* Source/cmake/OptionsWin.cmake:
* Source/cmake/WebKitCommon.cmake:
* Source/cmake/WebKitFeatures.cmake:

Source/WebCore:

No new tests. No change in behavior.

Remove refernces to PAL derived sources.

* PlatformWin.cmake:
* config.h:

Source/WebCore/PAL:

Remove AVFoundationSupport.py file and its invocation.

* AVFoundationSupport.py: Removed.
* config.h:
* pal/PlatformWin.cmake:

Source/WebKitLegacy/win:

Remove references to the config.h contained in WebCore as it should
not be accessible from outside of WebCore.

* WebKitPrefix.h:

Source/WTF:

Rely on CMake values for the added HAVE_* checks.

* wtf/Platform.h:

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

16 files changed:
ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/PAL/AVFoundationSupport.py [deleted file]
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/config.h
Source/WebCore/PAL/pal/PlatformWin.cmake
Source/WebCore/PlatformWin.cmake
Source/WebCore/config.h
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebKitPrefix.h
Source/cmake/OptionsAppleWin.cmake
Source/cmake/OptionsWin.cmake
Source/cmake/WebKitCommon.cmake
Source/cmake/WebKitFeatures.cmake

index fefeda8..3db6d56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2018-08-30  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Replace AVFoundationSupport.py using CMake
+        https://bugs.webkit.org/show_bug.cgi?id=182891
+
+        Reviewed by Per Arne Vollan.
+
+        Adds CMake checks for AVFoundation support replacing the functionality
+        of AVFoundationSupport.py.
+
+        CMake is used to detect the symbols expected with the HAVE_* checks for
+        AVFoundation support. This involves creating source files that will be
+        built which verifies the presence of symbols. For Apple frameworks it
+        is customary to include the main framework file which includes the
+        other associated headers.
+
+        The check for HAVE_AVCFPLAYERITEM_CALLBACK_VERSION_2 involves looking
+        for an enumeration which a symbol check cannot detect. Instead a small
+        program is used which will compile and link when the version 2
+        enumeration is present.
+
+        * Source/cmake/OptionsAppleWin.cmake:
+        * Source/cmake/OptionsWin.cmake:
+        * Source/cmake/WebKitCommon.cmake:
+        * Source/cmake/WebKitFeatures.cmake:
+
 2018-08-28  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Use CMake's FindFreetype
index 9267c1f..d3e261f 100644 (file)
@@ -1,3 +1,14 @@
+2018-08-30  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Replace AVFoundationSupport.py using CMake
+        https://bugs.webkit.org/show_bug.cgi?id=182891
+
+        Reviewed by Per Arne Vollan.
+
+        Rely on CMake values for the added HAVE_* checks.
+
+        * wtf/Platform.h:
+
 2018-08-30  Tim Horton  <timothy_horton@apple.com>
 
         Bundle unified sources more tightly in projects with deep directory structures
index 67cfa93..2adf0fb 100644 (file)
 #endif
 #endif
 
-#if PLATFORM(IOS) || PLATFORM(MAC) || (OS(WINDOWS) && USE(CG))
+#if PLATFORM(IOS) || PLATFORM(MAC)
 #define HAVE_AVFOUNDATION_MEDIA_SELECTION_GROUP 1
 #endif
 
-#if PLATFORM(IOS) || PLATFORM(MAC) || (OS(WINDOWS) && USE(CG))
+#if PLATFORM(IOS) || PLATFORM(MAC)
 #define HAVE_AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT 1
 #define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
 #endif
index a5427ec..10b5f37 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-30  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Replace AVFoundationSupport.py using CMake
+        https://bugs.webkit.org/show_bug.cgi?id=182891
+
+        Reviewed by Per Arne Vollan.
+
+        No new tests. No change in behavior.
+
+        Remove refernces to PAL derived sources.
+
+        * PlatformWin.cmake:
+        * config.h:
+
 2018-08-30  Olivia Barnett  <obarnett@apple.com>
 
         REGRESSION(r235489): fast/dom/navigator-detached-no-crash.html crashes under Navigator::share
diff --git a/Source/WebCore/PAL/AVFoundationSupport.py b/Source/WebCore/PAL/AVFoundationSupport.py
deleted file mode 100644 (file)
index 94d0e62..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python
-
-# Copyright (C) 2015 Apple Inc.  All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1.  Redistributions of source code must retain the above copyright
-#     notice, this list of conditions and the following disclaimer.
-# 2.  Redistributions in binary form must reproduce the above copyright
-#     notice, this list of conditions and the following disclaimer in the
-#     documentation and/or other materials provided with the distribution.
-# 3.  Neither the name of Apple puter, Inc. ("Apple") nor the names of
-#     its contributors may be used to endorse or promote products derived
-#     from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
-# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import re
-import sys
-import os
-
-
-def lookFor(relativePath):
-    return os.path.isfile(sys.argv[1] + relativePath)
-
-
-def fileContains(relativePath, regexp):
-    with open(sys.argv[1] + relativePath) as file:
-        for line in file:
-            if regexp.search(line):
-                return True
-    return False
-
-
-print("/* Identifying AVFoundation Support */")
-if lookFor("/include/AVFoundationCF/AVCFBase.h"):
-    print("#define HAVE_AVCF 1")
-if lookFor("/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h"):
-    print("#define HAVE_AVCF_LEGIBLE_OUTPUT 1")
-if lookFor("/include/AVFoundationCF/AVCFAssetResourceLoader.h"):
-    print("#define HAVE_AVFOUNDATION_LOADER_DELEGATE 1")
-if lookFor("/include/AVFoundationCF/AVCFAsset.h"):
-    regexp = re.compile("AVCFURLAssetIsPlayableExtendedMIMEType")
-    if fileContains("/include/AVFoundationCF/AVCFAsset.h", regexp):
-        print("#define HAVE_AVCFURL_PLAYABLE_MIMETYPE 1")
-if lookFor("/include/QuartzCore/CACFLayer.h"):
-    regexp = re.compile("CACFLayerSetContentsScale")
-    if fileContains("/include/QuartzCore/CACFLayer.h", regexp):
-        print("#define HAVE_CACFLAYER_SETCONTENTSSCALE 1")
-if lookFor("/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h"):
-    regexp = re.compile("kAVCFPlayerItemLegibleOutput_CallbacksVersion_2")
-    if fileContains("/include/AVFoundationCF/AVCFPlayerItemLegibleOutput.h", regexp):
-        print("#define HAVE_AVCFPLAYERITEM_CALLBACK_VERSION_2 1")
index 7cc5f63..e695f7a 100644 (file)
@@ -1,3 +1,16 @@
+2018-08-30  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Replace AVFoundationSupport.py using CMake
+        https://bugs.webkit.org/show_bug.cgi?id=182891
+
+        Reviewed by Per Arne Vollan.
+
+        Remove AVFoundationSupport.py file and its invocation.
+
+        * AVFoundationSupport.py: Removed.
+        * config.h:
+        * pal/PlatformWin.cmake:
+
 2018-08-29  Jer Noble  <jer.noble@apple.com>
 
         Muted elements do not have their Now Playing status updated when unmuted.
index e01af2f..260c060 100644 (file)
 
 #include <wtf/Platform.h>
 
-#if PLATFORM(WIN)
-#include <PALHeaderDetection.h>
-#endif
-
 #include <pal/ExportMacros.h>
 
 #ifdef __cplusplus
 #endif
 
 #include <wtf/DisallowCType.h>
-
-#if PLATFORM(WIN) && USE(CG) && HAVE(AVCF)
-#define USE_AVFOUNDATION 1
-
-#if HAVE(AVCF_LEGIBLE_OUTPUT)
-#define USE_AVFOUNDATION 1
-#define HAVE_AVFOUNDATION_MEDIA_SELECTION_GROUP 1
-#define HAVE_AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT 1
-#define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
-#endif
-
-#endif
index cbcbcb9..4b1176c 100644 (file)
@@ -13,7 +13,6 @@ list(APPEND PAL_SOURCES
 list(APPEND PAL_INCLUDE_DIRECTORIES
     "${CMAKE_BINARY_DIR}"
     "${CMAKE_BINARY_DIR}/../include/private"
-    "${DERIVED_SOURCES_PAL_DIR}"
 )
 
 if (${WTF_PLATFORM_WIN_CAIRO})
@@ -23,12 +22,3 @@ else ()
 endif ()
 
 set(PAL_OUTPUT_NAME PAL${DEBUG_SUFFIX})
-
-# 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)
index ff3994a..a24a919 100644 (file)
@@ -15,7 +15,6 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/platform/win"
     "${THIRDPARTY_DIR}/ANGLE/include"
     "${THIRDPARTY_DIR}/ANGLE/include/egl"
-    "${DERIVED_SOURCES_PAL_DIR}"
 )
 
 list(APPEND WebCore_SOURCES
@@ -317,7 +316,7 @@ endif ()
 
 WEBKIT_MAKE_FORWARDING_HEADERS(WebCore
     DIRECTORIES ${WebCore_FORWARDING_HEADERS_DIRECTORIES}
-    DERIVED_SOURCE_DIRECTORIES ${DERIVED_SOURCES_WEBCORE_DIR} ${DERIVED_SOURCES_PAL_DIR}
+    DERIVED_SOURCE_DIRECTORIES ${DERIVED_SOURCES_WEBCORE_DIR}
     FLATTENED
 )
 
index 6e5c16b..8f45050 100644 (file)
 #define USE_FILE_LOCK 1
 #endif
 
-#if PLATFORM(WIN)
-#include <PALHeaderDetection.h>
-#endif
-
 #include "PlatformExportMacros.h"
 #include <JavaScriptCore/JSExportMacros.h>
 #include <pal/ExportMacros.h>
@@ -74,15 +70,3 @@ typedef float CGFloat;
 #define CGFLOAT_DEFINED 1
 #endif
 #endif /* USE(CG) */
-
-#if PLATFORM(WIN) && USE(CG) && HAVE(AVCF)
-#define USE_AVFOUNDATION 1
-
-#if HAVE(AVCF_LEGIBLE_OUTPUT)
-#define USE_AVFOUNDATION 1
-#define HAVE_AVFOUNDATION_MEDIA_SELECTION_GROUP 1
-#define HAVE_AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT 1
-#define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
-#endif
-
-#endif
index 283618c..2254702 100644 (file)
@@ -1,3 +1,15 @@
+2018-08-30  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Replace AVFoundationSupport.py using CMake
+        https://bugs.webkit.org/show_bug.cgi?id=182891
+
+        Reviewed by Per Arne Vollan.
+
+        Remove references to the config.h contained in WebCore as it should
+        not be accessible from outside of WebCore.
+
+        * WebKitPrefix.h:
+
 2018-08-21  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [Attachment Support] Augment _WKAttachment SPI to handle NSFileWrappers in addition to NSData
index 3525310..3fbacf6 100644 (file)
 #include "cmakeconfig.h"
 #endif
 
+#include <JavaScriptCore/JSExportMacros.h>
+#include <WebCore/PlatformExportMacros.h>
+#include <pal/ExportMacros.h>
+
+#if USE(CF)
 #include <CoreFoundation/CoreFoundation.h>
+#endif
+
 #include <WebKit.h>
-#include "config.h"
+
+#ifdef __cplusplus
+
+// These undefs match up with defines in WebCorePrefix.h for Mac OS X.
+// Helps us catch if anyone uses new or delete by accident in code and doesn't include "config.h".
+#undef new
+#undef delete
+#include <wtf/FastMalloc.h>
+
+#endif
+
+#include <wtf/DisallowCType.h>
+
+#if USE(CG)
+#ifndef CGFLOAT_DEFINED
+#if (defined(__LP64__) && __LP64__) || (defined(__x86_64__) && __x86_64__) || defined(_M_X64) || defined(__amd64__)
+typedef double CGFloat;
+#else
+typedef float CGFloat;
+#endif
+#define CGFLOAT_DEFINED 1
+#endif
+#endif /* USE(CG) */
 
 // WebKit.dll is expected to export the symbols in WebCore that have been marked
 // as WEBCORE_EXPORT
index 7a5dac4..05f0719 100644 (file)
@@ -23,6 +23,48 @@ if (${USE_DIRECT2D})
 else ()
     SET_AND_EXPOSE_TO_BUILD(USE_CA ON)
     SET_AND_EXPOSE_TO_BUILD(USE_CG ON)
+
+    set(CMAKE_REQUIRED_INCLUDES ${WEBKIT_LIBRARIES_INCLUDE_DIR})
+    set(CMAKE_REQUIRED_LIBRARIES
+        "${WEBKIT_LIBRARIES_LINK_DIR}/CoreFoundation${DEBUG_SUFFIX}.lib"
+        "${WEBKIT_LIBRARIES_LINK_DIR}/AVFoundationCF${DEBUG_SUFFIX}.lib"
+        "${WEBKIT_LIBRARIES_LINK_DIR}/QuartzCore${DEBUG_SUFFIX}.lib"
+        "${WEBKIT_LIBRARIES_LINK_DIR}/libdispatch${DEBUG_SUFFIX}.lib"
+    )
+
+    WEBKIT_CHECK_HAVE_INCLUDE(HAVE_AVCF AVFoundationCF/AVCFBase.h)
+
+    if (HAVE_AVCF)
+         SET_AND_EXPOSE_TO_BUILD(USE_AVFOUNDATION ON)
+    endif ()
+
+    WEBKIT_CHECK_HAVE_SYMBOL(HAVE_AVCF_LEGIBLE_OUTPUT AVCFPlayerItemLegibleOutputSetCallbacks "TargetConditionals.h;dispatch/dispatch.h;AVFoundationCF/AVFoundationCF.h;AVFoundationCF/AVCFPlayerItemLegibleOutput.h")
+    WEBKIT_CHECK_HAVE_SYMBOL(HAVE_AVFOUNDATION_LOADER_DELEGATE AVCFAssetResourceLoaderSetCallbacks "TargetConditionals.h;dispatch/dispatch.h;AVFoundationCF/AVFoundationCF.h")
+    WEBKIT_CHECK_HAVE_SYMBOL(HAVE_AVCFURL_PLAYABLE_MIMETYPE AVCFURLAssetIsPlayableExtendedMIMEType "TargetConditionals.h;dispatch/dispatch.h;AVFoundationCF/AVFoundationCF.h")
+
+    # CMake cannot identify an enum through a symbol check so a source file is required
+    WEBKIT_CHECK_SOURCE_COMPILES(HAVE_AVCFPLAYERITEM_CALLBACK_VERSION_2 "
+    #include <AVFoundationCF/AVFoundationCF.h>
+    #include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
+    #include <CoreFoundation/CoreFoundation.h>
+    #include <dispatch/dispatch.h>
+
+    int main() {
+        CFArrayRef types = CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr);
+        AVCFPlayerItemLegibleOutputRef legibleOutput = AVCFPlayerItemLegibleOutputCreateWithMediaSubtypesForNativeRepresentation(kCFAllocatorDefault, types);
+        AVCFPlayerItemLegibleOutputCallbacks callbackInfo;
+        callbackInfo.version = kAVCFPlayerItemLegibleOutput_CallbacksVersion_2;
+        dispatch_queue_t dispatchQueue = dispatch_queue_create(\"test\", DISPATCH_QUEUE_SERIAL);
+        AVCFPlayerItemLegibleOutputSetCallbacks(legibleOutput, &callbackInfo, dispatchQueue);
+    }")
+
+    if (HAVE_AVCF_LEGIBLE_OUTPUT)
+        SET_AND_EXPOSE_TO_BUILD(HAVE_AVFOUNDATION_MEDIA_SELECTION_GROUP ON)
+        SET_AND_EXPOSE_TO_BUILD(HAVE_AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT ON)
+        SET_AND_EXPOSE_TO_BUILD(HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK ON)
+    endif ()
+
+    WEBKIT_CHECK_HAVE_SYMBOL(HAVE_CACFLAYER_SETCONTENTSSCALE CACFLayerSetContentsScale QuartzCore/CoreAnimationCF.h)
 endif ()
 
 # Warnings as errors (ignore narrowing conversions)
index a604d98..38292f3 100644 (file)
@@ -101,9 +101,9 @@ endif ()
 
 if (NOT WEBKIT_LIBRARIES_DIR)
     if (DEFINED ENV{WEBKIT_LIBRARIES})
-        set(WEBKIT_LIBRARIES_DIR "$ENV{WEBKIT_LIBRARIES}")
+        file(TO_CMAKE_PATH "$ENV{WEBKIT_LIBRARIES}" WEBKIT_LIBRARIES_DIR)
     else ()
-        set(WEBKIT_LIBRARIES_DIR "${CMAKE_SOURCE_DIR}/WebKitLibraries/win")
+        file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/WebKitLibraries/win" WEBKIT_LIBRARIES_DIR)
     endif ()
 endif ()
 
index 3843374..d659577 100644 (file)
@@ -75,7 +75,6 @@ if (NOT HAS_RUN_WEBKIT_COMMON)
     # -----------------------------------------------------------------------------
 
     if (ENABLE_WEBCORE)
-        file(MAKE_DIRECTORY ${DERIVED_SOURCES_PAL_DIR})
         file(MAKE_DIRECTORY ${DERIVED_SOURCES_WEBCORE_DIR})
     endif ()
 
index b70b616..116e0d9 100644 (file)
@@ -366,12 +366,17 @@ macro(WEBKIT_CHECK_HAVE_FUNCTION _variable _function)
 endmacro()
 
 macro(WEBKIT_CHECK_HAVE_SYMBOL _variable _symbol _header)
-    check_symbol_exists(${_symbol} ${_header} ${_variable}_value)
+    check_symbol_exists(${_symbol} "${_header}" ${_variable}_value)
     SET_AND_EXPOSE_TO_BUILD(${_variable} ${${_variable}_value})
 endmacro()
 
 macro(WEBKIT_CHECK_HAVE_STRUCT _variable _struct _member _header)
-    check_struct_has_member(${_struct} ${_member} ${_header} ${_variable}_value)
+    check_struct_has_member(${_struct} ${_member} "${_header}" ${_variable}_value)
+    SET_AND_EXPOSE_TO_BUILD(${_variable} ${${_variable}_value})
+endmacro()
+
+macro(WEBKIT_CHECK_SOURCE_COMPILES _variable _source)
+    check_cxx_source_compiles("${_source}" ${_variable}_value)
     SET_AND_EXPOSE_TO_BUILD(${_variable} ${${_variable}_value})
 endmacro()