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>
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
* 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, ...);
#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 {
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);
*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, ...)
{
"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)
{
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) \
+++ /dev/null
-/*
- * 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");
+++ /dev/null
-#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 */
*/
#define BT_LOG_TAG "PLUGIN-PY"
-#include "logging.h"
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/compiler-internal.h>
}
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;
}
}
- bt_plugin_freeze(plugin);
-
goto end;
error:
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;
htmlcov
.coverage
test_python_plugin_provider
+test_python_plugin_provider_env
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
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')
--- /dev/null
+#!/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 "$*"