python-plugin-provider: Make it build
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 8 Apr 2019 16:53:56 +0000 (12:53 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 May 2019 22:19:40 +0000 (18:19 -0400)
This patch fixes building with --enable-python-plugins.

One problem is that the python plugin provider uses some
functions coming from the internal headers of the lib, which use some
logging functions that are internal to the lib, but not included by
those internal headers.  Trying to add the relevant include file
(lib-logging-internal.h) conflicts with python-plugin-provider's own
logger.

python-plugin-provider doesn't really need to have its own logger.  Even
though it is built as a separate shared object (so that we can package
it separately), it can be considered as internal to the library (and
that's why it includes some internal lib headers).  Therefore, the
easiest way to fix this is to get rid of its logger and make the lib
header files that use lib logging include the required header file
(lib-logging-internal.h).

This requires the python-plugin-provider shared object to access a few
additional symbols not currently exposed by libbabeltrace, which
requires the removal of a few BT_HIDDEN.

I have also included fixes to the python-plugin-provider which I have
on hand.  However, it won't work until the Python bindings are up and
running, so I have marked it as skipped.

Change-Id: I9b46d91fc635d670fef2e4d3c8b32203ec34443f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1101
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
14 files changed:
configure.ac
include/babeltrace/lib-logging-internal.h
include/babeltrace/plugin/plugin-internal.h
include/babeltrace/plugin/plugin-so-internal.h
lib/lib-logging.c
lib/plugin/plugin-so.c
python-plugin-provider/Makefile.am
python-plugin-provider/logging.c [deleted file]
python-plugin-provider/logging.h [deleted file]
python-plugin-provider/python-plugin-provider.c
tests/python-plugin-provider/.gitignore
tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py
tests/python-plugin-provider/test_python_plugin_provider.py
tests/python-plugin-provider/test_python_plugin_provider_env.in [new file with mode: 0644]

index 5950c67033a4ecae54a0d2ca88f2dca4f3e8eba6..d23373bb9f74629f8daa73d7730ca6ec3279dfdb 100644 (file)
@@ -815,6 +815,7 @@ AS_IF([test "x$enable_python_bindings" = xyes],
 
 AS_IF([test "x$enable_python_plugins" = "xyes"],
   [AC_CONFIG_FILES([tests/python-plugin-provider/test_python_plugin_provider], [chmod +x tests/python-plugin-provider/test_python_plugin_provider])]
+  [AC_CONFIG_FILES([tests/python-plugin-provider/test_python_plugin_provider_env], [chmod +x tests/python-plugin-provider/test_python_plugin_provider_env])]
 )
 
 AC_OUTPUT
index ec8ce7f2e3b5074d4e9c4ea979f2d38ffc71aea8..ae7fb9e6b31c171079e12414f76705e235269504 100644 (file)
@@ -186,7 +186,7 @@ int bt_lib_log_level;
  * Use one of the BT_LIB_LOGF*() macros above instead of calling this
  * function directly.
  */
-BT_HIDDEN
+
 void bt_lib_log(const char *func, const char *file, unsigned line,
                int lvl, const char *tag, const char *fmt, ...);
 
index 763a68b2a9941ae5316e32646c7fab3b7fe6263b..781c4ef3b5ba8955c835ae217048ae5c03c7973a 100644 (file)
@@ -32,6 +32,7 @@
 #include <babeltrace/object-internal.h>
 #include <babeltrace/types.h>
 #include <babeltrace/assert-internal.h>
+#include <babeltrace/lib-logging-internal.h>
 #include <glib.h>
 
 enum bt_plugin_type {
index 41544d186a9fc3e2641ceaeb046c8dd6fe931538..fb41e6590c7bfa67d560c290f2febc2cd9241d8c 100644 (file)
@@ -57,7 +57,6 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path);
 BT_HIDDEN
 struct bt_plugin_set *bt_plugin_so_create_all_from_static(void);
 
-BT_HIDDEN
 void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
                struct bt_component_class *comp_class);
 
index 0011475c50205e757bdd85da53b3eed8032c6352..7e897fa38e457c3ae7ba1321662d6b6028dd965c 100644 (file)
@@ -1387,7 +1387,6 @@ update_fmt:
        *out_fmt_ch = fmt_ch;
 }
 
-BT_HIDDEN
 void bt_lib_log(const char *func, const char *file, unsigned line,
                int lvl, const char *tag, const char *fmt, ...)
 {
index ac0ec75b206c777f37d744bb8d1c395be1712a5d..ac701ec2c0a19139878735f553a1fa3a8102df23 100644 (file)
@@ -1602,7 +1602,6 @@ void plugin_comp_class_destroy_listener(struct bt_component_class *comp_class,
                "comp-cls-addr=%p", comp_class);
 }
 
-BT_HIDDEN
 void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
                struct bt_component_class *comp_class)
 {
index 28a45e80b5a3127fc28ca01ab4c08c7d1d1ea111..840938811bafa6f573cc412fc9ad78fd4aedd309 100644 (file)
@@ -3,7 +3,7 @@ AM_CPPFLAGS += $(PYTHON_INCLUDE)
 lib_LTLIBRARIES = libbabeltrace-python-plugin-provider.la
 
 libbabeltrace_python_plugin_provider_la_SOURCES = \
-       python-plugin-provider.c logging.c logging.h
+       python-plugin-provider.c
 libbabeltrace_python_plugin_provider_la_LDFLAGS = \
        $(LT_NO_UNDEFINED) \
        -version-info $(BABELTRACE_LIBRARY_VERSION) \
diff --git a/python-plugin-provider/logging.c b/python-plugin-provider/logging.c
deleted file mode 100644 (file)
index c6ba438..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
-#include <babeltrace/logging-internal.h>
-
-BT_LOG_INIT_LOG_LEVEL(python_plugin_provider_log_level,
-       "BABELTRACE_PYTHON_PLUGIN_PROVIDER_LOG_LEVEL");
diff --git a/python-plugin-provider/logging.h b/python-plugin-provider/logging.h
deleted file mode 100644 (file)
index d5ab7ef..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PYTHON_PLUGIN_PROVIDER_LOGGING_H
-#define PYTHON_PLUGIN_PROVIDER_LOGGING_H
-
-/*
- * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define BT_LOG_OUTPUT_LEVEL python_plugin_provider_log_level
-#include <babeltrace/logging-internal.h>
-
-BT_LOG_LEVEL_EXTERN_SYMBOL(python_plugin_provider_log_level);
-
-#endif /* PYTHON_PLUGIN_PROVIDER_LOGGING_H */
index f4747ef7e6972769abae94c6341ba4d4a3a1c8ae..631a971b1287eeade67e59d63be665c6098dfdb1 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #define BT_LOG_TAG "PLUGIN-PY"
-#include "logging.h"
 
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler-internal.h>
@@ -157,9 +156,9 @@ void fini_python(void) {
 }
 
 static
-const bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
+bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
 {
-       const bt_plugin *plugin = NULL;
+       bt_plugin *plugin = NULL;
        PyObject *py_name = NULL;
        PyObject *py_author = NULL;
        PyObject *py_description = NULL;
@@ -367,8 +366,6 @@ const bt_plugin *bt_plugin_from_python_plugin_info(PyObject *plugin_info)
                }
        }
 
