babeltrace-ctf.pc
])
-AC_CONFIG_FILES([converter/babeltrace], [chmod +x converter/babeltrace])
+#AC_CONFIG_FILES([converter/babeltrace], [chmod +x converter/babeltrace])
AC_CONFIG_FILES([tests/lib/test_ctf_writer_complete], [chmod +x tests/lib/test_ctf_writer_complete])
AC_CONFIG_FILES([tests/lib/test_seek_big_trace], [chmod +x tests/lib/test_seek_big_trace])
AC_CONFIG_FILES([tests/lib/test_seek_empty_packet], [chmod +x tests/lib/test_seek_empty_packet])
AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include \
- -DINSTALL_LIBDIR=\"$(libdir)\"
+ -DINSTALL_LIBDIR=\"$(libdir)\" \
+ -DCONFIG_IN_TREE_PLUGIN_DIR=\"$(abs_top_builddir)/plugins/\"
AM_LDFLAGS = -lpopt
bin_PROGRAMS = babeltrace.bin babeltrace-log
+noinst_PROGRAMS = babeltrace
+#check_PROGRAMS = babeltrace
babeltrace_bin_SOURCES = \
babeltrace.c \
babeltrace-cfg.c \
- babeltrace-cfg.h
+ babeltrace-cfg.h \
+ default-cfg.h \
+ default-cfg.c
# -Wl,--no-as-needed is needed for recent gold linker who seems to think
# it knows better and considers libraries with constructors having
babeltrace_bin_LDADD += -lrpcrt4 -lintl -liconv -lole32 -lpopt -lpthread
endif
-check_SCRIPTS = babeltrace
+# Only used for in-tree execution and tests
+babeltrace_SOURCES = $(babeltrace_bin_SOURCES)
+babeltrace_LDFLAGS = $(babeltrace_bin_LDFLAGS)
+babeltrace_LDADD = $(babeltrace_bin_LDADD)
+babeltrace_CFLAGS = $(AM_CFLAGS) -DBT_SET_DEFAULT_IN_TREE_CONFIGURATION
LEGACY_OUTPUT_FORMAT_DUMMY,
};
-static bool omit_system_plugin_path;
-static bool omit_home_plugin_path;
-
/*
* Prints the "out of memory" error.
*/
static int add_internal_plugin_paths(struct bt_config *cfg)
{
- if (!omit_home_plugin_path) {
+ if (!cfg->omit_home_plugin_path) {
char path[PATH_MAX];
const char *home_dir;
}
}
- if (!omit_system_plugin_path) {
+ if (!cfg->omit_system_plugin_path) {
if (plugin_paths_from_arg(cfg->plugin_paths,
SYSTEM_PLUGIN_PATH)) {
printf_err("Invalid system plugin path\n");
return -1;
}
+struct bt_config *bt_config_create(void)
+{
+ struct bt_config *cfg;
+
+ /* Create config */
+ cfg = g_new0(struct bt_config, 1);
+ if (!cfg) {
+ print_err_oom();
+ goto error;
+ }
+
+ bt_object_init(cfg, bt_config_destroy);
+ cfg->sources = g_ptr_array_new_with_free_func((GDestroyNotify) bt_put);
+ if (!cfg->sources) {
+ print_err_oom();
+ goto error;
+ }
+
+ cfg->sinks = g_ptr_array_new_with_free_func((GDestroyNotify) bt_put);
+ if (!cfg->sinks) {
+ print_err_oom();
+ goto error;
+ }
+
+ cfg->plugin_paths = bt_value_array_create();
+ if (!cfg->plugin_paths) {
+ print_err_oom();
+ goto error;
+ }
+end:
+ return cfg;
+error:
+ BT_PUT(cfg);
+ goto end;
+}
+
/*
* Returns a Babeltrace configuration, out of command-line arguments,
* containing everything that is needed to instanciate specific
* components with given parameters.
*
- * *exit_code is set to the appropriate exit code to use as far as this
- * function goes.
- *
- * Return value is NULL on error, otherwise it's owned by the caller.
+ * Return value is set to the appropriate exit code to use.
*/
-struct bt_config *bt_config_from_args(int argc, const char *argv[], int *exit_code)
+int bt_config_init_from_args(struct bt_config *cfg, int argc, const char *argv[])
{
- struct bt_config *cfg = NULL;
poptContext pc = NULL;
char *arg = NULL;
struct ctf_legacy_opts ctf_legacy_opts;
enum bt_config_component_dest cur_cfg_comp_dest =
BT_CONFIG_COMPONENT_DEST_SOURCE;
struct bt_value *cur_base_params = NULL;
- int opt, nr_omit_opt = 0;
+ int opt, ret = 0;
memset(&ctf_legacy_opts, 0, sizeof(ctf_legacy_opts));
memset(&text_legacy_opts, 0, sizeof(text_legacy_opts));
- *exit_code = 0;
text_legacy_opts.output = g_string_new(NULL);
if (!text_legacy_opts.output) {
goto error;
}
- /* Create config */
- cfg = g_new0(struct bt_config, 1);
- if (!cfg) {
- print_err_oom();
- goto error;
- }
-
- bt_object_init(cfg, bt_config_destroy);
- cfg->sources = g_ptr_array_new_with_free_func((GDestroyNotify) bt_put);
- if (!cfg->sources) {
- print_err_oom();
- goto error;
- }
-
- cfg->sinks = g_ptr_array_new_with_free_func((GDestroyNotify) bt_put);
- if (!cfg->sinks) {
- print_err_oom();
- goto error;
- }
-
legacy_input_paths = bt_value_array_create();
if (!legacy_input_paths) {
print_err_oom();
DEFAULT_SOURCE_COMPONENT_NAME);
}
- cfg->plugin_paths = bt_value_array_create();
- if (!cfg->plugin_paths) {
- print_err_oom();
- goto error;
- }
-
/* Parse options */
pc = poptGetContext(NULL, argc, (const char **) argv, long_options, 0);
if (!pc) {
}
break;
case OPT_OMIT_SYSTEM_PLUGIN_PATH:
- omit_system_plugin_path = true;
- nr_omit_opt += 2;
+ cfg->omit_system_plugin_path = true;
break;
case OPT_OMIT_HOME_PLUGIN_PATH:
- omit_home_plugin_path = true;
- nr_omit_opt += 2;
+ cfg->omit_home_plugin_path = true;
break;
case OPT_OUTPUT_PATH:
if (text_legacy_opts.output->len > 0) {
arg = NULL;
}
- if (argc - nr_omit_opt <= 1) {
+ if (argc <= 1) {
print_usage(stdout);
- goto put_cfg;
+ goto end;
}
/* Check for option parsing error */
goto end;
error:
- *exit_code = 1;
-put_cfg:
- BT_PUT(cfg);
- cfg = NULL;
+ ret = 1;
end:
if (pc) {
poptFreeContext(pc);
BT_PUT(text_legacy_opts.names);
BT_PUT(text_legacy_opts.fields);
BT_PUT(legacy_input_paths);
- return cfg;
+ return ret;
}
bool verbose;
bool do_list;
bool force_correlate;
+ bool omit_system_plugin_path;
+ bool omit_home_plugin_path;
};
static inline
return bt_get(g_ptr_array_index(array, index));
}
-struct bt_config *bt_config_from_args(int argc, const char *argv[], int *exit_code);
+struct bt_config *bt_config_create(void);
+
+int bt_config_init_from_args(struct bt_config *cfg, int argc,
+ const char *argv[]);
#endif /* BABELTRACE_CONVERTER_CFG_H */
#include <string.h>
#include <stdio.h>
#include "babeltrace-cfg.h"
+#include "default-cfg.h"
static struct bt_component_factory *component_factory;
enum bt_component_status sink_status;
struct bt_config_component *source_cfg = NULL, *sink_cfg = NULL;
- cfg = bt_config_from_args(argc, argv, &ret);
- if (cfg) {
+ cfg = bt_config_create();
+ if (!cfg) {
+ fprintf(stderr, "Failed to create Babeltrace configuration\n");
+ ret = 1;
+ goto end;
+ }
+
+ ret = set_default_config(cfg);
+ if (ret) {
+ goto end;
+ }
+
+ ret = bt_config_init_from_args(cfg, argc, argv);
+ if (ret == 0) {
print_cfg(cfg);
} else {
goto end;
+++ /dev/null
-#!/bin/sh
-
-@abs_top_builddir@/converter/babeltrace.bin \
- --omit-system-plugin-path --omit-home-plugin-path \
- --plugin-path "@abs_top_builddir@/plugins" ${*}
--- /dev/null
+/*
+ * default-cfg.c
+ *
+ * Babeltrace Trace Converter - Default Configuration
+ *
+ * Copyright 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#include <babeltrace/values.h>
+#include "default-cfg.h"
+#include "config.h"
+
+#ifdef BT_SET_DEFAULT_IN_TREE_CONFIGURATION
+
+int set_default_config(struct bt_config *cfg)
+{
+ int ret;
+
+ cfg->omit_system_plugin_path = true;
+ cfg->omit_home_plugin_path = true;
+ ret = bt_value_array_append_string(cfg->plugin_paths,
+ CONFIG_IN_TREE_PLUGIN_DIR);
+ return ret;
+}
+
+#else /* BT_SET_DEFAULT_IN_TREE_CONFIGURATION */
+
+int set_default_config(struct bt_config *cfg)
+{
+ /* Nothing to set. */
+ return 0;
+}
+
+#endif /* BT_SET_DEFAULT_IN_TREE_CONFIGURATION */
--- /dev/null
+#ifndef BABELTRACE_DEFAULT_CFG_H
+#define BABELTRACE_DEFAULT_CFG_H
+
+/*
+ * Babeltrace Trace Converter - Default Configuration
+ *
+ * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@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.
+ */
+
+#include "babeltrace-cfg.h"
+
+int set_default_config(struct bt_config *cfg);
+
+#endif /* BABELTRACE_DEFAULT_CFG_H */