mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #18083 from CodaFi/system-of-a-down
Add -track-system-dependencies Flag
This commit is contained in:
@@ -44,7 +44,7 @@ class DependencyTracker {
|
|||||||
std::shared_ptr<clang::DependencyCollector> clangCollector;
|
std::shared_ptr<clang::DependencyCollector> clangCollector;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DependencyTracker();
|
explicit DependencyTracker(bool TrackSystemDeps);
|
||||||
|
|
||||||
/// Adds a file as a dependency.
|
/// Adds a file as a dependency.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
/// \brief Create a new clang::DependencyCollector customized to
|
/// \brief Create a new clang::DependencyCollector customized to
|
||||||
/// ClangImporter's specific uses.
|
/// ClangImporter's specific uses.
|
||||||
static std::shared_ptr<clang::DependencyCollector>
|
static std::shared_ptr<clang::DependencyCollector>
|
||||||
createDependencyCollector();
|
createDependencyCollector(bool TrackSystemDeps);
|
||||||
|
|
||||||
/// \brief Check whether the module with a given name can be imported without
|
/// \brief Check whether the module with a given name can be imported without
|
||||||
/// importing it.
|
/// importing it.
|
||||||
|
|||||||
@@ -421,9 +421,9 @@ public:
|
|||||||
Diagnostics.addConsumer(*DC);
|
Diagnostics.addConsumer(*DC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createDependencyTracker() {
|
void createDependencyTracker(bool TrackSystemDeps) {
|
||||||
assert(!Context && "must be called before setup()");
|
assert(!Context && "must be called before setup()");
|
||||||
DepTracker = llvm::make_unique<DependencyTracker>();
|
DepTracker = llvm::make_unique<DependencyTracker>(TrackSystemDeps);
|
||||||
}
|
}
|
||||||
DependencyTracker *getDependencyTracker() { return DepTracker.get(); }
|
DependencyTracker *getDependencyTracker() { return DepTracker.get(); }
|
||||||
|
|
||||||
|
|||||||
@@ -243,6 +243,10 @@ public:
|
|||||||
/// variables by name when we print it out. This eases diffing of SIL files.
|
/// variables by name when we print it out. This eases diffing of SIL files.
|
||||||
bool EmitSortedSIL = false;
|
bool EmitSortedSIL = false;
|
||||||
|
|
||||||
|
/// Indices whether the dependency tracker should track system
|
||||||
|
/// dependencies as well.
|
||||||
|
bool TrackSystemDeps = false;
|
||||||
|
|
||||||
/// The different modes for validating TBD against the LLVM IR.
|
/// The different modes for validating TBD against the LLVM IR.
|
||||||
enum class TBDValidationMode {
|
enum class TBDValidationMode {
|
||||||
Default, ///< Do the default validation for the current platform.
|
Default, ///< Do the default validation for the current platform.
|
||||||
|
|||||||
@@ -232,6 +232,9 @@ def profile_stats_entities: Flag<["-"], "profile-stats-entities">,
|
|||||||
def emit_dependencies : Flag<["-"], "emit-dependencies">,
|
def emit_dependencies : Flag<["-"], "emit-dependencies">,
|
||||||
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
|
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
|
||||||
HelpText<"Emit basic Make-compatible dependencies files">;
|
HelpText<"Emit basic Make-compatible dependencies files">;
|
||||||
|
def track_system_dependencies : Flag<["-"], "track-system-dependencies">,
|
||||||
|
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>,
|
||||||
|
HelpText<"Track system dependencies while emitting Make-style dependencies">;
|
||||||
|
|
||||||
def emit_loaded_module_trace : Flag<["-"], "emit-loaded-module-trace">,
|
def emit_loaded_module_trace : Flag<["-"], "emit-loaded-module-trace">,
|
||||||
Flags<[FrontendOption, NoInteractiveOption]>,
|
Flags<[FrontendOption, NoInteractiveOption]>,
|
||||||
|
|||||||
@@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
namespace swift {
|
namespace swift {
|
||||||
|
|
||||||
DependencyTracker::DependencyTracker()
|
DependencyTracker::DependencyTracker(bool TrackSystemDeps)
|
||||||
// NB: The ClangImporter believes it's responsible for the construction of
|
// NB: The ClangImporter believes it's responsible for the construction of
|
||||||
// this instance, and it static_cast<>s the instance pointer to its own
|
// this instance, and it static_cast<>s the instance pointer to its own
|
||||||
// subclass based on that belief. If you change this to be some other
|
// subclass based on that belief. If you change this to be some other
|
||||||
// instance, you will need to change ClangImporter's code to handle the
|
// instance, you will need to change ClangImporter's code to handle the
|
||||||
// difference.
|
// difference.
|
||||||
: clangCollector(ClangImporter::createDependencyCollector())
|
: clangCollector(ClangImporter::createDependencyCollector(TrackSystemDeps))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -318,8 +318,11 @@ private:
|
|||||||
class ClangImporterDependencyCollector : public clang::DependencyCollector
|
class ClangImporterDependencyCollector : public clang::DependencyCollector
|
||||||
{
|
{
|
||||||
llvm::StringSet<> ExcludedPaths;
|
llvm::StringSet<> ExcludedPaths;
|
||||||
|
const bool TrackSystemDeps;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ClangImporterDependencyCollector() = default;
|
ClangImporterDependencyCollector(bool TrackSystemDeps)
|
||||||
|
: TrackSystemDeps(TrackSystemDeps) {}
|
||||||
|
|
||||||
void excludePath(StringRef filename) {
|
void excludePath(StringRef filename) {
|
||||||
ExcludedPaths.insert(filename);
|
ExcludedPaths.insert(filename);
|
||||||
@@ -331,9 +334,7 @@ public:
|
|||||||
|| Filename == ImporterImpl::bridgingHeaderBufferName);
|
|| Filename == ImporterImpl::bridgingHeaderBufferName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently preserving older ClangImporter behavior of ignoring system
|
bool needSystemDependencies() override { return TrackSystemDeps; }
|
||||||
// dependencies, but possibly revisit?
|
|
||||||
bool needSystemDependencies() override { return false; }
|
|
||||||
|
|
||||||
bool sawDependency(StringRef Filename, bool FromClangModule,
|
bool sawDependency(StringRef Filename, bool FromClangModule,
|
||||||
bool IsSystem, bool IsClangModuleFile,
|
bool IsSystem, bool IsClangModuleFile,
|
||||||
@@ -354,9 +355,9 @@ public:
|
|||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
std::shared_ptr<clang::DependencyCollector>
|
std::shared_ptr<clang::DependencyCollector>
|
||||||
ClangImporter::createDependencyCollector()
|
ClangImporter::createDependencyCollector(bool TrackSystemDeps)
|
||||||
{
|
{
|
||||||
return std::make_shared<ClangImporterDependencyCollector>();
|
return std::make_shared<ClangImporterDependencyCollector>(TrackSystemDeps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangImporter::Implementation::addBridgeHeaderTopLevelDecls(
|
void ClangImporter::Implementation::addBridgeHeaderTopLevelDecls(
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ bool ArgsToFrontendOptionsConverter::convert(
|
|||||||
Opts.EnableTesting |= Args.hasArg(OPT_enable_testing);
|
Opts.EnableTesting |= Args.hasArg(OPT_enable_testing);
|
||||||
Opts.EnableResilience |= Args.hasArg(OPT_enable_resilience);
|
Opts.EnableResilience |= Args.hasArg(OPT_enable_resilience);
|
||||||
|
|
||||||
|
Opts.TrackSystemDeps |= Args.hasArg(OPT_track_system_dependencies);
|
||||||
|
|
||||||
computePrintStatsOptions();
|
computePrintStatsOptions();
|
||||||
computeDebugTimeOptions();
|
computeDebugTimeOptions();
|
||||||
computeTBDOptions();
|
computeTBDOptions();
|
||||||
|
|||||||
@@ -1806,7 +1806,7 @@ int swift::performFrontend(ArrayRef<const char *> Args,
|
|||||||
if (Invocation.getFrontendOptions()
|
if (Invocation.getFrontendOptions()
|
||||||
.InputsAndOutputs.hasDependencyTrackerPath() ||
|
.InputsAndOutputs.hasDependencyTrackerPath() ||
|
||||||
!Invocation.getFrontendOptions().IndexStorePath.empty())
|
!Invocation.getFrontendOptions().IndexStorePath.empty())
|
||||||
Instance->createDependencyTracker();
|
Instance->createDependencyTracker(Invocation.getFrontendOptions().TrackSystemDeps);
|
||||||
|
|
||||||
if (Instance->setup(Invocation)) {
|
if (Instance->setup(Invocation)) {
|
||||||
return finishDiagProcessing(1);
|
return finishDiagProcessing(1);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
// CHECK-MULTIPLE-OUTPUTS-NOT: :
|
// CHECK-MULTIPLE-OUTPUTS-NOT: :
|
||||||
|
|
||||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/dependencies/extra-header.h -emit-dependencies-path - -resolve-imports %s | %FileCheck -check-prefix=CHECK-IMPORT %s
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/dependencies/extra-header.h -emit-dependencies-path - -resolve-imports %s | %FileCheck -check-prefix=CHECK-IMPORT %s
|
||||||
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/dependencies/extra-header.h -track-system-dependencies -emit-dependencies-path - -resolve-imports %s | %FileCheck -check-prefix=CHECK-IMPORT-TRACK-SYSTEM %s
|
||||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/dependencies/extra-header.h -emit-reference-dependencies-path - -typecheck -primary-file %s | %FileCheck -check-prefix=CHECK-IMPORT-YAML %s
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/dependencies/extra-header.h -emit-reference-dependencies-path - -typecheck -primary-file %s | %FileCheck -check-prefix=CHECK-IMPORT-YAML %s
|
||||||
|
|
||||||
// CHECK-IMPORT-LABEL: - :
|
// CHECK-IMPORT-LABEL: - :
|
||||||
@@ -53,6 +54,27 @@
|
|||||||
// CHECK-IMPORT-DAG: CoreGraphics.swift
|
// CHECK-IMPORT-DAG: CoreGraphics.swift
|
||||||
// CHECK-IMPORT-NOT: :
|
// CHECK-IMPORT-NOT: :
|
||||||
|
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-LABEL: - :
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM: dependencies.swift
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: CoreFoundation.swift
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: CoreGraphics.swift
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: Foundation.swift
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: ObjectiveC.swift
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: Inputs/dependencies/$$$$$$$$$$.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: Inputs/dependencies/UserClangModule.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: Inputs/dependencies/extra-header.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: Inputs/dependencies/module.modulemap
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: swift/shims/module.modulemap
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/CoreFoundation.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/CoreGraphics.apinotes
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/CoreGraphics.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/Foundation.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/objc/NSObject.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/objc/ObjectiveC.apinotes
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/objc/module.map
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-DAG: usr/include/objc/objc.h
|
||||||
|
// CHECK-IMPORT-TRACK-SYSTEM-NOT: :
|
||||||
|
|
||||||
// CHECK-IMPORT-YAML-LABEL: depends-external:
|
// CHECK-IMPORT-YAML-LABEL: depends-external:
|
||||||
// CHECK-IMPORT-YAML-NOT: dependencies.swift
|
// CHECK-IMPORT-YAML-NOT: dependencies.swift
|
||||||
// CHECK-IMPORT-YAML-DAG: "{{.*}}/Swift.swiftmodule"
|
// CHECK-IMPORT-YAML-DAG: "{{.*}}/Swift.swiftmodule"
|
||||||
|
|||||||
Reference in New Issue
Block a user