Skip to content

Commit 204f061

Browse files
committed
Merge changes from upstream
1 parent 5d38461 commit 204f061

File tree

101 files changed

+8871
-3544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+8871
-3544
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ if(CMAKE_VERSION VERSION_LESS 3.16)
1919
set(CMAKE_LINK_LIBRARY_FLAG "-l")
2020
endif()
2121

22-
# ensure Swift compiler can find _CSwiftDriver
23-
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-I$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/Sources/_CSwiftDriver/include>)
22+
# ensure Swift compiler can find _CSwiftScan
23+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-I$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/Sources/CSwiftScan/include>)
2424

2525
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
2626

Package.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ let package = Package(
3636
targets: ["SwiftDriverExecution"]),
3737
],
3838
targets: [
39-
.target(name: "_CSwiftDriver"),
39+
40+
/// C modules wrapper for _InternalLibSwiftScan.
41+
.target(name: "CSwiftScan"),
4042

4143
/// The driver library.
4244
.target(
4345
name: "SwiftDriver",
44-
dependencies: ["SwiftOptions", "SwiftToolsSupport-auto", "Yams", "_CSwiftDriver"]),
46+
dependencies: ["SwiftOptions", "SwiftToolsSupport-auto",
47+
"CSwiftScan", "Yams"]),
4548

