diff --git a/CMakeLists.txt b/CMakeLists.txt index a39da660f..c1b2b5a1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.15.1) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) -project(SwiftDriver LANGUAGES Swift) +project(SwiftDriver LANGUAGES Swift C) set(SWIFT_VERSION 5) set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION}) @@ -19,6 +19,9 @@ if(CMAKE_VERSION VERSION_LESS 3.16) set(CMAKE_LINK_LIBRARY_FLAG "-l") endif() +# ensure Swift compiler can find _CSwiftDriver +add_compile_options($<$:-I$${CMAKE_CURRENT_SOURCE_DIR}/Sources/_CSwiftDriver/include>) + set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) if(CMAKE_VERSION VERSION_LESS 3.16 AND CMAKE_SYSTEM_NAME STREQUAL Windows) diff --git a/Package.swift b/Package.swift index 8d4947a3d..5e774dd7b 100644 --- a/Package.swift +++ b/Package.swift @@ -36,10 +36,12 @@ let package = Package( targets: ["SwiftDriverExecution"]), ], targets: [ + .target(name: "_CSwiftDriver"), + /// The driver library. .target( name: "SwiftDriver", - dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "Yams"]), + dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "Yams", "_CSwiftDriver"]), /// The execution library. .target( diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 4df57ecfc..c93dd937f 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -6,6 +6,7 @@ # See http://swift.org/LICENSE.txt for license information # See http://swift.org/CONTRIBUTORS.txt for Swift project authors +add_subdirectory(_CSwiftDriver) add_subdirectory(SwiftOptions) add_subdirectory(SwiftDriver) add_subdirectory(SwiftDriverExecution) diff --git a/Sources/SwiftDriver/CMakeLists.txt b/Sources/SwiftDriver/CMakeLists.txt index b2f041317..778e3f68d 100644 --- a/Sources/SwiftDriver/CMakeLists.txt +++ b/Sources/SwiftDriver/CMakeLists.txt @@ -99,7 +99,8 @@ target_link_libraries(SwiftDriver PUBLIC SwiftOptions) target_link_libraries(SwiftDriver PRIVATE CYaml - Yams) + Yams + CSwiftDriver) set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftDriver) diff --git a/Sources/SwiftDriver/Driver/Driver.swift b/Sources/SwiftDriver/Driver/Driver.swift index b52e6af2b..fa260f9c0 100644 --- a/Sources/SwiftDriver/Driver/Driver.swift +++ b/Sources/SwiftDriver/Driver/Driver.swift @@ -13,6 +13,7 @@ import TSCBasic import TSCUtility import Foundation import SwiftOptions +@_implementationOnly import _CSwiftDriver /// The Swift driver. public struct Driver { diff --git a/Sources/_CSwiftDriver/CMakeLists.txt b/Sources/_CSwiftDriver/CMakeLists.txt new file mode 100644 index 000000000..48b097aea --- /dev/null +++ b/Sources/_CSwiftDriver/CMakeLists.txt @@ -0,0 +1,10 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2014 - 2020 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 Swift project authors + +add_library(CSwiftDriver STATIC + _CSwiftDriverImpl.c) diff --git a/Sources/_CSwiftDriver/_CSwiftDriverImpl.c b/Sources/_CSwiftDriver/_CSwiftDriverImpl.c new file mode 100644 index 000000000..890092f18 --- /dev/null +++ b/Sources/_CSwiftDriver/_CSwiftDriverImpl.c @@ -0,0 +1 @@ +// This file is here to prevent the package manager from warning about a target with no sources. diff --git a/Sources/_CSwiftDriver/include/_CSwiftDriver.h b/Sources/_CSwiftDriver/include/_CSwiftDriver.h new file mode 100644 index 000000000..849d305f3 --- /dev/null +++ b/Sources/_CSwiftDriver/include/_CSwiftDriver.h @@ -0,0 +1,9 @@ +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2020 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 Swift project authors + +void dummyfunction(); diff --git a/Sources/_CSwiftDriver/include/module.modulemap b/Sources/_CSwiftDriver/include/module.modulemap new file mode 100644 index 000000000..1faecf1b2 --- /dev/null +++ b/Sources/_CSwiftDriver/include/module.modulemap @@ -0,0 +1,4 @@ +module _CSwiftDriver { + umbrella "." + export * +}