Skip to content

[Dependency Scanner] Batch scanner: extract target triple from the PCMArgs for the batch invocation. #33671

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
merged 1 commit into from
Aug 28, 2020
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
2 changes: 2 additions & 0 deletions lib/ClangImporter/ClangModuleDependencyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ Optional<ModuleDependencies> ClangImporter::getModuleDependencies(
// Reform the Clang importer options.
// FIXME: Just save a reference or copy so we can get this back.
ClangImporterOptions importerOpts;
importerOpts.ExtraArgs = getExtraClangArgs();

// Determine the command-line arguments for dependency scanning.
auto &ctx = Impl.SwiftContext;
Expand Down Expand Up @@ -351,6 +352,7 @@ bool ClangImporter::addBridgingHeaderDependencies(
// Reform the Clang importer options.
// FIXME: Just save a reference or copy so we can get this back.
ClangImporterOptions importerOpts;
importerOpts.ExtraArgs = getExtraClangArgs();

// Retrieve the bridging header.
std::string bridgingHeader = *targetModule.getBridgingHeader();
Expand Down
5 changes: 5 additions & 0 deletions test/ScanDependencies/Inputs/CHeaders/G.h
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
#include "X.h"
#endif

void funcG(void);

1 change: 1 addition & 0 deletions test/ScanDependencies/Inputs/CHeaders/X.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void funcX(void);
5 changes: 5 additions & 0 deletions test/ScanDependencies/Inputs/CHeaders/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ module I {
header "I.h"
export *
}

module X {
header "X.h"
export *
}
49 changes: 49 additions & 0 deletions test/ScanDependencies/batch_module_scan_versioned.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/inputs)
// RUN: %empty-directory(%t/outputs)
// RUN: mkdir -p %t/clang-module-cache

// RUN: echo "[{" > %/t/inputs/input.json
// RUN: echo "\"clangModuleName\": \"G\"," >> %/t/inputs/input.json
// RUN: echo "\"arguments\": \"-Xcc -target -Xcc x86_64-apple-macosx10.9\"," >> %/t/inputs/input.json
// RUN: echo "\"output\": \"%/t/outputs/G_109.pcm.json\"" >> %/t/inputs/input.json
// RUN: echo "}," >> %/t/inputs/input.json
// RUN: echo "{" >> %/t/inputs/input.json
// RUN: echo "\"clangModuleName\": \"G\"," >> %/t/inputs/input.json
// RUN: echo "\"arguments\": \"-Xcc -target -Xcc x86_64-apple-macosx11.0\"," >> %/t/inputs/input.json
// RUN: echo "\"output\": \"%/t/outputs/G_110.pcm.json\"" >> %/t/inputs/input.json
// RUN: echo "}]" >> %/t/inputs/input.json

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -batch-scan-input-file %/t/inputs/input.json

// Check the contents of the JSON output
// RUN: %FileCheck %s -check-prefix=CHECK-PCM109 < %t/outputs/G_109.pcm.json
// RUN: %FileCheck %s -check-prefix=CHECK-PCM110 < %t/outputs/G_110.pcm.json

// CHECK-PCM109: {
// CHECK-PCM109-NEXT: "mainModuleName": "G",
// CHECK-PCM109-NEXT: "modules": [
// CHECK-PCM109-NEXT: {
// CHECK-PCM109-NEXT: "clang": "G"
// CHECK-PCM109-NEXT: },
// CHECK-PCM109-NEXT: {
// CHECK-PCM109-NEXT: "modulePath": "G.pcm",
// CHECK-PCM109: "directDependencies": [
// CHECK-PCM109-NEXT: {
// CHECK-PCM109-NEXT: "clang": "X"
// CHECK-PCM109-NEXT: }
// CHECK-PCM109-NEXT: ],
// CHECK-PCM109: "-I

// CHECK-PCM110: {
// CHECK-PCM110-NEXT: "mainModuleName": "G",
// CHECK-PCM110-NEXT: "modules": [
// CHECK-PCM110-NEXT: {
// CHECK-PCM110-NEXT: "clang": "G"
// CHECK-PCM110-NEXT: },
// CHECK-PCM110-NEXT: {
// CHECK-PCM110-NEXT: "modulePath": "G.pcm",
// CHECK-PCM110: "directDependencies": [
// CHECK-PCM110-NEXT: ],
// CHECK-PCM110-NOT: "clang": "X"
// CHECK-PCM110: "-I
2 changes: 1 addition & 1 deletion test/ScanDependencies/can_import_placeholder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
// RUN: echo "}]" >> %/t/inputs/map.json

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/diagnose_dependency_cycle.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/clang-module-cache

// RUN: not %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules &> %t/out.txt
// RUN: not %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 &> %t/out.txt

// RUN: %FileCheck %s < %t/out.txt

Expand Down
3 changes: 1 addition & 2 deletions test/ScanDependencies/module_deps.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/clang-module-cache
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down Expand Up @@ -105,7 +105,6 @@ import SubE
// CHECK-NEXT: "-only-use-extra-clang-opts"
// CHECK-NEXT: "-Xcc"
// CHECK-NEXT: "clang"
// CHECK: "-fno-implicit-modules"

/// --------Swift module E
// CHECK: "swift": "E"
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/module_deps_clang_only.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/clang-module-cache
// RUN: %target-swift-frontend -scan-clang-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules -module-name C
// RUN: %target-swift-frontend -scan-clang-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -module-name C

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: mkdir -p %t/clang-module-cache
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/module_deps_external.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// RUN: echo "\"isFramework\": false" >> %/t/inputs/map.json
// RUN: echo "}]" >> %/t/inputs/map.json

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -placeholder-dependency-module-map-file %t/inputs/map.json -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/Inputs/CHeaders/Bridging.h -swift-version 4

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/module_deps_private_interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// RUN: cp %t/Foo.swiftinterface %t/Foo.private.swiftinterface

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %t -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %t

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down
2 changes: 1 addition & 1 deletion test/ScanDependencies/module_framework.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -emit-dependencies -emit-dependencies-path %t/deps.d -swift-version 4 -disable-implicit-swift-modules -Xcc -Xclang -Xcc -fno-implicit-modules
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -emit-dependencies -emit-dependencies-path %t/deps.d -swift-version 4 -Xcc -Xclang

// Check the contents of the JSON output
// RUN: %FileCheck %s < %t/deps.json
Expand Down