summaryrefslogtreecommitdiffstats
path: root/test cases/d/3 shared library
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/d/3 shared library
parentInitial commit. (diff)
downloadmeson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.tar.xz
meson-7b6e527f440cd7e6f8be2b07cee320ee6ca18786.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/d/3 shared library')
-rw-r--r--test cases/d/3 shared library/app.d8
-rw-r--r--test cases/d/3 shared library/libstuff.d14
-rw-r--r--test cases/d/3 shared library/libstuff.di3
-rw-r--r--test cases/d/3 shared library/lld-test.py20
-rw-r--r--test cases/d/3 shared library/meson.build26
-rw-r--r--test cases/d/3 shared library/sub/libstuff.d14
-rw-r--r--test cases/d/3 shared library/sub/meson.build1
-rw-r--r--test cases/d/3 shared library/test.json11
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"}
+ ]
+}