2 // RUN: split-file %s %t
7 //--- first/first/module.modulemap
8 module first
{ header
"first.h" }
9 //--- first/first/first.h
10 #include <second/sub.h>
12 //--- second/second/module.modulemap
13 module second
{ extern module sub
"sub.modulemap" }
14 //--- second/second/sub.modulemap
15 module second
.sub
{ header
"sub.h" }
16 //--- second/second/sub.h
19 //--- third/module.modulemap
22 //--- cdb.json.template
26 "command": "clang -I DIR/first -I DIR/second -I DIR/third -fmodules -fmodules-cache-path=DIR/cache -c DIR/tu.m -o DIR/tu.o"
29 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
30 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
31 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
34 // CHECK-NEXT: "modules": [
36 // CHECK-NEXT: "clang-module-deps": [
38 // CHECK-NEXT: "context-hash": "{{.*}}",
39 // CHECK-NEXT: "module-name": "second"
42 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/first/first/module.modulemap",
43 // CHECK-NEXT: "command-line": [
44 // CHECK-NEXT: "-cc1",
45 // CHECK: "-fmodule-map-file=[[PREFIX]]/second/second/module.modulemap"
46 // CHECK-NOT: "-fmodule-map-file=[[PREFIX]]/second/second/sub.modulemap"
47 // CHECK-NOT: "-fmodule-map-file=[[PREFIX]]/third/module.modulemap"
48 // CHECK: "-fmodule-file=second=[[PREFIX]]/cache/{{.*}}/second-{{.*}}.pcm"
50 // CHECK-NEXT: "context-hash": "{{.*}}",
51 // CHECK-NEXT: "file-deps": [
52 // CHECK-NEXT: "[[PREFIX]]/first/first/module.modulemap",
53 // CHECK-NEXT: "[[PREFIX]]/first/first/first.h",
54 // CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
55 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap"
57 // CHECK-NEXT: "link-libraries": [],
58 // CHECK-NEXT: "name": "first"
61 // CHECK-NEXT: "clang-module-deps": [
63 // CHECK-NEXT: "context-hash": "{{.*}}",
64 // CHECK-NEXT: "module-name": "third"
67 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/second/second/module.modulemap",
68 // CHECK-NEXT: "command-line": [
69 // CHECK-NEXT: "-cc1",
70 // CHECK: "-fmodule-map-file=[[PREFIX]]/third/module.modulemap",
71 // CHECK: "-fmodule-file=third=[[PREFIX]]/cache/{{.*}}/third-{{.*}}.pcm",
73 // CHECK-NEXT: "context-hash": "{{.*}}",
74 // CHECK-NEXT: "file-deps": [
75 // CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
76 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap",
77 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.h",
78 // CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
80 // CHECK-NEXT: "link-libraries": [],
81 // CHECK-NEXT: "name": "second"
84 // CHECK-NEXT: "clang-module-deps": [],
85 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/third/module.modulemap",
86 // CHECK-NEXT: "command-line": [
87 // CHECK-NEXT: "-cc1",
88 // CHECK-NOT: "-fmodule-map-file=
89 // CHECK-NOT: "-fmodule-file=third=
91 // CHECK-NEXT: "context-hash": "{{.*}}",
92 // CHECK-NEXT: "file-deps": [
93 // CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
95 // CHECK-NEXT: "link-libraries": [],
96 // CHECK-NEXT: "name": "third"
99 // CHECK-NEXT: "translation-units": [
101 // CHECK-NEXT: "commands": [
103 // CHECK-NEXT: "clang-context-hash": "{{.*}}",
104 // CHECK-NEXT: "clang-module-deps": [
106 // CHECK-NEXT: "context-hash": "{{.*}}",
107 // CHECK-NEXT: "module-name": "first"
110 // CHECK-NEXT: "command-line": [
111 // CHECK-NEXT: "-cc1",
112 // CHECK: "-fmodule-map-file=[[PREFIX]]/first/first/module.modulemap",
113 // CHECK: "-fmodule-file=first=[[PREFIX]]/cache/{{.*}}/first-{{.*}}.pcm",
115 // CHECK: "file-deps": [
116 // CHECK-NEXT: "[[PREFIX]]/tu.m"
118 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
125 // RUN: %deps-to-rsp %t/result.json --module-name=third > %t/third.cc1.rsp
126 // RUN: %deps-to-rsp %t/result.json --module-name=second > %t/second.cc1.rsp
127 // RUN: %deps-to-rsp %t/result.json --module-name=first > %t/first.cc1.rsp
128 // RUN: %clang @%t/third.cc1.rsp
129 // RUN: %clang @%t/second.cc1.rsp
130 // RUN: %clang @%t/first.cc1.rsp