| 1 |
// UNSUPPORTED: system-windows |
| 2 |
// RUN: cd %S |
| 3 |
// RUN: rm -rf %t |
| 4 |
// RUN: mkdir %t |
| 5 |
// RUN: split-file %s %t |
| 6 |
// RUN: cd %t |
| 7 |
// |
| 8 |
// RUN: %hmaptool write a.hmap.json hmap |
| 9 |
// |
| 10 |
// RUN: %clang -Rmodule-build -fmodules -fimplicit-modules -fimplicit-module-maps -fmodule-map-file=module.modulemap -fsyntax-only -I hmap -fmodules-cache-path=%t test.cpp |
| 11 |
// |
| 12 |
// RUN: cd %S |
| 13 |
// RUN: rm -rf %t |
| 14 |
// RUN: mkdir %t |
| 15 |
// RUN: split-file %s %t |
| 16 |
// RUN: cd %t |
| 17 |
// |
| 18 |
// RUN: sed -e "s|OUTPUTS_DIR|%t|g" b.hmap.json > hmap.json |
| 19 |
// RUN: %hmaptool write hmap.json hmap |
| 20 |
// |
| 21 |
// RUN: %clang -Rmodule-build -fmodules -fimplicit-modules -fimplicit-module-maps -fmodule-map-file=module.modulemap -fsyntax-only -I hmap -fmodules-cache-path=%t test.cpp |
| 22 |
|
| 23 |
//--- After/Mapping.h |
| 24 |
#ifdef FOO |
| 25 |
#error foo |
| 26 |
#endif |
| 27 |
|
| 28 |
//--- a.hmap.json |
| 29 |
{ |
| 30 |
"mappings" : |
| 31 |
{ |
| 32 |
"Before/Mapping.h" : "After/Mapping.h", |
| 33 |
"After/Mapping.h" : "After/Mapping.h" |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
//--- b.hmap.json |
| 38 |
{ |
| 39 |
"mappings" : |
| 40 |
{ |
| 41 |
"Before/Mapping.h" : "OUTPUTS_DIR/After/Mapping.h" |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
//--- module.modulemap |
| 46 |
module a { |
| 47 |
header "After/Mapping.h" |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
//--- test.cpp |
| 52 |
#define FOO |
| 53 |
// This include will fail if: |
| 54 |
// 1) modules are't used, as the `FOO` define will propagate into the included |
| 55 |
// header and trip a `#error`, or |
| 56 |
// 2) header maps aren't used, as the header name doesn't exist and relies on |
| 57 |
// the header map to remap it to the real header. |
| 58 |
#include "Before/Mapping.h" |