summaryrefslogtreecommitdiff
path: root/test cases
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-04-15 18:16:35 +0300
committerGitHub <noreply@github.com>2017-04-15 18:16:35 +0300
commit4e1249c920a6f64e2ca953334e9ec700f30693da (patch)
tree4ff1e03ac95c0827c6519b0fe684f41602bb47c3 /test cases
parentdcc95d7f705c5fbc036d7d6511f6df50beaac44a (diff)
parent62b86824f03d6b401f7bc8da6ce68b334726df44 (diff)
downloadmeson-4e1249c920a6f64e2ca953334e9ec700f30693da.tar.gz
Merge pull request #1549 from mesonbuild/linkwhole
Add option to link the entire contents of a static library to a target.
Diffstat (limited to 'test cases')
-rw-r--r--test cases/common/145 whole archive/dylib.c7
-rw-r--r--test cases/common/145 whole archive/libfile.c7
-rw-r--r--test cases/common/145 whole archive/meson.build22
-rw-r--r--test cases/common/145 whole archive/mylib.h21
-rw-r--r--test cases/common/145 whole archive/prog.c5
5 files changed, 62 insertions, 0 deletions
diff --git a/test cases/common/145 whole archive/dylib.c b/test cases/common/145 whole archive/dylib.c
new file mode 100644
index 000000000..9e287a4db
--- /dev/null
+++ b/test cases/common/145 whole archive/dylib.c
@@ -0,0 +1,7 @@
+#define BUILDING_DLL
+
+#include<mylib.h>
+
+int func2() {
+ return 42;
+}
diff --git a/test cases/common/145 whole archive/libfile.c b/test cases/common/145 whole archive/libfile.c
new file mode 100644
index 000000000..b2690a07f
--- /dev/null
+++ b/test cases/common/145 whole archive/libfile.c
@@ -0,0 +1,7 @@
+#define BUILDING_DLL
+
+#include<mylib.h>
+
+int func1() {
+ return 42;
+}
diff --git a/test cases/common/145 whole archive/meson.build b/test cases/common/145 whole archive/meson.build
new file mode 100644
index 000000000..eadebf8bd
--- /dev/null
+++ b/test cases/common/145 whole archive/meson.build
@@ -0,0 +1,22 @@
+project('whole archive', 'c')
+
+cc = meson.get_compiler('c')
+
+if cc.get_id() == 'msvc'
+ if cc.version().version_compare('<19')
+ error('MESON_SKIP_TEST link_whole only works on VS2015 or newer.')
+ endif
+endif
+
+stlib = static_library('allofme', 'libfile.c')
+
+# Nothing in dylib.c uses func1, so the linker would throw it
+# away and thus linking the exe would fail.
+dylib = shared_library('shlib', 'dylib.c',
+ link_whole : stlib)
+
+exe = executable('prog', 'prog.c',
+ link_with : dylib)
+
+test('prog', exe)
+
diff --git a/test cases/common/145 whole archive/mylib.h b/test cases/common/145 whole archive/mylib.h
new file mode 100644
index 000000000..813cc6783
--- /dev/null
+++ b/test cases/common/145 whole archive/mylib.h
@@ -0,0 +1,21 @@
+#pragma once
+
+/* Both funcs here for simplicity. */
+
+#if defined _WIN32 || defined __CYGWIN__
+#if defined BUILDING_DLL
+ #define DLL_PUBLIC __declspec(dllexport)
+#else
+ #define DLL_PUBLIC __declspec(dllimport)
+#endif
+#else
+ #if defined __GNUC__
+ #define DLL_PUBLIC __attribute__ ((visibility("default")))
+ #else
+ #pragma message ("Compiler does not support symbol visibility.")
+ #define DLL_PUBLIC
+ #endif
+#endif
+
+int DLL_PUBLIC func1();
+int DLL_PUBLIC func2();
diff --git a/test cases/common/145 whole archive/prog.c b/test cases/common/145 whole archive/prog.c
new file mode 100644
index 000000000..9111ad45a
--- /dev/null
+++ b/test cases/common/145 whole archive/prog.c
@@ -0,0 +1,5 @@
+#include<mylib.h>
+
+int main(int argc, char **argv) {
+ return func1() - func2();
+}