# file : tests/cc/modules/headers.testscript # license : MIT; see accompanying LICENSE file # Test header units. # .include common.testscript +$headers || exit # Common source files that are symlinked in the test directories if used. # +cat <=core.hxx #ifdef CORE_IN # error macro isolation #endif #define CORE_OUT 1 inline int f () {return 1;} EOI +cat <=base.mxx #define CORE_IN 1 #ifdef BASE_INCLUDE // Cannot include (even if translated) in module purview. // module; #include "core.hxx" export module foo.base; #else export module foo.base; #ifdef BASE_RE_EXPORT export import "core.hxx"; #else import "core.hxx"; #endif #endif #ifndef CORE_OUT # error macro export #endif export inline int g () {return f () - 1 /*CORE_OUT*/;} //@@ MODGCC EOI +cat <=core.hxx.in #ifdef CORE_IN # error macro isolation #endif inline int f () {return 0;} EOI : basics : ln -s ../core.hxx ./; cat <=driver-imp.cxx; #define CORE_IN 1 import "core.hxx"; #ifndef CORE_OUT # error macro export #endif int main () {return f () - CORE_OUT;} EOI cat <=driver-inc.cxx; #define CORE_IN 1 #include "core.hxx" #ifndef CORE_OUT # error macro export #endif int main () {return f () - CORE_OUT;} EOI $* test clean config.cxx.translate_include="$~/core.hxx" <=driver.cxx #define CORE_IN 1 import foo.base; #ifdef CORE_OUT # error macro export #endif EOI : import : ln -s ../../core.hxx ../../base.mxx ./; cat ../driver.cxx - <=driver.cxx; int main () {return g ();} EOI $* test clean <=driver.cxx; int main () {return g ();} EOI $* test clean config.cxx.poptions=-DBASE_INCLUDE \ config.cxx.translate_include="$~/core.hxx" <=driver.cxx; int main () {return g () + (f () - 1);} EOI $* test clean config.cxx.poptions=-DBASE_RE_EXPORT <=driver-imp.cxx; import ; int main () {return f ();} EOI cat <=driver-inc.cxx; #define CORE_IN 1 #include int main () {return f ();} EOI $* test clean config.cxx.translate_include="$~/core.hxx" <=core.hxx; #error poison EOI cat <=driver-imp.cxx; import ; int main () {return f ();} EOI cat <=driver-inc.cxx; #define CORE_IN 1 #include int main () {return f ();} EOI # Remapping can only be tested with an out of source build. Note that we # need a private out because of module sidebuilds. # out = ../../headers-remapped-out; $* 'test:' ./@$out/remapped/ \ config.cxx.translate_include=$out/remapped/core.hxx <