4649
/// The execution library.
4750
.target(
@@ -69,7 +72,7 @@ let package = Package(
6972
/// The help executable.
7073
.target(
7174
name: "swift-help",
72-
dependencies: ["SwiftOptions", "ArgumentParser"]),
75+
dependencies: ["SwiftOptions", "ArgumentParser", "SwiftToolsSupport-auto"]),
7376

7477
/// The `makeOptions` utility (for importing option definitions).
7578
// .target(

Sources/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +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)
9+
add_subdirectory(CSwiftScan)
1010
add_subdirectory(SwiftOptions)
1111
add_subdirectory(SwiftDriver)
1212
add_subdirectory(SwiftDriverExecution)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
add_library(CSwiftDriver STATIC
10-
_CSwiftDriverImpl.c)
9+
add_library(CSwiftScan STATIC
10+
CSwiftScanImpl.c)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// This file is here to prevent the package manager from warning about a
2+
// target with no sources.
3+
#include "include/swiftscan_header.h"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module CSwiftScan {
2+
header "swiftscan_header.h"
3+
export *
4+
}
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
//===-- swiftscan_header.h - C API for Swift Dependency Scanning --*- C -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_C_DEPENDENCY_SCAN_H
14+
#define SWIFT_C_DEPENDENCY_SCAN_H
15+
16+
#include <stdbool.h>
17+
#include <stddef.h>
18+
#include <stdint.h>
19+
20+
#define SWIFTSCAN_VERSION_MAJOR 0
21+
#define SWIFTSCAN_VERSION_MINOR 1
22+
23+
//=== Public Scanner Data Types -------------------------------------------===//
24+
25+
typedef struct {
26+
const void *data;
27+
size_t length;
28+
} swiftscan_string_ref_t;
29+
30+
typedef struct {
31+
swiftscan_string_ref_t *strings;
32+
size_t count;
33+
} swiftscan_string_set_t;
34+
35+
typedef enum {
36+
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_TEXTUAL = 0,
37+
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY = 1,
38+
SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER = 2,
39+
SWIFTSCAN_DEPENDENCY_INFO_CLANG = 3
40+
} swiftscan_dependency_info_kind_t;
41+
42+
typedef struct swiftscan_module_details_s *swiftscan_module_details_t;
43+
typedef struct swiftscan_dependency_info_s *swiftscan_dependency_info_t;
44+
typedef struct swiftscan_dependency_graph_s *swiftscan_dependency_graph_t;
45+
typedef struct swiftscan_import_set_s *swiftscan_import_set_t;
46+
typedef struct {
47+
swiftscan_dependency_info_t *modules;
48+
size_t count;
49+
} swiftscan_dependency_set_t;
50+
51+
//=== Batch Scan Input Specification --------------------------------------===//
52+
53+
typedef struct swiftscan_batch_scan_entry_s *swiftscan_batch_scan_entry_t;
54+
typedef struct {
55+
swiftscan_batch_scan_entry_t *modules;
56+
size_t count;
57+
} swiftscan_batch_scan_input_t;
58+
typedef struct {
59+
swiftscan_dependency_graph_t *results;
60+
size_t count;
61+
} swiftscan_batch_scan_result_t;
62+
63+
//=== Scanner Invocation Specification ------------------------------------===//
64+
65+
typedef struct swiftscan_scan_invocation_s *swiftscan_scan_invocation_t;
66+
typedef void *swiftscan_scanner_t;
67+
68+
//=== libSwiftScan Functions ------------------------------------------------===//
69+
70+
typedef struct {
71+
72+
//=== Dependency Result Functions -----------------------------------------===//
73+
swiftscan_string_ref_t
74+
(*swiftscan_dependency_graph_get_main_module_name)(swiftscan_dependency_graph_t);
75+
swiftscan_dependency_set_t *
76+
(*swiftscan_dependency_graph_get_dependencies)(swiftscan_dependency_graph_t);
77+
78+
//=== Dependency Module Info Functions ------------------------------------===//
79+
swiftscan_string_ref_t
80+
(*swiftscan_module_info_get_module_name)(swiftscan_dependency_info_t);
81+
swiftscan_string_ref_t
82+
(*swiftscan_module_info_get_module_path)(swiftscan_dependency_info_t);
83+
swiftscan_string_set_t *
84+
(*swiftscan_module_info_get_source_files)(swiftscan_dependency_info_t);
85+
swiftscan_string_set_t *
86+
(*swiftscan_module_info_get_direct_dependencies)(swiftscan_dependency_info_t);
87+
swiftscan_module_details_t
88+
(*swiftscan_module_info_get_details)(swiftscan_dependency_info_t);
89+
90+
//=== Dependency Module Info Details Functions ----------------------------===//
91+
swiftscan_dependency_info_kind_t
92+
(*swiftscan_module_detail_get_kind)(swiftscan_module_details_t);
93+
94+
//=== Swift Textual Module Details query APIs -----------------------------===//
95+
swiftscan_string_ref_t
96+
(*swiftscan_swift_textual_detail_get_module_interface_path)(swiftscan_module_details_t);
97+
swiftscan_string_set_t *
98+
(*swiftscan_swift_textual_detail_get_compiled_module_candidates)(swiftscan_module_details_t);
99+
swiftscan_string_ref_t
100+
(*swiftscan_swift_textual_detail_get_bridging_header_path)(swiftscan_module_details_t);
101+
swiftscan_string_set_t *
102+
(*swiftscan_swift_textual_detail_get_bridging_source_files)(swiftscan_module_details_t);
103+
swiftscan_string_set_t *
104+
(*swiftscan_swift_textual_detail_get_bridging_module_dependencies)(swiftscan_module_details_t);
105+
swiftscan_string_set_t *
106+
(*swiftscan_swift_textual_detail_get_command_line)(swiftscan_module_details_t);
107+
swiftscan_string_set_t *
108+
(*swiftscan_swift_textual_detail_get_extra_pcm_args)(swiftscan_module_details_t);
109+
swiftscan_string_ref_t
110+
(*swiftscan_swift_textual_detail_get_context_hash)(swiftscan_module_details_t);
111+
bool
112+
(*swiftscan_swift_textual_detail_get_is_framework)(swiftscan_module_details_t);
113+
114+
//=== Swift Binary Module Details query APIs ------------------------------===//
115+
swiftscan_string_ref_t
116+
(*swiftscan_swift_binary_detail_get_compiled_module_path)(swiftscan_module_details_t);
117+
swiftscan_string_ref_t
118+
(*swiftscan_swift_binary_detail_get_module_doc_path)(swiftscan_module_details_t);
119+
swiftscan_string_ref_t
120+
(*swiftscan_swift_binary_detail_get_module_source_info_path)(swiftscan_module_details_t);
121+
122+
//=== Swift Placeholder Module Details query APIs -------------------------===//
123+
swiftscan_string_ref_t
124+
(*swiftscan_swift_placeholder_detail_get_compiled_module_path)(swiftscan_module_details_t);
125+
swiftscan_string_ref_t
126+
(*swiftscan_swift_placeholder_detail_get_module_doc_path)(swiftscan_module_details_t);
127+
swiftscan_string_ref_t
128+
(*swiftscan_swift_placeholder_detail_get_module_source_info_path)(swiftscan_module_details_t);
129+
130+
//=== Clang Module Details query APIs -------------------------------------===//
131+
swiftscan_string_ref_t
132+
(*swiftscan_clang_detail_get_module_map_path)(swiftscan_module_details_t);
133+
swiftscan_string_ref_t
134+
(*swiftscan_clang_detail_get_context_hash)(swiftscan_module_details_t);
135+
swiftscan_string_set_t *
136+
(*swiftscan_clang_detail_get_command_line)(swiftscan_module_details_t);
137+
138+
//=== Batch Scan Input Functions ------------------------------------------===//
139+
swiftscan_batch_scan_input_t *
140+
(*swiftscan_batch_scan_input_create)(void);
141+
void
142+
(*swiftscan_batch_scan_input_set_modules)(swiftscan_batch_scan_input_t *, int, swiftscan_batch_scan_entry_t *);
143+
144+
//=== Batch Scan Entry Functions ------------------------------------------===//
145+
swiftscan_batch_scan_entry_t
146+
(*swiftscan_batch_scan_entry_create)(void);
147+
void
148+
(*swiftscan_batch_scan_entry_set_module_name)(swiftscan_batch_scan_entry_t, const char *);
149+
void
150+
(*swiftscan_batch_scan_entry_set_arguments)(swiftscan_batch_scan_entry_t, const char *);
151+
void
152+
(*swiftscan_batch_scan_entry_set_is_swift)(swiftscan_batch_scan_entry_t, bool);
153+
swiftscan_string_ref_t
154+
(*swiftscan_batch_scan_entry_get_module_name)(swiftscan_batch_scan_entry_t);
155+
swiftscan_string_ref_t
156+
(*swiftscan_batch_scan_entry_get_arguments)(swiftscan_batch_scan_entry_t);
157+
bool
158+
(*swiftscan_batch_scan_entry_get_is_swift)(swiftscan_batch_scan_entry_t);
159+
160+
//=== Prescan Result Functions --------------------------------------------===//
161+
swiftscan_string_set_t *
162+
(*swiftscan_import_set_get_imports)(swiftscan_import_set_t);
163+
164+
//=== Scanner Invocation Functions ----------------------------------------===//
165+
swiftscan_scan_invocation_t
166+
(*swiftscan_scan_invocation_create)();
167+
void
168+
(*swiftscan_scan_invocation_set_working_directory)(swiftscan_scan_invocation_t, const char *);
169+
void
170+
(*swiftscan_scan_invocation_set_argv)(swiftscan_scan_invocation_t, int, const char **);
171+
swiftscan_string_ref_t
172+
(*swiftscan_scan_invocation_get_working_directory)(swiftscan_scan_invocation_t);
173+
int
174+
(*swiftscan_scan_invocation_get_argc)(swiftscan_scan_invocation_t);
175+
swiftscan_string_set_t *
176+
(*swiftscan_scan_invocation_get_argv)(swiftscan_scan_invocation_t);
177+
178+
//=== Cleanup Functions ---------------------------------------------------===//
179+
void
180+
(*swiftscan_string_set_dispose)(swiftscan_string_set_t *);
181+
void
182+
(*swiftscan_dependency_graph_dispose)(swiftscan_dependency_graph_t);
183+
void
184+
(*swiftscan_import_set_dispose)(swiftscan_import_set_t);
185+
void
186+
(*swiftscan_batch_scan_entry_dispose)(swiftscan_batch_scan_entry_t);
187+
void
188+
(*swiftscan_batch_scan_input_dispose)(swiftscan_batch_scan_input_t *);
189+
void
190+
(*swiftscan_batch_scan_result_dispose)(swiftscan_batch_scan_result_t *);
191+
void
192+
(*swiftscan_scan_invocation_dispose)(swiftscan_scan_invocation_t);
193+
194+
//=== Functionality Query Functions ---------------------------------------===//
195+
swiftscan_string_set_t *
196+
(*swiftscan_compiler_supported_arguments_query)(void);
197+
swiftscan_string_set_t *
198+
(*swiftscan_compiler_supported_features_query)(void);
199+
200+
//=== Scanner Functions ---------------------------------------------------===//
201+
swiftscan_scanner_t (*swiftscan_scanner_create)(void);
202+
void (*swiftscan_scanner_dispose)(swiftscan_scanner_t);
203+
204+
swiftscan_dependency_graph_t
205+
(*swiftscan_dependency_graph_create)(swiftscan_scanner_t, swiftscan_scan_invocation_t);
206+
207+
swiftscan_batch_scan_result_t *
208+
(*swiftscan_batch_scan_result_create)(swiftscan_scanner_t,
209+
swiftscan_batch_scan_input_t *,
210+
swiftscan_scan_invocation_t);
211+
212+
swiftscan_import_set_t
213+
(*swiftscan_import_set_create)(swiftscan_scanner_t, swiftscan_scan_invocation_t);
214+
} swiftscan_functions_t;
215+
216+
#endif // SWIFT_C_DEPENDENCY_SCAN_H

