1be795ee1SJan Svoboda // This test exercises the different ways explicit modular dependencies are 2be795ee1SJan Svoboda // provided on the command-line. 3be795ee1SJan Svoboda 4be795ee1SJan Svoboda // RUN: rm -rf %t 5be795ee1SJan Svoboda // RUN: split-file %s %t 6be795ee1SJan Svoboda 7be795ee1SJan Svoboda //--- cdb.json.template 8be795ee1SJan Svoboda [{ 9be795ee1SJan Svoboda "file": "DIR/tu.c", 10be795ee1SJan Svoboda "directory": "DIR", 11be795ee1SJan Svoboda "command": "clang DIR/tu.c -fmodules -fmodules-cache-path=DIR/cache -o DIR/tu.o" 12be795ee1SJan Svoboda }] 13be795ee1SJan Svoboda 14be795ee1SJan Svoboda //--- module.modulemap 15be795ee1SJan Svoboda module Transitive { header "transitive.h" } 16be795ee1SJan Svoboda module Direct { header "direct.h" } 17be795ee1SJan Svoboda //--- transitive.h 18be795ee1SJan Svoboda //--- direct.h 19be795ee1SJan Svoboda #include "transitive.h" 20be795ee1SJan Svoboda //--- tu.c 21be795ee1SJan Svoboda #include "direct.h" 22be795ee1SJan Svoboda 23be795ee1SJan Svoboda // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json 24be795ee1SJan Svoboda 25be795ee1SJan Svoboda // Check that the PCM path defaults to the modules cache from implicit build. 26be795ee1SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result_cache.json 27be795ee1SJan Svoboda // RUN: cat %t/result_cache.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_CACHE 28be795ee1SJan Svoboda 29be795ee1SJan Svoboda // Check that the PCM path can be customized. 30be795ee1SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-files-dir %t/build > %t/result_build.json 31be795ee1SJan Svoboda // RUN: cat %t/result_build.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_BUILD 32be795ee1SJan Svoboda 33be795ee1SJan Svoboda // Check that the PCM file is loaded lazily by default. 34be795ee1SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result_lazy.json 35be795ee1SJan Svoboda // RUN: cat %t/result_lazy.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_LAZY 36be795ee1SJan Svoboda 37be795ee1SJan Svoboda // Check that the PCM file can be loaded eagerly. 38be795ee1SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -eager-load-pcm > %t/result_eager.json 39be795ee1SJan Svoboda // RUN: cat %t/result_eager.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t --check-prefixes=CHECK,CHECK_EAGER 40be795ee1SJan Svoboda 41be795ee1SJan Svoboda // CHECK: { 42be795ee1SJan Svoboda // CHECK-NEXT: "modules": [ 43be795ee1SJan Svoboda // CHECK-NEXT: { 44be795ee1SJan Svoboda // CHECK-NEXT: "clang-module-deps": [ 45be795ee1SJan Svoboda // CHECK-NEXT: { 46be795ee1SJan Svoboda // CHECK-NEXT: "context-hash": "{{.*}}", 47be795ee1SJan Svoboda // CHECK-NEXT: "module-name": "Transitive" 48be795ee1SJan Svoboda // CHECK-NEXT: } 49be795ee1SJan Svoboda // CHECK-NEXT: ], 50be795ee1SJan Svoboda // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap", 51be795ee1SJan Svoboda // CHECK-NEXT: "command-line": [ 52be795ee1SJan Svoboda // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Transitive-{{.*}}.pcm" 53be795ee1SJan Svoboda // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Transitive-{{.*}}.pcm" 54be795ee1SJan Svoboda // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap" 55be795ee1SJan Svoboda // CHECK_LAZY: "-fmodule-file=Transitive=[[PREFIX]]/{{.*}}/Transitive-{{.*}}.pcm" 56be795ee1SJan Svoboda // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}" 57be795ee1SJan Svoboda // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Transitive-{{.*}}.pcm" 58be795ee1SJan Svoboda // CHECK: ], 59be795ee1SJan Svoboda // CHECK-NEXT: "context-hash": "{{.*}}", 60be795ee1SJan Svoboda // CHECK-NEXT: "file-deps": [ 61*9d4837f4SJan Svoboda // CHECK-NEXT: "[[PREFIX]]/module.modulemap", 62*9d4837f4SJan Svoboda // CHECK-NEXT: "[[PREFIX]]/direct.h" 63be795ee1SJan Svoboda // CHECK-NEXT: ], 6468eb3b20SArtem Chikin // CHECK-NEXT: "link-libraries": [], 65be795ee1SJan Svoboda // CHECK-NEXT: "name": "Direct" 66be795ee1SJan Svoboda // CHECK-NEXT: }, 67be795ee1SJan Svoboda // CHECK-NEXT: { 68be795ee1SJan Svoboda // CHECK-NEXT: "clang-module-deps": [], 69be795ee1SJan Svoboda // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap", 70be795ee1SJan Svoboda // CHECK-NEXT: "command-line": [ 71be795ee1SJan Svoboda // CHECK: ], 72be795ee1SJan Svoboda // CHECK-NEXT: "context-hash": "{{.*}}", 73be795ee1SJan Svoboda // CHECK-NEXT: "file-deps": [ 74be795ee1SJan Svoboda // CHECK-NEXT: "[[PREFIX]]/module.modulemap", 75be795ee1SJan Svoboda // CHECK-NEXT: "[[PREFIX]]/transitive.h" 76be795ee1SJan Svoboda // CHECK-NEXT: ], 7768eb3b20SArtem Chikin // CHECK-NEXT: "link-libraries": [], 78be795ee1SJan Svoboda // CHECK-NEXT: "name": "Transitive" 79be795ee1SJan Svoboda // CHECK-NEXT: } 80be795ee1SJan Svoboda // CHECK-NEXT: ], 81be795ee1SJan Svoboda // CHECK-NEXT: "translation-units": [ 82be795ee1SJan Svoboda // CHECK-NEXT: { 8383902c40SBen Langmuir // CHECK: "clang-context-hash": "{{.*}}", 84be795ee1SJan Svoboda // CHECK-NEXT: "clang-module-deps": [ 85be795ee1SJan Svoboda // CHECK-NEXT: { 86be795ee1SJan Svoboda // CHECK-NEXT: "context-hash": "{{.*}}", 87be795ee1SJan Svoboda // CHECK-NEXT: "module-name": "Direct" 88be795ee1SJan Svoboda // CHECK-NEXT: } 89be795ee1SJan Svoboda // CHECK-NEXT: ], 90be795ee1SJan Svoboda // CHECK-NEXT: "command-line": [ 91be795ee1SJan Svoboda // CHECK_CACHE: "-fmodule-file={{.*}}/cache/{{.*}}/Direct-{{.*}}.pcm" 92be795ee1SJan Svoboda // CHECK_BUILD: "-fmodule-file={{.*}}/build/{{.*}}/Direct-{{.*}}.pcm" 93be795ee1SJan Svoboda // CHECK_LAZY: "-fmodule-map-file=[[PREFIX]]/module.modulemap" 94be795ee1SJan Svoboda // CHECK_LAZY: "-fmodule-file=Direct=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm" 95be795ee1SJan Svoboda // CHECK_EAGER-NOT: "-fmodule-map-file={{.*}}" 96be795ee1SJan Svoboda // CHECK_EAGER: "-fmodule-file=[[PREFIX]]/{{.*}}/Direct-{{.*}}.pcm" 97be795ee1SJan Svoboda // CHECK: ], 9883902c40SBen Langmuir // CHECK: "file-deps": [ 99be795ee1SJan Svoboda // CHECK-NEXT: "[[PREFIX]]/tu.c" 100be795ee1SJan Svoboda // CHECK-NEXT: ], 101be795ee1SJan Svoboda // CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c" 102be795ee1SJan Svoboda // CHECK-NEXT: } 103