1// RUN: cd %S
2// RUN: rm -rf %t
3//
4// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse %s -dependency-file - -MT implicit.pcm -o %t/implicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd -fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap | FileCheck %s --check-prefix=IMPLICIT
5//
6// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test-base -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse Inputs/dependency-gen-base.modulemap -o %t/base.pcm -fmodule-map-file-home-is-cwd -fmodule-map-file=%S/Inputs/dependency-gen-base.modulemap
7// RUN: %clang_cc1 -I. -x c++ -fmodule-name=test -fmodules -emit-module -fno-validate-pch -fmodules-strict-decluse -fmodule-file=%t/base.pcm %s -dependency-file - -MT explicit.pcm -o %t/explicit.pcm -fmodules-cache-path=%t -fmodule-map-file-home-is-cwd | FileCheck %s --check-prefix=EXPLICIT
8//
9// RUN: %clang_cc1 -I. -x c++ -fmodules -include Inputs/dependency-gen.h -x c++ /dev/null -fmodule-file=%t/explicit.pcm -MT main.o -fsyntax-only -dependency-file - | FileCheck %s --check-prefix=EXPLICIT-USE
10module "test" {
11  export *
12  header "Inputs/dependency-gen.h"
13  use "test-base"
14  use "test-base2"
15}
16
17// For implicit use of a module via the module cache, the input files
18// referenced by the .pcm are also dependencies of this build.
19//
20// IMPLICIT-DAG: {{[/\\]}}dependency-gen.modulemap
21// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base.modulemap
22// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-base2.modulemap
23// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
24// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included.h
25// IMPLICIT-DAG: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen-included2.h
26
27// For an explicit use of a module via -fmodule-file=, the other module maps
28// and included headers are not dependencies of this target (they are instead
29// dependencies of the explicitly-specified .pcm input).
30//
31// EXPLICIT: {{^}}explicit.pcm:
32// EXPLICIT-NOT: dependency-gen-
33// EXPLICIT: {{.*[/\\]}}dependency-gen.modulemap
34// EXPLICIT-NOT: dependency-gen-
35// EXPLICIT: base.pcm
36// EXPLICIT-NOT: dependency-gen-
37// EXPLICIT: {{ |\.[/\\]}}Inputs{{[/\\]}}dependency-gen.h
38// EXPLICIT-NOT: dependency-gen-
39
40// EXPLICIT-USE: main.o:
41// EXPLICIT-USE-NOT: base.pcm
42// EXPLICIT-USE: explicit.pcm
43// EXPLICIT-USE-NOT: base.pcm
44