Skip to content

Commit 8b55078

Browse files
Merge pull request #73500 from cachemeifyoucan/eng/PR-127626011
[ScanDependency] Respect working directory set inside invocation
2 parents be1f461 + 47598bb commit 8b55078

File tree

11 files changed

+723
-568
lines changed

11 files changed

+723
-568
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===-------------- DependencyScanImpl.h - Swift Compiler -----------------===//
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+
// Implementation details of the dependency scanning C API
14+
//
15+
//===----------------------------------------------------------------------===//
16+
#ifndef SWIFT_DEPENDENCY_SCAN_JSON_H
17+
#define SWIFT_DEPENDENCY_SCAN_JSON_H
18+
19+
#include "swift-c/DependencyScan/DependencyScan.h"
20+
#include "llvm/Support/raw_ostream.h"
21+
22+
namespace swift::dependencies {
23+
24+
void writePrescanJSON(llvm::raw_ostream &out,
25+
swiftscan_import_set_t importSet);
26+
void writeJSON(llvm::raw_ostream &out,
27+
swiftscan_dependency_graph_t fullDependencies);
28+
} // namespace swift::dependencies
29+
30+
#endif // SWIFT_DEPENDENCY_SCAN_JSON_H

include/swift/DependencyScan/DependencyScanningTool.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,15 @@ class DependencyScanningTool {
8787
/// occurred, \c swiftscan_dependency_result_t otherwise.
8888
llvm::ErrorOr<swiftscan_dependency_graph_t>
8989
getDependencies(ArrayRef<const char *> Command,
90-
const llvm::StringSet<> &PlaceholderModules);
90+
const llvm::StringSet<> &PlaceholderModules,
91+
StringRef WorkingDirectory);
9192

9293
/// Collect the set of imports for the input module
9394
///
9495
/// \returns a \c StringError with the diagnostic output if errors
9596
/// occurred, \c swiftscan_prescan_result_t otherwise.
9697
llvm::ErrorOr<swiftscan_import_set_t>
97-
getImports(ArrayRef<const char *> Command);
98+
getImports(ArrayRef<const char *> Command, StringRef WorkingDirectory);
9899

99100
/// Collect the full module dependency graph for the input collection of
100101
/// module names (batch inputs) and output them to the
@@ -104,7 +105,8 @@ class DependencyScanningTool {
104105
std::vector<llvm::ErrorOr<swiftscan_dependency_graph_t>>
105106
getDependencies(ArrayRef<const char *> Command,
106107
const std::vector<BatchScanInput> &BatchInput,
107-
const llvm::StringSet<> &PlaceholderModules);
108+
const llvm::StringSet<> &PlaceholderModules,
109+
StringRef WorkingDirectory);
108110

109111
/// Writes the current `SharedCache` instance to a specified FileSystem path.
110112
void serializeCache(llvm::StringRef path);
@@ -121,13 +123,15 @@ class DependencyScanningTool {
121123
/// Using the specified invocation command, instantiate a CompilerInstance
122124
/// that will be used for this scan.
123125
llvm::ErrorOr<ScanQueryInstance>
124-
initCompilerInstanceForScan(ArrayRef<const char *> Command);
126+
initCompilerInstanceForScan(ArrayRef<const char *> Command,
127+
StringRef WorkingDirectory);
125128

126129
private:
127130
/// Using the specified invocation command, initialize the scanner instance
128131
/// for this scan. Returns the `CompilerInstance` that will be used.
129132
llvm::ErrorOr<ScanQueryInstance>
130-
initScannerForAction(ArrayRef<const char *> Command);
133+
initScannerForAction(ArrayRef<const char *> Command,
134+
StringRef WorkingDirectory);
131135

132136
/// Shared cache of module dependencies, re-used by individual full-scan queries
133137
/// during the lifetime of this Tool.

lib/DependencyScan/CMakeLists.txt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
1+
add_swift_host_library(swiftDependencyScanImpl STATIC
2+
DependencyScanJSON.cpp
3+
StringUtils.cpp)
24

35
add_swift_host_library(swiftDependencyScan STATIC
46
DependencyScanningTool.cpp
57
ModuleDependencyCacheSerialization.cpp
6-
ModuleDependencyScanner.cpp
7-
ScanDependencies.cpp
8-
StringUtils.cpp)
8+
ModuleDependencyScanner.cpp
9+
ScanDependencies.cpp)
910

1011
target_link_libraries(swiftDependencyScan INTERFACE
1112
clangBasic)
1213

1314
target_link_libraries(swiftDependencyScan PRIVATE
14-
swiftClangImporter
15-
swiftAST
16-
swiftSerialization)
15+
swiftClangImporter
16+
swiftAST
17+
swiftSerialization)
18+
19+
target_link_libraries(swiftDependencyScan PUBLIC
20+
swiftDependencyScanImpl)

0 commit comments

Comments
 (0)