Skip to content

Commit c52982c

Browse files
committed
Add option to accept external module dependency map as input
With: `-external-dependency-module-map-file`
1 parent 1c1a263 commit c52982c

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -122,6 +122,9 @@ ERROR(error_conflicting_options, none,
122122
ERROR(error_option_not_supported, none,
123123
"'%0' is not supported with '%1'",
124124
(StringRef, StringRef))
125+
ERROR(error_requirement_not_met, none,
126+
"'%0' requires '%1'",
127+
(StringRef, StringRef))
125128

126129
WARNING(warn_ignore_embed_bitcode, none,
127130
"ignoring -embed-bitcode since no object file is being generated", ())

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ ERROR(explicit_swift_module_map_corrupted,none,
266266
"explicit Swift module map from %0 is malformed",
267267
(StringRef))
268268

269+
ERROR(external_dependency_module_map_missing,none,
270+
"cannot open Swift external dependency module map from %0",
271+
(StringRef))
272+
273+
ERROR(external_dependency_module_map_corrupted,none,
274+
"Swift external dependency module map from %0 is malformed",
275+
(StringRef))
276+
269277
REMARK(default_previous_install_name, none,
270278
"default previous install name for %0 is %1", (StringRef, StringRef))
271279

include/swift/AST/SearchPathOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ class SearchPathOptions {
9090

9191
/// A map of explict Swift module information.
9292
std::string ExplicitSwiftModuleMap;
93+
94+
/// A map of external Swift module dependency information.
95+
std::string ExternalDependencyModuleMap;
9396
private:
9497
static StringRef
9598
pathStringFromFrameworkSearchPath(const FrameworkSearchPath &next) {

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ def swift_module_file
224224
def explict_swift_module_map
225225
: Separate<["-"], "explicit-swift-module-map-file">, MetaVarName<"<path>">,
226226
HelpText<"Specify a JSON file containing information of explict Swift modules">;
227+
228+
def external_dependency_module_map
229+
: Separate<["-"], "external-dependency-module-map-file">, MetaVarName<"<path>">,
230+
HelpText<"Specify a JSON file containing information of external Swift module dependencies">;
227231
}
228232

229233

lib/Driver/Driver.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ static void validateProfilingArgs(DiagnosticEngine &diags,
163163
}
164164
}
165165

166+
static void validateDependencyScanningArgs(DiagnosticEngine &diags,
167+
const ArgList &args) {
168+
const Arg *ExternalDependencyMap = args.getLastArg(options::OPT_external_dependency_module_map);
169+
const Arg *ScanDependencies = args.getLastArg(options::OPT_scan_dependencies);
170+
if (ExternalDependencyMap && !ScanDependencies) {
171+
diags.diagnose(SourceLoc(), diag::error_conflicting_options,
172+
"-external-dependency-module-map-file", "-scan-dependencies");
173+
}
174+
}
175+
166176
static void validateDebugInfoArgs(DiagnosticEngine &diags,
167177
const ArgList &args) {
168178
// Check for missing debug option when verifying debug info.
@@ -261,6 +271,7 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &args,
261271
validateBridgingHeaderArgs(diags, args);
262272
validateWarningControlArgs(diags, args);
263273
validateProfilingArgs(diags, args);
274+
validateDependencyScanningArgs(diags, args);
264275
validateDebugInfoArgs(diags, args);
265276
validateCompilationConditionArgs(diags, args);
266277
validateSearchPathArgs(diags, args);

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,8 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts,
905905
for (auto A: Args.filtered(OPT_candidate_module_file)) {
906906
Opts.CandidateCompiledModules.push_back(resolveSearchPath(A->getValue()));
907907
}
908+
if (const Arg *A = Args.getLastArg(OPT_external_dependency_module_map))
909+
Opts.ExternalDependencyModuleMap = A->getValue();
908910

909911
// Opts.RuntimeIncludePath is set by calls to
910912
// setRuntimeIncludePath() or setMainExecutablePath().

0 commit comments

Comments
 (0)