[CMake] Use target oriented design for bmalloc
authordon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 22:58:23 +0000 (22:58 +0000)
committerdon.olmstead@sony.com <don.olmstead@sony.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 May 2019 22:58:23 +0000 (22:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198046

Reviewed by Konstantin Tokarev.

.:

Add WEBKIT_COPY_FILES to WebKitMacros so it is available to all CMake code. Add
bmalloc_FRAMEWORK_HEADERS_DIR for specifying the location to copy bmalloc headers to.

* Source/cmake/WebKitFS.cmake:
* Source/cmake/WebKitMacros.cmake:

Source/bmalloc:

Switch to a target oriented dsign for bmalloc. Use target_include_directories directly
instead of include_directories.

List the headers for bmalloc and copy them using WEBKIT_COPY_FILES.

Add an intermediate target bmalloc_PostBuild which depends on bmalloc and the headers
being copied. Then alias that to WebKit::bmalloc.

* CMakeLists.txt:
* PlatformMac.cmake:

Source/ThirdParty/ANGLE:

Remove WEBKIT_COPY_FILES from CMakelists.txt now that it is in WebKitMacros.

* CMakeLists.txt:

Source/WTF:

Use WebKit::bmalloc target.

* wtf/CMakeLists.txt:

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

ChangeLog
Source/ThirdParty/ANGLE/CMakeLists.txt
Source/ThirdParty/ANGLE/ChangeLog
Source/WTF/ChangeLog
Source/WTF/wtf/CMakeLists.txt
Source/bmalloc/CMakeLists.txt
Source/bmalloc/ChangeLog
Source/bmalloc/PlatformMac.cmake
Source/cmake/WebKitFS.cmake
Source/cmake/WebKitMacros.cmake

index a653437..9298ad3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-05-23  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use target oriented design for bmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=198046
+
+        Reviewed by Konstantin Tokarev.
+
+        Add WEBKIT_COPY_FILES to WebKitMacros so it is available to all CMake code. Add
+        bmalloc_FRAMEWORK_HEADERS_DIR for specifying the location to copy bmalloc headers to.
+
+        * Source/cmake/WebKitFS.cmake:
+        * Source/cmake/WebKitMacros.cmake:
+
 2019-05-21  Don Olmstead  <don.olmstead@sony.com>
 
         [WinCairo] Build WebDriver
index 4726c8b..8767a2c 100644 (file)
@@ -1,35 +1,3 @@
-# FIXME: Remove when landing https://bugs.webkit.org/show_bug.cgi?id=197174
-function(WEBKIT_COPY_FILES target_name)
-    set(options FLATTENED)
-    set(oneValueArgs DESTINATION)
-    set(multiValueArgs FILES)
-    cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-    set(files ${opt_FILES})
-    set(dst_files)
-    foreach (file IN LISTS files)
-        if (IS_ABSOLUTE ${file})
-            set(src_file ${file})
-        else ()
-            set(src_file ${CMAKE_CURRENT_SOURCE_DIR}/${file})
-        endif ()
-        if (opt_FLATTENED)
-            get_filename_component(filename ${file} NAME)
-            set(dst_file ${opt_DESTINATION}/${filename})
-        else ()
-            get_filename_component(file_dir ${file} DIRECTORY)
-            file(MAKE_DIRECTORY ${opt_DESTINATION}/${file_dir})
-            set(dst_file ${opt_DESTINATION}/${file})
-        endif ()
-        add_custom_command(OUTPUT ${dst_file}
-            COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file}
-            MAIN_DEPENDENCY ${file}
-            VERBATIM
-        )
-        list(APPEND dst_files ${dst_file})
-    endforeach ()
-    add_custom_target(${target_name} DEPENDS ${dst_files})
-endfunction()
-
 include(Compiler.cmake)
 include(GLESv2.cmake)
 
