diff options
Diffstat (limited to 'test cases/d/3 shared library')
-rw-r--r-- | test cases/d/3 shared library/app.d | 8 | ||||
-rw-r--r-- | test cases/d/3 shared library/libstuff.d | 14 | ||||
-rw-r--r-- | test cases/d/3 shared library/libstuff.di | 3 | ||||
-rw-r--r-- | test cases/d/3 shared library/lld-test.py | 20 | ||||
-rw-r--r-- | test cases/d/3 shared library/meson.build | 26 | ||||
-rw-r--r-- | test cases/d/3 shared library/sub/libstuff.d | 14 | ||||
-rw-r--r-- | test cases/d/3 shared library/sub/meson.build | 1 | ||||
-rw-r--r-- | test cases/d/3 shared library/test.json | 11 |
8 files changed, 97 insertions, 0 deletions
diff --git a/test cases/d/3 shared library/app.d b/test cases/d/3 shared library/app.d new file mode 100644 index 0000000..5d84a69 --- /dev/null +++ b/test cases/d/3 shared library/app.d @@ -0,0 +1,8 @@ + +import libstuff; + +void main () +{ + immutable ret = printLibraryString ("foo"); + assert (ret == 4); +} diff --git a/test cases/d/3 shared library/libstuff.d b/test cases/d/3 shared library/libstuff.d new file mode 100644 index 0000000..8205490 --- /dev/null +++ b/test cases/d/3 shared library/libstuff.d @@ -0,0 +1,14 @@ +import std.stdio; +import std.string : format; + +export int printLibraryString (string str) +{ + writeln ("Library says: %s".format (str)); + return 4; +} + +version (Windows) +{ + import core.sys.windows.dll; + mixin SimpleDllMain; +} diff --git a/test cases/d/3 shared library/libstuff.di b/test cases/d/3 shared library/libstuff.di new file mode 100644 index 0000000..b6454b1 --- /dev/null +++ b/test cases/d/3 shared library/libstuff.di @@ -0,0 +1,3 @@ +module libstuff; + +int printLibraryString (string str); diff --git a/test cases/d/3 shared library/lld-test.py b/test cases/d/3 shared library/lld-test.py new file mode 100644 index 0000000..3f32f59 --- /dev/null +++ b/test cases/d/3 shared library/lld-test.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import argparse +import subprocess + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('ldd') + parser.add_argument('bin') + args = parser.parse_args() + + p, o, _ = subprocess.run([args.ldd, args.bin], stdout=subprocess.PIPE) + assert p == 0 + o = o.decode() + assert 'libstuff.so =>' in o, 'libstuff so not in linker path.' + assert 'libstuff.so => not found' not in o, 'libstuff.so not found correctly' + + +if __name__ == '__main__': + main() diff --git a/test cases/d/3 shared library/meson.build b/test cases/d/3 shared library/meson.build new file mode 100644 index 0000000..fa41779 --- /dev/null +++ b/test cases/d/3 shared library/meson.build @@ -0,0 +1,26 @@ +project('D Shared Library', 'd') + +dc = meson.get_compiler('d') +if dc.get_id() == 'gcc' + if dc.version().version_compare('< 8') + error('MESON_SKIP_TEST: GDC < 8.0 can not build shared libraries') + endif +endif + +subdir('sub') +ed = executable('app_d', 'app.d', link_with : ldyn, install : true) +test('linktest_dyn', ed) + +# test D attributes for pkg-config +pkgc = import('pkgconfig') +pkgc.generate(name: 'test', + libraries: ldyn, + subdirs: 'd/stuff', + description: 'A test of D attributes to pkgconfig.generate.', + d_module_versions: ['Use_Static'] +) + +ldd = find_program('ldd', required : false) +if ldd.found() + test('ldd-test.py', ed) +endif diff --git a/test cases/d/3 shared library/sub/libstuff.d b/test cases/d/3 shared library/sub/libstuff.d new file mode 100644 index 0000000..8205490 --- /dev/null +++ b/test cases/d/3 shared library/sub/libstuff.d @@ -0,0 +1,14 @@ +import std.stdio; +import std.string : format; + +export int printLibraryString (string str) +{ + writeln ("Library says: %s".format (str)); + return 4; +} + +version (Windows) +{ + import core.sys.windows.dll; + mixin SimpleDllMain; +} diff --git a/test cases/d/3 shared library/sub/meson.build b/test cases/d/3 shared library/sub/meson.build new file mode 100644 index 0000000..1599a33 --- /dev/null +++ b/test cases/d/3 shared library/sub/meson.build @@ -0,0 +1 @@ +ldyn = shared_library('stuff', 'libstuff.d', install : true) diff --git a/test cases/d/3 shared library/test.json b/test cases/d/3 shared library/test.json new file mode 100644 index 0000000..50eb9cb --- /dev/null +++ b/test cases/d/3 shared library/test.json @@ -0,0 +1,11 @@ +{ + "installed": [ + {"type": "exe", "file": "usr/bin/app_d"}, + {"type": "pdb", "file": "usr/bin/app_d", "language": "d"}, + {"type": "shared_lib", "platform": "msvc", "file": "usr/bin/stuff"}, + {"type": "pdb", "file": "usr/bin/stuff", "language": "d"}, + {"type": "shared_lib", "platform": "gcc", "file": "usr/lib/stuff"}, + {"type": "file", "platform": "msvc", "file": "usr/lib/stuff.lib"}, + {"type": "file", "file": "usr/lib/pkgconfig/test.pc"} + ] +} |