[build-script] Remove Xcode generation support

This was quite brittle and has now been superseded
by swift-xcodegen. Remove the CMake/build-script
logic for it, leaving the option behind to inform
users to switch to using xcodegen instead.
This commit is contained in:
Hamish Knight
2025-02-12 10:28:15 +00:00
parent 7a7e6c2830
commit d260bd8ddb
21 changed files with 39 additions and 511 deletions

View File

@@ -1023,11 +1023,6 @@ set(SWIFT_GYB_FLAGS
set(SWIFT_MODULE_CACHE_PATH
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/module-cache")
# Xcode: use libc++ and c++11 using proper build settings.
if(XCODE)
swift_common_xcode_cxx_config()
endif()
# Check what linux distribution is being used.
# This can be used to determine the default linker to use.
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22")

View File

@@ -1,6 +1,5 @@
include(macCatalystUtils)
include(SwiftList)
include(SwiftXcodeSupport)
include(SwiftWindowsSupport)
include(SwiftAndroidSupport)
include(SwiftCXXUtils)
@@ -689,24 +688,6 @@ function(add_swift_host_library name)
list(APPEND ASHL_LLVM_LINK_COMPONENTS "demangle")
endif()
if(XCODE)
get_filename_component(base_dir ${CMAKE_CURRENT_SOURCE_DIR} NAME)
file(GLOB_RECURSE ASHL_HEADERS
${SWIFT_SOURCE_DIR}/include/swift/${base_dir}/*.h
${SWIFT_SOURCE_DIR}/include/swift/${base_dir}/*.def
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*.def)
file(GLOB_RECURSE ASHL_TDS
${SWIFT_SOURCE_DIR}/include/swift${base_dir}/*.td)
set_source_files_properties(${ASHL_HEADERS} ${ASHL_TDS} PROPERTIES
HEADER_FILE_ONLY true)
source_group("TableGen descriptions" FILES ${ASHL_TDS})
set(ASHL_SOURCES ${ASHL_SOURCES} ${ASHL_HEADERS} ${ASHL_TDS})
endif()
if(ASHL_SHARED)
set(libkind SHARED)
elseif(ASHL_STATIC)

View File

@@ -1,5 +1,4 @@
include(CMakeParseArguments)
include(SwiftXcodeSupport)
include(CheckCXXCompilerFlag)
@@ -39,13 +38,8 @@ macro(swift_common_standalone_build_config_llvm product)
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
precondition(LLVM_TOOLS_BINARY_DIR)
escape_path_for_xcode("${LLVM_BUILD_TYPE}" "${LLVM_TOOLS_BINARY_DIR}" LLVM_TOOLS_BINARY_DIR)
precondition_translate_flag(LLVM_BUILD_LIBRARY_DIR LLVM_LIBRARY_DIR)
escape_path_for_xcode("${LLVM_BUILD_TYPE}" "${LLVM_LIBRARY_DIR}" LLVM_LIBRARY_DIR)
precondition(LLVM_LIBRARY_DIRS)
escape_path_for_xcode("${LLVM_BUILD_TYPE}" "${LLVM_LIBRARY_DIRS}" LLVM_LIBRARY_DIRS)
# This could be computed using ${CMAKE_CFG_INTDIR} if we want to link Swift
# against a matching LLVM build configuration. However, we usually want to be
@@ -54,10 +48,6 @@ macro(swift_common_standalone_build_config_llvm product)
set(LLVM_BINARY_OUTPUT_INTDIR "${LLVM_TOOLS_BINARY_DIR}")
set(LLVM_LIBRARY_OUTPUT_INTDIR "${LLVM_LIBRARY_DIR}")
if(XCODE)
fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS}")
endif()
if(NOT CMAKE_CROSSCOMPILING)
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
endif()
@@ -175,7 +165,6 @@ macro(swift_common_standalone_build_config_llvm product)
"Version number that will be placed into the libclang library , in the form XX.YY")
foreach(INCLUDE_DIR ${LLVM_INCLUDE_DIRS})
escape_path_for_xcode("${LLVM_BUILD_TYPE}" "${INCLUDE_DIR}" INCLUDE_DIR)
include_directories(${INCLUDE_DIR})
endforeach ()
@@ -184,9 +173,6 @@ macro(swift_common_standalone_build_config_llvm product)
link_directories("${LLVM_LIBRARY_DIR}")
set(LIT_ARGS_DEFAULT "-sv")
if(XCODE)
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
endif()
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
@@ -209,10 +195,6 @@ macro(swift_common_standalone_build_config_clang product)
set(${product}_NATIVE_CLANG_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
endif()
if(XCODE)
fix_imported_targets_for_xcode("${CLANG_EXPORTED_TARGETS}")
endif()
include_directories(${CLANG_INCLUDE_DIRS})
endmacro()

View File

@@ -1,134 +0,0 @@
# This file contains cmake configuration specifically related to support for the
# Xcode generator in CMake.
function(escape_path_for_xcode config path result_var_name)
# If we are not using the Xcode generator, be defensive and early exit.
if (NOT XCODE)
set(${result_var_name} "${path}" PARENT_SCOPE)
return()
endif()
# 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()
function(check_imported_target_has_imported_configuration target config)
get_target_property(IMPORTED_CONFIGS_LIST ${target} IMPORTED_CONFIGURATIONS)
if ("${IMPORTED_CONFIGS_LIST}" STREQUAL "IMPORTED_CONFIGS_LIST-NOTFOUND")
message(FATAL_ERROR "No import configuration of ${target} specified?!")
endif()
if(NOT "${config}" IN_LIST IMPORTED_CONFIGS_LIST)
message(FATAL_ERROR "${target} does not have imported config '${config}'?! Instead: ${IMPORTED_CONFIGS_LIST}")
endif()
endfunction()
function(fixup_imported_target_property_for_xcode target property llvm_build_type)
set(FULL_PROP_NAME "${property}_${llvm_build_type}")
# First try to lookup the value associated with the "real build type".
get_target_property(PROP_VALUE ${target} ${FULL_PROP_NAME})
# If the property is unspecified, return.
if ("${PROP_VALUE}" STREQUAL "PROP_VALUE-NOTFOUND")
return()
endif()
# Otherwise for each cmake configuration that is not real_build_type, hardcode
# its value to be PROP_VALUE.
foreach(build_type ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_type}" build_type_upper)
if ("${build_type_upper}" STREQUAL "${llvm_build_type}")
continue()
endif()
set(SWIFT_BUILD_PROPERTY_NAME "${property}_${build_type_upper}")
set_target_properties(${target} PROPERTIES "${SWIFT_BUILD_PROPERTY_NAME}" "${PROP_VALUE}")
endforeach()
endfunction()
# When building with Xcode, we only support compiling against the LLVM
# configuration that was specified by build-script. This becomes a problem since
# if we compile LLVM-Release and Swift-Debug, Swift is going to look in the
# Debug, not the Release folder for LLVM's code and thus will be compiling
# against an unintended set of libraries, if those libraries exist at all.
#
# Luckily, via LLVMConfig.cmake, we know the configuration that LLVM was
# compiled in, so we can grab the imported location for that configuration and
# splat it across the other configurations as well.
function(fix_imported_targets_for_xcode imported_targets)
string(TOUPPER "${LLVM_BUILD_TYPE}" LLVM_BUILD_TYPE_UPPER)
# This is the set of configuration specific cmake properties that are
# supported for imported targets in cmake 3.4.3. Sadly, beyond hacks, it seems
# that there is no way to dynamically query the list of set properties of a
# target.
#
# *NOTE* In fixup_imported_target_property_for_xcode, we add the _${CONFIG}
# *suffix.
set(imported_target_properties
IMPORTED_IMPLIB
IMPORTED_LINK_DEPENDENT_LIBRARIES
IMPORTED_LINK_INTERFACE_LANGUAGES
IMPORTED_LINK_INTERFACE_LIBRARIES
IMPORTED_LINK_INTERFACE_MULTIPLICITY
IMPORTED_LOCATION
IMPORTED_NO_SONAME
IMPORTED_SONAME)
foreach(target ${imported_targets})
if (NOT TARGET ${target})
message(FATAL_ERROR "${target} is not a target?!")
endif()
# First check that we actually imported the configuration that LLVM said
# that we did. This is just a soundness check.
check_imported_target_has_imported_configuration(${target} ${LLVM_BUILD_TYPE_UPPER})
# Then loop through all of the imported properties and translate.
foreach(property ${imported_target_properties})
fixup_imported_target_property_for_xcode(
${target} ${property} ${LLVM_BUILD_TYPE_UPPER})
endforeach()
endforeach()
endfunction()
# Common additional cmake project config for Xcode.
macro(swift_common_xcode_cxx_config)
# Force usage of Clang.
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0"
CACHE STRING "Xcode Compiler")
# Use C++'14.
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14"
CACHE STRING "Xcode C++ Language Standard")
# Use libc++.
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++"
CACHE STRING "Xcode C++ Standard Library")
# Enable some warnings not enabled by default. These
# mostly reset clang back to its default settings, since
# Xcode passes -Wno... for many warnings that are not enabled
# by default.
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_RETURN_TYPE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_ABOUT_MISSING_NEWLINE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VALUE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_VARIABLE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_SIGN_COMPARE "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNUSED_FUNCTION "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_UNINITIALIZED_AUTOS "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DOCUMENTATION_COMMENTS "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_BOOL_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_EMPTY_BODY "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_ENUM_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_INT_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_CONSTANT_CONVERSION "YES")
set(CMAKE_XCODE_ATTRIBUTE_GCC_WARN_NON_VIRTUAL_DESTRUCTOR "YES")
# Disable RTTI
set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_RTTI "NO")
# Disable exceptions
set(CMAKE_XCODE_ATTRIBUTE_GCC_ENABLE_CPP_EXCEPTIONS "NO")
endmacro()

View File

@@ -926,25 +926,6 @@ function(add_swift_target_library_single target name)
endif()
endif()
if(XCODE)
string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
list(GET split_path -1 dir)
file(GLOB_RECURSE SWIFTLIB_SINGLE_HEADERS
${SWIFT_SOURCE_DIR}/include/swift${dir}/*.h
${SWIFT_SOURCE_DIR}/include/swift${dir}/*.def
${CMAKE_CURRENT_SOURCE_DIR}/*.def)
file(GLOB_RECURSE SWIFTLIB_SINGLE_TDS
${SWIFT_SOURCE_DIR}/include/swift${dir}/*.td)
set_source_files_properties(${SWIFTLIB_SINGLE_HEADERS} ${SWIFTLIB_SINGLE_TDS}
PROPERTIES
HEADER_FILE_ONLY true)
source_group("TableGen descriptions" FILES ${SWIFTLIB_SINGLE_TDS})
set(SWIFTLIB_SINGLE_SOURCES ${SWIFTLIB_SINGLE_SOURCES} ${SWIFTLIB_SINGLE_HEADERS} ${SWIFTLIB_SINGLE_TDS})
endif()
# FIXME: swiftDarwin currently trips an assertion in SymbolGraphGen
if (SWIFTLIB_IS_STDLIB AND SWIFT_STDLIB_BUILD_SYMBOL_GRAPHS AND NOT ${name} STREQUAL "swiftDarwin")
list(APPEND SWIFTLIB_SINGLE_SWIFT_COMPILE_FLAGS "-Xfrontend;-emit-symbol-graph")
@@ -1122,14 +1103,6 @@ function(add_swift_target_library_single target name)
$<TARGET_OBJECTS:${object_library}${VARIANT_SUFFIX}>)
endforeach()
set(SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES)
if(XCODE)
set(SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES
# Note: the dummy.cpp source file provides no definitions. However,
# it forces Xcode to properly link the static library.
${SWIFT_SOURCE_DIR}/cmake/dummy.cpp)
endif()
set(INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS ${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS})
if(libkind STREQUAL "SHARED")
list(APPEND INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS
@@ -1148,8 +1121,7 @@ function(add_swift_target_library_single target name)
add_library("${target}" ${libkind}
${SWIFTLIB_SINGLE_SOURCES}
${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}
${INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES})
${INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS})
if (NOT SWIFTLIB_SINGLE_OBJECT_LIBRARY AND TARGET "${install_in_component}")
add_dependencies("${install_in_component}" "${target}")
endif()
@@ -1249,10 +1221,9 @@ function(add_swift_target_library_single target name)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config_upper)
escape_path_for_xcode("${config}" "${swiftlib_prefix}" config_lib_dir)
set_target_properties(${target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${output_sub_dir}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${output_sub_dir})
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${swiftlib_prefix}/${output_sub_dir}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${swiftlib_prefix}/${output_sub_dir})
endforeach()
if(SWIFTLIB_SINGLE_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
@@ -1331,8 +1302,7 @@ function(add_swift_target_library_single target name)
# library.
add_library(${target_static} STATIC
${SWIFTLIB_SINGLE_SOURCES}
${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS}
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES})
${SWIFTLIB_INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS})
set_output_directory(${target_static}
BINARY_DIR ${out_bin_dir}
@@ -1346,11 +1316,9 @@ function(add_swift_target_library_single target name)
foreach(config ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${config} config_upper)
escape_path_for_xcode(
"${config}" "${swift_lib_dir}" config_lib_dir)
set_target_properties(${target_static} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${output_sub_dir}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${config_lib_dir}/${output_sub_dir})
LIBRARY_OUTPUT_DIRECTORY_${config_upper} ${swift_lib_dir}/${output_sub_dir}
ARCHIVE_OUTPUT_DIRECTORY_${config_upper} ${swift_lib_dir}/${output_sub_dir})
endforeach()
set_target_properties(${target_static} PROPERTIES

View File

@@ -986,37 +986,6 @@ function(_compile_swift_files
# over '-I' in this case.
endif()
if(XCODE)
# HACK: work around an issue with CMake Xcode generator and the Swift
# driver.
#
# The Swift driver does not update the mtime of the output files if the
# existing output files on disk are identical to the ones that are about
# to be written. This behavior confuses the makefiles used in CMake Xcode
# projects: the makefiles will not consider everything up to date after
# invoking the compiler. As a result, the standard library gets rebuilt
# multiple times during a single build.
#
# To work around this issue we touch the output files so that their mtime
# always gets updated.
set(command_touch_standard_outputs
COMMAND "${CMAKE_COMMAND}" -E touch ${standard_outputs})
set(command_touch_module_outputs
COMMAND "${CMAKE_COMMAND}" -E touch ${module_outputs})
set(command_touch_sib_outputs
COMMAND "${CMAKE_COMMAND}" -E touch ${sib_outputs})
set(command_touch_sibopt_outputs
COMMAND "${CMAKE_COMMAND}" -E touch ${sibopt_outputs})
set(command_touch_sibgen_outputs
COMMAND "${CMAKE_COMMAND}" -E touch ${sibgen_outputs})
# macCatalyst zippered outputs
if(maccatalyst_build_flavor STREQUAL "zippered")
set(command_touch_maccatalyst_module_outputs
COMMAND "${CMAKE_COMMAND}" -E touch ${maccatalyst_module_outputs})
endif()
endif()
list(REMOVE_DUPLICATES dirs_to_create)
# Then we can compile both the object files and the swiftmodule files

View File

@@ -121,13 +121,6 @@ if "@SWIFT_ENABLE_REFLECTION@" == "TRUE":
if "@SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS@" == "TRUE":
config.available_features.add('runtime_function_counters')
if "@CMAKE_GENERATOR@" == "Xcode":
xcode_bin_dir = os.path.join(config.llvm_obj_root, "@LLVM_BUILD_TYPE@",
'bin')
lit_config.note('Adding to path: ' + xcode_bin_dir)
config.environment['PATH'] = \
os.path.pathsep.join((xcode_bin_dir, config.environment['PATH']))
config.available_features.add("CMAKE_GENERATOR=@CMAKE_GENERATOR@")
if "@SWIFT_ENABLE_MACCATALYST@" == "TRUE":

View File

@@ -212,7 +212,7 @@ macro(add_sourcekit_library name)
set(srcs ${SOURCEKITLIB_UNPARSED_ARGUMENTS})
llvm_process_sources(srcs ${srcs})
if(MSVC_IDE OR XCODE)
if(MSVC_IDE)
# Add public headers
file(RELATIVE_PATH lib_path
${SOURCEKIT_SOURCE_DIR}/lib/
@@ -406,9 +406,9 @@ macro(add_sourcekit_framework name)
endif()
endforeach()
if(MSVC_IDE OR XCODE)
if(MSVC_IDE)
set_source_files_properties(${headers} PROPERTIES HEADER_FILE_ONLY ON)
endif(MSVC_IDE OR XCODE)
endif(MSVC_IDE)
if(LLVM_COMMON_DEPENDS)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})

View File

@@ -231,6 +231,15 @@ def validate_arguments(toolchain, args):
fatal_error(
"can't find sccache (please install sccache)")
# Xcode project generation is no longer supported.
if args.cmake_generator == "Xcode":
fatal_error(
"build-script no longer supports Xcode project generation, you "
"should use utils/generate-xcode instead, see "
"https://github.com/swiftlang/swift/blob/main/docs/HowToGuides/"
"GettingStarted.md#using-ninja-with-xcode for more info"
)
if args.host_target is None or args.stdlib_deployment_targets is None:
fatal_error("unknown operating system")
@@ -324,8 +333,8 @@ def apply_default_arguments(toolchain, args):
if ninja_required and toolchain.ninja is None:
args.build_ninja = True
# Enable test colors if we're on a tty and aren't generating for Xcode.
if args.color_in_tests and sys.stdout.isatty() and args.cmake_generator != "Xcode":
# Enable test colors if we're on a tty.
if args.color_in_tests and sys.stdout.isatty():
args.lit_args += " --param color_output"
# Set the default stdlib-deployment-targets, if none were provided.
@@ -786,17 +795,6 @@ def main_normal():
tar(source=prefix.lstrip('/'),
destination=args.symbols_package)
if args.cmake_generator == "Xcode":
print_warning(
"The Xcode projects generated with '--xcode' can be used for "
"navigation or editing purposes, but are not a recommended means "
"to building, running or debugging. For a full-fledged Xcode "
"workflow using these generated projects, see "
"https://github.com/swiftlang/swift/blob/main/docs/HowToGuides/"
"GettingStarted.md#using-ninja-with-xcode"
)
print()
return 0

View File

@@ -1021,12 +1021,6 @@ if [[ "${CHECK_ARGS_ONLY}" ]]; then
exit 0
fi
# FIXME: We currently do not support building compiler-rt with the
# Xcode generator.
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]]; then
SKIP_BUILD_COMPILER_RT=1
fi
if [[ "${SKIP_RECONFIGURE}" ]]; then
RECONFIGURE=""
fi
@@ -1295,10 +1289,6 @@ eval BUILD_ARGS=(${BUILD_ARGS})
eval CMAKE_BUILD=("${DISTCC_PUMP}" "${CMAKE}" "--build")
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]]; then
BUILD_TARGET_FLAG="-target"
fi
function build_directory() {
host=$1
product=$2
@@ -1309,40 +1299,7 @@ function build_directory_bin() {
host=$1
product=$2
root="$(build_directory ${host} ${product})"
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
case ${product} in
llvm)
echo "${root}/${LLVM_BUILD_TYPE}/bin"
;;
libcxx)
# Reuse LLVM's build type.
echo "${root}/${LLVM_BUILD_TYPE}/bin"
;;
swift)
echo "${root}/${SWIFT_BUILD_TYPE}/bin"
;;
lldb)
;;
llbuild)
echo "${root}/${LLBUILD_BUILD_TYPE}/bin"
;;
xctest)
echo "${root}/${XCTEST_BUILD_TYPE}/bin"
;;
foundation|foundation_static|foundation_macros)
echo "${root}/${FOUNDATION_BUILD_TYPE}/bin"
;;
libdispatch|libdispatch_static)
echo "${root}/${LIBDISPATCH_BUILD_TYPE}/bin"
;;
*)
echo "error: unknown product: ${product}"
exit 1
;;
esac
else
echo "${root}/bin"
fi
echo "${root}/bin"
}
function is_cmake_release_build_type() {
@@ -1449,41 +1406,6 @@ function common_swift_flags() {
echo -n "${SWIFT_FLAGS[@]} ${COMMON_SWIFT_FLAGS} -module-cache-path \"${module_cache}\" "
}
function cmake_config_opt() {
product=$1
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
# CMake automatically adds --target ALL_BUILD if we don't pass this.
echo "--target ZERO_CHECK "
case ${product} in
libcxx)
# Reuse LLVM's build type.
echo "--config ${LLVM_BUILD_TYPE}"
;;
swift)
echo "--config ${SWIFT_BUILD_TYPE}"
;;
lldb)
;;
llbuild)
echo "--config ${LLBUILD_BUILD_TYPE}"
;;
xctest)
echo "--config ${XCTEST_BUILD_TYPE}"
;;
foundation|foundation_static|foundation_macros)
echo "--config ${FOUNDATION_BUILD_TYPE}"
;;
libdispatch|libdispatch_static)
echo "--config ${LIBDISPATCH_BUILD_TYPE}"
;;
*)
echo "error: unknown product: ${product}"
exit 1
;;
esac
fi
}
#
# Configure and build each product
#
@@ -2639,18 +2561,7 @@ for host in "${ALL_HOSTS[@]}"; do
# Build.
if [[ $(not ${SKIP_BUILD}) ]]; then
if [[ "${CMAKE_GENERATOR}" == "Xcode" ]] ; then
# Xcode generator uses "ALL_BUILD" instead of "all".
# Also, xcodebuild uses -target instead of bare names.
build_targets=("${build_targets[@]/all/ALL_BUILD}")
build_targets=("${build_targets[@]/#/${BUILD_TARGET_FLAG} }")
# Xcode can't restart itself if it turns out we need to reconfigure.
# Do an advance build to handle that.
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product})
fi
call "${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}" ${build_targets[@]}
call "${CMAKE_BUILD[@]}" "${build_dir}" -- "${BUILD_ARGS[@]}" ${build_targets[@]}
fi
done
done
@@ -2867,11 +2778,11 @@ for host in "${ALL_HOSTS[@]}"; do
trap "tests_busted ${product} ''" ERR
build_dir=$(build_directory ${host} ${product})
build_cmd=("${CMAKE_BUILD[@]}" "${build_dir}" $(cmake_config_opt ${product}) -- "${BUILD_ARGS[@]}")
build_cmd=("${CMAKE_BUILD[@]}" "${build_dir}" -- "${BUILD_ARGS[@]}")
if [[ "${executable_target}" != "" ]]; then
echo "--- Building tests for ${product} ---"
call "${build_cmd[@]}" ${BUILD_TARGET_FLAG} "${executable_target}"
call "${build_cmd[@]}" "${executable_target}"
fi
# We can only run tests built for the host machine, because
@@ -2892,7 +2803,7 @@ for host in "${ALL_HOSTS[@]}"; do
test_target="${test_target}-custom"
fi
call "${build_cmd[@]}" ${BUILD_TARGET_FLAG} ${test_target}
call "${build_cmd[@]}" ${test_target}
echo "-- ${target} finished --"
fi

View File

@@ -68,17 +68,10 @@ def _apply_default_arguments(args):
# Set the default CMake generator.
if args.cmake_generator is None:
args.cmake_generator = 'Ninja'
elif args.cmake_generator == 'Xcode':
# Building with Xcode is deprecated.
args.skip_build = True
args.build_early_swift_driver = False
args.build_early_swiftsyntax = False
# Set the default build variant.
if args.build_variant is None:
args.build_variant = (
'MinSizeRel' if args.cmake_generator == 'Xcode' else 'Debug'
)
args.build_variant = 'Debug'
if args.llvm_build_variant is None:
args.llvm_build_variant = args.build_variant
@@ -1041,9 +1034,11 @@ def create_argument_parser():
option(['-m', '--make'], store('cmake_generator'),
const='Unix Makefiles',
help="use CMake's Makefile generator (%(default)s by default)")
# Xcode generation is no longer supported, leave the option so we can
# inform the user.
option(['-x', '--xcode'], store('cmake_generator'),
const='Xcode',
help="use CMake's Xcode generator (%(default)s by default)")
const='Xcode', help=argparse.SUPPRESS)
# -------------------------------------------------------------------------
in_group('Run tests')
@@ -1670,10 +1665,6 @@ To use 'make' instead of 'ninja', use '-m':
[~/src/s]$ ./swift/utils/build-script -m -R
To create Xcode projects that can build Swift, use '-x':
[~/src/s]$ ./swift/utils/build-script -x -R
Preset mode in build-script
---------------------------

View File

@@ -639,11 +639,3 @@ class TestDriverArgumentParser(
def test_implied_defaults_swift_disable_dead_stripping(self):
namespace = self.parse_default_args(['--swift-disable-dead-stripping'])
self.assertTrue(namespace.swift_disable_dead_stripping)
def test_implied_defaults_xcode(self):
namespace = self.parse_default_args(['--xcode'])
self.assertEqual(namespace.cmake_generator, 'Xcode')
self.assertEqual(namespace.build_variant, 'MinSizeRel')
self.assertTrue(namespace.skip_build)
self.assertFalse(namespace.build_early_swift_driver)
self.assertFalse(namespace.build_early_swiftsyntax)

View File

@@ -1,11 +1,6 @@
# swift-xcodegen
A script for generating an Xcode project for the Swift repo, that sits on top of an existing Ninja build. This has a few advantages over CMake's Xcode generator (using `build-script --xcode`):
- Fast to regenerate (less than a second)
- Native Swift targets for ASTGen/SwiftCompilerSources + Standard Library
- Better file organization (by path rather than by target)
- Much fewer targets, easier to manage
A script for generating an Xcode project for the Swift repo, that sits on top of an existing Ninja build.
This script is primarily focussed on providing a good editor experience for working on the Swift project; it is not designed to produce compiled products or run tests, that should be done with `ninja` and `build-script`. It can however be used to [debug executables produced by the Ninja build](#debugging).

View File

@@ -167,10 +167,6 @@ class CMake(object):
define("CMAKE_AR:PATH", toolchain.ar)
define("CMAKE_RANLIB:PATH", toolchain.ranlib)
if args.cmake_generator == 'Xcode':
define("CMAKE_CONFIGURATION_TYPES",
"Debug;Release;MinSizeRel;RelWithDebInfo")
if args.clang_user_visible_version:
major, minor, patch = \
args.clang_user_visible_version.components[0:3]
@@ -210,10 +206,6 @@ class CMake(object):
if args.verbose_build:
build_args += ['VERBOSE=1']
elif args.cmake_generator == 'Xcode':
build_args += ['-parallelizeTargets',
'-jobs', str(jobs)]
return build_args
# Determine the version of the installed CMake binary.

View File

@@ -76,23 +76,6 @@ class CMakeProduct(product.Product):
):
cmake_opts = [self.build_dir, "--config", build_type]
if self.args.cmake_generator == "Xcode":
# CMake automatically adds "--target ALL_BUILD" if we don't
# pass this.
cmake_opts += ["--target", "ZERO_CHECK"]
# Xcode generator uses "ALL_BUILD" instead of "all".
# Also, xcodebuild uses -target instead of bare names.
build_targets = build_targets[:]
build_targets = [val for target in build_targets
for val in ["-target",
target if target != "all"
else "ALL_BUILD"]]
# Xcode can't restart itself if it turns out we need to reconfigure.
# Do an advance build to handle that.
shell.call(["env"] + cmake_build + cmake_opts)
shell.call(
["env"] + cmake_build + cmake_opts + ["--"] + build_args
+ _cmake.build_args() + build_targets
@@ -117,13 +100,8 @@ class CMakeProduct(product.Product):
"--config", build_type, "--"]
cmake_build.extend(cmake_args + build_args + _cmake.build_args())
def target_flag(target):
if self.args.cmake_generator == "Xcode":
return ["-target", target]
return [target]
if executable_target:
shell.call(cmake_build + target_flag(executable_target))
shell.call(cmake_build + [executable_target])
for target in results_targets:
if target:
@@ -134,7 +112,7 @@ class CMakeProduct(product.Product):
# note that passing variables via test_env won't affect lit tests -
# lit.cfg will filter environment variables out!
shell.call(cmake_build + target_flag(test_target), env=test_env)
shell.call(cmake_build + [test_target], env=test_env)
print("--- %s finished ---" % target)

View File

@@ -90,10 +90,6 @@ class CMark(cmake_product.CMakeProduct):
"""
executable_target = 'api_test'
results_targets = ['test']
if self.args.cmake_generator == 'Xcode':
# Xcode generator uses "RUN_TESTS" instead of "test".
results_targets = ['RUN_TESTS']
test_env = {
"CTEST_OUTPUT_ON_FAILURE": "ON"
}

View File

@@ -250,13 +250,9 @@ class LLVM(cmake_product.CMakeProduct):
build_targets = ['llvm-tblgen', 'clang-resource-headers',
'intrinsics_gen', 'clang-tablegen-targets']
# If we are not performing a toolchain-only build or generating
# Xcode projects, then we also want to include the following
# targets for testing purposes.
if (
not self.args.build_toolchain_only
and self.args.cmake_generator != 'Xcode'
):
# If we are not performing a toolchain-only build, then we
# also want to include the following targets for testing purposes.
if not self.args.build_toolchain_only:
build_targets.extend([
'FileCheck',
'not',

View File

@@ -305,22 +305,6 @@ class CMakeTestCase(unittest.TestCase):
"-DCMAKE_RANLIB:PATH=/path/to/ranlib",
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
def test_common_options_xcode(self):
args = self.default_args()
args.cmake_generator = 'Xcode'
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Xcode",
"-DCMAKE_C_COMPILER:PATH=/path/to/clang",
"-DCMAKE_CXX_COMPILER:PATH=/path/to/clang++",
"-DCMAKE_Swift_COMPILER:PATH=/path/to/swiftc",
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
"-DCMAKE_AR:PATH=/path/to/ar",
"-DCMAKE_RANLIB:PATH=/path/to/ranlib",
"-DCMAKE_CONFIGURATION_TYPES=" +
"Debug;Release;MinSizeRel;RelWithDebInfo"])
def test_common_options_clang_compiler_version(self):
args = self.default_args()
args.clang_compiler_version = Version("999.0.999")
@@ -378,14 +362,13 @@ class CMakeTestCase(unittest.TestCase):
args.enable_ubsan = True
args.export_compile_commands = True
args.distcc = True
args.cmake_generator = 'Xcode'
args.clang_user_visible_version = Version("9.0.0")
args.clang_compiler_version = Version("999.0.900")
args.build_ninja = True
cmake = self.cmake(args)
self.assertEqual(
list(cmake.common_options()),
["-G", "Xcode",
["-G", "Ninja",
"-DLLVM_USE_SANITIZER=Address;Undefined",
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DCMAKE_C_COMPILER_LAUNCHER:PATH=" + self.mock_distcc_path(),
@@ -396,16 +379,13 @@ class CMakeTestCase(unittest.TestCase):
"-DCMAKE_LIBTOOL:PATH=/path/to/libtool",
"-DCMAKE_AR:PATH=/path/to/ar",
"-DCMAKE_RANLIB:PATH=/path/to/ranlib",
"-DCMAKE_CONFIGURATION_TYPES=" +
"Debug;Release;MinSizeRel;RelWithDebInfo",
"-DLLVM_VERSION_MAJOR:STRING=9",
"-DLLVM_VERSION_MINOR:STRING=0",
"-DLLVM_VERSION_PATCH:STRING=0",
"-DCLANG_VERSION_MAJOR:STRING=9",
"-DCLANG_VERSION_MINOR:STRING=0",
"-DCLANG_VERSION_PATCH:STRING=0"])
# NOTE: No "-DCMAKE_MAKE_PROGRAM=/path/to/built/ninja" because
# cmake_generator is 'Xcode'
"-DCLANG_VERSION_PATCH:STRING=0",
"-DCMAKE_MAKE_PROGRAM=" + self.which_ninja(args)])
def test_build_args_ninja(self):
args = self.default_args()
@@ -434,21 +414,6 @@ class CMakeTestCase(unittest.TestCase):
list(cmake.build_args()),
["-j8", "VERBOSE=1"])
def test_build_args_xcode(self):
args = self.default_args()
args.cmake_generator = "Xcode"
cmake = self.cmake(args)
self.assertEqual(
list(cmake.build_args()),
["-parallelizeTargets", "-jobs", "8"])
# NOTE: Xcode generator DOES NOT take 'verbose-build' into account.
args.verbose_build = True
cmake = self.cmake(args)
self.assertEqual(
list(cmake.build_args()),
["-parallelizeTargets", "-jobs", "8"])
def test_build_args_eclipse_ninja(self):
# NOTE: Eclipse generator DOES NOT take 'build-jobs' into account,
# nor 'verbose-build'.

View File

@@ -1,20 +0,0 @@
# REQUIRES: rdar133492917
# RUN: %empty-directory(%t)
# RUN: %empty-directory(%t/Xcode)
# Build system generation for 'swift' depends on several LLVM tools
# (e.g. llvm-tblgen). This is why we still build them with '--skip-build' or
# '--skip-build-llvm' set, and have an additional '--build-llvm' option to
# actually skip building that bare minimum too.
#
# To save time, borrow these dependencies from the current build directories,
# and test Xcode project generation only for 'swift'.
# RUN: ln -s %swift_obj_root/../cmark-%target-os-%target-arch %t/Xcode/cmark-%target-os-%target-arch
# RUN: ln -s %swift_obj_root/../llvm-%target-os-%target-arch %t/Xcode/llvm-%target-os-%target-arch
# RUN: SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --cmake %cmake --swift-darwin-supported-archs="$(uname -m)" --build-subdir="Xcode" --skip-build-cmark --build-llvm=0 --xcode
# REQUIRES: standalone_build
# REQUIRES: OS=macosx
# REQUIRES: target-same-as-host

View File

@@ -1,13 +0,0 @@
# RUN: %empty-directory(%t)
# RUN: SKIP_XCODE_VERSION_CHECK=1 SWIFT_BUILD_ROOT=%t %swift_src_root/utils/build-script --xcode --release --swift-darwin-supported-archs="$(uname -m)" --dry-run --cmake %cmake 2>&1 | %FileCheck %s
# REQUIRES: standalone_build
# REQUIRES: OS=macosx
# Make sure we pass '--target ZERO_CHECK' (otherwise CMake automatically adds
# '--target ALL_BUILD' and we end up building everything) and build the bare
# minimum required to configure Swift.
#
# CHECK: --- Building llvm ---
# CHECK: env {{.+}}/cmake --build {{.+}}/Xcode-ReleaseAssert/llvm-macosx-{{.+}} --config Release --target ZERO_CHECK{{$}}
# CHECK-NEXT: env {{.+}}/cmake --build {{.+}}/Xcode-ReleaseAssert/llvm-macosx-{{.+}} --config Release --target ZERO_CHECK -- {{.*}}-target llvm-tblgen -target clang-resource-headers -target intrinsics_gen -target clang-tablegen-targets{{$}}

View File

@@ -116,13 +116,6 @@ if "@SWIFT_ENABLE_OBSERVATION@" == "TRUE":
if "@SWIFT_BUILT_STANDALONE@" == "TRUE":
config.available_features.add('standalone_build')
if "@CMAKE_GENERATOR@" == "Xcode":
xcode_bin_dir = os.path.join(config.llvm_obj_root, "@LLVM_BUILD_TYPE@",
'bin')
lit_config.note('Adding to path: ' + xcode_bin_dir)
config.environment['PATH'] = \
os.path.pathsep.join((xcode_bin_dir, config.environment['PATH']))
config.available_features.add("CMAKE_GENERATOR=@CMAKE_GENERATOR@")
if "@SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING@" == "TRUE":