mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
cmake: Add a SWIFT_XCODE_GENERATE_FOR_IDE_ONLY flag.
This flag disables the generation of dependency targets that are necessary to accurately rebuild Swift code, but which completely tank the Xcode IDE experience. Since Xcode is primarily useful as a source editor/navigator for the compiler C++ code, and Ninja is a more performant and featureful build system for Swift at this point, provide a mode that generates enough of an Xcode project to edit the Swift compiler source, but which can't build it, as a compromise so we can use Xcode's editor alongside a Ninja build environment. Swift SVN r24186
This commit is contained in:
@@ -123,6 +123,10 @@ option(SWIFT_STDLIB_USE_ASSERT_CONFIG_RELEASE
|
|||||||
"Should the stdlib be build with assert config set to release"
|
"Should the stdlib be build with assert config set to release"
|
||||||
FALSE)
|
FALSE)
|
||||||
|
|
||||||
|
option(SWIFT_XCODE_GENERATE_FOR_IDE_ONLY
|
||||||
|
"Generate an Xcode project suitable for IDE use, but which cannot build"
|
||||||
|
FALSE)
|
||||||
|
|
||||||
#
|
#
|
||||||
# End of user-configurable options.
|
# End of user-configurable options.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -125,15 +125,16 @@ function(add_custom_command_target dependency_out_var_name)
|
|||||||
# Use a hash so that the file name does not push the OS limits for filename
|
# Use a hash so that the file name does not push the OS limits for filename
|
||||||
# length.
|
# length.
|
||||||
list(GET ACCT_OUTPUT 0 output_filename)
|
list(GET ACCT_OUTPUT 0 output_filename)
|
||||||
string(MD5 ACCT_CUSTOM_TARGET_NAME
|
string(MD5 target_md5
|
||||||
"add_custom_command_target${CMAKE_CURRENT_BINARY_DIR}/${output_filename}")
|
"add_custom_command_target${CMAKE_CURRENT_BINARY_DIR}/${output_filename}")
|
||||||
get_filename_component(output_filename_basename "${output_filename}" NAME)
|
get_filename_component(output_filename_basename "${output_filename}" NAME)
|
||||||
set(ACCT_CUSTOM_TARGET_NAME
|
set(target_name
|
||||||
"add_custom_command_target-${ACCT_CUSTOM_TARGET_NAME}-${output_filename_basename}")
|
"add_custom_command_target-${target_md5}-${output_filename_basename}")
|
||||||
|
else()
|
||||||
|
set(target_name "${ACCT_CUSTOM_TARGET_NAME}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if((NOT ACCT_IDEMPOTENT) OR
|
if((NOT ACCT_IDEMPOTENT) OR (ACCT_IDEMPOTENT AND NOT TARGET "${target_name}"))
|
||||||
(ACCT_IDEMPOTENT AND NOT TARGET "${ACCT_CUSTOM_TARGET_NAME}"))
|
|
||||||
# For each keyword argument k that was passed to this function, set
|
# 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 to ${k}. That will allow us to use the incantation
|
||||||
# '${${k}_keyword} ${ACCT_${k}}' to forward the arguments on.
|
# '${${k}_keyword} ${ACCT_${k}}' to forward the arguments on.
|
||||||
@@ -146,17 +147,38 @@ function(add_custom_command_target dependency_out_var_name)
|
|||||||
IMPLICIT_DEPENDS WORKING_DIRECTORY COMMENT VERBATIM APPEND)
|
IMPLICIT_DEPENDS WORKING_DIRECTORY COMMENT VERBATIM APPEND)
|
||||||
add_custom_command(${ACCT_COMMANDS} ${args})
|
add_custom_command(${ACCT_COMMANDS} ${args})
|
||||||
|
|
||||||
|
# Skip generating the target if we are generating an Xcode project only
|
||||||
|
# for IDE use. The volume of dependencies here causes performance problems
|
||||||
|
# in Xcode that make it impractical to use.
|
||||||
|
if(NOT (SWIFT_XCODE_GENERATE_FOR_IDE_ONLY
|
||||||
|
AND "${ACCT_CUSTOM_TARGET_NAME}" STREQUAL ""))
|
||||||
_make_acct_argument_list(ALL WORKING_DIRECTORY SOURCES)
|
_make_acct_argument_list(ALL WORKING_DIRECTORY SOURCES)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
"${ACCT_CUSTOM_TARGET_NAME}" ${args}
|
"${target_name}" ${args}
|
||||||
DEPENDS ${ACCT_OUTPUT}
|
DEPENDS ${ACCT_OUTPUT}
|
||||||
COMMENT "${ACCT_OUTPUT}")
|
COMMENT "${ACCT_OUTPUT}")
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
"${ACCT_CUSTOM_TARGET_NAME}" PROPERTIES
|
"${target_name}" PROPERTIES
|
||||||
FOLDER "add_custom_command_target artifacts")
|
FOLDER "add_custom_command_target artifacts")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# "Return" the name of the custom target
|
# "Return" the name of the custom target
|
||||||
set("${dependency_out_var_name}" "${ACCT_CUSTOM_TARGET_NAME}" PARENT_SCOPE)
|
if(SWIFT_XCODE_GENERATE_FOR_IDE_ONLY
|
||||||
|
AND "${ACCT_CUSTOM_TARGET_NAME}" STREQUAL "")
|
||||||
|
set("${dependency_out_var_name}" xcode_generate_for_ide_only_dummy
|
||||||
|
PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set("${dependency_out_var_name}" "${target_name}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# A dummy target for XCODE_GENERATE_FOR_IDE_ONLY targets that stands in for
|
||||||
|
# the targets we don't generate in that mode.
|
||||||
|
if(SWIFT_XCODE_GENERATE_FOR_IDE_ONLY)
|
||||||
|
add_custom_command(OUTPUT xcode_generate_for_ide_only_dummy.txt
|
||||||
|
COMMAND echo "This Xcode project is configured for IDE use only and cannot build Swift."
|
||||||
|
COMMAND false)
|
||||||
|
add_custom_target(xcode_generate_for_ide_only_dummy ALL
|
||||||
|
DEPENDS xcode_generate_for_ide_only_dummy.txt)
|
||||||
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user