mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Runtimes][CMake] Add differentiation build
Adding initial pass at the differentiation build. Co-authored-by: Andrew Sukach <a_sukach@apple.com>
This commit is contained in:
committed by
Andrew Sukach
parent
11cf263347
commit
7a1fdb3c08
@@ -149,11 +149,12 @@ copy_files(public/Platform Overlay/Windows/CRT
|
||||
TiocConstants.swift
|
||||
tgmath.swift.gyb)
|
||||
|
||||
# TODO: Add source directories for the platform overlays, supplemental
|
||||
# libraries, and test support libraries.
|
||||
|
||||
# Supplemental Libraries
|
||||
|
||||
# Copy Differentiation sources
|
||||
copy_library_sources("linker-support" "" "Supplemental/Differentiation")
|
||||
copy_library_sources("Differentiation" "public" "Supplemental")
|
||||
|
||||
# Copy StringProcessing, RegexParser, RegexBuilder
|
||||
if(NOT DEFINED StringProcessing_ROOT_DIR)
|
||||
find_path(StringProcessing_ROOT_DIR
|
||||
|
||||
@@ -47,3 +47,15 @@ if(SwiftRuntime_ENABLE_stringprocessing)
|
||||
CMAKE_ARGS
|
||||
${COMMON_OPTIONS})
|
||||
endif()
|
||||
|
||||
|
||||
# Differentiation
|
||||
if(SwiftRuntime_ENABLE_differentiation)
|
||||
ExternalProject_Add(Differentiation
|
||||
PREFIX "Differentiation"
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Differentiation"
|
||||
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
|
||||
INSTALL_COMMAND ""
|
||||
CMAKE_ARGS
|
||||
${COMMON_OPTIONS})
|
||||
endif()
|
||||
|
||||
96
Runtimes/Supplemental/Differentiation/CMakeLists.txt
Normal file
96
Runtimes/Supplemental/Differentiation/CMakeLists.txt
Normal file
@@ -0,0 +1,96 @@
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
|
||||
if($ENV{BUILD_NUMBER})
|
||||
math(EXPR BUILD_NUMBER "$ENV{BUILD_NUMBER} % 65535")
|
||||
set(BUILD_NUMBER ".${BUILD_NUMBER}")
|
||||
endif()
|
||||
project(SwiftDifferentiation
|
||||
LANGUAGES Swift C
|
||||
VERSION 6.1.0${BUILD_NUMBER})
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
|
||||
set(CMAKE_Swift_LANGUAGE_VERSION 5)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake/modules")
|
||||
|
||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||
message(SEND_ERROR "Swift Differentiation must build as a standalone project")
|
||||
endif()
|
||||
|
||||
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR
|
||||
"${PROJECT_SOURCE_DIR}/../../../"
|
||||
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
|
||||
|
||||
find_package(SwiftCore)
|
||||
|
||||
include(gyb)
|
||||
include(AvailabilityMacros)
|
||||
include(CatalystSupport)
|
||||
include(EmitSwiftInterface)
|
||||
include(ResourceEmbedding)
|
||||
include(InstallSwiftInterface)
|
||||
|
||||
option(${PROJECT_NAME}_ENABLE_VECTOR_TYPES "Enable vector support"
|
||||
${SwiftCore_ENABLE_VECTOR_TYPES})
|
||||
|
||||
option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Enable library evolution"
|
||||
${SwiftCore_ENABLE_LIBRARY_EVOLUTION})
|
||||
|
||||
add_compile_options(
|
||||
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
|
||||
$<$<COMPILE_LANGUAGE:Swift>:-nostdlibimport>
|
||||
$<$<COMPILE_LANGUAGE:Swift>:-parse-stdlib>
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-library-level api>"
|
||||
$<$<COMPILE_LANGUAGE:Swift>:-enforce-exclusivity=unchecked>
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-target-min-inlining-version min>"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NoncopyableGenerics2>"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SuppressedAssociatedTypes>"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SE427NoInferenceOnExtension>"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NonescapableTypes>"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependence>"
|
||||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature MemberImportVisibility>"
|
||||
$<$<AND:$<BOOL:${SwiftDifferentiation_ENABLE_LIBRARY_EVOLUTION}>,$<COMPILE_LANGUAGE:Swift>>:-enable-library-evolution>)
|
||||
|
||||
if(SwiftDifferentiation_ENABLE_VECTOR_TYPES)
|
||||
gyb_expand(SIMDDifferentiation.swift.gyb SIMDDifferentiation.swift)
|
||||
endif()
|
||||
gyb_expand(TgmathDerivatives.swift.gyb TgmathDerivatives.swift)
|
||||
gyb_expand(FloatingPointDifferentiation.swift.gyb
|
||||
FloatingPointDifferentiation.swift)
|
||||
|
||||
add_library(swift_Differentiation
|
||||
AnyDifferentiable.swift
|
||||
ArrayDifferentiation.swift
|
||||
Differentiable.swift
|
||||
DifferentialOperators.swift
|
||||
DifferentiationUtilities.swift
|
||||
OptionalDifferentiation.swift
|
||||
$<$<BOOL:${SwiftDifferentiation_ENABLE_VECTOR_TYPES}>:SIMDDifferentiation.swift>
|
||||
TgmathDerivatives.swift
|
||||
FloatingPointDifferentiation.swift
|
||||
linker-support/magic-symbols-for-install-name.c)
|
||||
|
||||
set_target_properties(swift_Differentiation PROPERTIES
|
||||
Swift_MODULE_NAME _Differentiation)
|
||||
|
||||
if(APPLE AND BUILD_SHARED_LIBS)
|
||||
target_link_options(swift_Differentiation PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
|
||||
endif()
|
||||
|
||||
target_link_libraries(swift_Differentiation PRIVATE swiftCore)
|
||||
|
||||
set(${PROJECT_NAME}_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${Supplemental_INSTALL_NESTED_SUBDIR}>:/${Supplemental_PLATFORM_SUBDIR}/${Supplemental_ARCH_SUBDIR}>" CACHE STRING "")
|
||||
set(${PROJECT_NAME}_INSTALL_SWIFTMODULEDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${Supplemental_INSTALL_NESTED_SUBDIR}>:/${Supplemental_PLATFORM_SUBDIR}>" CACHE STRING "")
|
||||
|
||||
install(TARGETS swift_Differentiation
|
||||
EXPORT SwiftSupplementalTargets
|
||||
COMPONENT ${PROJECT_NAME}_runtime
|
||||
ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
emit_swift_interface(swift_Differentiation)
|
||||
install_swift_interface(swift_Differentiation)
|
||||
|
||||
# Configure plist creation for Darwin platforms.
|
||||
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swift_Differentiation)
|
||||
embed_manifest(swift_Differentiation)
|
||||
Reference in New Issue
Block a user