mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
CMake: Pull swift-testing from the Swift toolchain
This confirmed works on Xcode 16, and Xcode 16.1 Beta 2, with CMake 3.28 or higher. On linux, the 6.0.0 release from swiftly is still missing my libstdc++ workaround, so it needs a snapshot to work.
This commit is contained in:
parent
7ab1d117f1
commit
0bedc79ca5
Notes:
github-actions[bot]
2024-09-23 17:07:17 +00:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/0bedc79ca58 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1477
2 changed files with 19 additions and 108 deletions
|
@ -1,45 +1,24 @@
|
||||||
# Finds the swift-testing library
|
# Finds the swift-testing library
|
||||||
# On Apple platforms, this is a framework included in the Xcode release
|
# On Apple platforms, this is a framework included in the Xcode release
|
||||||
|
|
||||||
# FIXME: Using Xcode's library actually doesn't work for rpath reasons
|
find_library(SWIFT_TESTING NAMES Testing
|
||||||
# When swift-testing ships better toolchain CMake support, we'll need to revisit this
|
PATHS ${SWIFT_LIBRARY_SEARCH_PATHS}
|
||||||
|
|
||||||
include(FetchContent)
|
|
||||||
|
|
||||||
# Allow the Ninja generators to output messages as they happen by assigning
|
|
||||||
# these jobs to the 'console' job pool
|
|
||||||
set(console_access "")
|
|
||||||
if(CMAKE_GENERATOR MATCHES "^Ninja")
|
|
||||||
set(console_access
|
|
||||||
USES_TERMINAL_CONFIGURE YES
|
|
||||||
USES_TERMINAL_BUILD YES
|
|
||||||
USES_TERMINAL_INSTALL YES
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE OPT_IN)
|
|
||||||
FetchContent_Declare(SwiftTesting
|
|
||||||
GIT_REPOSITORY https://github.com/swiftlang/swift-testing.git
|
|
||||||
GIT_TAG d00d46920f9bb35342ad29398ea4740a2bbf3d38
|
|
||||||
PATCH_COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/patches/git-patch.cmake"
|
|
||||||
"${CMAKE_CURRENT_LIST_DIR}/patches/swift-testing//0001-CMake-Allow-ExternalProjects-to-use-console-with-Nin.patch"
|
|
||||||
OVERRIDE_FIND_PACKAGE
|
|
||||||
SYSTEM
|
|
||||||
${console_access}
|
|
||||||
)
|
)
|
||||||
|
if (SWIFT_TESTING)
|
||||||
block()
|
if (NOT TARGET SwiftTesting::SwiftTesting)
|
||||||
add_cxx_compile_options(-Wno-error)
|
add_library(SwiftTesting::SwiftTesting IMPORTED UNKNOWN)
|
||||||
set(SwiftTesting_MACRO "<auto>")
|
message(STATUS "Found SwiftTesting: ${SWIFT_TESTING}")
|
||||||
FetchContent_MakeAvailable(SwiftTesting)
|
cmake_path(GET SWIFT_TESTING PARENT_PATH _SWIFT_TESTING_DIR)
|
||||||
add_cxx_compile_options(-Werror)
|
set_target_properties(SwiftTesting::SwiftTesting PROPERTIES
|
||||||
endblock()
|
IMPORTED_LOCATION "${SWIFT_TESTING}"
|
||||||
|
INTERFACE_LINK_DIRECTORIES "${_SWIFT_TESTING_DIR}"
|
||||||
if (NOT TARGET SwiftTesting::SwiftTesting)
|
)
|
||||||
# FIXME: This should be an interface property on the target itself, if the maintainers intend
|
if (UNIX AND NOT APPLE)
|
||||||
# for the repository to be fetch-content-able
|
cmake_path(GET _SWIFT_TESTING_DIR PARENT_PATH _SWIFT_TESTING_TARGETLESS_DIR)
|
||||||
set_property(TARGET Testing APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-load-plugin-executable ${CMAKE_BINARY_DIR}/bin/TestingMacros#TestingMacros>")
|
set_target_properties(SwiftTesting::SwiftTesting PROPERTIES
|
||||||
add_library(SwiftTesting::SwiftTesting ALIAS Testing)
|
INTERFACE_COMPILE_OPTIONS "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-load-plugin-library ${_SWIFT_TESTING_TARGETLESS_DIR}/host/plugins/libTestingMacros.so>"
|
||||||
set(SwiftTesting_LIBRARIES SwiftTesting::SwiftTesting)
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
set(SwiftTesting_FOUND TRUE)
|
||||||
endif()
|
endif()
|
||||||
set(SwiftTesting_FOUND TRUE)
|
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andrew Kaster <andrew@ladybird.org>
|
|
||||||
Date: Mon, 26 Aug 2024 21:35:45 -0600
|
|
||||||
Subject: [PATCH] [CMake] Allow ExternalProjects to use console with Ninja
|
|
||||||
generator
|
|
||||||
|
|
||||||
Also stop forcing the SwiftMacros project to build every rebuild.
|
|
||||||
---
|
|
||||||
Sources/CMakeLists.txt | 13 ++++++++++++-
|
|
||||||
Sources/TestingMacros/CMakeLists.txt | 14 +++++++++++++-
|
|
||||||
2 files changed, 25 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt
|
|
||||||
index 83a9a2b2330c9847ebac89e273c6ade9bf398a25..d917509ba47c2ddaf6b7a2d7d17de2afaabc68fd 100644
|
|
||||||
--- a/Sources/CMakeLists.txt
|
|
||||||
+++ b/Sources/CMakeLists.txt
|
|
||||||
@@ -43,10 +43,21 @@ if(SwiftTesting_MACRO STREQUAL "<auto>")
|
|
||||||
# Build and install the plugin into the current build directry.
|
|
||||||
set(SwiftTesting_MACRO_INSTALL_PREFIX "${CMAKE_BINARY_DIR}")
|
|
||||||
|
|
||||||
+ # Allow the Ninja generators to output messages as they happen by assigning
|
|
||||||
+ # these jobs to the 'console' job pool
|
|
||||||
+ set(SwiftTesting_ConsoleAccess "")
|
|
||||||
+ if(CMAKE_GENERATOR MATCHES "^Ninja")
|
|
||||||
+ set(SwiftTesting_ConsoleAccess
|
|
||||||
+ USES_TERMINAL_CONFIGURE YES
|
|
||||||
+ USES_TERMINAL_BUILD YES
|
|
||||||
+ USES_TERMINAL_INSTALL YES)
|
|
||||||
+ endif()
|
|
||||||
+
|
|
||||||
ExternalProject_Add(TestingMacros
|
|
||||||
PREFIX "tm"
|
|
||||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/TestingMacros"
|
|
||||||
- BUILD_ALWAYS ON
|
|
||||||
+ BUILD_ALWAYS OFF
|
|
||||||
+ ${SwiftTesting_ConsoleAccess}
|
|
||||||
CMAKE_ARGS
|
|
||||||
-DCMAKE_MAKE_PROGRAM=${SwiftTesting_MACRO_MAKE_PROGRAM}
|
|
||||||
-DCMAKE_Swift_COMPILER=${SwiftTesting_MACRO_Swift_COMPILER}
|
|
||||||
diff --git a/Sources/TestingMacros/CMakeLists.txt b/Sources/TestingMacros/CMakeLists.txt
|
|
||||||
index a45663025a43adf39d17f0d94d692c9bf6092194..aa9939079ff18dee00288bf7fb0c92c124438228 100644
|
|
||||||
--- a/Sources/TestingMacros/CMakeLists.txt
|
|
||||||
+++ b/Sources/TestingMacros/CMakeLists.txt
|
|
||||||
@@ -28,11 +28,23 @@ if(SwiftTesting_BuildMacrosAsExecutables)
|
|
||||||
# When building the macro plugin as an executable, clone and build
|
|
||||||
# swift-syntax.
|
|
||||||
include(FetchContent)
|
|
||||||
+
|
|
||||||
+ # Allow the Ninja generators to output messages as they happen by assigning
|
|
||||||
+ # these jobs to the 'console' job pool
|
|
||||||
+ set(SwiftTesting_ConsoleAccess "")
|
|
||||||
+ if(CMAKE_GENERATOR MATCHES "^Ninja")
|
|
||||||
+ set(SwiftTesting_ConsoleAccess
|
|
||||||
+ USES_TERMINAL_CONFIGURE YES
|
|
||||||
+ USES_TERMINAL_BUILD YES
|
|
||||||
+ USES_TERMINAL_INSTALL YES)
|
|
||||||
+ endif()
|
|
||||||
+
|
|
||||||
set(FETCHCONTENT_BASE_DIR ${CMAKE_BINARY_DIR}/_d)
|
|
||||||
# TODO: Update GIT_TAG to the 6.0 release tag once it is available.
|
|
||||||
FetchContent_Declare(SwiftSyntax
|
|
||||||
GIT_REPOSITORY https://github.com/swiftlang/swift-syntax
|
|
||||||
- GIT_TAG 27b74edd5de625d0e399869a5af08f1501af8837)
|
|
||||||
+ GIT_TAG 27b74edd5de625d0e399869a5af08f1501af8837
|
|
||||||
+ ${SwiftTesting_ConsoleAccess})
|
|
||||||
FetchContent_MakeAvailable(SwiftSyntax)
|
|
||||||
endif()
|
|
||||||
|
|
Loading…
Reference in a new issue