From a69751532ad81841fcc0c18d2e9540cb230b26b1 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 15 Jun 2017 11:25:39 +0200 Subject: Implement module search in prerequisite libraries --- tests/cc/modules/testscript | 64 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/cc/modules/testscript b/tests/cc/modules/testscript index 36a5ebe..b17c1cb 100644 --- a/tests/cc/modules/testscript +++ b/tests/cc/modules/testscript @@ -16,7 +16,7 @@ cxx.std = experimental # Force modules except for VC where we need at least 15u3. # -if ($cxx.id != "msvc") +if ($cxx.id != 'msvc') cxx.features.modules = true using cxx @@ -25,6 +25,9 @@ hxx{*}: extension = hxx mxx{*}: extension = mxx cxx{*}: extension = cxx +if ($cxx.target.class == 'windows') + bmis{*}: cxx.poptions += '-DLIBFOO_EXPORT=__declspec(dllexport)' + exe{*}: test = true EOI @@ -43,12 +46,16 @@ if $modules # test directories if used. # +cat <=core.mxx +#ifndef LIBFOO_EXPORT +# define LIBFOO_EXPORT +#endif + #if __cpp_modules >= 201704 export #endif module foo.core; -export int f (int); +export LIBFOO_EXPORT int f (int); EOI +cat <=core.cxx @@ -168,6 +175,15 @@ $* test &*.d <'exe{test}: cxx{driver} mxx{core}' 2>>EOE != 0 info: consider explicitly specifying module name with @@ MOD EOE +: library +: +: Test importing a module from a library. +: +cp ../core.mxx ../core.cxx ../driver.cxx ./; +$* test clean <=base.mxx #if __cpp_modules >= 201704 - export + export #endif module foo.base; + export import foo.core; EOI +cat <=extra.mxx + #ifndef LIBFOO_EXPORT + # define LIBFOO_EXPORT + #endif + #if __cpp_modules >= 201704 - export + export #endif module foo.extra; - export import foo.base; + + export + { + import foo.base; + + // VC appears to require dll-export of inline functions. + // + LIBFOO_EXPORT inline int g (int i) {return i != 0 ? i : -1;} + } EOI +cat <=foo.mxx #if __cpp_modules >= 201704 - export + export #endif module foo; + export { import foo.core; @@ -211,25 +241,37 @@ if ($cxx.id.type != "clang") import foo.base; int main (int argc, char*[]) {return f (argc);} EOI - $* test clean <'exe{test}: cxx{driver core} {mxx}{core base}' + $* test clean <'exe{test}: cxx{driver core} mxx{core base}' : recursive : cp ../base.mxx ../extra.mxx ../../core.mxx ../../core.cxx ./; cat <=driver.cxx; import foo.extra; - int main (int argc, char*[]) {return f (argc);} + int main (int argc, char*[]) {return f (g (argc));} EOI - $* test clean <'exe{test}: cxx{driver core} {mxx}{core base extra}' + $* test clean <'exe{test}: cxx{driver core} mxx{core base extra}' : duplicate : cp ../base.mxx ../extra.mxx ../foo.mxx ../../core.mxx ../../core.cxx ./; cat <=driver.cxx; import foo; - int main (int argc, char*[]) {return f (argc);} + int main (int argc, char*[]) {return f (g (argc));} + EOI + $* test clean <'exe{test}: cxx{driver core} mxx{core base extra foo}' + + : library + : + cp ../base.mxx ../extra.mxx ../foo.mxx ../../core.mxx ../../core.cxx ./; + cat <=driver.cxx; + import foo; + int main (int argc, char*[]) {return f (g (argc));} + EOI + $* test clean <