Sources/SwiftDriver/CMakeLists.txt

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
add_library(SwiftDriver
10-
"Explicit Module Builds/ClangModuleBuildJobCache.swift"
11-
"Explicit Module Builds/ClangVersionedDependencyResolution.swift"
12-
"Explicit Module Builds/ExplicitDependencyBuildPlanner.swift"
13-
"Explicit Module Builds/ModuleDependencyScanning.swift"
14-
"Explicit Module Builds/PlaceholderDependencyResolution.swift"
15-
"Explicit Module Builds/SerializableModuleArtifacts.swift"
16-
"Explicit Module Builds/Inter Module Dependencies/CommonDependencyOperations.swift"
17-
"Explicit Module Builds/Inter Module Dependencies/InterModuleDependencyGraph.swift"
18-
"Explicit Module Builds/Inter Module Dependencies/InterModuleDependencyOracle.swift"
10+
"ExplicitModuleBuilds/ClangVersionedDependencyResolution.swift"
11+
"ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift"
12+
"ExplicitModuleBuilds/ModuleDependencyScanning.swift"
13+
"ExplicitModuleBuilds/PlaceholderDependencyResolution.swift"
14+
"ExplicitModuleBuilds/SerializableModuleArtifacts.swift"
15+
"ExplicitModuleBuilds/InterModuleDependencies/CommonDependencyOperations.swift"
16+
"ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyGraph.swift"
17+
"ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyOracle.swift"
18+
19+
SwiftScan/DependencyGraphBuilder.swift
20+
SwiftScan/SwiftScan.swift
1921

2022
Driver/CompilerMode.swift
2123
Driver/DebugInfo.swift
@@ -31,29 +33,34 @@ add_library(SwiftDriver
3133
Execution/ParsableOutput.swift
3234
Execution/ProcessProtocol.swift
3335

34-
"Incremental Compilation/ModuleDependencyGraph Parts/Integrator.swift"
35-
"Incremental Compilation/ModuleDependencyGraph Parts/Node.swift"
36-
"Incremental Compilation/ModuleDependencyGraph Parts/NodeFinder.swift"
37-
"Incremental Compilation/ModuleDependencyGraph Parts/SwiftDeps.swift"
38-
"Incremental Compilation/ModuleDependencyGraph Parts/Tracer.swift"
39-
"Incremental Compilation/BidirectionalMap.swift"
40-
"Incremental Compilation/BuildRecord.swift"
41-
"Incremental Compilation/BuildRecordInfo.swift"
42-
"Incremental Compilation/DependencyKey.swift"
43-
"Incremental Compilation/DictionaryOfDictionaries.swift"
44-
"Incremental Compilation/IncrementalCompilationState.swift"
45-
"Incremental Compilation/InputInfo.swift"
46-
"Incremental Compilation/ModuleDependencyGraph.swift"
47-
"Incremental Compilation/Multidictionary.swift"
48-
"Incremental Compilation/SourceFileDependencyGraph.swift"
49-
"Incremental Compilation/TwoDMap.swift"
36+
"IncrementalCompilation/ModuleDependencyGraphParts/Integrator.swift"
37+
"IncrementalCompilation/ModuleDependencyGraphParts/Node.swift"
38+
"IncrementalCompilation/ModuleDependencyGraphParts/NodeFinder.swift"
39+
"IncrementalCompilation/ModuleDependencyGraphParts/DependencySource.swift"
40+
"IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift"
41+
"IncrementalCompilation/BidirectionalMap.swift"
42+
"IncrementalCompilation/BuildRecord.swift"
43+
"IncrementalCompilation/BuildRecordInfo.swift"
44+
"IncrementalCompilation/DependencyGraphDotFileWriter.swift"
45+
"IncrementalCompilation/DependencyKey.swift"
46+
"IncrementalCompilation/DictionaryOfDictionaries.swift"
47+
"IncrementalCompilation/ExternalDependencyAndFingerprintEnforcer.swift"
48+
"IncrementalCompilation/IncrementalCompilationState.swift"
49+
"IncrementalCompilation/InitialStateComputer.swift"
50+
"IncrementalCompilation/InputInfo.swift"
51+
"IncrementalCompilation/KeyAndFingerprintHolder.swift"
52+
"IncrementalCompilation/ModuleDependencyGraph.swift"
53+
"IncrementalCompilation/Multidictionary.swift"
54+
"IncrementalCompilation/SourceFileDependencyGraph.swift"
55+
"IncrementalCompilation/TwoDMap.swift"
5056

5157
Jobs/AutolinkExtractJob.swift
5258
Jobs/BackendJob.swift
5359
Jobs/CommandLineArguments.swift
5460
Jobs/CompileJob.swift
5561
Jobs/DarwinToolchain+LinkerSupport.swift
5662
Jobs/EmitModuleJob.swift
63+
Jobs/EmitSupportedFeaturesJob.swift
5764
Jobs/FrontendJobHelpers.swift
5865
Jobs/GenerateDSYMJob.swift
5966
Jobs/GeneratePCHJob.swift
@@ -103,7 +110,7 @@ target_link_libraries(SwiftDriver PUBLIC
103110
target_link_libraries(SwiftDriver PRIVATE
104111
CYaml
105112
Yams
106-
CSwiftDriver)
113+
CSwiftScan)
107114

108115
set_property(GLOBAL APPEND PROPERTY SWIFTDRIVER_EXPORTS SwiftDriver)
109116

0 commit comments

Comments
 (0)