1 // This test exercises the different ways explicit modular dependencies are
2 // provided on the command-line.
5 // RUN: split-file %s %t
7 //--- cdb.json.template
11 "command": "clang DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -o DIR/tu.o"
14 //--- module.modulemap
15 module Transitive
{ header
"transitive.h" }
16 module Direct
{ header
"direct.h" }
19 #include "transitive.h"
23 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
25 // Check that the PCM path defaults to the modules cache from implicit build.
26 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result_cache.json
27 // RUN: cat %t/result_cache.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_CACHE
29 // Check that the PCM path can be customized.
30 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-files-dir %t/build > %t/result_build.json
31 // RUN: cat %t/result_build.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_BUILD
33 // Check that the PCM file is loaded lazily by default.
34 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result_lazy.json
35 // RUN: cat %t/result_lazy.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_LAZY
37 // Check that the PCM file can be loaded eagerly.
38 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -eager-load-pcm > %t/result_eager.json
39 // RUN: cat %t/result_eager.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_EAGER
42 // CHECK-NEXT: "modules": [
44 // CHECK-NEXT: "clang-module-deps": [
46 // CHECK-NEXT: "context-hash": "{{.*}}",
47 // CHECK-NEXT: "module-name": "Transitive"
50 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
51 // CHECK-NEXT: "command-line": [
52 // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Transitive-{{.*}}.pcm"
53 // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Transitive-{{.*}}.pcm"
54 // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
55 // CHECK_LAZY: "-fmodule-file=Transitive=[[PREFIX]]/{{.*}}/Transitive-{{.*}}.pcm"
56 // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}"
57 // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Transitive-{{.*}}.pcm"
59 // CHECK-NEXT: "context-hash": "{{.*}}",
60 // CHECK-NEXT: "file-deps": [
61 // CHECK-NEXT: "[[PREFIX]]/module.modulemap",
62 // CHECK-NEXT: "[[PREFIX]]/direct.h"
64 // CHECK-NEXT: "link-libraries": [],
65 // CHECK-NEXT: "name": "Direct"
68 // CHECK-NEXT: "clang-module-deps": [],
69 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
70 // CHECK-NEXT: "command-line": [
72 // CHECK-NEXT: "context-hash": "{{.*}}",
73 // CHECK-NEXT: "file-deps": [
74 // CHECK-NEXT: "[[PREFIX]]/module.modulemap",
75 // CHECK-NEXT: "[[PREFIX]]/transitive.h"
77 // CHECK-NEXT: "link-libraries": [],
78 // CHECK-NEXT: "name": "Transitive"
81 // CHECK-NEXT: "translation-units": [
83 // CHECK: "clang-context-hash": "{{.*}}",
84 // CHECK-NEXT: "clang-module-deps": [
86 // CHECK-NEXT: "context-hash": "{{.*}}",
87 // CHECK-NEXT: "module-name": "Direct"
90 // CHECK-NEXT: "command-line": [
91 // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Direct-{{.*}}.pcm"
92 // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Direct-{{.*}}.pcm"
93 // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
94 // CHECK_LAZY: "-fmodule-file=Direct=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm"
95 // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}"
96 // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm"
98 // CHECK: "file-deps": [
99 // CHECK-NEXT: "[[PREFIX]]/tu.c"
101 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"