Skip to content

Commit 5064adc

Browse files
committed
Set up a client-side C library to talk with C APIs exposed from the compiler
We could use functions like dlopen and dlsym in this client-side library to talk with compiler-side C APIs.
1 parent cf36366 commit 5064adc

File tree

9 files changed

+34
-3
lines changed

9 files changed

+34
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cmake_minimum_required(VERSION 3.15.1)
1010

1111
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
1212

13-
project(SwiftDriver LANGUAGES Swift)
13+
project(SwiftDriver LANGUAGES Swift C)
1414

1515
set(SWIFT_VERSION 5)
1616
set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION})

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ let package = Package(
3636
targets: ["SwiftDriverExecution"]),
3737
],
3838
targets: [
39+
.target(name: "_CSwiftDriver"),
40+
3941
/// The driver library.
4042
.target(
4143
name: "SwiftDriver",
42-
dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "Yams"]),
44+
dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "Yams", "_CSwiftDriver"]),
4345

4446
/// The execution library.
4547
.target(

Sources/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9+
add_subdirectory(_CSwiftDriver)
910
add_subdirectory(SwiftOptions)
1011
add_subdirectory(SwiftDriver)
1112
add_subdirectory(SwiftDriverExecution)

Sources/SwiftDriver/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ target_link_libraries(SwiftDriver PUBLIC
9999
SwiftOptions)
100100
target_link_libraries(SwiftDriver PRIVATE
101101
CYaml
102-
Yams)
102+
Yams
103+
CSwiftDriver)
103104

104105
set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftDriver)
105106

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import TSCBasic
1313
import TSCUtility
1414
import Foundation
1515
import SwiftOptions
16+
import _CSwiftDriver
1617

1718
/// The Swift driver.
1819
public struct Driver {

Sources/_CSwiftDriver/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
add_library(CSwiftDriver STATIC
10+
_CSwiftDriverImpl.c)
11+
target_include_directories(CSwiftDriver PUBLIC
12+
include)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file is here to prevent the package manager from warning about a target with no sources.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This source file is part of the Swift.org open source project
2+
//
3+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
4+
// Licensed under Apache License v2.0 with Runtime Library Exception
5+
//
6+
// See http://swift.org/LICENSE.txt for license information
7+
// See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
void dummyfunction();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module _CSwiftDriver {
2+
umbrella "."
3+
export *
4+
}

0 commit comments

Comments
 (0)