|
| 1 | +// REQUIRES: objc_interop |
| 2 | +// RUN: %empty-directory(%t) |
| 3 | +// RUN: split-file %s %t |
| 4 | + |
| 5 | +// RUN: %target-swift-frontend -scan-dependencies -module-name Test %t/main.swift -module-cache-path %t/clang-module-cache \ |
| 6 | +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -O \ |
| 7 | +// RUN: -o %t/deps-1.json -I %t/include |
| 8 | + |
| 9 | +// RUN: %target-swift-frontend -scan-dependencies -module-name Test %t/main.swift -module-cache-path %t/clang-module-cache \ |
| 10 | +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -O \ |
| 11 | +// RUN: -o %t/deps-2.json -Xcc -DHAS_FOO=1 -I %t/include |
| 12 | + |
| 13 | +// RUN: %target-swift-frontend -scan-dependencies -module-name Test %t/main.swift -module-cache-path %t/clang-module-cache \ |
| 14 | +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -O \ |
| 15 | +// RUN: -o %t/deps-3.json -Xcc -fapplication-extension -I %t/include |
| 16 | + |
| 17 | +/// Check module hash for the swiftmodule. 1 and 2 should match, but not 3. |
| 18 | +// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-1.json Library modulePath > %t/path-1 |
| 19 | +// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-2.json Library modulePath > %t/path-2 |
| 20 | +// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-3.json Library modulePath > %t/path-3 |
| 21 | +// RUN: diff %t/path-1 %t/path-2 |
| 22 | +// RUN: not diff %t/path-1 %t/path-3 |
| 23 | + |
| 24 | +/// Check build command (exclude dependency module file path). 1 and 2 should match, but not 3. |
| 25 | +// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-1.json Library | grep -v fmodule-file= > %t/lib-1.cmd |
| 26 | +// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-2.json Library | grep -v fmodule-file= > %t/lib-2.cmd |
| 27 | +// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-3.json Library | grep -v fmodule-file= > %t/lib-3.cmd |
| 28 | +// RUN: diff %t/lib-1.cmd %t/lib-2.cmd |
| 29 | +// RUN: not diff %t/lib-1.cmd %t/lib-3.cmd |
| 30 | + |
| 31 | +/// Test direct-cc1 mode. |
| 32 | +// RUN: %target-swift-frontend -scan-dependencies -module-name Test %t/main.swift -module-cache-path %t/clang-module-cache \ |
| 33 | +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -O \ |
| 34 | +// RUN: -o %t/deps-4.json -I %t/include -experimental-clang-importer-direct-cc1-scan |
| 35 | +// RUN: %target-swift-frontend -scan-dependencies -module-name Test %t/main.swift -module-cache-path %t/clang-module-cache \ |
| 36 | +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -O \ |
| 37 | +// RUN: -o %t/deps-5.json -Xcc -DHAS_FOO=1 -I %t/include -experimental-clang-importer-direct-cc1-scan |
| 38 | +// RUN: %target-swift-frontend -scan-dependencies -module-name Test %t/main.swift -module-cache-path %t/clang-module-cache \ |
| 39 | +// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -O \ |
| 40 | +// RUN: -o %t/deps-6.json -Xcc -fapplication-extension -I %t/include -experimental-clang-importer-direct-cc1-scan |
| 41 | + |
| 42 | +// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-4.json Library modulePath > %t/path-4 |
| 43 | +// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-5.json Library modulePath > %t/path-5 |
| 44 | +// RUN: %{python} %S/../CAS/Inputs/SwiftDepsExtractor.py %t/deps-6.json Library modulePath > %t/path-6 |
| 45 | +// RUN: diff %t/path-4 %t/path-5 |
| 46 | +// RUN: not diff %t/path-4 %t/path-6 |
| 47 | +// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-4.json Library | grep -v fmodule-file= > %t/lib-4.cmd |
| 48 | +// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-5.json Library | grep -v fmodule-file= > %t/lib-5.cmd |
| 49 | +// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps-6.json Library | grep -v fmodule-file= > %t/lib-6.cmd |
| 50 | +// RUN: diff %t/lib-4.cmd %t/lib-5.cmd |
| 51 | +// RUN: not diff %t/lib-4.cmd %t/lib-6.cmd |
| 52 | + |
| 53 | +//--- main.swift |
| 54 | +import Library |
| 55 | + |
| 56 | +//--- include/Library.swiftinterface |
| 57 | +// swift-interface-format-version: 1.0 |
| 58 | +// swift-module-flags: -module-name Library -O -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -user-module-version 1.0 |
| 59 | +import Swift |
| 60 | +@_exported import A |
| 61 | +public func test() {} |
| 62 | + |
| 63 | +//--- include/a.h |
| 64 | +#ifdef HAS_FOO |
| 65 | +void foo(void); |
| 66 | +#endif |
| 67 | +void bar(void); |
| 68 | + |
| 69 | +//--- include/module.modulemap |
| 70 | +module A { |
| 71 | + header "a.h" |
| 72 | + export * |
| 73 | +} |
0 commit comments