diff --git a/CMakeLists.txt b/CMakeLists.txt index be5e1cf2333be..f2ab512a9f20f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -605,6 +605,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY "Enable build of the Swift concurrency module" FALSE) +option(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP + "Enable experimental C++ interop modules" + FALSE) + option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED "Enable experimental distributed actors and functions" FALSE) diff --git a/stdlib/public/CMakeLists.txt b/stdlib/public/CMakeLists.txt index 81ee651b10a65..d0ae4a9e8cd9d 100644 --- a/stdlib/public/CMakeLists.txt +++ b/stdlib/public/CMakeLists.txt @@ -65,7 +65,9 @@ endif() add_subdirectory(SwiftShims/swift/shims) add_subdirectory(CommandLineSupport) -add_subdirectory(Cxx) +if(SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP) + add_subdirectory(Cxx) +endif() add_subdirectory(Threading) # This static library is shared across swiftCore and swiftRemoteInspection diff --git a/utils/build-windows-toolchain.bat b/utils/build-windows-toolchain.bat index 54be41db605a2..f7084bcb18584 100644 --- a/utils/build-windows-toolchain.bat +++ b/utils/build-windows-toolchain.bat @@ -212,6 +212,7 @@ cmake ^ -D LLVM_VERSION_SUFFIX="" ^ -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES ^ + -D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^ @@ -254,6 +255,7 @@ cmake ^ -D SWIFT_PATH_TO_STRING_PROCESSING_SOURCE=%SourceRoot%\swift-experimental-string-processing ^ -D SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES ^ + -D SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES ^ -D SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES ^ diff --git a/utils/build-windows.bat b/utils/build-windows.bat index c4062d54c9244..aa47a290119dd 100644 --- a/utils/build-windows.bat +++ b/utils/build-windows.bat @@ -262,6 +262,7 @@ cmake^ -DSWIFT_BUILD_SOURCEKIT:BOOL=YES^ -DSWIFT_ENABLE_SOURCEKIT_TESTS:BOOL=YES^ -DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES^ + -DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=YES^ -DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES^ -DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES^ -DSWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=YES^ diff --git a/utils/build_swift/build_swift/driver_arguments.py b/utils/build_swift/build_swift/driver_arguments.py index 0692436f01da7..65d20882d912b 100644 --- a/utils/build_swift/build_swift/driver_arguments.py +++ b/utils/build_swift/build_swift/driver_arguments.py @@ -1321,10 +1321,13 @@ def create_argument_parser(): default=True, help='Enable experimental Swift differentiable programming.') - option('--enable-experimental-concurrency', toggle_true, - default=True, + option('--enable-experimental-concurrency', toggle_true, default=True, help='Enable experimental Swift concurrency model.') + option('--enable-experimental-cxx-interop', toggle_true, + default=True, + help='Enable experimental C++ interop.') + option('--enable-experimental-distributed', toggle_true, default=True, help='Enable experimental Swift distributed actors.') diff --git a/utils/build_swift/tests/expected_options.py b/utils/build_swift/tests/expected_options.py index 6e27397b84156..322e063128e2a 100644 --- a/utils/build_swift/tests/expected_options.py +++ b/utils/build_swift/tests/expected_options.py @@ -162,6 +162,7 @@ 'enable_asan': False, 'enable_experimental_differentiable_programming': True, 'enable_experimental_concurrency': True, + 'enable_experimental_cxx_interop': True, 'enable_experimental_distributed': True, 'enable_experimental_string_processing': True, 'enable_experimental_observation': True, @@ -579,6 +580,7 @@ class BuildScriptImplOption(_BaseOption): EnableOption('--enable-asan'), EnableOption('--enable-experimental-differentiable-programming'), EnableOption('--enable-experimental-concurrency'), + EnableOption('--enable-experimental-cxx-interop'), EnableOption('--enable-experimental-distributed'), EnableOption('--enable-experimental-string-processing'), EnableOption('--enable-experimental-observation'), diff --git a/utils/swift_build_support/swift_build_support/products/swift.py b/utils/swift_build_support/swift_build_support/products/swift.py index 98bfe20da7339..f841e468b10f2 100644 --- a/utils/swift_build_support/swift_build_support/products/swift.py +++ b/utils/swift_build_support/swift_build_support/products/swift.py @@ -52,6 +52,9 @@ def __init__(self, args, toolchain, source_dir, build_dir): # Add experimental concurrency flag. self.cmake_options.extend(self._enable_experimental_concurrency) + # Add experimental cxx interop flag. + self.cmake_options.extend(self._enable_experimental_cxx_interop) + # Add experimental distributed flag. self.cmake_options.extend(self._enable_experimental_distributed) @@ -168,6 +171,11 @@ def _enable_experimental_concurrency(self): return [('SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL', self.args.enable_experimental_concurrency)] + @property + def _enable_experimental_cxx_interop(self): + return [('SWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL', + self.args.enable_experimental_cxx_interop)] + @property def _enable_experimental_distributed(self): return [('SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL', diff --git a/utils/swift_build_support/tests/products/test_swift.py b/utils/swift_build_support/tests/products/test_swift.py index 2af3407471a47..ad76bf4f8243f 100644 --- a/utils/swift_build_support/tests/products/test_swift.py +++ b/utils/swift_build_support/tests/products/test_swift.py @@ -55,6 +55,7 @@ def setUp(self): enable_stdlibcore_exclusivity_checking=False, enable_experimental_differentiable_programming=False, enable_experimental_concurrency=False, + enable_experimental_cxx_interop=False, enable_experimental_distributed=False, enable_experimental_observation=False, swift_enable_backtracing=False, @@ -96,6 +97,7 @@ def test_by_default_no_cmake_options(self): '-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE', + '-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE', '-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE', @@ -121,6 +123,7 @@ def test_swift_runtime_tsan(self): '-DSWIFT_STDLIB_ENABLE_STDLIBCORE_EXCLUSIVITY_CHECKING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY:BOOL=FALSE', + '-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE', '-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE', '-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE', @@ -355,6 +358,18 @@ def test_experimental_concurrency_flags(self): [x for x in swift.cmake_options if 'DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY' in x]) + def test_experimental_cxx_interop_flags(self): + self.args.enable_experimental_cxx_interop = True + swift = Swift( + args=self.args, + toolchain=self.toolchain, + source_dir='/path/to/src', + build_dir='/path/to/build') + self.assertEqual( + ['-DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP:BOOL=TRUE'], + [option for option in swift.cmake_options + if 'DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP' in option]) + def test_experimental_distributed_flags(self): self.args.enable_experimental_distributed = True swift = Swift(