index 3ed106d..dd1e479 100644 (file)
@@ -1,3 +1,14 @@
+2019-05-23  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use target oriented design for bmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=198046
+
+        Reviewed by Konstantin Tokarev.
+
+        Remove WEBKIT_COPY_FILES from CMakelists.txt now that it is in WebKitMacros.
+
+        * CMakeLists.txt:
+
 2019-05-14  Miguel Gomez  <magomez@igalia.com>
 
         REGRESSION(r245088): [GTK] Several WebGL tests failing
index a8f45dd..c265abd 100644 (file)
@@ -1,3 +1,14 @@
+2019-05-23  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use target oriented design for bmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=198046
+
+        Reviewed by Konstantin Tokarev.
+
+        Use WebKit::bmalloc target.
+
+        * wtf/CMakeLists.txt:
+
 2019-05-23  Ross Kirsling  <ross.kirsling@sony.com>
 
         [PlayStation] Implement platformUserPreferredLanguages.
index 07f501a..4d2e3f9 100644 (file)
@@ -458,7 +458,6 @@ set(WTF_SOURCES
 )
 
 set(WTF_INCLUDE_DIRECTORIES
-    "${BMALLOC_DIR}"
     # FIXME: https://bugs.webkit.org/show_bug.cgi?id=196734#c1
     "${CMAKE_BINARY_DIR}"
     "${DERIVED_SOURCES_DIR}"
@@ -483,7 +482,7 @@ set(WTF_LIBRARIES
 )
 
 if (NOT USE_SYSTEM_MALLOC)
-    list(APPEND WTF_LIBRARIES bmalloc)
+    list(APPEND WTF_LIBRARIES WebKit::bmalloc)
 endif ()
 
 list(APPEND WTF_SOURCES
index f33bd52..2e07f1a 100644 (file)
@@ -1,6 +1,6 @@
 set_property(DIRECTORY . PROPERTY FOLDER "bmalloc")
 
-set(bmalloc_INCLUDE_DIRECTORIES
+set(bmalloc_PRIVATE_INCLUDE_DIRECTORIES
     "${BMALLOC_DIR}"
 )
 
@@ -36,6 +36,101 @@ set(bmalloc_SOURCES
     bmalloc/mbmalloc.cpp
 )
 
+set(bmalloc_PUBLIC_HEADERS
+    bmalloc/Algorithm.h
+    bmalloc/AllIsoHeaps.h
+    bmalloc/AllIsoHeapsInlines.h
+    bmalloc/Allocator.h
+    bmalloc/AvailableMemory.h
+    bmalloc/BAssert.h
+    bmalloc/BCompiler.h
+    bmalloc/BExport.h
+    bmalloc/BInline.h
+    bmalloc/BMalloced.h
+    bmalloc/BPlatform.h
+    bmalloc/BVMTags.h
+    bmalloc/Bits.h
+    bmalloc/BulkDecommit.h
+    bmalloc/BumpAllocator.h
+    bmalloc/BumpRange.h
+    bmalloc/Cache.h
+    bmalloc/Chunk.h
+    bmalloc/CryptoRandom.h
+    bmalloc/Deallocator.h
+    bmalloc/DebugHeap.h
+    bmalloc/DeferredDecommit.h
+    bmalloc/DeferredDecommitInlines.h
+    bmalloc/DeferredTrigger.h
+    bmalloc/DeferredTriggerInlines.h
+    bmalloc/EligibilityResult.h
+    bmalloc/EligibilityResultInlines.h
+    bmalloc/Environment.h
+    bmalloc/FixedVector.h
+    bmalloc/FreeList.h
+    bmalloc/FreeListInlines.h
+    bmalloc/Gigacage.h
+    bmalloc/Heap.h
+    bmalloc/HeapKind.h
+    bmalloc/IsoAllocator.h
+    bmalloc/IsoAllocatorInlines.h
+    bmalloc/IsoConfig.h
+    bmalloc/IsoDeallocator.h
+    bmalloc/IsoDeallocatorInlines.h
+    bmalloc/IsoDirectory.h
+    bmalloc/IsoDirectoryInlines.h
+    bmalloc/IsoDirectoryPage.h
+    bmalloc/IsoDirectoryPageInlines.h
+    bmalloc/IsoHeap.h
+    bmalloc/IsoHeapImpl.h
+    bmalloc/IsoHeapImplInlines.h
+    bmalloc/IsoHeapInlines.h
+    bmalloc/IsoPage.h
+    bmalloc/IsoPageInlines.h
+    bmalloc/IsoPageTrigger.h
+    bmalloc/IsoSharedConfig.h
+    bmalloc/IsoSharedHeap.h
+    bmalloc/IsoSharedHeapInlines.h
+    bmalloc/IsoSharedPage.h
+    bmalloc/IsoSharedPageInlines.h
+    bmalloc/IsoTLS.h
+    bmalloc/IsoTLSAllocatorEntry.h
+    bmalloc/IsoTLSAllocatorEntryInlines.h
+    bmalloc/IsoTLSDeallocatorEntry.h
+    bmalloc/IsoTLSDeallocatorEntryInlines.h
+    bmalloc/IsoTLSEntry.h
+    bmalloc/IsoTLSEntryInlines.h
+    bmalloc/IsoTLSInlines.h
+    bmalloc/IsoTLSLayout.h
+    bmalloc/LargeMap.h
+    bmalloc/LargeRange.h
+    bmalloc/LineMetadata.h
+    bmalloc/List.h
+    bmalloc/Logging.h
+    bmalloc/Map.h
+    bmalloc/Mutex.h
+    bmalloc/Object.h
+    bmalloc/ObjectType.h
+    bmalloc/PerHeapKind.h
+    bmalloc/PerProcess.h
+    bmalloc/PerThread.h
+    bmalloc/PhysicalPageMap.h
+    bmalloc/ProcessCheck.h
+    bmalloc/Range.h
+    bmalloc/Scavenger.h
+    bmalloc/ScopeExit.h
+    bmalloc/Sizes.h
+    bmalloc/SmallLine.h
+    bmalloc/SmallPage.h
+    bmalloc/StaticPerProcess.h
+    bmalloc/StdLibExtras.h
+    bmalloc/Syscall.h
+    bmalloc/VMAllocate.h
+    bmalloc/VMHeap.h
+    bmalloc/Vector.h
+    bmalloc/Zone.h
+    bmalloc/bmalloc.h
+)
+
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
     list(APPEND bmalloc_SOURCES
         bmalloc/Zone.cpp
@@ -49,13 +144,27 @@ set(bmalloc_LIBRARIES
 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
 
 WEBKIT_WRAP_SOURCELIST(${bmalloc_SOURCES})
-include_directories(${bmalloc_INCLUDE_DIRECTORIES})
+
 add_library(bmalloc STATIC ${bmalloc_SOURCES})
+target_include_directories(bmalloc PRIVATE ${bmalloc_PRIVATE_INCLUDE_DIRECTORIES})
+target_include_directories(bmalloc INTERFACE "$<BUILD_INTERFACE:${bmalloc_FRAMEWORK_HEADERS_DIR}>")
 target_link_libraries(bmalloc ${bmalloc_LIBRARIES})
 set_target_properties(bmalloc PROPERTIES COMPILE_DEFINITIONS "BUILDING_bmalloc")
 
+WEBKIT_COPY_FILES(bmalloc_CopyHeaders
+    DESTINATION ${bmalloc_FRAMEWORK_HEADERS_DIR}
+    FILES ${bmalloc_PUBLIC_HEADERS}
+)
+
+add_library(bmalloc_PostBuild INTERFACE)
+target_link_libraries(bmalloc_PostBuild INTERFACE bmalloc)
+add_dependencies(bmalloc_PostBuild bmalloc_CopyHeaders)
+
+add_library(WebKit::bmalloc ALIAS bmalloc_PostBuild)
+
 if (DEVELOPER_MODE)
     add_library(mbmalloc SHARED bmalloc/mbmalloc.cpp)
+    target_include_directories(mbmalloc PRIVATE ${bmalloc_PRIVATE_INCLUDE_DIRECTORIES})
     target_link_libraries(mbmalloc bmalloc ${CMAKE_THREAD_LIBS_INIT} ${bmalloc_LIBRARIES})
     set_target_properties(mbmalloc PROPERTIES COMPILE_DEFINITIONS "BUILDING_mbmalloc")
 endif ()
index 988eb70..ddfd806 100644 (file)
@@ -1,3 +1,21 @@
+2019-05-23  Don Olmstead  <don.olmstead@sony.com>
+
+        [CMake] Use target oriented design for bmalloc
+        https://bugs.webkit.org/show_bug.cgi?id=198046
+
+        Reviewed by Konstantin Tokarev.
+
+        Switch to a target oriented dsign for bmalloc. Use target_include_directories directly
+        instead of include_directories.
+
+        List the headers for bmalloc and copy them using WEBKIT_COPY_FILES.
+
+        Add an intermediate target bmalloc_PostBuild which depends on bmalloc and the headers
+        being copied. Then alias that to WebKit::bmalloc.
+
+        * CMakeLists.txt:
+        * PlatformMac.cmake:
+
 2019-05-16  Keith Miller  <keith_miller@apple.com>
 
         Wasm should cage the memory base pointers in structs
index c53c48e..48bd546 100644 (file)
@@ -3,3 +3,8 @@ add_definitions(-DBPLATFORM_MAC=1)
 list(APPEND bmalloc_SOURCES
     bmalloc/ProcessCheck.mm
 )
+
+list(APPEND bmalloc_PUBLIC_HEADERS
+    bmalloc/darwin/BSoftLinking.h
+    bmalloc/darwin/MemoryStatusSPI.h
+)
index b4918c1..5b36481 100644 (file)
@@ -50,6 +50,7 @@ set(WebInspectorUI_DERIVED_SOURCES_DIR "${CMAKE_BINARY_DIR}/DerivedSources/WebIn
 
 set(FORWARDING_HEADERS_DIR ${DERIVED_SOURCES_DIR}/ForwardingHeaders)
 
+set(bmalloc_FRAMEWORK_HEADERS_DIR ${FORWARDING_HEADERS_DIR})
 set(ANGLE_FRAMEWORK_HEADERS_DIR ${FORWARDING_HEADERS_DIR})
 set(WTF_FRAMEWORK_HEADERS_DIR ${FORWARDING_HEADERS_DIR})
 set(JavaScriptCore_FRAMEWORK_HEADERS_DIR ${FORWARDING_HEADERS_DIR})
index 4aacbd6..6d57ee3 100644 (file)
@@ -333,6 +333,37 @@ function(WEBKIT_MAKE_FORWARDING_HEADERS framework)
     add_dependencies(${framework} ${target_name})
 endfunction()
 
+function(WEBKIT_COPY_FILES target_name)
+    set(options FLATTENED)
+    set(oneValueArgs DESTINATION)
+    set(multiValueArgs FILES)
+    cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+    set(files ${opt_FILES})
+    set(dst_files)
+    foreach (file IN LISTS files)
+        if (IS_ABSOLUTE ${file})
+            set(src_file ${file})
+        else ()
+            set(src_file ${CMAKE_CURRENT_SOURCE_DIR}/${file})
+        endif ()
+        if (opt_FLATTENED)
+            get_filename_component(filename ${file} NAME)
+            set(dst_file ${opt_DESTINATION}/${filename})
+        else ()
+            get_filename_component(file_dir ${file} DIRECTORY)
+            file(MAKE_DIRECTORY ${opt_DESTINATION}/${file_dir})
+            set(dst_file ${opt_DESTINATION}/${file})
+        endif ()
+        add_custom_command(OUTPUT ${dst_file}
+            COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file}
+            MAIN_DEPENDENCY ${file}
+            VERBATIM
+        )
+        list(APPEND dst_files ${dst_file})
+    endforeach ()
+    add_custom_target(${target_name} DEPENDS ${dst_files})
+endfunction()
+
 # Helper macros for debugging CMake problems.
 macro(WEBKIT_DEBUG_DUMP_COMMANDS)
     set(CMAKE_VERBOSE_MAKEFILE ON)