xref: /aosp_15_r20/external/clang/test/Modules/rebuild.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: rm -rf %t
2*67e74705SXin Li
3*67e74705SXin Li// Build Module and set its timestamp
4*67e74705SXin Li// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
5*67e74705SXin Li// RUN: touch -m -a -t 201101010000 %t/Module.pcm
6*67e74705SXin Li// RUN: cp %t/Module.pcm %t/Module.pcm.saved
7*67e74705SXin Li// RUN: wc -c %t/Module.pcm > %t/Module.size.saved
8*67e74705SXin Li
9*67e74705SXin Li// Build DependsOnModule
10*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
11*67e74705SXin Li// RUN: diff %t/Module.pcm %t/Module.pcm.saved
12*67e74705SXin Li// RUN: cp %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
13*67e74705SXin Li
14*67e74705SXin Li// Rebuild Module, reset its timestamp, and verify its size hasn't changed
15*67e74705SXin Li// RUN: rm %t/Module.pcm
16*67e74705SXin Li// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
17*67e74705SXin Li// RUN: touch -m -a -t 201101010000 %t/Module.pcm
18*67e74705SXin Li// RUN: wc -c %t/Module.pcm > %t/Module.size
19*67e74705SXin Li// RUN: diff %t/Module.size %t/Module.size.saved
20*67e74705SXin Li// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
21*67e74705SXin Li
22*67e74705SXin Li// But the signature at least is expected to change, so we rebuild DependsOnModule.
23*67e74705SXin Li// NOTE: if we change how the signature is created, this test may need updating.
24*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
25*67e74705SXin Li// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
26*67e74705SXin Li// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
27*67e74705SXin Li
28*67e74705SXin Li// Rebuild Module, reset its timestamp, and verify its size hasn't changed
29*67e74705SXin Li// RUN: rm %t/Module.pcm
30*67e74705SXin Li// RUN: echo '@import Module;' | %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs -x objective-c -
31*67e74705SXin Li// RUN: touch -m -a -t 201101010000 %t/Module.pcm
32*67e74705SXin Li// RUN: wc -c %t/Module.pcm > %t/Module.size
33*67e74705SXin Li// RUN: diff %t/Module.size %t/Module.size.saved
34*67e74705SXin Li// RUN: cp %t/Module.pcm %t/Module.pcm.saved.2
35*67e74705SXin Li
36*67e74705SXin Li// Verify again with Module pre-imported.
37*67e74705SXin Li// NOTE: if we change how the signature is created, this test may need updating.
38*67e74705SXin Li// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -fsyntax-only -F %S/Inputs %s
39*67e74705SXin Li// RUN: diff %t/Module.pcm %t/Module.pcm.saved.2
40*67e74705SXin Li// RUN: not diff %t/DependsOnModule.pcm %t/DependsOnModule.pcm.saved
41*67e74705SXin Li
42*67e74705SXin Li#ifdef PREIMPORT
43*67e74705SXin Li@import Module;
44*67e74705SXin Li#endif
45*67e74705SXin Li@import DependsOnModule;
46