aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-04-20 14:40:19 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-04-21 10:15:18 -0700
commitaf9d1f8f15a57a99af376bd6b30730ff9b9812b1 (patch)
tree90b23430f210ed9c43e64c172109f4ba83f0d0f3
parent407130a1d2b83a624520ff1d5c7de82336362aed (diff)
downloadmeson-af9d1f8f15a57a99af376bd6b30730ff9b9812b1.zip
meson-af9d1f8f15a57a99af376bd6b30730ff9b9812b1.tar.gz
meson-af9d1f8f15a57a99af376bd6b30730ff9b9812b1.tar.bz2
Add a testcase for linking C and C++ static archives into a shared library
This exercises a regression where the C rather than C++ linker is chosen, resulting in symbol errors. Test for #1653
-rw-r--r--test cases/common/146 C and CPP link/foo.c19
-rw-r--r--test cases/common/146 C and CPP link/foo.cpp24
-rw-r--r--test cases/common/146 C and CPP link/foo.h16
-rw-r--r--test cases/common/146 C and CPP link/foo.hpp24
-rw-r--r--test cases/common/146 C and CPP link/foobar.c23
-rw-r--r--test cases/common/146 C and CPP link/foobar.h16
-rw-r--r--test cases/common/146 C and CPP link/meson.build28
7 files changed, 150 insertions, 0 deletions
diff --git a/test cases/common/146 C and CPP link/foo.c b/test cases/common/146 C and CPP link/foo.c
new file mode 100644
index 0000000..77c7e39
--- /dev/null
+++ b/test cases/common/146 C and CPP link/foo.c
@@ -0,0 +1,19 @@
+/* Copyright © 2017 Dylan Baker
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "foo.h"
+
+int forty_two(void) {
+ return 42;
+}
diff --git a/test cases/common/146 C and CPP link/foo.cpp b/test cases/common/146 C and CPP link/foo.cpp
new file mode 100644
index 0000000..639af8e
--- /dev/null
+++ b/test cases/common/146 C and CPP link/foo.cpp
@@ -0,0 +1,24 @@
+/* Copyright © 2017 Dylan Baker
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <vector>
+#include <boost/assign/list_of.hpp>
+
+namespace {
+ std::vector<int> numbers = boost::assign::list_of(61);
+}
+
+extern "C" int six_one(void) {
+ return numbers[1];
+}
diff --git a/test cases/common/146 C and CPP link/foo.h b/test cases/common/146 C and CPP link/foo.h
new file mode 100644
index 0000000..1ed8ce9
--- /dev/null
+++ b/test cases/common/146 C and CPP link/foo.h
@@ -0,0 +1,16 @@
+/* Copyright © 2017 Dylan Baker
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+int forty_two(void);
diff --git a/test cases/common/146 C and CPP link/foo.hpp b/test cases/common/146 C and CPP link/foo.hpp
new file mode 100644
index 0000000..e47f01d
--- /dev/null
+++ b/test cases/common/146 C and CPP link/foo.hpp
@@ -0,0 +1,24 @@
+/* Copyright © 2017 Dylan Baker
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int six_one(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/test cases/common/146 C and CPP link/foobar.c b/test cases/common/146 C and CPP link/foobar.c
new file mode 100644
index 0000000..bd6cb00
--- /dev/null
+++ b/test cases/common/146 C and CPP link/foobar.c
@@ -0,0 +1,23 @@
+/* Copyright © 2017 Dylan Baker
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "foo.h"
+#include "foo.hpp"
+#include "foobar.h"
+
+void mynumbers(int nums[]) {
+ nums[0] = forty_two();
+ nums[1] = six_one();
+}
diff --git a/test cases/common/146 C and CPP link/foobar.h b/test cases/common/146 C and CPP link/foobar.h
new file mode 100644
index 0000000..6dcb096
--- /dev/null
+++ b/test cases/common/146 C and CPP link/foobar.h
@@ -0,0 +1,16 @@
+/* Copyright © 2017 Dylan Baker
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+void mynumbers(int nums[]);
diff --git a/test cases/common/146 C and CPP link/meson.build b/test cases/common/146 C and CPP link/meson.build
new file mode 100644
index 0000000..bfee4b2
--- /dev/null
+++ b/test cases/common/146 C and CPP link/meson.build
@@ -0,0 +1,28 @@
+# Copyright © 2017 Dylan Baker
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+project('C and C++ static link test', ['c', 'cpp'],
+ default_options : ['cpp_std=c++03'])
+
+dep_boost = dependency('boost')
+
+libcppfoo = static_library('cppfoo', ['foo.cpp', 'foo.hpp'],
+ dependencies : dep_boost)
+libcfoo = static_library('cfoo', ['foo.c', 'foo.h'])
+
+libfoo = shared_library(
+ 'foo',
+ ['foobar.c', 'foobar.h'],
+ link_with : [libcfoo, libcppfoo],
+)