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/first.h",
53 // CHECK-NEXT: "[[PREFIX]]/first/first/module.modulemap",
54 // CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
55 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap"
57 // CHECK-NEXT: "name": "first"
60 // CHECK-NEXT: "clang-module-deps": [
62 // CHECK-NEXT: "context-hash": "{{.*}}",
63 // CHECK-NEXT: "module-name": "third"
66 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/second/second/module.modulemap",
67 // CHECK-NEXT: "command-line": [
68 // CHECK-NEXT: "-cc1",
69 // CHECK: "-fmodule-map-file=[[PREFIX]]/third/module.modulemap",
70 // CHECK: "-fmodule-file=third=[[PREFIX]]/cache/{{.*}}/third-{{.*}}.pcm",
72 // CHECK-NEXT: "context-hash": "{{.*}}",
73 // CHECK-NEXT: "file-deps": [
74 // CHECK-NEXT: "[[PREFIX]]/second/second/module.modulemap",
75 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.h",
76 // CHECK-NEXT: "[[PREFIX]]/second/second/sub.modulemap",
77 // CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
79 // CHECK-NEXT: "name": "second"
82 // CHECK-NEXT: "clang-module-deps": [],
83 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/third/module.modulemap",
84 // CHECK-NEXT: "command-line": [
85 // CHECK-NEXT: "-cc1",
86 // CHECK-NOT: "-fmodule-map-file=
87 // CHECK-NOT: "-fmodule-file=third=
89 // CHECK-NEXT: "context-hash": "{{.*}}",
90 // CHECK-NEXT: "file-deps": [
91 // CHECK-NEXT: "[[PREFIX]]/third/module.modulemap"
93 // CHECK-NEXT: "name": "third"
96 // CHECK-NEXT: "translation-units": [
98 // CHECK-NEXT: "commands": [
100 // CHECK-NEXT: "clang-context-hash": "{{.*}}",
101 // CHECK-NEXT: "clang-module-deps": [
103 // CHECK-NEXT: "context-hash": "{{.*}}",
104 // CHECK-NEXT: "module-name": "first"
107 // CHECK-NEXT: "command-line": [
108 // CHECK-NEXT: "-cc1",
109 // CHECK: "-fmodule-map-file=[[PREFIX]]/first/first/module.modulemap",
110 // CHECK: "-fmodule-file=first=[[PREFIX]]/cache/{{.*}}/first-{{.*}}.pcm",
112 // CHECK-NEXT: "executable": "clang",
113 // CHECK-NEXT: "file-deps": [
114 // CHECK-NEXT: "[[PREFIX]]/tu.m"
116 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
123 // RUN: %deps-to-rsp %t/result.json --module-name=third > %t/third.cc1.rsp
124 // RUN: %deps-to-rsp %t/result.json --module-name=second > %t/second.cc1.rsp
125 // RUN: %deps-to-rsp %t/result.json --module-name=first > %t/first.cc1.rsp
126 // RUN: %clang @%t/third.cc1.rsp
127 // RUN: %clang @%t/second.cc1.rsp
128 // RUN: %clang @%t/first.cc1.rsp