| 1 |
/// Most likely platform specific sed differences |
| 2 |
// UNSUPPORTED: system-windows |
| 3 |
|
| 4 |
/// This test validates that modules that depend on prebuilt modules |
| 5 |
/// resolve `is-in-stable-directories` correctly. |
| 6 |
/// The steps are: |
| 7 |
/// 1. Scan dependencies to build the PCH. One of the module's depend on header |
| 8 |
/// that is seemingly from the sysroot. However, it depends on a local header that is overlaid. |
| 9 |
/// 2. Build the PCH & dependency PCMs. |
| 10 |
/// 3. Scan a source file that transitively depends on the same modules as the pcm. |
| 11 |
|
| 12 |
// RUN: rm -rf %t |
| 13 |
// RUN: split-file %s %t |
| 14 |
// RUN: sed -e "s|DIR|%/t|g" %t/overlay.json.template > %t/overlay.json |
| 15 |
// RUN: sed -e "s|DIR|%/t|g" %t/compile-pch.json.in > %t/compile-pch.json |
| 16 |
// RUN: clang-scan-deps -compilation-database %t/compile-pch.json \ |
| 17 |
// RUN: -j 1 -format experimental-full > %t/deps_pch.db |
| 18 |
// RUN: %clang -x c-header -c %t/prebuild.h -isysroot %t/MacOSX.sdk \ |
| 19 |
// RUN: -I%t/BuildDir -ivfsoverlay %t/overlay.json \ |
| 20 |
// RUN: -I %t/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=%t/module-cache \ |
| 21 |
// RUN: -fimplicit-module-maps -o %t/prebuild.pch |
| 22 |
// RUN: sed -e "s|DIR|%/t|g" %t/compile-commands.json.in > %t/compile-commands.json |
| 23 |
// RUN: clang-scan-deps -compilation-database %t/compile-commands.json \ |
| 24 |
// RUN: -j 1 -format experimental-full > %t/deps.db |
| 25 |
// RUN: cat %t/deps_pch.db | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefix PCH_DEP |
| 26 |
// RUN: cat %t/deps.db | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefix CLIENT |
| 27 |
|
| 28 |
// PCH_DEP: "is-in-stable-directories": true |
| 29 |
// PCH_DEP: "name": "A" |
| 30 |
|
| 31 |
// PCH_DEP-NOT: "is-in-stable-directories": true |
| 32 |
|
| 33 |
// Verify is-in-stable-directories is only assigned to the module that only depends on A. |
| 34 |
// CLIENT-NOT: "is-in-stable-directories": true |
| 35 |
|
| 36 |
// CLIENT: "name": "D" |
| 37 |
// CLIENT: "is-in-stable-directories": true |
| 38 |
// CLIENT: "name": "sys" |
| 39 |
|
| 40 |
// CLIENT-NOT: "is-in-stable-directories": true |
| 41 |
|
| 42 |
//--- compile-pch.json.in |
| 43 |
[ |
| 44 |
{ |
| 45 |
"directory": "DIR", |
| 46 |
"command": "clang -x c-header -c DIR/prebuild.h -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -o DIR/prebuild.pch", |
| 47 |
"file": "DIR/prebuild.h" |
| 48 |
} |
| 49 |
] |
| 50 |
|
| 51 |
//--- compile-commands.json.in |
| 52 |
[ |
| 53 |
{ |
| 54 |
"directory": "DIR", |
| 55 |
"command": "clang -c DIR/client.c -isysroot DIR/MacOSX.sdk -IDIR/BuildDir -ivfsoverlay DIR/overlay.json -IDIR/MacOSX.sdk/usr/include -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -include-pch DIR/prebuild.pch", |
| 56 |
"file": "DIR/client.c" |
| 57 |
} |
| 58 |
] |
| 59 |
|
| 60 |
//--- overlay.json.template |
| 61 |
{ |
| 62 |
"version": 0, |
| 63 |
"case-sensitive": "false", |
| 64 |
"roots": [ |
| 65 |
{ |
| 66 |
"external-contents": "DIR/BuildDir/B_vfs.h", |
| 67 |
"name": "DIR/MacOSX.sdk/usr/include/B/B_vfs.h", |
| 68 |
"type": "file" |
| 69 |
} |
| 70 |
] |
| 71 |
} |
| 72 |
|
| 73 |
//--- MacOSX.sdk/usr/include/A/module.modulemap |
| 74 |
module A [system] { |
| 75 |
umbrella "." |
| 76 |
} |
| 77 |
|
| 78 |
//--- MacOSX.sdk/usr/include/A/A.h |
| 79 |
typedef int A_type; |
| 80 |
|
| 81 |
//--- MacOSX.sdk/usr/include/B/module.modulemap |
| 82 |
module B [system] { |
| 83 |
umbrella "." |
| 84 |
} |
| 85 |
|
| 86 |
//--- MacOSX.sdk/usr/include/B/B.h |
| 87 |
#include <B/B_vfs.h> |
| 88 |
|
| 89 |
//--- BuildDir/B_vfs.h |
| 90 |
typedef int local_t; |
| 91 |
|
| 92 |
//--- MacOSX.sdk/usr/include/sys/sys.h |
| 93 |
#include <A/A.h> |
| 94 |
typedef int sys_t_m; |
| 95 |
|
| 96 |
//--- MacOSX.sdk/usr/include/sys/module.modulemap |
| 97 |
module sys [system] { |
| 98 |
umbrella "." |
| 99 |
} |
| 100 |
|
| 101 |
//--- MacOSX.sdk/usr/include/B_transitive/B.h |
| 102 |
#include <B/B.h> |
| 103 |
|
| 104 |
//--- MacOSX.sdk/usr/include/B_transitive/module.modulemap |
| 105 |
module B_transitive [system] { |
| 106 |
umbrella "." |
| 107 |
} |
| 108 |
|
| 109 |
//--- MacOSX.sdk/usr/include/C/module.modulemap |
| 110 |
module C [system] { |
| 111 |
umbrella "." |
| 112 |
} |
| 113 |
|
| 114 |
//--- MacOSX.sdk/usr/include/C/C.h |
| 115 |
#include <B_transitive/B.h> |
| 116 |
|
| 117 |
|
| 118 |
//--- MacOSX.sdk/usr/include/D/module.modulemap |
| 119 |
module D [system] { |
| 120 |
umbrella "." |
| 121 |
} |
| 122 |
|
| 123 |
//--- MacOSX.sdk/usr/include/D/D.h |
| 124 |
#include <C/C.h> |
| 125 |
|
| 126 |
//--- prebuild.h |
| 127 |
#include <A/A.h> |
| 128 |
#include <C/C.h> // This dependency transitively depends on a local header. |
| 129 |
|
| 130 |
//--- client.c |
| 131 |
#include <sys/sys.h> |
| 132 |
#include <D/D.h> // This dependency transitively depends on a local header. |