From afe821caedf56baa63d94c5b7b87805922db7a7c Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 10 Jul 2019 15:39:10 -0400 Subject: [PATCH] Make the in-tree CLI use the in-tree PPP We build an in-tree version of the CLI binary that refers to in-tree versions of the plugins and other artefacts which currently doesn't support the Pyhton plugin provider. Add the logic to use the in-tree version of the Python plugin provider using the LIBBABELTRACE2_PLUGIN_PROVIDER_DIR environment variable. If the variable is already set, do not overwrite it. If the python plugin is enabled, set it to the appropriate in-tree path, otherwise set it to an invalid path so we don't load an hypothetical system installed provider. Signed-off-by: Michael Jeanson Change-Id: I4151c36fef90c791cc8b515233d0d3e8fefcdbd5 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1683 Tested-by: jenkins Reviewed-by: Philippe Proulx --- src/cli/Makefile.am | 4 ++++ src/cli/babeltrace2-cfg-cli-args-default.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index 6466d39d..c4087b14 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -13,6 +13,10 @@ endif AM_CPPFLAGS += '-DCONFIG_IN_TREE_PLUGIN_PATH="$(IN_TREE_PLUGIN_PATH)"' +if ENABLE_PYTHON_PLUGINS +AM_CPPFLAGS += '-DCONFIG_IN_TREE_PROVIDER_DIR="$(abs_top_builddir)/src/python-plugin-provider/.libs"' +endif + bin_PROGRAMS = babeltrace2.bin babeltrace2-log.bin noinst_PROGRAMS = babeltrace2 babeltrace2-log diff --git a/src/cli/babeltrace2-cfg-cli-args-default.c b/src/cli/babeltrace2-cfg-cli-args-default.c index aef23a53..b73457a2 100644 --- a/src/cli/babeltrace2-cfg-cli-args-default.c +++ b/src/cli/babeltrace2-cfg-cli-args-default.c @@ -52,6 +52,22 @@ struct bt_config *bt_config_cli_args_create_with_default(int argc, goto error; } +#ifdef CONFIG_IN_TREE_PROVIDER_DIR + /* + * Set LIBBABELTRACE2_PLUGIN_PROVIDER_DIR to load the in-tree Python + * plugin provider, if the env variable is already set, do not overwrite + * it. + */ + setenv("LIBBABELTRACE2_PLUGIN_PROVIDER_DIR", CONFIG_IN_TREE_PROVIDER_DIR, 0); +#else + /* + * If the Pyhton plugin provider is disabled, use a non-exitent path to avoid + * loading the system installed provider if it exit, if the env variable is + * already set, do not overwrite it. + */ + setenv("LIBBABELTRACE2_PLUGIN_PROVIDER_DIR", "/nonexistent", 0); +#endif + cfg = bt_config_cli_args_create(argc, argv, retcode, true, true, initial_plugin_paths); goto end; -- 2.34.1