-       bt_plugin_freeze(plugin);
-
        goto end;
 
 error:
@@ -390,7 +387,7 @@ G_MODULE_EXPORT
 bt_plugin_set *bt_plugin_python_create_all_from_file(const char *path)
 {
        bt_plugin_set *plugin_set = NULL;
-       const bt_plugin *plugin = NULL;
+       bt_plugin *plugin = NULL;
        PyObject *py_plugin_info = NULL;
        gchar *basename = NULL;
        size_t path_len;
index 557bfd33cc2ad757d11e657d567837bfecd7c060..a0f0c488706e765e760bb5dd8995292c3af86b47 100644 (file)
@@ -1,3 +1,4 @@
 htmlcov
 .coverage
 test_python_plugin_provider
+test_python_plugin_provider_env
index 83f5e3dc76d4b3980d8ebd161d5e15ee4c9767aa..2f53ccaa680ffd45bc2604367756b2a8a1b3ce78 100644 (file)
@@ -1,19 +1,19 @@
 import bt2
 
 
-class MyIter(bt2._UserNotificationIterator):
+class MyIter(bt2._UserMessageIterator):
     pass
 
 
 @bt2.plugin_component_class
 class MySource(bt2._UserSourceComponent,
-               notification_iterator_class=MyIter):
+               message_iterator_class=MyIter):
     pass
 
 
 @bt2.plugin_component_class
 class MyFilter(bt2._UserFilterComponent,
-               notification_iterator_class=MyIter):
+               message_iterator_class=MyIter):
     pass
 
 
index a1071c9c4a78900d3e039e71582989015923ab9f..12bdac5a688a6e18424204916115691cd357022a 100644 (file)
@@ -3,9 +3,11 @@ import bt2
 import os
 
 
+@unittest.skip('depends on Python bindings, which are broken')
 class PythonPluginProviderTestCase(unittest.TestCase):
     def test_python_plugin_provider(self):
-        pset = bt2.find_plugins(os.environ['PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH'])
+        path = os.environ['PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH']
+        pset = bt2.find_plugins(path)
         self.assertEqual(len(pset), 1)
         plugin = pset[0]
         self.assertEqual(plugin.name, 'sparkling')
diff --git a/tests/python-plugin-provider/test_python_plugin_provider_env.in b/tests/python-plugin-provider/test_python_plugin_provider_env.in
new file mode 100644 (file)
index 0000000..8430778
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 - Philippe Proulx <pproulx@efficios.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; only version 2
+# of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+
+. "@abs_top_builddir@/tests/utils/common.sh"
+
+export PYTHON_PLUGIN_PROVIDER_TEST_PLUGIN_PATH="${BT_SRC_PATH}/tests/python-plugin-provider/bt_plugin_test_python_plugin_provider.py"
+
+PYTHON_BUILD_DIR="${BT_BUILD_PATH}/bindings/python/bt2/build/build_lib"
+TESTS_UTILS_PYTHON_DIR="${BT_SRC_PATH}/tests/utils/python"
+export PYTHONPATH="${PYTHON_BUILD_DIR}:${TESTS_UTILS_PYTHON_DIR}"
+
+if [ "x${MSYSTEM}" != "x" ]; then
+       export PATH="${BT_BUILD_PATH}/lib/.libs:${BT_BUILD_PATH}/python-plugin-provider/.libs:${PATH}"
+else
+       export LD_LIBRARY_PATH="${BT_BUILD_PATH}/lib/.libs:${BT_BUILD_PATH}/python-plugin-provider/.libs:${LD_LIBRARY_PATH}"
+fi
+
+exec "$*"
This page took 0.031939 seconds and 4 git commands to generate.