Skip to content

[6.0][ScanDependency] Respect working directory set inside invocation #74950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions include/swift/DependencyScan/DependencyScanJSON.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//===-------------- DependencyScanImpl.h - Swift Compiler -----------------===//
//
// 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 https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Implementation details of the dependency scanning C API
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_DEPENDENCY_SCAN_JSON_H
#define SWIFT_DEPENDENCY_SCAN_JSON_H

#include "swift-c/DependencyScan/DependencyScan.h"
#include "llvm/Support/raw_ostream.h"

namespace swift::dependencies {

void writePrescanJSON(llvm::raw_ostream &out,
swiftscan_import_set_t importSet);
void writeJSON(llvm::raw_ostream &out,
swiftscan_dependency_graph_t fullDependencies);
} // namespace swift::dependencies

#endif // SWIFT_DEPENDENCY_SCAN_JSON_H
14 changes: 9 additions & 5 deletions include/swift/DependencyScan/DependencyScanningTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ class DependencyScanningTool {
/// occurred, \c swiftscan_dependency_result_t otherwise.
llvm::ErrorOr<swiftscan_dependency_graph_t>
getDependencies(ArrayRef<const char *> Command,
const llvm::StringSet<> &PlaceholderModules);
const llvm::StringSet<> &PlaceholderModules,
StringRef WorkingDirectory);

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

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

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

private:
/// Using the specified invocation command, initialize the scanner instance
/// for this scan. Returns the `CompilerInstance` that will be used.
llvm::ErrorOr<ScanQueryInstance>
initScannerForAction(ArrayRef<const char *> Command);
initScannerForAction(ArrayRef<const char *> Command,
StringRef WorkingDirectory);

/// Shared cache of module dependencies, re-used by individual full-scan queries
/// during the lifetime of this Tool.
Expand Down
18 changes: 11 additions & 7 deletions lib/DependencyScan/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@

add_swift_host_library(swiftDependencyScanImpl STATIC
DependencyScanJSON.cpp
StringUtils.cpp)

add_swift_host_library(swiftDependencyScan STATIC
DependencyScanningTool.cpp
ModuleDependencyCacheSerialization.cpp
ModuleDependencyScanner.cpp
ScanDependencies.cpp
StringUtils.cpp)
ModuleDependencyScanner.cpp
ScanDependencies.cpp)

target_link_libraries(swiftDependencyScan INTERFACE
clangBasic)

target_link_libraries(swiftDependencyScan PRIVATE
swiftClangImporter
swiftAST
swiftSerialization)
swiftClangImporter
swiftAST
swiftSerialization)

target_link_libraries(swiftDependencyScan PUBLIC
swiftDependencyScanImpl)
Loading