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]]/direct.h",
62 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
64 // CHECK-NEXT: "name": "Direct"
67 // CHECK-NEXT: "clang-module-deps": [],
68 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
69 // CHECK-NEXT: "command-line": [
71 // CHECK-NEXT: "context-hash": "{{.*}}",
72 // CHECK-NEXT: "file-deps": [
73 // CHECK-NEXT: "[[PREFIX]]/module.modulemap",
74 // CHECK-NEXT: "[[PREFIX]]/transitive.h"
76 // CHECK-NEXT: "name": "Transitive"
79 // CHECK-NEXT: "translation-units": [
81 // CHECK: "clang-context-hash": "{{.*}}",
82 // CHECK-NEXT: "clang-module-deps": [
84 // CHECK-NEXT: "context-hash": "{{.*}}",
85 // CHECK-NEXT: "module-name": "Direct"
88 // CHECK-NEXT: "command-line": [
89 // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Direct-{{.*}}.pcm"
90 // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Direct-{{.*}}.pcm"
91 // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
92 // CHECK_LAZY: "-fmodule-file=Direct=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm"
93 // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}"
94 // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm"
96 // CHECK: "file-deps": [
97 // CHECK-NEXT: "[[PREFIX]]/tu.c"
99 // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"