@@ -454,6 +454,8 @@ tests.package.test_python_passlib.TestPythonPy2Passlib: { extends: .runtime_test
tests.package.test_python_passlib.TestPythonPy3Passlib: { extends: .runtime_test }
tests.package.test_python_pexpect.TestPythonPy2Pexpect: { extends: .runtime_test }
tests.package.test_python_pexpect.TestPythonPy3Pexpect: { extends: .runtime_test }
+tests.package.test_python_pybind11.TestPythonPy2Pybind11: { extends: .runtime_test }
+tests.package.test_python_pybind11.TestPythonPy3Pybind11: { extends: .runtime_test }
tests.package.test_python_pynacl.TestPythonPy2Pynacl: { extends: .runtime_test }
tests.package.test_python_pynacl.TestPythonPy3Pynacl: { extends: .runtime_test }
tests.package.test_python_pyyaml.TestPythonPy2Pyyaml: { extends: .runtime_test }
@@ -76,6 +76,8 @@ F: package/setools/
F: package/sngrep/
F: package/spidermonkey/
F: package/systemd/
+F: support/testing/tests/package/br2-external/python-pybind11/
+F: support/testing/tests/package/test_python_pybind11.py
N: Adam Heinrich <adam@adamh.cz>
F: package/jack1/
new file mode 100644
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_PYTHON_PYBIND11_PATH/package/python-pybind11-addition-example/Config.in"
new file mode 100644
@@ -0,0 +1 @@
+name: PYTHON_PYBIND11
new file mode 100644
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_PYTHON_PYBIND11_PATH)/package/*/*.mk))
new file mode 100644
@@ -0,0 +1,5 @@
+config BR2_PACKAGE_PYTHON_PYBIND11_ADDITION_EXAMPLE
+ bool "python-pybind11 addition example"
+ depends on BR2_PACKAGE_PYTHON_PYBIND11
+ help
+ Simple class for testing python-pybind11
new file mode 100644
@@ -0,0 +1,9 @@
+#include <pybind11/pybind11.h>
+
+int add(int i, int j) {
+ return i + j;
+}
+
+PYBIND11_MODULE(pybind11_addition_example, m) {
+ m.def("add", &add, "A function which adds two numbers");
+}
new file mode 100644
@@ -0,0 +1,39 @@
+################################################################################
+#
+# python-pybind11_addition_example
+#
+################################################################################
+
+PYTHON_PYBIND11_ADDITION_EXAMPLE_DEPENDENCIES = python-pybind11
+
+ifeq ($(BR2_PACKAGE_PYTHON),y)
+PYTHON_PYBIND11_ADDITION_EXAMPLE_INCLUDES=`$(STAGING_DIR)/usr/bin/python2-config --includes`
+PYTHON_PYBIND11_ADDITION_EXAMPLE_SUFFIX=`$(STAGING_DIR)/usr/bin/python2-config --extension-suffix`
+else
+PYTHON_PYBIND11_ADDITION_EXAMPLE_INCLUDES=`$(STAGING_DIR)/usr/bin/python3-config --includes`
+PYTHON_PYBIND11_ADDITION_EXAMPLE_SUFFIX=`$(STAGING_DIR)/usr/bin/python3-config --extension-suffix`
+endif
+PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT=pybind11_addition_example$(PYTHON_PYBIND11_ADDITION_EXAMPLE_SUFFIX)
+
+define PYTHON_PYBIND11_ADDITION_EXAMPLE_BUILD_CMDS
+ $(INSTALL) -D $(PYTHON_PYBIND11_ADDITION_EXAMPLE_PKGDIR)/pybind11_addition_example.cpp \
+ $(@D)/pybind11_addition_example.cpp
+
+ $(INSTALL) -D $(PYTHON_PYBIND11_ADDITION_EXAMPLE_PKGDIR)/sample_python_pybind11.py \
+ $(@D)/sample_python_pybind11.py
+
+ cd $(@D); \
+ $(TARGET_CXX) -std=c++11 -fPIC -shared \
+ $(PYTHON_PYBIND11_ADDITION_EXAMPLE_INCLUDES) pybind11_addition_example.cpp \
+ -o $(PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT)
+endef
+
+define PYTHON_PYBIND11_ADDITION_EXAMPLE_INSTALL_TARGET_CMDS
+ $(INSTALL) -D -m 755 $(@D)/$(PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT) \
+ $(TARGET_DIR)/root/$(PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT)
+
+ $(INSTALL) -D -m 755 $(@D)/sample_python_pybind11.py \
+ $(TARGET_DIR)/root/sample_python_pybind11.py
+endef
+
+$(eval $(generic-package))
new file mode 100644
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+import pybind11_addition_example
+
+print(pybind11_addition_example.add(1, 2))
+
new file mode 100644
@@ -0,0 +1,76 @@
+import os
+import infra.basetest
+
+class TestPythonPy2Pybind11(infra.basetest.BRTest):
+ br2_external = [infra.filepath("tests/package/br2-external/python-pybind11")]
+ config = \
+ """
+ BR2_aarch64=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.86"
+ BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+ BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+ BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_TARGET_ROOTFS_CPIO_GZIP=y
+ BR2_PACKAGE_PYTHON=y
+ BR2_PACKAGE_PYTHON_PYBIND11=y
+ BR2_PACKAGE_PYTHON_PYBIND11_ADDITION_EXAMPLE=y
+ """
+
+ def login(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+ kern = os.path.join(self.builddir, "images", "Image")
+ self.emulator.boot(arch="aarch64",
+ kernel=kern,
+ kernel_cmdline=["console=ttyAMA0"],
+ options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M", "-initrd", img])
+ self.emulator.login()
+
+ def test_run(self):
+ self.login()
+ cmd = "python sample_python_pybind11.py"
+ output, exit_code = self.emulator.run(cmd, 120)
+ print(output)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output, ["3"])
+
+class TestPythonPy3Pybind11(infra.basetest.BRTest):
+ br2_external = [infra.filepath("tests/package/br2-external/python-pybind11")]
+ config = \
+ """
+ BR2_aarch64=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.86"
+ BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+ BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+ BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_TARGET_ROOTFS_CPIO_GZIP=y
+ BR2_PACKAGE_PYTHON3=y
+ BR2_PACKAGE_PYTHON_PYBIND11=y
+ BR2_PACKAGE_PYTHON_PYBIND11_ADDITION_EXAMPLE=y
+ """
+
+ def login(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+ kern = os.path.join(self.builddir, "images", "Image")
+ self.emulator.boot(arch="aarch64",
+ kernel=kern,
+ kernel_cmdline=["console=ttyAMA0"],
+ options=["-M", "virt", "-cpu", "cortex-a57", "-m", "512M", "-initrd", img])
+ self.emulator.login()
+
+ def test_run(self):
+ self.login()
+ cmd = "python3 sample_python_pybind11.py"
+ output, exit_code = self.emulator.run(cmd, 120)
+ print(output)
+ self.assertEqual(exit_code, 0)
+ self.assertEqual(output, ["3"])