mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Rewrite the CMake build system
Swift SVN r24124
This commit is contained in:
1813
CMakeLists.txt
1813
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
@@ -1,30 +0,0 @@
|
||||
# Minimal CMake toolchain file for iOS builds.
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Darwin)
|
||||
set(CMAKE_SYSTEM_VERSION 13.0) # Pretend to be OS X 10.9
|
||||
|
||||
execute_process(COMMAND xcrun -sdk iphoneos -toolchain XcodeDefault -find clang
|
||||
OUTPUT_VARIABLE cc_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND xcrun -sdk iphoneos -toolchain XcodeDefault -find clang++
|
||||
OUTPUT_VARIABLE cxx_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if (SWIFT_DISTCC)
|
||||
set(CMAKE_C_COMPILER_ARG1 "${cc_path}")
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "${cxx_path}")
|
||||
# These two calls don't have any effect other than to bypass the
|
||||
# check for a working compiler (since we're cross-compiling)
|
||||
CMAKE_FORCE_C_COMPILER("${SWIFT_DISTCC}" Clang)
|
||||
CMAKE_FORCE_CXX_COMPILER("${SWIFT_DISTCC}" Clang)
|
||||
else()
|
||||
CMAKE_FORCE_C_COMPILER("${cc_path}" Clang)
|
||||
CMAKE_FORCE_CXX_COMPILER("${cxx_path}" Clang)
|
||||
endif()
|
||||
|
||||
set(CXX_SUPPORTS_CXX11 ON FORCE)
|
||||
|
||||
# Compiler forcing leaves the compiler version unset, which the llvm
|
||||
# build machinery doesn't like. Pacify it.
|
||||
set(LLVM_FORCE_USE_OLD_TOOLCHAIN ON)
|
||||
@@ -1,30 +0,0 @@
|
||||
# Minimal CMake toolchain file for iOS simulator builds.
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Darwin)
|
||||
set(CMAKE_SYSTEM_VERSION 13.0) # Pretend to be OS X 10.9
|
||||
|
||||
execute_process(COMMAND xcrun -sdk iphonesimulator -toolchain XcodeDefault -find clang
|
||||
OUTPUT_VARIABLE cc_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND xcrun -sdk iphonesimulator -toolchain XcodeDefault -find clang++
|
||||
OUTPUT_VARIABLE cxx_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if (SWIFT_DISTCC)
|
||||
set(CMAKE_C_COMPILER_ARG1 "${cc_path}")
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "${cxx_path}")
|
||||
# These two calls don't have any effect other than to bypass the
|
||||
# check for a working compiler (since we're cross-compiling)
|
||||
CMAKE_FORCE_C_COMPILER("${SWIFT_DISTCC}" Clang)
|
||||
CMAKE_FORCE_CXX_COMPILER("${SWIFT_DISTCC}" Clang)
|
||||
else()
|
||||
CMAKE_FORCE_C_COMPILER("${cc_path}" Clang)
|
||||
CMAKE_FORCE_CXX_COMPILER("${cxx_path}" Clang)
|
||||
endif()
|
||||
|
||||
set(CXX_SUPPORTS_CXX11 ON FORCE)
|
||||
|
||||
# Compiler forcing leaves the compiler version unset, which the llvm
|
||||
# build machinery doesn't like. Pacify it.
|
||||
set(LLVM_FORCE_USE_OLD_TOOLCHAIN ON)
|
||||
@@ -1,18 +0,0 @@
|
||||
# Minimal CMake toolchain file for OS X builds.
|
||||
include(CMakeForceCompiler)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Darwin)
|
||||
|
||||
execute_process(COMMAND xcrun -sdk macosx -toolchain XcodeDefault -find clang
|
||||
OUTPUT_VARIABLE cc_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND xcrun -sdk macosx -toolchain XcodeDefault -find clang++
|
||||
OUTPUT_VARIABLE cxx_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
CMAKE_FORCE_C_COMPILER("${cc_path}" Clang)
|
||||
CMAKE_FORCE_CXX_COMPILER("${cxx_path}" Clang)
|
||||
|
||||
# Compiler forcing leaves the compiler version unset, which the llvm
|
||||
# build machinery doesn't like. Pacify it.
|
||||
set(LLVM_FORCE_USE_OLD_TOOLCHAIN ON)
|
||||
1574
cmake/modules/AddSwift.cmake
Normal file
1574
cmake/modules/AddSwift.cmake
Normal file
File diff suppressed because it is too large
Load Diff
162
cmake/modules/SwiftAddCustomCommandTarget.cmake
Normal file
162
cmake/modules/SwiftAddCustomCommandTarget.cmake
Normal file
@@ -0,0 +1,162 @@
|
||||
include(CMakeParseArguments)
|
||||
include(SwiftTranslateFlag)
|
||||
|
||||
# Populate the variable 'args' in the parent scope with a keyword
|
||||
# argument list. We read the variables options, ${k}_keyword, and
|
||||
# ACCT_${k} from the parent scope, for each ${k} in the list of
|
||||
# keyword names other than COMMAND accepted by
|
||||
# add_custom_command_target.
|
||||
#
|
||||
# ${k}_keyword must expand to ${k} if ${k} was passed to
|
||||
# add_custom_command_target, and be empty otherwise.
|
||||
#
|
||||
# ACCT_${k} must expand to the list of arguments to
|
||||
# add_custom_command_target marked by ${k}, and be empty otherwise.
|
||||
#
|
||||
function(_make_acct_argument_list)
|
||||
set(args)
|
||||
foreach(k ${ARGN})
|
||||
list(FIND options ${k} option_index)
|
||||
if(${option_index} EQUAL -1)
|
||||
list(APPEND args ${${k}_keyword} ${ACCT_${k}})
|
||||
else()
|
||||
list(APPEND args ${${k}_keyword})
|
||||
endif()
|
||||
endforeach()
|
||||
set(args ${args} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Add a custom command/target pair. Use this instead of
|
||||
# add_custom_command because it provides proper dependency tracking
|
||||
# when used with parallel builds and the 'Unix Makefiles' generator.
|
||||
# See https://www.cmake.org/Bug/view.php?id=10082
|
||||
#
|
||||
# The CMake documentation for add_custom_command quoth,
|
||||
#
|
||||
# "Do not list the output in more than one independent target that
|
||||
# may build in parallel or the two instances of the rule may
|
||||
# conflict (instead use add_custom_target to drive the command and
|
||||
# make the other targets depend on that one)."
|
||||
#
|
||||
# This function implements the suggested pattern.
|
||||
#
|
||||
# add_custom_command_target(
|
||||
# dependency_out_var_name
|
||||
#
|
||||
# COMMAND command1 [ARGS] [args1...]
|
||||
# [COMMAND command2 [ARGS] [args2...] ...]
|
||||
#
|
||||
# OUTPUT output1 [output2 ...]
|
||||
# [MAIN_DEPENDENCY depend]
|
||||
# [DEPENDS [depends...]]
|
||||
# [IMPLICIT_DEPENDS <lang1> depend1
|
||||
# [<lang2> depend2] ...]
|
||||
# [WORKING_DIRECTORY dir]
|
||||
# [COMMENT comment] [VERBATIM] [APPEND]
|
||||
# [ALL]
|
||||
# [SOURCES src1 [src2...]])
|
||||
#
|
||||
# dependency_out_var_name is the name of a variable, to be set in the
|
||||
# parent scope with the name of a target that all targets using the
|
||||
# OUTPUT should depend on. For example:
|
||||
#
|
||||
# add_custom_command_target(
|
||||
# TheDependency
|
||||
# COMMAND echo "int main() {}" ">" z.c
|
||||
# OUTPUT z.c
|
||||
# VERBATIM
|
||||
# DEPENDS z.c.gyb)
|
||||
#
|
||||
# add_executable(exe1 z.c)
|
||||
# add_dependencies(exe1 ${TheDependency})
|
||||
# add_executable(exe2 z.c)
|
||||
# add_dependencies(exe2 ${TheDependency})
|
||||
#
|
||||
# **Note1**: all COMMAND arguments must immediately follow
|
||||
# dependency_out_var_name or this function will misbehave.
|
||||
#
|
||||
# **Note2**: any subdirectories that define targets dependent on
|
||||
# OUTPUT ${o} should invoke:
|
||||
#
|
||||
# set_source_files_properties(${o} PROPERTIES GENERATED true)
|
||||
#
|
||||
# All arguments other than ALL, SOURCES, and dependency_out_var_name
|
||||
# are forwarded to add_custom_command; arguments ALL, SOURCES, and
|
||||
# WORKING_DIRECTORY are forwarded to add_custom_target. See the
|
||||
# documentation of those functions for a description of all arguments.
|
||||
#
|
||||
# How This Function Works
|
||||
#
|
||||
# CMake offers one way to add new build rules: add_custom_command.
|
||||
# Most people, however, overlook its actual semantics.
|
||||
# add_custom_command does *not* create a target. The CMake
|
||||
# documentation declareth,
|
||||
#
|
||||
# "A target created in the same directory (CMakeLists.txt file) that
|
||||
# specifies any output of the custom command as a source file is
|
||||
# given a rule to generate the file using the command at build
|
||||
# time."
|
||||
#
|
||||
# Therefore, when two targets built in parallel depend on an output of
|
||||
# the same custom command, they may race to rebuild that output.
|
||||
# Hilarity ensues. You might not notice this effect depending on the
|
||||
# generator you use, but it happens with 'Unix Makefiles'.
|
||||
#
|
||||
# By injecting a target into the dependency graph between the custom
|
||||
# command output and any targets that depend on that output, we force
|
||||
# the output to be built before starting on any of its dependent
|
||||
# targets.
|
||||
function(add_custom_command_target dependency_out_var_name)
|
||||
# Parse the arguments. We don't look for COMMAND arguments because
|
||||
# they don't follow the pattern supported by cmake_parse_arguments.
|
||||
# As a result, they end up in ACCT_UNPARSED_ARGUMENTS and are
|
||||
# forwarded verbatim.
|
||||
set(options ALL VERBATIM APPEND IDEMPOTENT)
|
||||
set(single_value_args
|
||||
MAIN_DEPENDENCY WORKING_DIRECTORY COMMENT CUSTOM_TARGET_NAME)
|
||||
set(multi_value_args OUTPUT DEPENDS IMPLICIT_DEPENDS SOURCES)
|
||||
cmake_parse_arguments(
|
||||
ACCT # prefix
|
||||
"${options}" "${single_value_args}" "${multi_value_args}" ${ARGN})
|
||||
set(ACCT_COMMANDS ${ACCT_UNPARSED_ARGUMENTS})
|
||||
|
||||
if("${ACCT_CUSTOM_TARGET_NAME}" STREQUAL "")
|
||||
# Construct a unique name for the custom target.
|
||||
# Use a hash so that the file name does not push the OS limits for filename
|
||||
# length.
|
||||
list(GET ACCT_OUTPUT 0 output_filename)
|
||||
string(MD5 ACCT_CUSTOM_TARGET_NAME
|
||||
"add_custom_command_target${CMAKE_CURRENT_BINARY_DIR}/${output_filename}")
|
||||
get_filename_component(output_filename_basename "${output_filename}" NAME)
|
||||
set(ACCT_CUSTOM_TARGET_NAME
|
||||
"add_custom_command_target-${ACCT_CUSTOM_TARGET_NAME}-${output_filename_basename}")
|
||||
endif()
|
||||
|
||||
if((NOT ACCT_IDEMPOTENT) OR
|
||||
(ACCT_IDEMPOTENT AND NOT TARGET "${ACCT_CUSTOM_TARGET_NAME}"))
|
||||
# For each keyword argument k that was passed to this function, set
|
||||
# ${k}_keyword to ${k}. That will allow us to use the incantation
|
||||
# '${${k}_keyword} ${ACCT_${k}}' to forward the arguments on.
|
||||
foreach(var ${options} ${single_value_args} ${multi_value_args})
|
||||
translate_flag(ACCT_${var} ${var} ${var}_keyword)
|
||||
endforeach()
|
||||
|
||||
_make_acct_argument_list(
|
||||
OUTPUT MAIN_DEPENDENCY DEPENDS
|
||||
IMPLICIT_DEPENDS WORKING_DIRECTORY COMMENT VERBATIM APPEND)
|
||||
add_custom_command(${ACCT_COMMANDS} ${args})
|
||||
|
||||
_make_acct_argument_list(ALL WORKING_DIRECTORY SOURCES)
|
||||
add_custom_target(
|
||||
"${ACCT_CUSTOM_TARGET_NAME}" ${args}
|
||||
DEPENDS ${ACCT_OUTPUT}
|
||||
COMMENT "${ACCT_OUTPUT}")
|
||||
set_target_properties(
|
||||
"${ACCT_CUSTOM_TARGET_NAME}" PROPERTIES
|
||||
FOLDER "add_custom_command_target artifacts")
|
||||
endif()
|
||||
|
||||
# "Return" the name of the custom target
|
||||
set("${dependency_out_var_name}" "${ACCT_CUSTOM_TARGET_NAME}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
9
cmake/modules/SwiftApplyXcodeSubstitutions.cmake
Normal file
9
cmake/modules/SwiftApplyXcodeSubstitutions.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
function(apply_xcode_substitutions config path result_var_name)
|
||||
# Hack to deal with the fact that paths contain the build-time
|
||||
# variables. Note that this fix is Xcode-specific.
|
||||
string(REPLACE "$(CONFIGURATION)" "${config}" result "${path}")
|
||||
string(REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "" result "${result}")
|
||||
|
||||
set("${result_var_name}" "${result}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
25
cmake/modules/SwiftBuildType.cmake
Normal file
25
cmake/modules/SwiftBuildType.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
function(is_build_type_optimized build_type result_var_name)
|
||||
if("${build_type}" STREQUAL "Debug")
|
||||
set("${result_var_name}" FALSE PARENT_SCOPE)
|
||||
elseif("${build_type}" STREQUAL "RelWithDebInfo" OR
|
||||
"${build_type}" STREQUAL "Release" OR
|
||||
"${build_type}" STREQUAL "MinSizeRel")
|
||||
set("${result_var_name}" TRUE PARENT_SCOPE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown build type: ${build_type}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(is_build_type_with_debuginfo build_type result_var_name)
|
||||
if("${build_type}" STREQUAL "Debug" OR
|
||||
"${build_type}" STREQUAL "RelWithDebInfo")
|
||||
set("${result_var_name}" TRUE PARENT_SCOPE)
|
||||
elseif("${build_type}" STREQUAL "Release" OR
|
||||
"${build_type}" STREQUAL "MinSizeRel")
|
||||
set("${result_var_name}" FALSE PARENT_SCOPE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown build type: ${build_type}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
149
cmake/modules/SwiftConfigureSDK.cmake
Normal file
149
cmake/modules/SwiftConfigureSDK.cmake
Normal file
@@ -0,0 +1,149 @@
|
||||
# Variable that tracks the set of configured SDKs.
|
||||
#
|
||||
# Each element in this list is an SDK for which the various
|
||||
# SWIFT_SDK_${name}_* variables are defined. Swift libraries will be
|
||||
# built for each variant.
|
||||
set(SWIFT_CONFIGURED_SDKS)
|
||||
|
||||
# Report the given SDK to the user.
|
||||
function(_report_sdk prefix)
|
||||
message(STATUS "${SWIFT_SDK_${prefix}_NAME} SDK:")
|
||||
message(STATUS " Path: ${SWIFT_SDK_${prefix}_PATH}")
|
||||
message(STATUS " Version: ${SWIFT_SDK_${prefix}_VERSION}")
|
||||
message(STATUS " Deployment version: ${SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION}")
|
||||
message(STATUS " Library subdir: ${SWIFT_SDK_${prefix}_LIB_SUBDIR}")
|
||||
message(STATUS " Version min name: ${SWIFT_SDK_${prefix}_VERSION_MIN_NAME}")
|
||||
message(STATUS " Triple name: ${SWIFT_SDK_${prefix}_TRIPLE_NAME}")
|
||||
message(STATUS " Architectures: ${SWIFT_SDK_${prefix}_ARCHITECTURES}")
|
||||
|
||||
foreach(arch ${SWIFT_SDK_${prefix}_ARCHITECTURES})
|
||||
message(STATUS
|
||||
" Triple for ${arch} is ${SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE}")
|
||||
endforeach()
|
||||
|
||||
message(STATUS "")
|
||||
endfunction()
|
||||
|
||||
# Configure an SDK
|
||||
#
|
||||
# Usage:
|
||||
# configure_sdk_darwin(
|
||||
# prefix # Prefix to use for SDK variables (e.g., OSX)
|
||||
# name # Display name for this SDK
|
||||
# deployment_version # Deployment version
|
||||
# xcrun_name # SDK name to use with xcrun
|
||||
# version_min_name # The name used in the -mOS-version-min flag
|
||||
# triple_name # The name used in Swift's -triple
|
||||
# architectures # A list of architectures this SDK supports
|
||||
# internal # Whether the prefer the internal SDK, if present
|
||||
# )
|
||||
#
|
||||
# Sadly there are three OS naming conventions.
|
||||
# xcrun SDK name: macosx iphoneos iphonesimulator (+ "internal" or version)
|
||||
# -mOS-version-min: macosx ios ios-simulator
|
||||
# swift -triple: macosx ios ios
|
||||
#
|
||||
# This macro attempts to configure a given SDK. When successful, it
|
||||
# defines a number of variables:
|
||||
#
|
||||
# SWIFT_SDK_${prefix}_NAME Display name for the SDK
|
||||
# SWIFT_SDK_${prefix}_PATH Path to the SDK
|
||||
# SWIFT_SDK_${prefix}_VERSION SDK version number (e.g., 10.9, 7.0)
|
||||
# SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION Deployment version (e.g., 10.9, 7.0)
|
||||
# SWIFT_SDK_${prefix}_LIB_SUBDIR Library subdir for this SDK
|
||||
# SWIFT_SDK_${prefix}_VERSION_MIN_NAME Version min name for this SDK
|
||||
# SWIFT_SDK_${prefix}_TRIPLE_NAME Triple name for this SDK
|
||||
# SWIFT_SDK_${prefix}_ARCHITECTURES Architectures (as a list)
|
||||
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_TRIPLE Triple name
|
||||
macro(configure_sdk_darwin
|
||||
prefix name deployment_version xcrun_name
|
||||
version_min_name triple_name architectures internal)
|
||||
# Note: this has to be implemented as a macro because it sets global
|
||||
# variables.
|
||||
|
||||
# Find the SDK
|
||||
set(SWIFT_SDK_${prefix}_PATH "" CACHE PATH "Path to the ${name} SDK")
|
||||
|
||||
if(NOT SWIFT_SDK_${prefix}_PATH)
|
||||
if(${internal})
|
||||
execute_process(
|
||||
COMMAND "xcrun" "--sdk" "${xcrun_name}.internal" "--show-sdk-path"
|
||||
OUTPUT_VARIABLE SWIFT_SDK_${prefix}_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT SWIFT_SDK_${prefix}_PATH)
|
||||
execute_process(
|
||||
COMMAND "xcrun" "--sdk" "${xcrun_name}" "--show-sdk-path"
|
||||
OUTPUT_VARIABLE SWIFT_SDK_${prefix}_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${SWIFT_SDK_${prefix}_PATH}/System/Library/Frameworks/module.map")
|
||||
message(FATAL_ERROR "${name} SDK not found at SWIFT_SDK_${prefix}_PATH.")
|
||||
endif()
|
||||
|
||||
# Determine the SDK version we found.
|
||||
string(REGEX MATCH "/[A-Za-z]+[0-9]+\\.[0-9]+(\\.Internal)?\\.sdk"
|
||||
SCRATCH ${SWIFT_SDK_${prefix}_PATH})
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+"
|
||||
SWIFT_SDK_${prefix}_VERSION ${SCRATCH})
|
||||
|
||||
# Set other variables.
|
||||
set(SWIFT_SDK_${prefix}_NAME "${name}")
|
||||
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}")
|
||||
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}")
|
||||
set(SWIFT_SDK_${prefix}_VERSION_MIN_NAME "${version_min_name}")
|
||||
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_name}")
|
||||
set(SWIFT_SDK_${prefix}_ARCHITECTURES "${architectures}")
|
||||
|
||||
foreach(arch ${architectures})
|
||||
set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE
|
||||
"${arch}-apple-${SWIFT_SDK_${prefix}_TRIPLE_NAME}${SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION}")
|
||||
endforeach()
|
||||
|
||||
# Add this to the list of known SDKs.
|
||||
list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}")
|
||||
|
||||
_report_sdk("${prefix}")
|
||||
endmacro()
|
||||
|
||||
macro(configure_sdk_unix
|
||||
prefix name lib_subdir triple_name arch triple)
|
||||
# Note: this has to be implemented as a macro because it sets global
|
||||
# variables.
|
||||
|
||||
set(SWIFT_SDK_${prefix}_NAME "${name}")
|
||||
set(SWIFT_SDK_${prefix}_PATH "/")
|
||||
set(SWIFT_SDK_${prefix}_VERSION "don't use")
|
||||
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "don't use")
|
||||
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${lib_subdir}")
|
||||
set(SWIFT_SDK_${prefix}_VERSION_MIN_NAME "")
|
||||
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_name}")
|
||||
set(SWIFT_SDK_${prefix}_ARCHITECTURES "${arch}")
|
||||
|
||||
set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE "${triple}")
|
||||
|
||||
# Add this to the list of known SDKs.
|
||||
list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}")
|
||||
|
||||
_report_sdk("${prefix}")
|
||||
endmacro()
|
||||
|
||||
# Configure a variant of a certain SDK
|
||||
#
|
||||
# In addition to the SDK and architecture, a variant determines build settings.
|
||||
#
|
||||
# FIXME: this is not wired up with anything yet.
|
||||
function(configure_target_variant prefix name sdk build_config lib_subdir)
|
||||
set(SWIFT_VARIANT_${prefix}_NAME ${name})
|
||||
set(SWIFT_VARIANT_${prefix}_SDK_PATH ${SWIFT_SDK_${sdk}_PATH})
|
||||
set(SWIFT_VARIANT_${prefix}_VERSION ${SWIFT_SDK_${sdk}_VERSION})
|
||||
set(SWIFT_VARIANT_${prefix}_DEPLOYMENT_VERSION ${SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION})
|
||||
set(SWIFT_VARIANT_${prefix}_LIB_SUBDIR "${lib_subdir}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
|
||||
set(SWIFT_VARIANT_${prefix}_VERSION_MIN_NAME ${SWIFT_SDK_${sdk}_VERSION_MIN_NAME})
|
||||
set(SWIFT_VARIANT_${prefix}_TRIPLE_NAME ${SWIFT_SDK_${sdk}_TRIPLE_NAME})
|
||||
set(SWIFT_VARIANT_${prefix}_ARCHITECTURES ${SWIFT_SDK_${sdk}_ARCHITECTURES})
|
||||
endfunction()
|
||||
|
||||
13
cmake/modules/SwiftDarwin.cmake
Normal file
13
cmake/modules/SwiftDarwin.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
# On Darwin platforms that have xcrun, returns the path to the
|
||||
# default toolchain directory.
|
||||
function(get_default_toolchain_dir result_var_name)
|
||||
execute_process(
|
||||
COMMAND "xcrun" "--toolchain" "default" "--find" "clang"
|
||||
OUTPUT_VARIABLE toolchain_dir
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
get_filename_component(toolchain_dir "${toolchain_dir}" PATH)
|
||||
get_filename_component(toolchain_dir "${toolchain_dir}" PATH)
|
||||
get_filename_component(toolchain_dir "${toolchain_dir}" PATH)
|
||||
set("${result_var_name}" "${toolchain_dir}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
8
cmake/modules/SwiftGetConfigurationTypes.cmake
Normal file
8
cmake/modules/SwiftGetConfigurationTypes.cmake
Normal file
@@ -0,0 +1,8 @@
|
||||
function(swift_get_configuration_types result_var_name)
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
set("${result_var_name}" "${CMAKE_CONFIGURATION_TYPES}" PARENT_SCOPE)
|
||||
else()
|
||||
set("${result_var_name}" "." PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
69
cmake/modules/SwiftHandleGybSources.cmake
Normal file
69
cmake/modules/SwiftHandleGybSources.cmake
Normal file
@@ -0,0 +1,69 @@
|
||||
include(SwiftAddCustomCommandTarget)
|
||||
include(SwiftSetIfArchBitness)
|
||||
|
||||
# Create a target to process .gyb files with the 'gyb' tool.
|
||||
#
|
||||
# handle_gyb_sources(
|
||||
# dependency_out_var_name
|
||||
# sources_var_name
|
||||
# arch)
|
||||
#
|
||||
# Replace, in ${sources_var_name}, the given .gyb-suffixed sources with
|
||||
# their un-suffixed intermediate files, which will be generated by processing
|
||||
# the .gyb files with gyb.
|
||||
#
|
||||
# dependency_out_var_name
|
||||
# The name of a variable, to be set in the parent scope to the list of
|
||||
# targets that invoke gyb. Every target that depends on the generated
|
||||
# sources should depend on ${dependency_out_var_name} targets.
|
||||
#
|
||||
# arch
|
||||
# The architecture that the files will be compiled for.
|
||||
function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
|
||||
set_if_arch_bitness(ptr_size
|
||||
ARCH "${arch}"
|
||||
CASE_32_BIT "4"
|
||||
CASE_64_BIT "8")
|
||||
|
||||
set(gyb_flags
|
||||
"--test" # Run gyb's self-tests whenever we use it. They're cheap
|
||||
# enough and it keeps us honest.
|
||||
${SWIFT_GYB_FLAGS}
|
||||
"-DCMAKE_SIZEOF_VOID_P=${ptr_size}")
|
||||
|
||||
set(dependency_targets)
|
||||
set(de_gybbed_sources)
|
||||
set(gyb_sources)
|
||||
set(gyb_tool "${SWIFT_SOURCE_DIR}/utils/gyb")
|
||||
set(gyb_extra_sources "${SWIFT_SOURCE_DIR}/utils/GYBUnicodeDataUtils.py")
|
||||
foreach (src ${${sources_var_name}})
|
||||
string(REGEX REPLACE "[.]gyb$" "" src_sans_gyb "${src}")
|
||||
if(src STREQUAL src_sans_gyb)
|
||||
list(APPEND de_gybbed_sources "${src}")
|
||||
else()
|
||||
set(dir "${CMAKE_CURRENT_BINARY_DIR}/${ptr_size}")
|
||||
set(output_file_name "${dir}/${src_sans_gyb}")
|
||||
list(APPEND de_gybbed_sources "${output_file_name}")
|
||||
string(MD5 output_file_name_hash "${output_file_name}")
|
||||
add_custom_command_target(
|
||||
dependency_target
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E make_directory "${dir}"
|
||||
COMMAND
|
||||
"${gyb_tool}" "${gyb_flags}" -o "${output_file_name}.tmp" "${src}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E copy_if_different "${output_file_name}.tmp" "${output_file_name}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" -E remove "${output_file_name}.tmp"
|
||||
OUTPUT "${output_file_name}"
|
||||
DEPENDS "${gyb_tool}" "${src}" "${gyb_extra_sources}"
|
||||
COMMENT "Generating ${src_sans_gyb} from ${src} with ptr size = ${ptr_size}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
IDEMPOTENT)
|
||||
list(APPEND dependency_targets "${dependency_target}")
|
||||
endif()
|
||||
endforeach()
|
||||
set("${dependency_out_var_name}" "${dependency_targets}" PARENT_SCOPE)
|
||||
set("${sources_var_name}" "${de_gybbed_sources}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
54
cmake/modules/SwiftInstallComponents.cmake
Normal file
54
cmake/modules/SwiftInstallComponents.cmake
Normal file
@@ -0,0 +1,54 @@
|
||||
function(swift_is_installing_component component result_var_name)
|
||||
if("${component}" STREQUAL "")
|
||||
message(FATAL_ERROR "Component name is required")
|
||||
endif()
|
||||
if("${component}" STREQUAL "never_install")
|
||||
set("${result_var_name}" FALSE PARENT_SCOPE)
|
||||
else()
|
||||
list(FIND _SWIFT_KNOWN_INSTALL_COMPONENTS "${component}" index)
|
||||
if(${index} EQUAL -1)
|
||||
message(FATAL_ERROR "unknown install component: ${component}")
|
||||
endif()
|
||||
|
||||
string(TOUPPER "${component}" var_name_piece)
|
||||
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
|
||||
set("${result_var_name}" "${SWIFT_INSTALL_${var_name_piece}}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# swift_install_in_component(<COMPONENT NAME>
|
||||
# <same parameters as install()>)
|
||||
#
|
||||
# Executes the specified installation actions if the named component is
|
||||
# requested to be installed.
|
||||
#
|
||||
# This function accepts the same parameters as install().
|
||||
function(swift_install_in_component component)
|
||||
if("${component}" STREQUAL "")
|
||||
message(FATAL_ERROR "Component name is required")
|
||||
endif()
|
||||
swift_is_installing_component("${component}" is_installing)
|
||||
if(is_installing)
|
||||
install(${ARGN})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(swift_configure_install_components install_components)
|
||||
foreach(component ${_SWIFT_KNOWN_INSTALL_COMPONENTS})
|
||||
string(TOUPPER "${component}" var_name_piece)
|
||||
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
|
||||
set(SWIFT_INSTALL_${var_name_piece} FALSE)
|
||||
endforeach()
|
||||
|
||||
foreach(component ${install_components})
|
||||
list(FIND _SWIFT_KNOWN_INSTALL_COMPONENTS "${component}" index)
|
||||
if(${index} EQUAL -1)
|
||||
message(FATAL_ERROR "unknown install component: ${component}")
|
||||
endif()
|
||||
|
||||
string(TOUPPER "${component}" var_name_piece)
|
||||
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
|
||||
set(SWIFT_INSTALL_${var_name_piece} TRUE)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
22
cmake/modules/SwiftList.cmake
Normal file
22
cmake/modules/SwiftList.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
function(list_subtract lhs rhs result_var_name)
|
||||
set(result)
|
||||
foreach(item IN LISTS lhs)
|
||||
list(FIND rhs "${item}" index)
|
||||
if(${index} EQUAL -1)
|
||||
list(APPEND result "${item}")
|
||||
endif()
|
||||
endforeach()
|
||||
set("${result_var_name}" "${result}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(list_intersect lhs rhs result_var_name)
|
||||
set(result)
|
||||
foreach(item IN LISTS lhs)
|
||||
list(FIND rhs "${item}" index)
|
||||
if(NOT ${index} EQUAL -1)
|
||||
list(APPEND result "${item}")
|
||||
endif()
|
||||
endforeach()
|
||||
set("${result_var_name}" "${result}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
45
cmake/modules/SwiftManpage.cmake
Normal file
45
cmake/modules/SwiftManpage.cmake
Normal file
@@ -0,0 +1,45 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
find_program(POD2MAN pod2man)
|
||||
|
||||
# Create a target to create a man page from a pod file.
|
||||
#
|
||||
# manpage(
|
||||
# SOURCE foobar.pod
|
||||
# PAGE_HEADER "text"
|
||||
# MAN_FILE_BASENAME foobar
|
||||
# MAN_SECTION N
|
||||
# INSTALL_IN_COMPONENT comp
|
||||
# )
|
||||
function(manpage)
|
||||
cmake_parse_arguments(
|
||||
MP # prefix
|
||||
"" # options
|
||||
"SOURCE;PAGE_HEADER;MAN_FILE_BASENAME;MAN_SECTION;INSTALL_IN_COMPONENT" # single-value args
|
||||
"" # multi-value args
|
||||
${ARGN})
|
||||
|
||||
if(NOT POD2MAN)
|
||||
message(FATAL_ERROR "Need pod2man installed to generate man page")
|
||||
endif()
|
||||
|
||||
set(output_file_name
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${MP_MAN_FILE_BASENAME}.${MP_MAN_SECTION}")
|
||||
|
||||
add_custom_command_target(
|
||||
unused_var
|
||||
COMMAND
|
||||
"${POD2MAN}" "--section" "${MP_MAN_SECTION}"
|
||||
"--center" "${MP_PAGE_HEADER}" "--release"
|
||||
"--name" "${MP_MAN_FILE_BASENAME}"
|
||||
"--stderr"
|
||||
"${MP_SOURCE}" > "${output_file_name}"
|
||||
OUTPUT "${output_file_name}"
|
||||
DEPENDS "${MP_SOURCE}"
|
||||
ALL)
|
||||
|
||||
swift_install_in_component("${MP_INSTALL_IN_COMPONENT}"
|
||||
FILES "${output_file_name}"
|
||||
DESTINATION "share/man/man${MP_MAN_SECTION}")
|
||||
endfunction()
|
||||
|
||||
19
cmake/modules/SwiftSetIfArchBitness.cmake
Normal file
19
cmake/modules/SwiftSetIfArchBitness.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
function(set_if_arch_bitness var_name)
|
||||
cmake_parse_arguments(
|
||||
SIA # prefix
|
||||
"" # options
|
||||
"ARCH;CASE_32_BIT;CASE_64_BIT" # single-value args
|
||||
"" # multi-value args
|
||||
${ARGN})
|
||||
|
||||
if("${SIA_ARCH}" STREQUAL "i386" OR
|
||||
"${SIA_ARCH}" STREQUAL "armv7")
|
||||
set("${var_name}" "${SIA_CASE_32_BIT}" PARENT_SCOPE)
|
||||
elseif("${SIA_ARCH}" STREQUAL "x86_64" OR
|
||||
"${SIA_ARCH}" STREQUAL "arm64")
|
||||
set("${var_name}" "${SIA_CASE_64_BIT}" PARENT_SCOPE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown architecture: ${SIA_ARCH}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
22
cmake/modules/SwiftTranslateFlag.cmake
Normal file
22
cmake/modules/SwiftTranslateFlag.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
# Translate a yes/no variable to the presence of a given string in a
|
||||
# variable.
|
||||
#
|
||||
# Usage:
|
||||
# translate_flag(is_set flag_name var_name)
|
||||
#
|
||||
# If is_set is true, sets ${var_name} to ${flag_name}. Otherwise,
|
||||
# unsets ${var_name}.
|
||||
function(translate_flag is_set flag_name var_name)
|
||||
if(${is_set})
|
||||
set("${var_name}" "${flag_name}" PARENT_SCOPE)
|
||||
else()
|
||||
set("${var_name}" "" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(translate_flags prefix options)
|
||||
foreach(var ${options})
|
||||
translate_flag("${${prefix}_${var}}" "${var}" "${prefix}_${var}_keyword")
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
@@ -22,20 +22,18 @@ if(SPHINX_EXECUTABLE)
|
||||
COMMENT "Building HTML documentation")
|
||||
|
||||
# Selectively install docs intended for general consumption.
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_BINARY_DIR}/docs/html/LangRef.html
|
||||
DESTINATION share/swift/docs/html)
|
||||
swift_install_in_component(lang-docs
|
||||
FILES "${CMAKE_BINARY_DIR}/docs/html/LangRef.html"
|
||||
DESTINATION "share/swift/docs/html")
|
||||
|
||||
install(
|
||||
swift_install_in_component(lang-docs
|
||||
DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/docs/html/_static
|
||||
${CMAKE_BINARY_DIR}/docs/html/whitepaper
|
||||
DESTINATION share/swift/docs/html)
|
||||
|
||||
else(SPHINX_EXECUTABLE)
|
||||
"${CMAKE_BINARY_DIR}/docs/html/_static"
|
||||
"${CMAKE_BINARY_DIR}/docs/html/whitepaper"
|
||||
DESTINATION "share/swift/docs/html")
|
||||
else()
|
||||
message(WARNING "Unable to find sphinx-build program. Not building docs")
|
||||
endif(SPHINX_EXECUTABLE)
|
||||
endif()
|
||||
|
||||
## Example testing
|
||||
|
||||
@@ -98,21 +96,20 @@ if(LITRE_EXECUTABLE)
|
||||
# Only update the real top-level CMakeLists.txt if something changed
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
litre-tests/CMakeLists.txt
|
||||
"litre-tests/CMakeLists.txt"
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different litre-top-CMakeLists.cmake litre-tests/CMakeLists.txt
|
||||
"${CMAKE_COMMAND}" "-E" "copy_if_different"
|
||||
"litre-top-CMakeLists.cmake" "litre-tests/CMakeLists.txt"
|
||||
DEPENDS
|
||||
litre-top-CMakeLists.cmake
|
||||
"litre-top-CMakeLists.cmake"
|
||||
COMMENT
|
||||
"Updating top-level LitRe CMakeLists.txt"
|
||||
VERBATIM
|
||||
)
|
||||
VERBATIM)
|
||||
|
||||
# Create a build directory
|
||||
add_custom_command(
|
||||
OUTPUT litre-tests/build
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory litre-tests/build
|
||||
)
|
||||
OUTPUT "litre-tests/build"
|
||||
COMMAND "${CMAKE_COMMAND}" "-E" "make_directory" "litre-tests/build")
|
||||
|
||||
# Run CMake itself to configure/build the tests
|
||||
add_custom_command(
|
||||
@@ -184,13 +181,12 @@ if (DOXYGEN_FOUND)
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating swift doxygen documentation." VERBATIM)
|
||||
|
||||
if (LLVM_BUILD_DOCS)
|
||||
if(LLVM_BUILD_DOCS)
|
||||
add_dependencies(doxygen doxygen-swift)
|
||||
endif()
|
||||
|
||||
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
|
||||
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
|
||||
DESTINATION docs/html)
|
||||
endif()
|
||||
swift_install_in_component(dev
|
||||
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html"
|
||||
DESTINATION "docs/html")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
manpage("${CMAKE_CURRENT_SOURCE_DIR}/swift.pod" "Swift Documentation" swift 1)
|
||||
include(SwiftManpage)
|
||||
|
||||
manpage(
|
||||
SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/swift.pod"
|
||||
PAGE_HEADER "Swift Documentation"
|
||||
MAN_FILE_BASENAME swift
|
||||
MAN_SECTION 1
|
||||
INSTALL_IN_COMPONENT compiler)
|
||||
|
||||
|
||||
@@ -34,13 +34,34 @@ add_swift_library(swiftAST
|
||||
TypeWalker.cpp
|
||||
USRGeneration.cpp
|
||||
Verifier.cpp
|
||||
DEPENDS swiftBasic swiftReST
|
||||
LINK_LIBRARIES
|
||||
swiftReST
|
||||
swiftBasic
|
||||
|
||||
# Clang dependencies.
|
||||
# FIXME: Clang should really export these in some reasonable manner.
|
||||
clangIndex
|
||||
clangFormat
|
||||
clangToolingCore
|
||||
LLVMCore
|
||||
)
|
||||
clangFrontendTool
|
||||
clangFrontend
|
||||
clangDriver
|
||||
clangSerialization
|
||||
clangParse
|
||||
clangSema
|
||||
clangAnalysis
|
||||
clangEdit
|
||||
clangRewriteFrontend
|
||||
clangRewrite
|
||||
clangAST
|
||||
clangLex
|
||||
clangAPINotes
|
||||
clangBasic)
|
||||
|
||||
if( NOT SWIFT_BUILT_STANDALONE )
|
||||
llvm_config(swiftAST
|
||||
profiledata object mc mcparser bitreader option core support)
|
||||
|
||||
if(NOT SWIFT_BUILT_STANDALONE)
|
||||
add_dependencies(swiftAST intrinsics_gen)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
add_swift_library(swiftASTSectionImporter
|
||||
ASTSectionImporter.cpp
|
||||
DEPENDS swiftBasic LLVMCore)
|
||||
LINK_LIBRARIES swiftBasic LLVMCore)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
find_package(UUID REQUIRED)
|
||||
|
||||
set(UNICODE_TABLES UnicodeExtendedGraphemeClusters.cpp.gyb)
|
||||
|
||||
add_swift_library(swiftBasic
|
||||
Cache.cpp
|
||||
Demangle.cpp
|
||||
@@ -31,11 +29,10 @@ add_swift_library(swiftBasic
|
||||
# Platform-agnostic fallback TaskQueue implementation
|
||||
Default/TaskQueue.inc
|
||||
|
||||
${UNICODE_TABLES}
|
||||
UnicodeExtendedGraphemeClusters.cpp.gyb
|
||||
|
||||
C_COMPILE_FLAGS "-I${UUID_INCLUDE_DIRS}"
|
||||
DEPENDS ${UUID_LIBRARIES}
|
||||
)
|
||||
LINK_LIBRARIES ${UUID_LIBRARIES})
|
||||
|
||||
set(SWIFT_VERSION "1.1")
|
||||
message(STATUS "Swift version: ${SWIFT_VERSION}")
|
||||
|
||||
@@ -31,5 +31,8 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
|
||||
if (triple.isMacOSX())
|
||||
return "macosx";
|
||||
|
||||
if (triple.isOSLinux())
|
||||
return "linux";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -4,31 +4,6 @@ add_swift_library(swiftClangImporter
|
||||
ImportDecl.cpp
|
||||
ImportMacro.cpp
|
||||
ImportType.cpp
|
||||
DEPENDS swiftAST)
|
||||
LINK_LIBRARIES
|
||||
swiftAST)
|
||||
|
||||
# Clang dependencies.
|
||||
# FIXME: Clang should really export these in some reasonable manner.
|
||||
target_link_libraries(swiftClangImporter
|
||||
clangIndex
|
||||
clangFormat
|
||||
clangToolingCore
|
||||
clangFrontendTool
|
||||
clangFrontend
|
||||
clangDriver
|
||||
clangSerialization
|
||||
clangParse
|
||||
clangSema
|
||||
clangAnalysis
|
||||
clangEdit
|
||||
clangRewriteFrontend
|
||||
clangRewrite
|
||||
clangAST
|
||||
clangLex
|
||||
clangAPINotes
|
||||
clangBasic
|
||||
LLVMBitReader
|
||||
LLVMMC
|
||||
LLVMMCParser
|
||||
LLVMOption
|
||||
LLVMTransformUtils
|
||||
LLVMSupport)
|
||||
|
||||
@@ -13,4 +13,5 @@ add_swift_library(swiftDriver
|
||||
ToolChains.cpp
|
||||
Types.cpp
|
||||
Util.cpp
|
||||
DEPENDS swiftAST swiftBasic swiftFrontend swiftOption)
|
||||
DEPENDS SwiftOptions
|
||||
LINK_LIBRARIES swiftAST swiftBasic swiftFrontend swiftOption)
|
||||
|
||||
@@ -684,7 +684,9 @@ Job *linux::Linker::constructJob(const JobAction &JA,
|
||||
|
||||
// Add the linker script that coalesces protocol conformance sections.
|
||||
Arguments.push_back("-Xlinker");
|
||||
Arguments.push_back("-Tswift.ld");
|
||||
Arguments.push_back("-T");
|
||||
Arguments.push_back(
|
||||
Args.MakeArgString(Twine(RuntimeLibPath) + "/linux/x86_64/swift.ld"));
|
||||
|
||||
// This should be the last option, for convenience in checking output.
|
||||
Arguments.push_back("-o");
|
||||
|
||||
@@ -6,4 +6,11 @@ add_swift_library(swiftFrontend
|
||||
FrontendOptions.cpp
|
||||
PrintingDiagnosticConsumer.cpp
|
||||
SerializedDiagnosticConsumer.cpp
|
||||
DEPENDS swiftAST swiftOption swiftParse swiftSema swiftSerialization swiftSIL)
|
||||
DEPENDS SwiftOptions
|
||||
LINK_LIBRARIES
|
||||
swiftSIL
|
||||
swiftOption
|
||||
swiftParse
|
||||
swiftSema
|
||||
swiftSerialization)
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
add_swift_library(functionNameDemangle SHARED
|
||||
FunctionNameDemangle.cpp
|
||||
MangleHack.cpp
|
||||
DEPENDS swiftBasic
|
||||
LINK_LIBRARIES swiftBasic
|
||||
COMPONENT_DEPENDS support)
|
||||
|
||||
install(TARGETS functionNameDemangle
|
||||
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
||||
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
||||
swift_install_in_component(compiler
|
||||
TARGETS functionNameDemangle
|
||||
LIBRARY DESTINATION "lib${LLVM_LIBDIR_SUFFIX}"
|
||||
ARCHIVE DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ add_swift_library(swiftIDE
|
||||
SourceEntityWalker.cpp
|
||||
SyntaxModel.cpp
|
||||
Utils.cpp
|
||||
DEPENDS
|
||||
swiftAST swiftParse swiftSema swiftClangImporter
|
||||
)
|
||||
LINK_LIBRARIES
|
||||
swiftClangImporter
|
||||
swiftParse
|
||||
swiftSema
|
||||
swiftAST)
|
||||
|
||||
|
||||
@@ -27,11 +27,14 @@ add_swift_library(swiftIRGen
|
||||
SwiftTargetInfo.cpp
|
||||
StructLayout.cpp
|
||||
UnimplementedTypeInfo.cpp
|
||||
DEPENDS LLVMMC LLVMProfileData LLVMSupport LLVMCore LLVMObjCARCOpts
|
||||
swiftAST swiftLLVMPasses)
|
||||
LINK_LIBRARIES
|
||||
swiftAST
|
||||
swiftLLVMPasses
|
||||
|
||||
# Clang dependencies.
|
||||
# FIXME: Clang should really export these in some reasonable manner.
|
||||
target_link_libraries(swiftIRGen
|
||||
# Clang dependencies.
|
||||
# FIXME: Clang should really export these in some reasonable manner.
|
||||
clangCodeGen)
|
||||
|
||||
llvm_config(swiftIRGen
|
||||
profiledata)
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
add_swift_library(swiftImmediate
|
||||
Helpers.cpp
|
||||
Immediate.cpp
|
||||
DEPENDS swiftBasic swiftAST swiftFrontend swiftParse swiftIDE swiftSIL
|
||||
LINK_LIBRARIES
|
||||
swiftFrontend swiftParse swiftIDE swiftSILGen
|
||||
swiftSILPasses swiftIRGen)
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
add_swift_library(swiftOption
|
||||
Options.cpp
|
||||
DEPENDS swiftBasic)
|
||||
DEPENDS SwiftOptions
|
||||
LINK_LIBRARIES swiftBasic
|
||||
FILE_DEPENDS SwiftOptions)
|
||||
|
||||
add_dependencies(swiftOption SwiftOptions)
|
||||
|
||||
@@ -10,4 +10,7 @@ add_swift_library(swiftParse
|
||||
ParseType.cpp
|
||||
PersistentParserState.cpp
|
||||
Scope.cpp
|
||||
DEPENDS clangBasic swiftAST swiftSIL)
|
||||
LINK_LIBRARIES
|
||||
swiftSIL
|
||||
swiftAST)
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
add_swift_library(swiftPrintAsObjC
|
||||
PrintAsObjC.cpp
|
||||
DEPENDS swiftAST)
|
||||
|
||||
# Clang dependencies.
|
||||
# FIXME: Clang should really export these in some reasonable manner.
|
||||
target_link_libraries(swiftPrintAsObjC
|
||||
clangAST)
|
||||
LINK_LIBRARIES
|
||||
swiftIDE
|
||||
swiftFrontend
|
||||
swiftClangImporter
|
||||
swiftAST)
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@ add_swift_library(swiftReST
|
||||
BriefParser.cpp
|
||||
LineList.cpp
|
||||
Parser.cpp
|
||||
DEPENDS clangBasic
|
||||
)
|
||||
LINK_LIBRARIES clangBasic)
|
||||
|
||||
|
||||
@@ -25,13 +25,7 @@ add_swift_library(swiftSIL
|
||||
LoopInfo.cpp
|
||||
Projection.cpp
|
||||
Mangle.cpp
|
||||
DEPENDS swiftAST swiftSerialization)
|
||||
LINK_LIBRARIES
|
||||
swiftSerialization
|
||||
swiftSema)
|
||||
|
||||
# Clang dependencies.
|
||||
# FIXME: remove this. SIL should not depend on Clang.
|
||||
target_link_libraries(swiftSIL
|
||||
clangAnalysis
|
||||
clangAST
|
||||
clangLex
|
||||
clangBasic
|
||||
LLVMSupport)
|
||||
|
||||
@@ -13,4 +13,4 @@ add_swift_library(swiftSILAnalysis
|
||||
SimplifyInstruction.cpp
|
||||
RCIdentityAnalysis.cpp
|
||||
DestructorAnalysis.cpp
|
||||
DEPENDS swiftSILPassesUtils)
|
||||
LINK_LIBRARIES swiftSILPassesUtils)
|
||||
|
||||
@@ -12,5 +12,5 @@ add_swift_library(swiftSILGen
|
||||
SILGenPattern.cpp
|
||||
SILGenPoly.cpp
|
||||
SILGenStmt.cpp
|
||||
DEPENDS swiftSIL)
|
||||
LINK_LIBRARIES swiftSIL)
|
||||
|
||||
|
||||
@@ -45,4 +45,4 @@ add_swift_library(swiftSILPasses
|
||||
ArrayBoundsCheckOpts.cpp
|
||||
ClosureSpecializer.cpp
|
||||
SILCombinerVisitors.cpp
|
||||
DEPENDS swiftSILPassesUtils swiftSILAnalysis)
|
||||
LINK_LIBRARIES swiftSILPassesUtils swiftSILAnalysis)
|
||||
|
||||
@@ -3,5 +3,5 @@ add_swift_library(swiftSILPassesUtils
|
||||
Local.cpp
|
||||
SILInliner.cpp
|
||||
SILSSAUpdater.cpp
|
||||
DEPENDS swiftSIL)
|
||||
LINK_LIBRARIES swiftSIL)
|
||||
|
||||
|
||||
@@ -29,4 +29,7 @@ add_swift_library(swiftSema
|
||||
TypeCheckREPL.cpp
|
||||
TypeCheckStmt.cpp
|
||||
TypeCheckType.cpp
|
||||
DEPENDS swiftAST swiftParse)
|
||||
LINK_LIBRARIES
|
||||
swiftParse
|
||||
swiftAST)
|
||||
|
||||
|
||||
@@ -6,4 +6,6 @@ add_swift_library(swiftSerialization
|
||||
SerializedModuleLoader.cpp
|
||||
SerializedSILLoader.cpp
|
||||
SerializeSIL.cpp
|
||||
DEPENDS swiftAST swiftClangImporter LLVMBitReader LLVMBitWriter LLVMCore)
|
||||
LINK_LIBRARIES
|
||||
swiftClangImporter)
|
||||
|
||||
|
||||
@@ -114,46 +114,54 @@ set(SWIFTLIB_SOURCES
|
||||
Zip.swift
|
||||
)
|
||||
|
||||
set(swift_core_link_flags)
|
||||
set(swift_core_framework_depends)
|
||||
set(swift_core_private_link_libraries)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(LINK_FLAGS "-all_load -Xlinker -reexport-lobjc")
|
||||
set(RUNTIME_DEPENDENCY swiftRuntime)
|
||||
list(APPEND swift_core_link_flags
|
||||
"-all_load" "-Xlinker" "-reexport-lobjc")
|
||||
list(APPEND swift_core_private_link_libraries swiftRuntime)
|
||||
list(APPEND swift_core_framework_depends Foundation)
|
||||
else()
|
||||
set(LINK_FLAGS)
|
||||
# With the GNU linker the equivalent of -all_load is to tell the linker
|
||||
# --whole-archive before the archive and --no-whole-archive after (without
|
||||
# the second, it causes errors when the system libraries are told to
|
||||
# include everything). The best way to get it in there, according to the
|
||||
# documentation, is to put the flags in the target_link_Libraries setting.
|
||||
# documentation, is to put the flags in the target_link_libraries setting.
|
||||
|
||||
# TODO: However, for the moment this actually makes things explode with an
|
||||
# incomplete runtime. This should be turned back on when more of the porting
|
||||
# effort has been completed.
|
||||
#set(LINK_FLAGS
|
||||
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
|
||||
set(RUNTIME_DEPENDENCY swiftRuntime)
|
||||
list(APPEND swift_core_private_link_libraries swiftRuntime)
|
||||
endif()
|
||||
|
||||
set(SWIFT_CHECK_ESSENTIAL_STDLIB NO CACHE BOOL
|
||||
"Check core standard library layering by linking its essential subset")
|
||||
if(SWIFT_HAVE_CRASH_REPORTER_CLIENT)
|
||||
list(APPEND swift_core_private_link_libraries "CrashReporterClient")
|
||||
endif()
|
||||
|
||||
option(SWIFT_CHECK_ESSENTIAL_STDLIB
|
||||
"Check core standard library layering by linking its essential subset"
|
||||
FALSE)
|
||||
|
||||
if(SWIFT_CHECK_ESSENTIAL_STDLIB)
|
||||
add_swift_library(swift_stdlib_essential IS_STDLIB_CORE TARGET_LIBRARY
|
||||
${SWIFTLIB_ESSENTIAL}
|
||||
)
|
||||
add_swift_library(swift_stdlib_essential SHARED IS_STDLIB IS_STDLIB_CORE
|
||||
${SWIFTLIB_ESSENTIAL})
|
||||
target_link_libraries(swift_stdlib_essential ${RUNTIME_DEPENDENCY})
|
||||
endif()
|
||||
|
||||
set(SHARED_LIBRARY ON)
|
||||
add_swift_library(swiftCore INSTALL IS_STDLIB_CORE TARGET_LIBRARY
|
||||
add_swift_library(swiftCore SHARED IS_STDLIB IS_STDLIB_CORE
|
||||
${SWIFTLIB_SOURCES}
|
||||
# The copy_shim_headers target dependency is required to let the
|
||||
# Makefile build know that there's a rule to produce the shims
|
||||
# directory, but is not sufficient to cause Swift.o to be rebuilt
|
||||
# build system know that there's a rule to produce the shims
|
||||
# directory, but is not sufficient to cause the object file to be rebuilt
|
||||
# when the shim header changes. Therefore, we pass both the target
|
||||
# and the generated directory as dependencies
|
||||
# and the generated directory as dependencies.
|
||||
FILE_DEPENDS
|
||||
copy_shim_headers ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/shims
|
||||
LINK_FLAGS ${LINK_FLAGS}
|
||||
DEPENDS ${RUNTIME_DEPENDENCY}
|
||||
)
|
||||
add_dependencies(swiftCore swift)
|
||||
copy_shim_headers "${SWIFTLIB_DIR}/shims"
|
||||
LINK_FLAGS ${swift_core_link_flags}
|
||||
PRIVATE_LINK_LIBRARIES ${swift_core_private_link_libraries}
|
||||
FRAMEWORK_DEPENDS ${swift_core_framework_depends}
|
||||
INSTALL_IN_COMPONENT stdlib)
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ struct _SliceBuffer<T> : _ArrayBufferType {
|
||||
) {
|
||||
_invariantCheck()
|
||||
// FIXME: <rdar://problem/17464946> with
|
||||
// -DSWIFT_STDLIB_INTERNAL_CHECKS=OFF, enabling this sanityCheck
|
||||
// -DSWIFT_STDLIB_ASSERTIONS=FALSE, enabling this sanityCheck
|
||||
// actually causes leaks in the stdlib/NewArray.swift.gyb test
|
||||
/* _sanityCheck(insertCount <= numericCast(count(newValues))) */
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftSwiftExperimental INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftSwiftExperimental SHARED IS_STDLIB
|
||||
# This file should be listed the first. Module name is inferred from the
|
||||
# filename.
|
||||
SwiftExperimental.swift
|
||||
|
||||
SWIFT_COMPILE_FLAGS -Xfrontend -sil-serialize-all
|
||||
|
||||
DEPENDS swiftCore)
|
||||
INSTALL_IN_COMPONENT stdlib-experimental)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
add_swift_library(swiftAppKit INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftAppKit IS_SDK_OVERLAY
|
||||
AppKit.swift
|
||||
TARGET_SDKS "OSX"
|
||||
DEPENDS swiftCore swiftObjectiveC swiftFoundation swiftQuartzCore
|
||||
TARGET_SDKS OSX
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC Foundation QuartzCore
|
||||
FRAMEWORK_DEPENDS AppKit QuartzCore)
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftAssetsLibrary INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftAssetsLibrary IS_SDK_OVERLAY
|
||||
AssetsLibrary.swift
|
||||
TARGET_SDKS IOS IOS_SIMULATOR
|
||||
DEPENDS swiftCore swiftObjectiveC swiftFoundation swiftCoreGraphics
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC Foundation CoreGraphics
|
||||
FRAMEWORK_DEPENDS AssetsLibrary)
|
||||
|
||||
|
||||
@@ -1,31 +1,16 @@
|
||||
# All libraries in this directory tree are overlays.
|
||||
list(APPEND SWIFT_EXTRA_FLAGS
|
||||
"-autolink-force-load")
|
||||
|
||||
add_subdirectory(AppKit)
|
||||
add_subdirectory(AssetsLibrary)
|
||||
add_subdirectory(CoreGraphics)
|
||||
add_subdirectory(CoreImage)
|
||||
add_subdirectory(Darwin)
|
||||
add_subdirectory(Dispatch)
|
||||
add_subdirectory(CoreGraphics)
|
||||
add_subdirectory(Foundation)
|
||||
add_subdirectory(ObjectiveC)
|
||||
add_subdirectory(QuartzCore)
|
||||
add_subdirectory(Security)
|
||||
add_subdirectory(SpriteKit)
|
||||
add_subdirectory(UIKit)
|
||||
add_subdirectory(XCTest)
|
||||
add_subdirectory(GLKit)
|
||||
|
||||
if (SWIFT_SDKS)
|
||||
add_subdirectory(AppKit)
|
||||
add_subdirectory(AssetsLibrary)
|
||||
add_subdirectory(CoreImage)
|
||||
add_subdirectory(QuartzCore)
|
||||
add_subdirectory(UIKit)
|
||||
else()
|
||||
if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx")
|
||||
add_subdirectory(AppKit)
|
||||
add_subdirectory(QuartzCore)
|
||||
else()
|
||||
add_subdirectory(AssetsLibrary)
|
||||
add_subdirectory(CoreImage)
|
||||
add_subdirectory(UIKit)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftCoreGraphics
|
||||
add_swift_library(swiftCoreGraphics IS_SDK_OVERLAY
|
||||
CoreGraphics.swift
|
||||
CGFloat.swift.gyb
|
||||
CoreGraphicsMirrors.swift.gyb
|
||||
INSTALL TARGET_LIBRARY
|
||||
DEPENDS swiftCore swiftObjectiveC swiftDispatch swiftDarwin
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC Dispatch Darwin
|
||||
FRAMEWORK_DEPENDS CoreGraphics)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
add_swift_library(swiftCoreImage INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftCoreImage IS_SDK_OVERLAY
|
||||
CoreImage.swift
|
||||
TARGET_SDKS IOS IOS_SIMULATOR
|
||||
DEPENDS swiftCore swiftFoundation swiftObjectiveC
|
||||
SWIFT_MODULE_DEPENDS Foundation ObjectiveC
|
||||
FRAMEWORK_DEPENDS CoreImage)
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftDarwin INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftDarwin IS_SDK_OVERLAY
|
||||
Darwin.swift
|
||||
Misc.mm
|
||||
tgmath.swift.gyb
|
||||
DEPENDS swiftCore
|
||||
API_NOTES_NON_OVERLAY)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftDispatch
|
||||
add_swift_library(swiftDispatch IS_SDK_OVERLAY
|
||||
Dispatch.swift
|
||||
Dispatch.mm
|
||||
INSTALL TARGET_LIBRARY
|
||||
DEPENDS swiftCore swiftObjectiveC)
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC)
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftFoundation INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftFoundation IS_SDK_OVERLAY
|
||||
Foundation.swift
|
||||
FoundationMirrors.swift.gyb
|
||||
ExtraStringAPIs.swift
|
||||
@@ -8,5 +6,6 @@ add_swift_library(swiftFoundation INSTALL TARGET_LIBRARY
|
||||
MixedStringNSStringOperations.swift.gyb
|
||||
NSStringAPI.swift
|
||||
NSValue.swift
|
||||
DEPENDS swiftCore swiftObjectiveC swiftCoreGraphics swiftDispatch swiftSecurity
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC CoreGraphics Dispatch Security
|
||||
FRAMEWORK_DEPENDS Foundation)
|
||||
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx")
|
||||
set(SWIFTGLKIT_UI swiftAppKit)
|
||||
else()
|
||||
set(SWIFTGLKIT_UI swiftUIKit)
|
||||
endif()
|
||||
|
||||
add_swift_library(swiftGLKit INSTALL
|
||||
add_swift_library(swiftGLKit IS_SDK_OVERLAY
|
||||
GLKit.swift.gyb
|
||||
DEPENDS ${SWIFTGLKIT_UI}
|
||||
|
||||
SWIFT_MODULE_DEPENDS Foundation
|
||||
SWIFT_MODULE_DEPENDS_OSX AppKit
|
||||
SWIFT_MODULE_DEPENDS_IOS UIKit
|
||||
FRAMEWORK_DEPENDS GLKit)
|
||||
|
||||
if (SWIFT_SDKS)
|
||||
add_swift_library(swiftGLKit INSTALL TARGET_LIBRARY
|
||||
GLKit.swift.gyb
|
||||
TARGET_SDKS IOS IOS_SIMULATOR
|
||||
DEPENDS swiftUIKit
|
||||
FRAMEWORK_DEPENDS GLKit)
|
||||
endif()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftObjectiveC INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftObjectiveC IS_SDK_OVERLAY
|
||||
ObjectiveC.swift
|
||||
DEPENDS swiftCore swiftDarwin)
|
||||
SWIFT_MODULE_DEPENDS Darwin)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
add_swift_library(swiftQuartzCore INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftQuartzCore IS_SDK_OVERLAY
|
||||
QuartzCore.swift
|
||||
TARGET_SDKS OSX
|
||||
DEPENDS swiftCore swiftFoundation swiftObjectiveC
|
||||
SWIFT_MODULE_DEPENDS Foundation ObjectiveC
|
||||
FRAMEWORK_DEPENDS QuartzCore)
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
add_swift_library(swiftSecurity
|
||||
add_swift_library(swiftSecurity IS_SDK_OVERLAY
|
||||
Security.swift
|
||||
INSTALL TARGET_LIBRARY
|
||||
FRAMEWORK_DEPENDS Security
|
||||
DEPENDS swiftCore swiftObjectiveC swiftDispatch swiftDarwin)
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC Dispatch Darwin
|
||||
FRAMEWORK_DEPENDS Security)
|
||||
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
|
||||
if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx")
|
||||
set(SWIFTSPRITEKIT_UI swiftAppKit)
|
||||
else()
|
||||
set(SWIFTSPRITEKIT_UI swiftUIKit)
|
||||
endif()
|
||||
|
||||
add_swift_library(swiftSpriteKit INSTALL
|
||||
add_swift_library(swiftSpriteKit IS_SDK_OVERLAY
|
||||
SpriteKit.swift
|
||||
SpriteKitMirrors.swift.gyb
|
||||
DEPENDS ${SWIFTSPRITEKIT_UI} swiftGLKit
|
||||
|
||||
SWIFT_MODULE_DEPENDS Foundation GLKit
|
||||
SWIFT_MODULE_DEPENDS_OSX AppKit
|
||||
SWIFT_MODULE_DEPENDS_IOS UIKit
|
||||
FRAMEWORK_DEPENDS SpriteKit)
|
||||
if (SWIFT_SDKS)
|
||||
add_swift_library(swiftSpriteKit INSTALL TARGET_LIBRARY
|
||||
SpriteKit.swift
|
||||
SpriteKitMirrors.swift.gyb
|
||||
TARGET_SDKS IOS IOS_SIMULATOR
|
||||
DEPENDS swiftUIKit swiftGLKit
|
||||
FRAMEWORK_DEPENDS SpriteKit)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
add_swift_library(swiftUIKit INSTALL TARGET_LIBRARY
|
||||
add_swift_library(swiftUIKit IS_SDK_OVERLAY
|
||||
DesignatedInitializers.mm
|
||||
UIKit.swift
|
||||
TARGET_SDKS IOS IOS_SIMULATOR
|
||||
DEPENDS swiftCore swiftObjectiveC swiftFoundation swiftCoreImage
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC Foundation CoreImage
|
||||
FRAMEWORK_DEPENDS UIKit)
|
||||
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
set(DISABLE_APPLICATION_EXTENSION ON)
|
||||
|
||||
# XCTest.framework is not in the default search paths, add a search path for it
|
||||
# both when building and when linking. For compiling, that's accomplished by
|
||||
# modifying SWIFT_EXTRA_FLAGS before invoking add_swift_library. For linking,
|
||||
# that's accomplished by adding the extra flag to target_link_libraries since
|
||||
# that will just pass through to the linker invocation.
|
||||
|
||||
set(XCTEST_FRAMEWORK_LOCATION "${MODULES_SDK}/../../../Developer/Library/Frameworks")
|
||||
|
||||
list(APPEND SWIFT_EXTRA_FLAGS
|
||||
"-F${XCTEST_FRAMEWORK_LOCATION}"
|
||||
"-framework" "XCTest")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -F${XCTEST_FRAMEWORK_LOCATION}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -framework XCTest")
|
||||
|
||||
add_swift_library(swiftXCTest INSTALL
|
||||
add_swift_library(swiftXCTest IS_SDK_OVERLAY
|
||||
XCTestCaseAdditions.mm
|
||||
XCTest.swift
|
||||
DEPENDS swiftCore swiftObjectiveC swiftFoundation)
|
||||
SWIFT_MODULE_DEPENDS ObjectiveC Foundation
|
||||
FRAMEWORK_DEPENDS Foundation XCTest)
|
||||
|
||||
target_link_libraries(swiftXCTest
|
||||
"-F${XCTEST_FRAMEWORK_LOCATION}"
|
||||
"-framework Foundation" "-framework XCTest")
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
if (SWIFT_OPTIMIZED)
|
||||
set(SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS_DEFAULT OFF)
|
||||
else()
|
||||
set(SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS_DEFAULT ON)
|
||||
endif()
|
||||
set(swift_runtime_compile_flags)
|
||||
|
||||
set(SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS
|
||||
${SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS_DEFAULT}
|
||||
CACHE BOOL "Overwrite memory for deallocated Swift objects")
|
||||
|
||||
set(SWIFT_RUNTIME_COMPILE_FLAGS)
|
||||
if(SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS)
|
||||
list(APPEND SWIFT_RUNTIME_COMPILE_FLAGS "-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=1")
|
||||
list(APPEND swift_runtime_compile_flags
|
||||
"-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=1")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(SWIFT_RUNTIME_OBJC_SOURCES
|
||||
if(SWIFT_HAVE_CRASH_REPORTER_CLIENT)
|
||||
list(APPEND swift_runtime_compile_flags
|
||||
"-DSWIFT_HAVE_CRASHREPORTERCLIENT=1")
|
||||
endif()
|
||||
|
||||
set(swift_runtime_objc_sources)
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set(swift_runtime_objc_sources
|
||||
Availability.mm
|
||||
SwiftObject.mm
|
||||
SwiftNativeNSXXXBase.mm.gyb
|
||||
Reflection.mm)
|
||||
|
||||
set(FRAMEWORKS Foundation)
|
||||
else()
|
||||
set(SWIFT_RUNTIME_OBJC_SOURCES)
|
||||
set(FRAMEWORKS)
|
||||
endif()
|
||||
|
||||
add_swift_library(swiftRuntime
|
||||
add_swift_library(swiftRuntime IS_STDLIB IS_STDLIB_CORE
|
||||
Casting.cpp
|
||||
Demangle.cpp
|
||||
GlobalObjects.cpp
|
||||
@@ -41,24 +34,18 @@ add_swift_library(swiftRuntime
|
||||
Heap.cpp
|
||||
Errors.cpp
|
||||
UnicodeExtendedGraphemeClusters.cpp.gyb
|
||||
${SWIFT_RUNTIME_OBJC_SOURCES}
|
||||
C_COMPILE_FLAGS ${SWIFT_RUNTIME_COMPILE_FLAGS}
|
||||
TARGET_LIBRARY INSTALL
|
||||
FRAMEWORK_DEPENDS ${FRAMEWORKS})
|
||||
${swift_runtime_objc_sources}
|
||||
C_COMPILE_FLAGS ${swift_runtime_compile_flags}
|
||||
INSTALL_IN_COMPONENT stdlib)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
# FIXME: This is probably not flexible enough to deal with 32bit builds,
|
||||
# but SWIFTLIB_DIR isn't available in this cmake file and duplicating
|
||||
# the logic seems wrong. rdar://problem/19035586
|
||||
configure_file(swift.ld ${CMAKE_BINARY_DIR}/lib/swift/swift.ld COPYONLY)
|
||||
target_link_libraries(swiftRuntime "-lpthread" "-ldl")
|
||||
endif()
|
||||
foreach(sdk ${SWIFTLIB_TARGET_SDKS})
|
||||
if("${sdk}" STREQUAL "LINUX")
|
||||
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
|
||||
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
|
||||
|
||||
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_OSX_SYSROOT}")
|
||||
find_library(CRASHREPORTERCLIENT CrashReporterClient ONLY_CMAKE_FIND_ROOT_PATH)
|
||||
# FIXME: We will need a different linker script for 32-bit builds.
|
||||
configure_file(
|
||||
"swift.ld" "${SWIFTLIB_DIR}/${arch_subdir}/swift.ld" COPYONLY)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
if (CRASHREPORTERCLIENT)
|
||||
target_link_libraries(swiftRuntime "-lCrashReporterClient")
|
||||
set_property(TARGET swiftRuntime APPEND_STRING PROPERTY
|
||||
COMPILE_FLAGS " -DSWIFT_HAVE_CRASHREPORTERCLIENT=1")
|
||||
endif()
|
||||
|
||||
@@ -12,57 +12,67 @@ set(sources
|
||||
)
|
||||
set(output_dir "${SWIFTLIB_DIR}/shims")
|
||||
|
||||
set(commands)
|
||||
set(outputs)
|
||||
set(commands
|
||||
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}")
|
||||
set(outputs "${output_dir}")
|
||||
foreach(input ${sources})
|
||||
list(APPEND outputs "${output_dir}/${input}")
|
||||
list(APPEND commands
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${input}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" "-E" "copy_if_different"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/${input}"
|
||||
"${output_dir}/${input}")
|
||||
list(APPEND outputs "${output_dir}/${input}")
|
||||
endforeach()
|
||||
|
||||
add_custom_command(OUTPUT "${output_dir}" ${outputs}
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${output_dir}"
|
||||
add_custom_command_target(unused_var
|
||||
${commands}
|
||||
DEPENDS ${sources}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
COMMENT "Copying SwiftShims module to ${output_dir}"
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
copy_shim_headers
|
||||
DEPENDS "${output_dir}" ${outputs}
|
||||
SOURCES ${sources}
|
||||
)
|
||||
CUSTOM_TARGET_NAME "copy_shim_headers"
|
||||
OUTPUT "${outputs}"
|
||||
DEPENDS "${sources}"
|
||||
COMMENT "Copying SwiftShims module to ${output_dir}")
|
||||
|
||||
# Symlink in the Clang headers.
|
||||
add_custom_command(TARGET copy_shim_headers POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
add_custom_command_target(unused_var
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" "-E" "make_directory" "${SWIFTLIB_DIR}"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" "-E" "create_symlink"
|
||||
"${SWIFT_PATH_TO_CLANG_BUILD}/${CMAKE_CFG_INTDIR}/lib/clang"
|
||||
"${SWIFTLIB_DIR}/clang"
|
||||
CUSTOM_TARGET_NAME "symlink_clang_headers"
|
||||
OUTPUT "${SWIFTLIB_DIR}/clang"
|
||||
COMMENT "Symlinking Clang resource headers into ${SWIFTLIB_DIR}/clang")
|
||||
add_dependencies(copy_shim_headers symlink_clang_headers)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
include(SwiftDarwin)
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
# Symlink in arclite from the XcodeDefault toolchain.
|
||||
execute_process(COMMAND xcrun --toolchain XcodeDefault -find clang
|
||||
OUTPUT_VARIABLE toolchain_dir
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(LENGTH "${toolchain_dir}" len)
|
||||
math(EXPR len "${len} - 14") # "/usr/bin/clang"
|
||||
string(SUBSTRING "${toolchain_dir}" 0 ${len} toolchain_dir)
|
||||
|
||||
add_custom_command(TARGET copy_shim_headers POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
get_default_toolchain_dir(toolchain_dir)
|
||||
add_custom_command_target(unused_var
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" "-E" "make_directory"
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib"
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}" "-E" "create_symlink"
|
||||
"${toolchain_dir}/usr/lib/arc"
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/arc"
|
||||
CUSTOM_TARGET_NAME "symlink_arclite"
|
||||
OUTPUT "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/arc"
|
||||
COMMENT "Symlinking toolchain's arclite into ${SWIFTLIB_DIR}/arc")
|
||||
add_dependencies(copy_shim_headers symlink_arclite)
|
||||
|
||||
swift_install_in_component(arclite-symlink
|
||||
DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib/arc"
|
||||
DESTINATION "lib")
|
||||
endif()
|
||||
|
||||
install(FILES ${sources} DESTINATION "lib/swift/shims")
|
||||
swift_install_in_component(compiler
|
||||
FILES ${sources}
|
||||
DESTINATION "lib/swift/shims")
|
||||
|
||||
# Install Clang headers under the Swift library so that an installed swift's
|
||||
# module importer can find the compiler headers corresponding to its clang.
|
||||
install(
|
||||
swift_install_in_component(clang-builtin-headers
|
||||
DIRECTORY "${SWIFT_PATH_TO_CLANG_BUILD}/lib/clang"
|
||||
DESTINATION "lib/swift"
|
||||
PATTERN "*.h")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
set(SHARED_LIBRARY ON)
|
||||
set(SWIFTUNITTEST_SOURCES
|
||||
add_swift_library(swiftStdlibUnittest SHARED IS_STDLIB
|
||||
# This file should be listed the first. Module name is inferred from the
|
||||
# filename.
|
||||
StdlibUnittest.swift.gyb
|
||||
@@ -16,10 +15,6 @@ set(SWIFTUNITTEST_SOURCES
|
||||
StdlibCoreExtras.swift
|
||||
SwiftBlockToCFunctionThunks.cpp
|
||||
LifetimeTracked.swift
|
||||
)
|
||||
|
||||
add_swift_library(swiftStdlibUnittest INSTALL TARGET_LIBRARY
|
||||
${SWIFTUNITTEST_SOURCES}
|
||||
|
||||
# Can not serialize StdlibUnittest because of:
|
||||
# <rdar://problem/18917405> Compiling StdlibUnittest with -sil-serialize-all
|
||||
@@ -27,6 +22,7 @@ add_swift_library(swiftStdlibUnittest INSTALL TARGET_LIBRARY
|
||||
#
|
||||
# SWIFT_COMPILE_FLAGS -Xfrontend -sil-serialize-all
|
||||
|
||||
SWIFT_MODULE_DEPENDS Darwin Foundation
|
||||
FRAMEWORK_DEPENDS Foundation
|
||||
DEPENDS swiftCore swiftDarwin swiftFoundation)
|
||||
INSTALL_IN_COMPONENT stdlib-experimental)
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
// LINUX-DAG: -lswiftCore
|
||||
// LINUX-DAG: -L [[STDLIB_PATH:[^ ]+/lib/swift]]
|
||||
// LINUX-DAG: -Xlinker -rpath -Xlinker [[STDLIB_PATH]]
|
||||
// LINUX-DAG: -Xlinker -Tswift.ld
|
||||
// LINUX-DAG: -Xlinker -T /{{[^ ]+}}/linux/x86_64/swift.ld
|
||||
// LINUX-DAG: -F foo
|
||||
// LINUX-DAG: -framework bar
|
||||
// LINUX-DAG: -L baz
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
## Autogenerated by Swift configuration.
|
||||
# Do not edit!
|
||||
@@ -8,7 +9,7 @@ config.llvm_obj_root = "@LLVM_BINARY_DIR@"
|
||||
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
|
||||
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
|
||||
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
|
||||
config.swift_src_root = "@SWIFT_SOURCE_DIR@"
|
||||
config.swift_src_root = lit_config.params.get("swift_src_root", "@SWIFT_SOURCE_DIR@")
|
||||
config.swift_obj_root = "@SWIFT_BINARY_DIR@"
|
||||
config.target_triple = "@TARGET_TRIPLE@"
|
||||
config.targets_to_build = "@TARGETS_TO_BUILD@"
|
||||
@@ -25,21 +26,24 @@ except KeyError:
|
||||
key, = e.args
|
||||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
|
||||
|
||||
if "@SWIFT_RUN_LONG_TESTS@" != "OFF" and "@SWIFT_RUN_LONG_TESTS@" != "NO":
|
||||
config.available_features.add("long_tests")
|
||||
|
||||
if "@SWIFT_ASAN_BUILD@" != "OFF" and "@SWIFT_ASAN_BUILD@" != "NO":
|
||||
if "@SWIFT_ASAN_BUILD@" == "TRUE":
|
||||
config.available_features.add("asan")
|
||||
|
||||
if "@SWIFT_STDLIB_INTERNAL_CHECKS@" != "OFF" and "@SWIFT_STDLIB_INTERNAL_CHECKS@" != "NO":
|
||||
if "@LLVM_ENABLE_ASSERTIONS@" == "TRUE":
|
||||
config.available_features.add('asserts')
|
||||
else:
|
||||
config.available_features.add('no_asserts')
|
||||
|
||||
if "@SWIFT_STDLIB_ASSERTIONS@" == "TRUE":
|
||||
config.available_features.add('swift_stdlib_asserts')
|
||||
else:
|
||||
config.available_features.add('swift_stdlib_no_asserts')
|
||||
|
||||
if "@SWIFT_OPTIMIZED@" == "ON" or "@SWIFT_OPTIMIZED@" == "YES":
|
||||
if "@SWIFT_OPTIMIZED@" == "TRUE":
|
||||
config.available_features.add("optimized_stdlib")
|
||||
|
||||
# Let the main config do the real work.
|
||||
if config.test_exec_root is None:
|
||||
config.test_exec_root = os.path.dirname(os.path.realpath(__file__))
|
||||
lit_config.load_config(config, "@SWIFT_SOURCE_DIR@/test/lit.cfg")
|
||||
lit_config.load_config(
|
||||
config, os.path.join(config.swift_src_root, "test", "lit.cfg"))
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
if(NOT SWIFT_INSTALL_TESTSUITE_TOOLS)
|
||||
# Prevent SwiftLLVMPasses from being installed.
|
||||
set(LLVM_INSTALL_TOOLCHAIN_ONLY TRUE)
|
||||
endif()
|
||||
|
||||
add_llvm_loadable_module(SwiftLLVMPasses
|
||||
SwiftLLVMPasses.cpp
|
||||
@@ -9,14 +13,10 @@ set_target_properties(SwiftLLVMPasses PROPERTIES
|
||||
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${config} config_upper)
|
||||
# Hack to deal with the fact that ${SWIFTLIB_DIR} contains the build-time
|
||||
# variable $(CONFIGURATION). Note that this fix is Xcode-specific.
|
||||
# You might think you could just replace ${CMAKE_CFG_INTDIR} here, but
|
||||
# that can actually have other things mangled into it besides just the
|
||||
# configuration. This at least doesn't pretend to do the right thing
|
||||
# outside of Xcode.
|
||||
string(REPLACE "$(CONFIGURATION)" ${config} config_lib_dir
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
|
||||
apply_xcode_substitutions(
|
||||
"${config}"
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib"
|
||||
config_lib_dir)
|
||||
set_target_properties(SwiftLLVMPasses PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}
|
||||
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir})
|
||||
|
||||
@@ -1,44 +1,49 @@
|
||||
add_swift_executable(swift
|
||||
driver.cpp
|
||||
frontend_main.cpp
|
||||
DEPENDS swiftDriver swiftIRGen swiftSIL swiftSILGen swiftSILPasses swiftImmediate
|
||||
swiftSerialization swiftFrontend swiftClangImporter swiftPrintAsObjC
|
||||
swiftIDE swiftOption
|
||||
COMPONENT_DEPENDS bitreader bitwriter codegen ipo linker mcjit asmparser
|
||||
selectiondag ${LLVM_TARGETS_TO_BUILD})
|
||||
LINK_LIBRARIES
|
||||
swiftDriver swiftIRGen swiftSIL swiftSILGen swiftSILPasses
|
||||
swiftImmediate
|
||||
swiftSerialization
|
||||
swiftPrintAsObjC
|
||||
swiftFrontend
|
||||
swiftClangImporter
|
||||
swiftIDE
|
||||
swiftOption
|
||||
COMPONENT_DEPENDS
|
||||
bitreader bitwriter codegen ipo linker mcjit asmparser selectiondag
|
||||
objcarcopts option support ${LLVM_TARGETS_TO_BUILD})
|
||||
|
||||
target_link_libraries(swift edit)
|
||||
|
||||
add_custom_command(TARGET swift POST_BUILD
|
||||
COMMAND "${CMAKE_COMMAND}" "-E" "create_symlink" "swift" "swiftc"
|
||||
WORKING_DIRECTORY "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
|
||||
|
||||
# If building as part of clang, make sure the headers are installed.
|
||||
if(SWIFT_PATH_TO_CLANG_BUILD STREQUAL ${CMAKE_BINARY_DIR})
|
||||
if(NOT SWIFT_BUILT_STANDALONE)
|
||||
add_dependencies(swift clang-headers)
|
||||
endif()
|
||||
|
||||
# Platforms that have a REPL need extra libraries to be linked into the 'swift'
|
||||
# binary.
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
include(SwiftDarwin)
|
||||
if(SWIFT_HOST_VARIANT STREQUAL "macosx")
|
||||
# Link in CoreFoundation on Darwin.
|
||||
find_library(CORE_FOUNDATION NAMES CoreFoundation)
|
||||
target_link_libraries(swift ${CORE_FOUNDATION})
|
||||
|
||||
# Link in arclite on Darwin.
|
||||
execute_process(
|
||||
COMMAND xcrun --toolchain default -f clang
|
||||
OUTPUT_VARIABLE default_toolchain_compiler)
|
||||
get_filename_component(ARCLITE_BASE ${default_toolchain_compiler} PATH)
|
||||
get_filename_component(ARCLITE_BASE ${ARCLITE_BASE} PATH)
|
||||
set(SWIFT_REPL_ARCLITE "${ARCLITE_BASE}/lib/arc/libarclite_${SWIFT_DEPLOYMENT_OS}.a")
|
||||
if (SWIFT_REPL_ARCLITE)
|
||||
get_default_toolchain_dir(toolchain_dir)
|
||||
set(SWIFT_REPL_ARCLITE "${toolchain_dir}/usr/lib/arc/libarclite_${SWIFT_HOST_VARIANT}.a")
|
||||
set_property(TARGET swift APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -lobjc -Wl,-force_load,\"${SWIFT_REPL_ARCLITE}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS swift
|
||||
RUNTIME DESTINATION bin)
|
||||
swift_install_in_component(compiler
|
||||
TARGETS swift
|
||||
RUNTIME DESTINATION "bin")
|
||||
swift_install_in_component(compiler
|
||||
FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swiftc"
|
||||
DESTINATION "bin")
|
||||
|
||||
add_custom_command(TARGET swift POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink swift swiftc
|
||||
WORKING_DIRECTORY ${SWIFT_RUNTIME_OUTPUT_INTDIR})
|
||||
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink swift swiftc WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin)")
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
add_swift_executable(lldb-moduleimport-test
|
||||
lldb-moduleimport-test.cpp
|
||||
DEPENDS swiftASTSectionImporter swiftFrontend swiftClangImporter
|
||||
COMPONENT_DEPENDS bitreader bitwriter support ${LLVM_TARGETS_TO_BUILD})
|
||||
LINK_LIBRARIES
|
||||
swiftASTSectionImporter swiftFrontend swiftClangImporter
|
||||
COMPONENT_DEPENDS
|
||||
bitreader bitwriter option support ${LLVM_TARGETS_TO_BUILD})
|
||||
|
||||
target_link_libraries(swift)
|
||||
swift_install_in_component(testsuite-tools
|
||||
TARGETS lldb-moduleimport-test
|
||||
RUNTIME DESTINATION "bin")
|
||||
|
||||
install(TARGETS lldb-moduleimport-test
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
add_swift_executable(sil-extract
|
||||
SILExtract.cpp
|
||||
DEPENDS swiftSIL swiftSILGen swiftSILPasses swiftSerialization
|
||||
swiftFrontend swiftClangImporter
|
||||
COMPONENT_DEPENDS option bitreader bitwriter support ${LLVM_TARGETS_TO_BUILD})
|
||||
LINK_LIBRARIES
|
||||
swiftFrontend
|
||||
swiftSILGen
|
||||
swiftSILPasses
|
||||
swiftSerialization
|
||||
swiftClangImporter
|
||||
COMPONENT_DEPENDS
|
||||
option bitreader bitwriter support ${LLVM_TARGETS_TO_BUILD})
|
||||
|
||||
swift_install_in_component(tools
|
||||
TARGETS sil-extract
|
||||
RUNTIME DESTINATION "bin")
|
||||
|
||||
install(TARGETS sil-extract
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
add_swift_executable(sil-opt
|
||||
SILOpt.cpp
|
||||
DEPENDS swiftIRGen swiftSIL swiftSILGen swiftSILPasses swiftSerialization
|
||||
swiftFrontend swiftClangImporter
|
||||
COMPONENT_DEPENDS option bitreader bitwriter support ${LLVM_TARGETS_TO_BUILD})
|
||||
LINK_LIBRARIES
|
||||
swiftFrontend
|
||||
swiftIRGen
|
||||
swiftSILGen
|
||||
swiftSILPasses
|
||||
COMPONENT_DEPENDS
|
||||
option bitreader bitwriter support ${LLVM_TARGETS_TO_BUILD})
|
||||
|
||||
install(TARGETS sil-opt
|
||||
swift_install_in_component(tools
|
||||
TARGETS sil-opt
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
add_swift_executable(swift-demangle
|
||||
swift-demangle.cpp
|
||||
DEPENDS swiftBasic
|
||||
LINK_LIBRARIES swiftBasic
|
||||
COMPONENT_DEPENDS support ${LLVM_TARGETS_TO_BUILD})
|
||||
|
||||
install(TARGETS swift-demangle
|
||||
RUNTIME DESTINATION bin)
|
||||
swift_install_in_component(compiler
|
||||
TARGETS swift-demangle
|
||||
RUNTIME DESTINATION "bin")
|
||||
|
||||
|
||||
@@ -2,16 +2,21 @@ add_swift_executable(swift-ide-test
|
||||
swift-ide-test.cpp
|
||||
ModuleAPIDiff.cpp
|
||||
XMLValidator.cpp
|
||||
DEPENDS swiftDriver swiftFrontend swiftIDE
|
||||
COMPONENT_DEPENDS bitreader bitwriter support ${LLVM_TARGETS_TO_BUILD})
|
||||
LINK_LIBRARIES
|
||||
swiftDriver
|
||||
swiftFrontend
|
||||
swiftIDE
|
||||
COMPONENT_DEPENDS
|
||||
bitreader bitwriter option support ${LLVM_TARGETS_TO_BUILD})
|
||||
|
||||
# If libxml2 is available, make it available for swift-ide-test.
|
||||
if (SWIFT_HAVE_LIBXML)
|
||||
if(SWIFT_HAVE_LIBXML)
|
||||
include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
|
||||
target_link_libraries(swift-ide-test ${LIBXML2_LIBRARIES})
|
||||
add_definitions( -DSWIFT_HAVE_LIBXML="1" )
|
||||
add_definitions(-DSWIFT_HAVE_LIBXML="1")
|
||||
endif()
|
||||
|
||||
install(TARGETS swift-ide-test
|
||||
swift_install_in_component(tools
|
||||
TARGETS swift-ide-test
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
set(GENERATED_TESTS UnicodeGraphemeBreakTest.cpp.gyb)
|
||||
set(generated_tests UnicodeGraphemeBreakTest.cpp.gyb)
|
||||
|
||||
handle_gyb_sources(${CMAKE_SIZEOF_VOID_P} GENERATED_TESTS)
|
||||
handle_gyb_sources(
|
||||
gyb_dependency_targets
|
||||
generated_tests
|
||||
${SWIFT_HOST_VARIANT_ARCH})
|
||||
|
||||
add_swift_unittest(SwiftBasicTests
|
||||
Demangle.cpp
|
||||
@@ -10,9 +13,11 @@ add_swift_unittest(SwiftBasicTests
|
||||
SuccessorMapTest.cpp
|
||||
Unicode.cpp
|
||||
|
||||
${GENERATED_TESTS}
|
||||
${generated_tests}
|
||||
)
|
||||
|
||||
add_dependencies(SwiftBasicTests "${gyb_dependency_targets}")
|
||||
|
||||
target_link_libraries(SwiftBasicTests
|
||||
swiftBasic
|
||||
clangBasic
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
add_custom_target(SwiftUnitTests)
|
||||
|
||||
if (NOT SWIFT_BUILD_TOOLS)
|
||||
# These tests are not properly configured for stdlib-only builds.
|
||||
else()
|
||||
set_target_properties(SwiftUnitTests PROPERTIES FOLDER "Tests")
|
||||
set_target_properties(SwiftUnitTests PROPERTIES FOLDER "Tests")
|
||||
|
||||
function(add_swift_unittest test_dirname)
|
||||
function(add_swift_unittest test_dirname)
|
||||
add_unittest(SwiftUnitTests ${test_dirname} ${ARGN})
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set_property(TARGET ${test_dirname} APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/${SWIFTLIB_SUBDIR}")
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
||||
LINK_FLAGS " -Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx")
|
||||
endif()
|
||||
endfunction()
|
||||
endfunction()
|
||||
|
||||
file(GLOB entries *)
|
||||
foreach(entry ${entries})
|
||||
# FIXME: cross-compile runtime unittests.
|
||||
file(GLOB entries *)
|
||||
foreach(entry ${entries})
|
||||
if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
|
||||
add_subdirectory(${entry})
|
||||
endif()
|
||||
endforeach(entry)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
core)
|
||||
add_swift_unittest(SwiftParseTests
|
||||
LexerTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(SwiftParseTests
|
||||
swiftParse swiftSIL swiftSema swiftClangImporter
|
||||
)
|
||||
swiftClangImporter
|
||||
swiftSIL
|
||||
swiftSema
|
||||
swiftParse
|
||||
swiftAST)
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
add_swift_unittest(SwiftRuntimeTests
|
||||
if(("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SDK}") AND
|
||||
("${SWIFT_HOST_VARIANT_ARCH}" STREQUAL "${SWIFT_PRIMARY_VARIANT_ARCH}"))
|
||||
|
||||
add_swift_unittest(SwiftRuntimeTests
|
||||
Metadata.cpp
|
||||
Enum.cpp
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
||||
find_library(FOUNDATION_LIBRARY Foundation)
|
||||
target_link_libraries(SwiftRuntimeTests ${FOUNDATION_LIBRARY})
|
||||
endif()
|
||||
|
||||
# FIXME: cross-compile for all variants.
|
||||
target_link_libraries(SwiftRuntimeTests
|
||||
swiftCore${SWIFT_PRIMARY_VARIANT_SUFFIX})
|
||||
endif()
|
||||
|
||||
target_link_libraries(SwiftRuntimeTests
|
||||
swiftCore
|
||||
)
|
||||
|
||||
126
utils/SwiftBuildSupport.py
Normal file
126
utils/SwiftBuildSupport.py
Normal file
@@ -0,0 +1,126 @@
|
||||
#===--- SwiftBuildSupport.py - Utilities for Swift build scripts -----------===#
|
||||
#
|
||||
# This source file is part of the Swift.org open source project
|
||||
#
|
||||
# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
||||
# Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
#
|
||||
# See http://swift.org/LICENSE.txt for license information
|
||||
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
#
|
||||
#===------------------------------------------------------------------------===#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import ConfigParser
|
||||
import os
|
||||
import pipes
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
HOME = os.environ["HOME"]
|
||||
|
||||
|
||||
# Set SWIFT_SOURCE_ROOT in your environment to control where the sources
|
||||
# are found.
|
||||
SWIFT_SOURCE_ROOT = os.environ.get(
|
||||
"SWIFT_SOURCE_ROOT", os.path.join(HOME, "src", "s"))
|
||||
|
||||
|
||||
# Set SWIFT_BUILD_ROOT to a directory that will contain a subdirectory
|
||||
# for each build configuration
|
||||
SWIFT_BUILD_ROOT = os.environ.get(
|
||||
"SWIFT_BUILD_ROOT", os.path.join(HOME, "build", "swift"))
|
||||
|
||||
|
||||
def print_with_argv0(message):
|
||||
print(sys.argv[0] + ": " + message)
|
||||
|
||||
|
||||
def bad_usage(message):
|
||||
print_with_argv0(message)
|
||||
print("Run '" + pipes.quote(sys.argv[0]) + " --help' for more information.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def quote_shell_command(args):
|
||||
return " ".join([ pipes.quote(a) for a in args ])
|
||||
|
||||
|
||||
def check_call(args, verbose=False):
|
||||
try:
|
||||
return subprocess.check_call(args)
|
||||
except:
|
||||
if verbose:
|
||||
print_with_argv0("failed command: " + quote_shell_command(args))
|
||||
else:
|
||||
print_with_argv0("command terminated with a non-zero exit status, aborting build")
|
||||
sys.stdout.flush()
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def check_output(args, verbose=False):
|
||||
try:
|
||||
return subprocess.check_output(args)
|
||||
except:
|
||||
if verbose:
|
||||
print_with_argv0("failed command: " + quote_shell_command(args))
|
||||
else:
|
||||
print_with_argv0("command terminated with a non-zero exit status, aborting build")
|
||||
sys.stdout.flush()
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def get_preset_options_impl(config, substitutions, preset_name):
|
||||
section_name = "preset: " + preset_name
|
||||
if section_name not in config.sections():
|
||||
return (None, None)
|
||||
|
||||
build_script_opts = []
|
||||
build_script_impl_opts = []
|
||||
dash_dash_seen = False
|
||||
for o, a in config.items(section_name):
|
||||
if o in substitutions:
|
||||
continue
|
||||
|
||||
opt = None
|
||||
if o == "mixin-preset":
|
||||
# Split on newlines and filter out empty lines.
|
||||
mixins = filter(None, [m.strip() for m in a.splitlines()])
|
||||
for mixin in mixins:
|
||||
(base_build_script_opts, base_build_script_impl_opts) = \
|
||||
get_preset_options_impl(config, substitutions, mixin)
|
||||
build_script_opts += base_build_script_opts
|
||||
build_script_impl_opts += base_build_script_impl_opts
|
||||
elif o == "dash-dash":
|
||||
dash_dash_seen = True
|
||||
elif a == "":
|
||||
opt = "--" + o
|
||||
else:
|
||||
opt = "--" + o + "=" + a
|
||||
|
||||
if opt:
|
||||
if not dash_dash_seen:
|
||||
build_script_opts.append(opt)
|
||||
else:
|
||||
build_script_impl_opts.append(opt)
|
||||
return (build_script_opts, build_script_impl_opts)
|
||||
|
||||
|
||||
def get_preset_options(substitutions, preset_file_names, preset_name):
|
||||
config = ConfigParser.SafeConfigParser(substitutions, allow_no_value=True)
|
||||
if config.read(preset_file_names) == []:
|
||||
print_with_argv0(
|
||||
"preset file not found (tried " + str(preset_file_names) + ")")
|
||||
sys.exit(1)
|
||||
|
||||
(build_script_opts, build_script_impl_opts) = \
|
||||
get_preset_options_impl(config, substitutions, preset_name)
|
||||
if build_script_opts is None:
|
||||
print_with_argv0("preset '" + preset_name + "'not found")
|
||||
sys.exit(1)
|
||||
|
||||
return build_script_opts + [ "--" ] + build_script_impl_opts
|
||||
|
||||
|
||||
@@ -1,627 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o pipefail
|
||||
set -e
|
||||
#
|
||||
# Note: Jenkins is set up to restore the repositories to pristine
|
||||
# state before building, so we rebuild from scratch every time. If
|
||||
# you use this script yourself, it will NOT auto-clean before building
|
||||
|
||||
# Set up the default path to cmake
|
||||
CMAKE_DEFAULT="$(which cmake || echo /usr/local/bin/cmake)"
|
||||
|
||||
# Declare the set of known settings along with each one's description
|
||||
#
|
||||
# If you add a user-settable variable, add it to this list.
|
||||
#
|
||||
# a default value of "" indicates that the corresponding variable
|
||||
# will remain unset unless set explicitly
|
||||
KNOWN_SETTINGS=(
|
||||
# name default description
|
||||
build-args "" "arguments to the build tool; defaults to -j8 when CMake generator is \"Unix Makefiles\""
|
||||
build-dir "" "out-of-tree build directory; default is in-tree. **This argument is required**"
|
||||
build-type Debug "the CMake build variant: Debug, RelWithDebInfo, Release, etc."
|
||||
llvm-build-dir "" "out-of-tree build directory for llvm; default is BUILD_DIR/llvm, where BUILD_DIR is given by --build-dir"
|
||||
llvm-build-type "$BUILD_TYPE" "the CMake build variant for clang and llvm: Debug, RelWithDebInfo, Release, etc. defaults to BUILD_TYPE, where BUILD_TYPE is given by --build-type"
|
||||
cmake "$CMAKE_DEFAULT" "path to the cmake binary"
|
||||
distcc "" "use distcc in pump mode"
|
||||
config-args "" "User-supplied arguments to cmake when used to do configuration"
|
||||
cmake-generator "Unix Makefiles" "kind of build system to generate; see output of cmake --help for choices"
|
||||
prefix "/usr" "installation prefix"
|
||||
show-sdks "" "print installed Xcode and SDK versions"
|
||||
reconfigure "" "force a CMake configuration run even if CMakeCache.txt already exists"
|
||||
skip-ios "" "set to skip everything iOS-related"
|
||||
skip-build-llvm "" "set to skip building LLVM/Clang"
|
||||
skip-build-swift "" "set to skip building Swift"
|
||||
skip-build-ios "" "set to skip building Swift stdlibs for iOS"
|
||||
skip-build-ios-device "" "set to skip building Swift stdlibs for iOS devices (i.e. build simulators only)"
|
||||
skip-build-ios-simulator "" "set to skip building Swift stdlibs for iOS simulators (i.e. build devices only)"
|
||||
skip-build-sourcekit "" "set to skip building SourceKit"
|
||||
skip-test-swift "" "set to skip testing Swift"
|
||||
skip-test-ios "" "set to skip testing Swift stdlibs for iOS"
|
||||
skip-test-ios-device "" "set to skip testing Swift stdlibs for iOS devices (i.e. test simulators only)"
|
||||
skip-test-ios-simulator "" "set to skip testing Swift stdlibs for iOS simulators (i.e. test devices only)"
|
||||
skip-test-sourcekit "" "set to skip testing SourceKit"
|
||||
skip-test-swift-performance "" "set to skip testing Swift performance"
|
||||
skip-test-validation "" "set to skip validation test suite"
|
||||
stress-test-sourcekit "" "set to run the stress-SourceKit target"
|
||||
workspace "${HOME}/src" "source directory containing llvm, clang, swift, and SourceKit"
|
||||
run-with-asan-compiler "" "the AddressSanitizer compiler to use (non-asan build if empty string is passed)"
|
||||
disable-assertions "" "set to disable assertions"
|
||||
)
|
||||
|
||||
function toupper() {
|
||||
echo "$@" | tr '[:lower:]' '[:upper:]'
|
||||
}
|
||||
|
||||
function to_varname() {
|
||||
toupper "${1//-/_}"
|
||||
}
|
||||
|
||||
# Set up an "associative array" of settings for error checking, and set
|
||||
# (or unset) each corresponding variable to its default value
|
||||
# If the Mac's bash were not stuck in the past, we could "declare -A" an
|
||||
# associative array, but instead we have to hack it by defining variables
|
||||
# declare -A IS_KNOWN_SETTING
|
||||
for ((i = 0; i < ${#KNOWN_SETTINGS[@]}; i += 3)); do
|
||||
setting="${KNOWN_SETTINGS[i]}"
|
||||
|
||||
default_value="${KNOWN_SETTINGS[$((i+1))]}"
|
||||
|
||||
varname="$(to_varname "${setting}")" # upcase the setting name to get the variable
|
||||
eval "${varname}_IS_KNOWN_SETTING=1"
|
||||
|
||||
if [[ "${default_value}" ]] ; then
|
||||
# For an explanation of the backslash see http://stackoverflow.com/a/9715377
|
||||
eval ${varname}=$\default_value
|
||||
else
|
||||
unset ${varname}
|
||||
fi
|
||||
done
|
||||
|
||||
COMMAND_NAME="$(basename "$0")"
|
||||
|
||||
# Print instructions for using this script to stdout
|
||||
usage() {
|
||||
echo "Usage: ${COMMAND_NAME} [--help|-h] [ --SETTING=VALUE | --SETTING VALUE | --SETTING | --release ] *"
|
||||
echo
|
||||
echo " Available settings. Each setting corresponds to a variable,"
|
||||
echo " obtained by upcasing its name, in this script. A variable"
|
||||
echo " with no default listed here will be unset in the script if"
|
||||
echo " not explicitly specified. A setting passed in the 3rd form"
|
||||
echo " will set its corresponding variable to \"1\"."
|
||||
echo
|
||||
|
||||
setting_list="
|
||||
| |Setting| Default|Description
|
||||
| |-------| -------|-----------
|
||||
"
|
||||
|
||||
for ((i = 0; i < ${#KNOWN_SETTINGS[@]}; i += 3)); do
|
||||
setting_list+="\
|
||||
| |--${KNOWN_SETTINGS[i]}| ${KNOWN_SETTINGS[$((i+1))]}|${KNOWN_SETTINGS[$((i+2))]}
|
||||
"
|
||||
done
|
||||
echo "${setting_list}" | column -x -s'|' -t
|
||||
echo
|
||||
echo "Note: when using the form --SETTING VALUE, VALUE must not begin "
|
||||
echo " with a hyphen."
|
||||
echo "Note: the \"--release\" option creates a pre-packaged combination"
|
||||
echo " of settings used by the buildbot."
|
||||
}
|
||||
|
||||
# Scan all command-line arguments
|
||||
while [[ "$1" ]] ; do
|
||||
case "$1" in
|
||||
-h | --help )
|
||||
usage
|
||||
exit
|
||||
;;
|
||||
|
||||
--release)
|
||||
BUILD_TYPE=RelWithDebInfo
|
||||
# Include a custom name to avoid picking up stale module files.
|
||||
CUSTOM_VERSION_NAME="release $(date -j '+%Y-%m-%d %H-%M-%S')"
|
||||
;;
|
||||
|
||||
--* )
|
||||
dashless="${1:2}"
|
||||
|
||||
# drop suffix beginning with the first "="
|
||||
setting="${dashless%%=*}"
|
||||
|
||||
# compute the variable to set
|
||||
varname="$(to_varname "${setting}")"
|
||||
|
||||
# check to see if this is a known option
|
||||
known_var_name="${varname}_IS_KNOWN_SETTING"
|
||||
if [[ ! "${!known_var_name}" ]] ; then
|
||||
echo "Error: Unknown setting: ${setting}" 1>&2
|
||||
usage 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# find the intended value
|
||||
if [[ "${dashless}" == *=* ]] ; then # if there's an '=', the value
|
||||
value="${dashless#*=}" # is everything after the first '='
|
||||
elif [[ "$2" ]] && [[ "${2:0:1}" != "-" ]] ; then # else if the next parameter exists
|
||||
value="$2" # but isn't an option, use that
|
||||
shift
|
||||
else # otherwise, the value is 1
|
||||
value=1
|
||||
fi
|
||||
|
||||
# For explanation of backslash see http://stackoverflow.com/a/9715377
|
||||
eval ${varname}=$\value
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Set this to the install prefix for release builds.
|
||||
INSTALL_PREFIX="${PREFIX}"
|
||||
|
||||
# Set these to the paths of the OS X SDK and toolchain.
|
||||
if [[ "$(uname -s)" == "Darwin" ]] ; then
|
||||
SYSROOT="$(xcrun --show-sdk-path --sdk macosx10.10internal)"
|
||||
TOOLCHAIN="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain"
|
||||
else
|
||||
SYSROOT="/"
|
||||
TOOLCHAIN="/"
|
||||
fi
|
||||
|
||||
# WORKSPACE and BUILD_DIR must be absolute paths
|
||||
case "${WORKSPACE}" in
|
||||
/*) ;;
|
||||
*) echo "workspace must be an absolute path (was '${WORKSPACE}')" ; exit 1 ;;
|
||||
esac
|
||||
case "${BUILD_DIR}" in
|
||||
/*) ;;
|
||||
"") echo "the --build-dir option is required"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
*) echo "build-dir must be an absolute path (was '${BUILD_DIR}')" ; exit 1 ;;
|
||||
esac
|
||||
|
||||
# WORKSPACE must exist
|
||||
if [ ! -e "$WORKSPACE" ]; then
|
||||
echo "Workspace does not exist (tried $WORKSPACE)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Swift-project products, in the order they must be built
|
||||
SWIFT_BUILD_PRODUCTS=(swift)
|
||||
if [[ ! "$SKIP_BUILD_SOURCEKIT" ]]; then
|
||||
SWIFT_BUILD_PRODUCTS=("${SWIFT_BUILD_PRODUCTS[@]}" SourceKit)
|
||||
fi
|
||||
|
||||
SWIFT_TEST_PRODUCTS=("${SWIFT_BUILD_PRODUCTS[@]}")
|
||||
|
||||
LLVM_TARGETS_TO_BUILD="X86;ARM;AArch64"
|
||||
|
||||
# Swift stdlib build products
|
||||
# macosx-x86_64 stdlib is part of the swift product itself
|
||||
if [[ ! "$SKIP_IOS" ]]; then
|
||||
IOS_SIMULATOR_PRODUCTS=(swift_stdlib_ios_simulator_x86_64 swift_stdlib_ios_simulator_i386)
|
||||
IOS_DEVICE_PRODUCTS=(swift_stdlib_ios_arm64 swift_stdlib_ios_armv7)
|
||||
if [[ ! "$SKIP_BUILD_IOS" ]]; then
|
||||
if [[ ! "$SKIP_BUILD_IOS_SIMULATOR" ]]; then
|
||||
IOS_BUILD_PRODUCTS=("${IOS_BUILD_PRODUCTS[@]}" "${IOS_SIMULATOR_PRODUCTS[@]}")
|
||||
fi
|
||||
if [[ ! "$SKIP_BUILD_IOS_DEVICE" ]]; then
|
||||
IOS_BUILD_PRODUCTS=("${IOS_BUILD_PRODUCTS[@]}" "${IOS_DEVICE_PRODUCTS[@]}")
|
||||
fi
|
||||
SWIFT_BUILD_PRODUCTS=("${SWIFT_BUILD_PRODUCTS[@]}" "${IOS_BUILD_PRODUCTS[@]}")
|
||||
fi
|
||||
if [[ ! "$SKIP_TEST_IOS" ]]; then
|
||||
if [[ ! "$SKIP_TEST_IOS_SIMULATOR" ]]; then
|
||||
IOS_TEST_PRODUCTS=("${IOS_TEST_PRODUCTS[@]}" "${IOS_SIMULATOR_PRODUCTS[@]}")
|
||||
fi
|
||||
if [[ ! "$SKIP_TEST_IOS_DEVICE" ]]; then
|
||||
IOS_TEST_PRODUCTS=("${IOS_TEST_PRODUCTS[@]}" "${IOS_DEVICE_PRODUCTS[@]}")
|
||||
fi
|
||||
SWIFT_TEST_PRODUCTS=("${SWIFT_TEST_PRODUCTS[@]}" "${IOS_TEST_PRODUCTS[@]}")
|
||||
fi
|
||||
fi
|
||||
|
||||
# All build products, in the order they must be built
|
||||
ALL_BUILD_PRODUCTS=(llvm "${SWIFT_BUILD_PRODUCTS[@]}")
|
||||
|
||||
#
|
||||
# Calculate source directories for each product.
|
||||
#
|
||||
|
||||
# iOS build products use the same source directory as swift itself.
|
||||
# Default to $WORKSPACE/swift if SWIFT_SOURCE_DIR if not set above.
|
||||
for product in "${IOS_BUILD_PRODUCTS[@]}" "${IOS_TEST_PRODUCTS[@]}" ; do
|
||||
varname="$(toupper "${product}")"_SOURCE_DIR
|
||||
eval $varname=${SWIFT_SOURCE_DIR:-$WORKSPACE/swift}
|
||||
done
|
||||
|
||||
# Default source directory is $WORKSPACE/$product if not set above.
|
||||
for product in "${ALL_BUILD_PRODUCTS[@]}" ; do
|
||||
_PRODUCT_SOURCE_DIR="$(toupper "${product}")"_SOURCE_DIR
|
||||
eval dir=\${$_PRODUCT_SOURCE_DIR:=$WORKSPACE/$product}
|
||||
if [ ! -e "${dir}" ] ; then
|
||||
echo "Can't find source directory for $product (tried $dir)"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
#
|
||||
# Calculate build directories for each product
|
||||
#
|
||||
|
||||
# Build directories are $BUILD_DIR/$product or $PRODUCT_SOURCE_DIR/build
|
||||
for product in "${ALL_BUILD_PRODUCTS[@]}" ; do
|
||||
PRODUCT=$(toupper "${product}")
|
||||
product_build_dir_var="${PRODUCT}_BUILD_DIR"
|
||||
eval "product_build_dir=\${${product_build_dir_var}}"
|
||||
if [[ ! "${product_build_dir}" ]] ; then
|
||||
eval "${PRODUCT}_BUILD_DIR=\"\${BUILD_DIR}/${product}\""
|
||||
fi
|
||||
done
|
||||
|
||||
# iOS build products use their own build directories, which are
|
||||
# subdirectories of swift's build directory if BUILD_DIR is not set.
|
||||
for product in "${IOS_BUILD_PRODUCTS[@]}" "${IOS_TEST_PRODUCTS[@]}" ; do
|
||||
_PRODUCT_BUILD_DIR="$(toupper "${product}")"_BUILD_DIR
|
||||
eval ${_PRODUCT_BUILD_DIR}="${BUILD_DIR}/${product}"
|
||||
done
|
||||
|
||||
|
||||
# Symlink clang into the llvm tree.
|
||||
CLANG_SOURCE_DIR="${LLVM_SOURCE_DIR}/tools/clang"
|
||||
CLANG_BUILD_DIR="${LLVM_BUILD_DIR}"
|
||||
if [ ! -e "${WORKSPACE}/clang" ]; then
|
||||
# If llvm/tools/clang is already a directory, use that and skip the symlink.
|
||||
if [ ! -d "${CLANG_SOURCE_DIR}" ]; then
|
||||
echo "Can't find source directory for clang (tried ${WORKSPACE}/clang and ${CLANG_SOURCE_DIR})"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ ! -d "${CLANG_SOURCE_DIR}" ]; then
|
||||
ln -sf "${WORKSPACE}/clang" "${CLANG_SOURCE_DIR}"
|
||||
fi
|
||||
|
||||
if [[ "$(uname -s)" == "Darwin" ]] ; then
|
||||
HOST_CC="$TOOLCHAIN/usr/bin/clang"
|
||||
HOST_CXX="$TOOLCHAIN/usr/bin/clang++"
|
||||
else
|
||||
HOST_CC="clang"
|
||||
HOST_CXX="clang++"
|
||||
fi
|
||||
|
||||
if [[ "$DISTCC" ]] ; then
|
||||
# On some platforms, pump may be unrelated to distcc, in which case it's
|
||||
# called distcc-pump.
|
||||
DISTCC_PUMP="$(which distcc-pump || which pump)"
|
||||
CMAKE_COMPILER_OPTIONS=(
|
||||
-DSWIFT_DISTCC="$(which distcc)"
|
||||
-DCMAKE_C_COMPILER="$(which distcc)"
|
||||
-DCMAKE_C_COMPILER_ARG1="${HOST_CC}"
|
||||
-DCMAKE_CXX_COMPILER="$(which distcc)"
|
||||
-DCMAKE_CXX_COMPILER_ARG1="${HOST_CXX}"
|
||||
)
|
||||
else
|
||||
CMAKE_COMPILER_OPTIONS=(
|
||||
-DCMAKE_C_COMPILER="${HOST_CC}"
|
||||
-DCMAKE_CXX_COMPILER="${HOST_CXX}"
|
||||
)
|
||||
fi
|
||||
|
||||
CMAKE_C_FLAGS=""
|
||||
CMAKE_CXX_FLAGS=""
|
||||
CMAKE_EXE_LINKER_FLAGS=""
|
||||
CMAKE_SHARED_LINKER_FLAGS=""
|
||||
|
||||
if [[ "${RUN_WITH_ASAN_COMPILER}" ]]; then
|
||||
CMAKE_COMPILER_OPTIONS=(
|
||||
-DCMAKE_C_COMPILER="${RUN_WITH_ASAN_COMPILER}"
|
||||
-DCMAKE_CXX_COMPILER="${RUN_WITH_ASAN_COMPILER}++"
|
||||
)
|
||||
CMAKE_C_FLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -mllvm -asan-globals=0"
|
||||
CMAKE_CXX_FLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer -mllvm -asan-globals=0"
|
||||
CMAKE_EXE_LINKER_FLAGS="-fsanitize=address"
|
||||
CMAKE_SHARED_LINKER_FLAGS="-fsanitize=address"
|
||||
fi
|
||||
|
||||
ENABLE_ASSERTIONS="ON"
|
||||
if [[ "$DISABLE_ASSERTIONS" ]]; then
|
||||
ENABLE_ASSERTIONS="OFF"
|
||||
fi
|
||||
|
||||
# CMake options used for all targets, including LLVM/Clang
|
||||
COMMON_CMAKE_OPTIONS=(
|
||||
"${CMAKE_COMPILER_OPTIONS[@]}"
|
||||
-DLLVM_ENABLE_ASSERTIONS="${ENABLE_ASSERTIONS}"
|
||||
)
|
||||
|
||||
case "${CMAKE_GENERATOR}" in
|
||||
'Unix Makefiles')
|
||||
BUILD_ARGS="${BUILD_ARGS:--j8}"
|
||||
;;
|
||||
Xcode)
|
||||
BUILD_TARGET_FLAG=-target
|
||||
COMMON_CMAKE_OPTIONS=(
|
||||
"${COMMON_CMAKE_OPTIONS[@]}"
|
||||
-DCMAKE_XCODE_ATTRIBUTE_GCC_VERSION:STRING=com.apple.compilers.llvm.clang.1_0
|
||||
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY:STRING=libc++
|
||||
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.8
|
||||
-DCMAKE_CONFIGURATION_TYPES="Debug;Release"
|
||||
)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Record SDK and tools versions for posterity
|
||||
if [[ "$SHOW_SDKS" ]]; then
|
||||
echo "--- SDK versions ---"
|
||||
xcodebuild -version || :
|
||||
echo
|
||||
xcodebuild -version -sdk macosx.internal || :
|
||||
if [[ ! "$SKIP_IOS" ]]; then
|
||||
xcodebuild -version -sdk iphoneos.internal || :
|
||||
xcodebuild -version -sdk iphonesimulator || :
|
||||
fi
|
||||
fi
|
||||
|
||||
# Build LLVM and Clang (x86 target only).
|
||||
if [ \! "$SKIP_BUILD_LLVM" ]; then
|
||||
echo "--- Building LLVM and Clang ---"
|
||||
if [[ "${RECONFIGURE}" || ! -f "${LLVM_BUILD_DIR}/CMakeCache.txt" ]] ; then
|
||||
set -x
|
||||
mkdir -p "${LLVM_BUILD_DIR}"
|
||||
# Note: we set LLVM_IMPLICIT_PROJECT_IGNORE below because this
|
||||
# script builds swift separately, and people often have reasons
|
||||
# to symlink the swift directory into llvm/tools, e.g. to build
|
||||
# LLDB
|
||||
(cd "${LLVM_BUILD_DIR}" &&
|
||||
"$CMAKE" -G "${CMAKE_GENERATOR}" "${COMMON_CMAKE_OPTIONS[@]}" \
|
||||
-DCMAKE_BUILD_TYPE="${LLVM_BUILD_TYPE}" \
|
||||
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}" \
|
||||
-DLLVM_IMPLICIT_PROJECT_IGNORE="${LLVM_SOURCE_DIR}/tools/swift" \
|
||||
-DLLVM_TARGETS_TO_BUILD="${LLVM_TARGETS_TO_BUILD}" \
|
||||
-DCLANG_REPOSITORY_STRING="$CUSTOM_VERSION_NAME" \
|
||||
${CONFIG_ARGS} \
|
||||
"${LLVM_SOURCE_DIR}" || exit 1)
|
||||
{ set +x; } 2>/dev/null
|
||||
fi
|
||||
set -x
|
||||
$DISTCC_PUMP "$CMAKE" --build "${LLVM_BUILD_DIR}" -- ${BUILD_ARGS}
|
||||
{ set +x; } 2>/dev/null
|
||||
fi
|
||||
|
||||
#
|
||||
# Now build all the Swift products
|
||||
#
|
||||
|
||||
if [[ "$(uname -s)" == "Darwin" ]] ; then
|
||||
SWIFT_CMAKE_OPTIONS=(
|
||||
-DCMAKE_OSX_SYSROOT="${SYSROOT}"
|
||||
-DMODULES_SDK="${SYSROOT}"
|
||||
-DCMAKE_C_FLAGS="-isysroot${SYSROOT} ${CMAKE_C_FLAGS}"
|
||||
-DCMAKE_CXX_FLAGS="-isysroot${SYSROOT} ${CMAKE_CXX_FLAGS}"
|
||||
)
|
||||
else
|
||||
SWIFT_CMAKE_OPTIONS=(
|
||||
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS}"
|
||||
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}"
|
||||
)
|
||||
fi
|
||||
|
||||
SWIFT_CMAKE_OPTIONS=(
|
||||
"${SWIFT_CMAKE_OPTIONS[@]}"
|
||||
-DSWIFT_RUN_LONG_TESTS="ON"
|
||||
-DLLVM_CONFIG="${LLVM_BUILD_DIR}/bin/llvm-config"
|
||||
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
|
||||
)
|
||||
|
||||
# set_ios_options options_var platform deployment_target internal_suffix arch
|
||||
function set_ios_options {
|
||||
local platform=$2
|
||||
local deployment_target=$3
|
||||
local internal_suffix=$4
|
||||
local arch=$5
|
||||
|
||||
local sdkroot=$(xcrun -sdk ${platform}${internal_suffix} -show-sdk-path)
|
||||
|
||||
local opts=(
|
||||
-DCMAKE_TOOLCHAIN_FILE="${SWIFT_SOURCE_DIR}/cmake/${platform}.cmake"
|
||||
-DCMAKE_SYSTEM_PROCESSOR=${arch}
|
||||
-DCMAKE_OSX_ARCHITECTURES=${arch}
|
||||
-DCMAKE_OSX_SYSROOT="${sdkroot}"
|
||||
-DMODULES_SDK="${sdkroot}"
|
||||
-DCMAKE_C_FLAGS="-isysroot${sdkroot}"
|
||||
-DCMAKE_CXX_FLAGS="-isysroot${sdkroot}"
|
||||
-DSWIFT_DEPLOYMENT_OS=${platform}
|
||||
-DSWIFT_DEPLOYMENT_TARGET=${deployment_target}
|
||||
-DSWIFT_BUILD_TOOLS=OFF
|
||||
-DSWIFT_RUN_LONG_TESTS="ON"
|
||||
-DPATH_TO_SWIFT_BUILD="${SWIFT_BUILD_DIR}"
|
||||
-DSWIFT_INCLUDE_DOCS=OFF
|
||||
-DLLVM_CONFIG="${LLVM_BUILD_DIR}/bin/llvm-config"
|
||||
)
|
||||
|
||||
eval $1=\(\${opts[@]}\)
|
||||
}
|
||||
|
||||
|
||||
if [[ ! "$SKIP_BUILD_IOS" ]]; then
|
||||
set_ios_options SWIFT_STDLIB_IOS_ARM64_CMAKE_OPTIONS iphoneos 7.0 .internal arm64
|
||||
set_ios_options SWIFT_STDLIB_IOS_SIMULATOR_X86_64_CMAKE_OPTIONS iphonesimulator 7.0 "" x86_64
|
||||
set_ios_options SWIFT_STDLIB_IOS_ARMV7_CMAKE_OPTIONS iphoneos 7.0 .internal armv7
|
||||
set_ios_options SWIFT_STDLIB_IOS_SIMULATOR_I386_CMAKE_OPTIONS iphonesimulator 7.0 "" i386
|
||||
fi
|
||||
|
||||
SOURCEKIT_CMAKE_OPTIONS=(
|
||||
-DSOURCEKIT_PATH_TO_SWIFT_SOURCE="${SWIFT_SOURCE_DIR}"
|
||||
-DSOURCEKIT_PATH_TO_SWIFT_BUILD="${SWIFT_BUILD_DIR}"
|
||||
-DLLVM_CONFIG="${LLVM_BUILD_DIR}/bin/llvm-config"
|
||||
-DCMAKE_C_FLAGS="-isysroot${SYSROOT} ${CMAKE_C_FLAGS}"
|
||||
-DCMAKE_CXX_FLAGS="-isysroot${SYSROOT} ${CMAKE_CXX_FLAGS}"
|
||||
)
|
||||
|
||||
ASAN_CMAKE_OPTIONS=(
|
||||
-DSOURCEKIT_USE_INPROC_LIBRARY="ON"
|
||||
-DSWIFT_ASAN_BUILD="ON"
|
||||
)
|
||||
|
||||
# Build each one. Note: in this block, names beginning with underscore
|
||||
# are used indirectly to access product-specific variables.
|
||||
for product in "${SWIFT_BUILD_PRODUCTS[@]}" ; do
|
||||
PRODUCT=$(toupper "${product}")
|
||||
|
||||
_SKIP_BUILD_PRODUCT=SKIP_BUILD_${PRODUCT}
|
||||
if [[ ! "${!_SKIP_BUILD_PRODUCT}" ]]; then
|
||||
|
||||
echo "--- Building ${product} ---"
|
||||
_PRODUCT_SOURCE_DIR=${PRODUCT}_SOURCE_DIR
|
||||
_PRODUCT_BUILD_DIR=${PRODUCT}_BUILD_DIR
|
||||
|
||||
# Clean product-local module cache.
|
||||
swift_module_cache="${!_PRODUCT_BUILD_DIR}/swift-module-cache"
|
||||
rm -rf "${swift_module_cache}"
|
||||
mkdir -p "${swift_module_cache}"
|
||||
|
||||
# Configure if necessary.
|
||||
if [[ "${RECONFIGURE}" || ! -f "${!_PRODUCT_BUILD_DIR}/CMakeCache.txt" ]] ; then
|
||||
mkdir -p "${!_PRODUCT_BUILD_DIR}"
|
||||
|
||||
_PRODUCT_CMAKE_OPTIONS=${PRODUCT}_CMAKE_OPTIONS[@]
|
||||
if [[ "${RUN_WITH_ASAN_COMPILER}" ]]; then
|
||||
_ASAN_OPTIONS=ASAN_CMAKE_OPTIONS[@]
|
||||
fi
|
||||
|
||||
case "${PRODUCT}" in
|
||||
SWIFT_STDLIB*) var_prefix="SWIFT" ;;
|
||||
*) var_prefix=${PRODUCT} ;;
|
||||
esac
|
||||
|
||||
set -x
|
||||
(cd "${!_PRODUCT_BUILD_DIR}" &&
|
||||
"$CMAKE" -G "${CMAKE_GENERATOR}" "${COMMON_CMAKE_OPTIONS[@]}" \
|
||||
"${!_PRODUCT_CMAKE_OPTIONS}" \
|
||||
"${!_ASAN_OPTIONS}" \
|
||||
-DSWIFT_MODULE_CACHE_PATH="${swift_module_cache}" \
|
||||
-DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \
|
||||
-D${var_prefix}_PATH_TO_CLANG_SOURCE="${CLANG_SOURCE_DIR}" \
|
||||
-D${var_prefix}_PATH_TO_CLANG_BUILD="${CLANG_BUILD_DIR}" \
|
||||
-D${var_prefix}_PATH_TO_LLVM_SOURCE="${LLVM_SOURCE_DIR}" \
|
||||
-D${var_prefix}_PATH_TO_LLVM_BUILD="${LLVM_BUILD_DIR}" \
|
||||
${CONFIG_ARGS} \
|
||||
"${!_PRODUCT_SOURCE_DIR}" || exit 1)
|
||||
{ set +x; } 2>/dev/null
|
||||
fi
|
||||
|
||||
# Build.
|
||||
set -x
|
||||
$DISTCC_PUMP "$CMAKE" --build "${!_PRODUCT_BUILD_DIR}" -- ${BUILD_ARGS}
|
||||
{ set +x; } 2>/dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
# Trap function to print the current test configuration when tests fail.
|
||||
# This is a function so the text is not unnecessarily displayed when running -x.
|
||||
tests_busted ()
|
||||
{
|
||||
echo "*** Failed while running tests for $1"
|
||||
}
|
||||
|
||||
# Run the tests for each product
|
||||
for product in "${SWIFT_TEST_PRODUCTS[@]}" ; do
|
||||
PRODUCT=$(toupper "${product}")
|
||||
|
||||
_SKIP_TEST_PRODUCT=SKIP_TEST_${PRODUCT}
|
||||
if [[ ! "${!_SKIP_TEST_PRODUCT}" ]]; then
|
||||
|
||||
echo "--- Running tests for ${product} ---"
|
||||
trap "tests_busted ${product}" ERR
|
||||
_PRODUCT_SOURCE_DIR=${PRODUCT}_SOURCE_DIR
|
||||
_PRODUCT_BUILD_DIR=${PRODUCT}_BUILD_DIR
|
||||
|
||||
build_cmd=("$CMAKE" --build "${!_PRODUCT_BUILD_DIR}" -- ${BUILD_ARGS})
|
||||
|
||||
if [[ "${product}" == SourceKit ]] ; then
|
||||
test_target=SourceKitUnitTests
|
||||
else
|
||||
test_target=SwiftUnitTests
|
||||
fi
|
||||
|
||||
set -x
|
||||
$DISTCC_PUMP "${build_cmd[@]}" ${BUILD_TARGET_FLAG} "${test_target}"
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
if [[ "${product}" == SourceKit ]] ; then
|
||||
test_target=check-${product}
|
||||
if [[ "$STRESS_TEST_SOURCEKIT" ]]; then
|
||||
test_target="${test_target} stress-SourceKit"
|
||||
fi
|
||||
else
|
||||
test_target=check-${product}-all
|
||||
if [[ "$SKIP_TEST_VALIDATION" ]]; then
|
||||
test_target=check-${product}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${CMAKE_GENERATOR}" == Ninja ]] ; then
|
||||
# Ninja buffers command output to avoid scrambling the output
|
||||
# of parallel jobs, which is awesome... except that it
|
||||
# interferes with the progress meter when testing. Instead of
|
||||
# executing ninja directly, have it dump the commands it would
|
||||
# run, strip Ninja's progress prefix with sed, and tell the
|
||||
# shell to execute that.
|
||||
sh -c "set -x && $("${build_cmd[@]}" -n -v ${test_target} | sed -e 's/[^]]*] //')"
|
||||
else
|
||||
set -x
|
||||
"${build_cmd[@]}" ${BUILD_TARGET_FLAG} ${test_target}
|
||||
{ set +x; } 2>/dev/null
|
||||
fi
|
||||
|
||||
trap - ERR
|
||||
echo "--- Finished tests for ${product} ---"
|
||||
fi
|
||||
done
|
||||
|
||||
# Run the Swift performance tests.
|
||||
if [ \! "$SKIP_TEST_SWIFT_PERFORMANCE" ]; then
|
||||
# Currently we use the toolchain-specific Clang as our CC under test, because
|
||||
# our locally built one might not end up invoking an LD that supports
|
||||
# autolinking on older machines. We can reconsider this when it becomes useful
|
||||
# to have the C/C++ tests be running using the same LLVM basis as the Swift we
|
||||
# are testing.
|
||||
echo "--- Running Swift Performance Tests ---"
|
||||
export CLANG="$TOOLCHAIN/usr/bin/clang"
|
||||
export SWIFT="${SWIFT_BUILD_DIR}/bin/swift"
|
||||
set -x
|
||||
if (cd "${SWIFT_BUILD_DIR}" &&
|
||||
"${LLVM_BUILD_DIR}/bin/llvm-lit" -v benchmark \
|
||||
-j1 --output benchmark/results.json); then
|
||||
PERFORMANCE_TESTS_PASSED=1
|
||||
else
|
||||
PERFORMANCE_TESTS_PASSED=0
|
||||
fi
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
echo "--- Submitting Swift Performance Tests ---"
|
||||
swift_source_revision="$("${LLVM_SOURCE_DIR}/utils/GetSourceVersion" "${SWIFT_SOURCE_DIR}")"
|
||||
set -x
|
||||
(cd "${SWIFT_BUILD_DIR}" &&
|
||||
"${SWIFT_SOURCE_DIR}/utils/submit-benchmark-results" benchmark/results.json \
|
||||
--output benchmark/lnt_results.json \
|
||||
--machine-name "matte.apple.com--${BUILD_TYPE}--x86_64--O3" \
|
||||
--run-order "$swift_source_revision" \
|
||||
--submit http://localhost:32169/submitRun) \
|
||||
|| echo "*** Swift performance test results not submitted."
|
||||
{ set +x; } 2>/dev/null
|
||||
|
||||
# If the performance tests failed, fail the build.
|
||||
if [ "$PERFORMANCE_TESTS_PASSED" -ne 1 ]; then
|
||||
echo "*** ERROR: Swift Performance Tests failed ***"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
add_swift_library(LeaksDetector SHARED
|
||||
leaksDetector.c)
|
||||
|
||||
if (APPLE)
|
||||
set(SHARED_LIBRARY YES)
|
||||
add_swift_library(LeaksDetector leaksDetector.c)
|
||||
get_property(LEAKS_DETECTOR_LIBRARY_PATH TARGET LeaksDetector PROPERTY LOCATION)
|
||||
swift_get_configuration_types(configs)
|
||||
foreach(config ${configs})
|
||||
set(LEAKS_DETECTOR_LIBRARY_PATH
|
||||
"${CMAKE_BINARY_DIR}/${config}/lib/libLeaksDetector${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/leaks-runner.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/leaks-runner
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/leaks-runner.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${config}/leaks-runner"
|
||||
@ONLY
|
||||
NEWLINE_STYLE UNIX)
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/leaks-runner
|
||||
DESTINATION ${CMAKE_BINARY_DIR}/bin
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
||||
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
endif()
|
||||
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/${config}/leaks-runner"
|
||||
DESTINATION "${CMAKE_BINARY_DIR}/${config}/bin"
|
||||
FILE_PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE)
|
||||
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# This is a wrapper for running the leaks detector tool on a binary.
|
||||
|
||||
LEAKS_DETECTOR_LIBRARY_PATH=@LEAKS_DETECTOR_LIBRARY_PATH@
|
||||
#
|
||||
|
||||
set -e
|
||||
DYLD_INSERT_LIBRARIES=$LEAKS_DETECTOR_LIBRARY_PATH $@
|
||||
set +e
|
||||
DYLD_INSERT_LIBRARIES="@LEAKS_DETECTOR_LIBRARY_PATH@" "$@"
|
||||
|
||||
|
||||
@@ -1,31 +1,22 @@
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
# Xcode support. See the CMakeLists.txt for the SwiftLLVMPasses library.
|
||||
|
||||
set(OPT ${PATH_TO_LLVM_BUILD}/${config}/bin/opt)
|
||||
|
||||
string(TOUPPER ${config} config_upper)
|
||||
get_property(SWIFT_LLVM_DYLIB
|
||||
TARGET SwiftLLVMPasses
|
||||
PROPERTY "LOCATION_${config_upper}")
|
||||
|
||||
# Note: this won't work if the EFFECTIVE_PLATFORM_NAME isn't empty.
|
||||
# Currently it always is on OS X.
|
||||
string(REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "" SWIFT_LLVM_DYLIB
|
||||
"${SWIFT_LLVM_DYLIB}")
|
||||
|
||||
swift_get_configuration_types(configs)
|
||||
foreach(config ${configs})
|
||||
set(OPT "${PATH_TO_LLVM_BUILD}/${config}/bin/opt")
|
||||
set(SWIFT_LLVM_DYLIB
|
||||
"${CMAKE_BINARY_DIR}/${config}/lib/SwiftLLVMPasses${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/llvm-opt.in
|
||||
${CMAKE_BINARY_DIR}/${config}/bin/llvm-opt
|
||||
@ONLY)
|
||||
endforeach()
|
||||
else()
|
||||
set(OPT ${PATH_TO_LLVM_BUILD}/bin/opt)
|
||||
get_property(SWIFT_LLVM_DYLIB
|
||||
TARGET SwiftLLVMPasses
|
||||
PROPERTY LOCATION)
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/llvm-opt.in
|
||||
${CMAKE_BINARY_DIR}/${config}/bin/llvm-opt
|
||||
@ONLY)
|
||||
endif()
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/llvm-opt.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${config}/llvm-opt"
|
||||
@ONLY
|
||||
NEWLINE_STYLE UNIX)
|
||||
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/${config}/llvm-opt"
|
||||
DESTINATION "${CMAKE_BINARY_DIR}/${config}/bin"
|
||||
FILE_PERMISSIONS
|
||||
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE
|
||||
WORLD_READ WORLD_EXECUTE)
|
||||
endforeach()
|
||||
|
||||
swift_install_in_component(testsuite-tools
|
||||
FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/llvm-opt"
|
||||
DESTINATION "bin")
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# This is a wrapper around llvm's opt command line tool that automatically
|
||||
# performs the necessary work to access swift's llvm passes.
|
||||
#
|
||||
|
||||
set -e
|
||||
"@OPT@" -load "@SWIFT_LLVM_DYLIB@" "$@"
|
||||
|
||||
"@OPT@" -load "@SWIFT_LLVM_DYLIB@" $@
|
||||
|
||||
@@ -61,7 +61,7 @@ def getWorkTreeSha():
|
||||
def buildBenchmarks(cacheDir):
|
||||
print('Building executables...')
|
||||
|
||||
configVars = {'SWIFT_INCLUDE_BENCHMARKS':'ON', 'SWIFT_INCLUDE_PERF_TESTSUITE':'ON', 'SWIFT_OPTIMIZED':'ON', 'SWIFT_STDLIB_INTERNAL_CHECKS':'OFF'}
|
||||
configVars = {'SWIFT_INCLUDE_BENCHMARKS':'TRUE', 'SWIFT_INCLUDE_PERF_TESTSUITE':'TRUE', 'SWIFT_STDLIB_BUILD_TYPE':'RelWithDebInfo', 'SWIFT_STDLIB_ASSERTIONS':'FALSE'}
|
||||
|
||||
cmakeCache = os.path.join(buildDir, 'CMakeCache.txt')
|
||||
|
||||
|
||||
116
utils/update-checkout
Executable file
116
utils/update-checkout
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/python
|
||||
#===--- update-checkout - Utility to update your local checkouts -----------===#
|
||||
#
|
||||
# This source file is part of the Swift.org open source project
|
||||
#
|
||||
# Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
|
||||
# Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
#
|
||||
# See http://swift.org/LICENSE.txt for license information
|
||||
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
#
|
||||
#===------------------------------------------------------------------------===#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import string
|
||||
import sys
|
||||
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
from SwiftBuildSupport import *
|
||||
|
||||
|
||||
def usage():
|
||||
print("""
|
||||
Usage:
|
||||
update-checkout [options]
|
||||
|
||||
source repositories.
|
||||
|
||||
By default, updates your checkouts of Swift, SourceKit and LLDB.
|
||||
|
||||
Options:
|
||||
|
||||
-a, --all update your checkouts of LLVM, Clang and Swift,
|
||||
SourceKit and LLDB
|
||||
""")
|
||||
|
||||
|
||||
class WorkingDirectory(object):
|
||||
def __init__(self, new_cwd):
|
||||
self.new_cwd = new_cwd
|
||||
|
||||
def __enter__(self):
|
||||
self.old_cwd = os.getcwd()
|
||||
os.chdir(self.new_cwd)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
os.chdir(self.old_cwd)
|
||||
|
||||
|
||||
def update_git_svn(repo_path):
|
||||
with WorkingDirectory(repo_path):
|
||||
use_stash = (check_output([ "git", "status", "--porcelain" ]) != "")
|
||||
if use_stash:
|
||||
check_call([ "git", "stash", "save", "--all"])
|
||||
|
||||
# Try first to pull from an upstream Git repo, assuming there is one
|
||||
if check_output([ "git", "remote" ]) != "":
|
||||
check_call([ "git", "pull", "--rebase" ])
|
||||
check_call([ "git", "svn", "rebase", "-l" ])
|
||||
else:
|
||||
check_call([ "git", "svn", "rebase" ])
|
||||
|
||||
if use_stash:
|
||||
check_call([ "git", "stash", "pop" ])
|
||||
|
||||
|
||||
def update_working_copy(repo_path):
|
||||
if not os.path.isdir(repo_path):
|
||||
return
|
||||
|
||||
with WorkingDirectory(repo_path):
|
||||
if os.path.isdir(os.path.join(".git", "svn")):
|
||||
update_git_svn(repo_path)
|
||||
elif os.path.isdir(".git"):
|
||||
check_call([ "git", "pull" ])
|
||||
else:
|
||||
check_call([ "svn", "update" ])
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "a",
|
||||
[ "all" ])
|
||||
except getopt.GetoptError as err:
|
||||
bad_usage(str(err))
|
||||
|
||||
opt_update_all = False
|
||||
|
||||
for o, a in opts:
|
||||
if o == "--all":
|
||||
opt_update_all = True
|
||||
else:
|
||||
assert False, "unhandled option " + o
|
||||
|
||||
if args != []:
|
||||
bad_usage("extra arguments: " + args)
|
||||
|
||||
if opt_update_all:
|
||||
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "llvm"))
|
||||
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "clang"))
|
||||
|
||||
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "swift"))
|
||||
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "SourceKit"))
|
||||
update_working_copy(os.path.join(SWIFT_SOURCE_ROOT, "lldb"))
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
install(
|
||||
swift_install_in_component(editor-integration
|
||||
DIRECTORY
|
||||
ftdetect
|
||||
syntax
|
||||
DESTINATION share/vim/vim73
|
||||
DESTINATION "share/vim/vim73"
|
||||
PATTERN ".*" EXCLUDE)
|
||||
|
||||
|
||||
@@ -25,18 +25,20 @@ except KeyError:
|
||||
key, = e.args
|
||||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
|
||||
|
||||
if "@SWIFT_ASAN_BUILD@" != "OFF" and "@SWIFT_ASAN_BUILD@" != "NO":
|
||||
if "@SWIFT_ASAN_BUILD@" == "TRUE":
|
||||
config.available_features.add("asan")
|
||||
|
||||
if "@LLVM_ENABLE_ASSERTIONS@" == "TRUE" or "@LLVM_ENABLE_ASSERTIONS@" == "ON":
|
||||
if "@LLVM_ENABLE_ASSERTIONS@" == "TRUE":
|
||||
config.available_features.add('asserts')
|
||||
else:
|
||||
config.available_features.add('no_asserts')
|
||||
|
||||
if "@SWIFT_STDLIB_INTERNAL_CHECKS@" != "OFF" and "@SWIFT_STDLIB_INTERNAL_CHECKS@" != "NO":
|
||||
if "@SWIFT_STDLIB_ASSERTIONS@" == "TRUE":
|
||||
config.available_features.add('swift_stdlib_asserts')
|
||||
else:
|
||||
config.available_features.add('swift_stdlib_no_asserts')
|
||||
|
||||
if "@SWIFT_OPTIMIZED@" == "ON" or "@SWIFT_OPTIMIZED@" == "YES":
|
||||
if "@SWIFT_OPTIMIZED@" == "TRUE":
|
||||
config.available_features.add("optimized_stdlib")
|
||||
|
||||
# Let the main config do the real work.
|
||||
|
||||
Reference in New Issue
Block a user