Move to kernel style SPDX license identifiers
[babeltrace.git] / src / cli / babeltrace2-cfg-cli-args-default.c
CommitLineData
c1870f57 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
c1870f57 3 *
0235b0db
MJ
4 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
c1870f57
JG
6 */
7
c5d7b1f0
MJ
8#include <glib.h>
9
3fadfbc0 10#include <babeltrace2/babeltrace.h>
ec2c5e50
MJ
11#include "babeltrace2-cfg.h"
12#include "babeltrace2-cfg-cli-args.h"
13#include "babeltrace2-cfg-cli-args-default.h"
c1870f57 14
ce406405
PP
15#ifdef ENABLE_DEBUG_INFO
16# define BT_ENABLE_DEBUG_INFO 1
17#else
18# define BT_ENABLE_DEBUG_INFO 0
19#endif
20
c1870f57
JG
21#ifdef BT_SET_DEFAULT_IN_TREE_CONFIGURATION
22
9009cc24 23struct bt_config *bt_config_cli_args_create_with_default(int argc,
3dae1685
SM
24 const char *argv[], int *retcode,
25 const bt_interrupter *interrupter)
c1870f57 26{
b19ff26f 27 bt_value *initial_plugin_paths;
290725f7 28 struct bt_config *cfg = NULL;
c1870f57
JG
29 int ret;
30
05e21286 31 initial_plugin_paths = bt_value_array_create();
290725f7
PP
32 if (!initial_plugin_paths) {
33 goto error;
34 }
35
36 ret = bt_config_append_plugin_paths(initial_plugin_paths,
5a3ee633 37 CONFIG_IN_TREE_PLUGIN_PATH);
290725f7
PP
38 if (ret) {
39 goto error;
40 }
41
afe821ca
MJ
42#ifdef CONFIG_IN_TREE_PROVIDER_DIR
43 /*
44 * Set LIBBABELTRACE2_PLUGIN_PROVIDER_DIR to load the in-tree Python
45 * plugin provider, if the env variable is already set, do not overwrite
46 * it.
47 */
c5d7b1f0 48 g_setenv("LIBBABELTRACE2_PLUGIN_PROVIDER_DIR", CONFIG_IN_TREE_PROVIDER_DIR, 0);
afe821ca
MJ
49#else
50 /*
51 * If the Pyhton plugin provider is disabled, use a non-exitent path to avoid
52 * loading the system installed provider if it exit, if the env variable is
53 * already set, do not overwrite it.
54 */
c5d7b1f0 55 g_setenv("LIBBABELTRACE2_PLUGIN_PROVIDER_DIR", "/nonexistent", 0);
afe821ca
MJ
56#endif
57
9009cc24 58 cfg = bt_config_cli_args_create(argc, argv, retcode, true, true,
3dae1685 59 initial_plugin_paths, interrupter);
290725f7
PP
60 goto end;
61
62error:
63 *retcode = 1;
65300d60 64 BT_OBJECT_PUT_REF_AND_RESET(cfg);
290725f7
PP
65
66end:
c5b9b441 67 bt_value_put_ref(initial_plugin_paths);
290725f7 68 return cfg;
c1870f57
JG
69}
70
71#else /* BT_SET_DEFAULT_IN_TREE_CONFIGURATION */
72
9009cc24 73struct bt_config *bt_config_cli_args_create_with_default(int argc,
3dae1685
SM
74 const char *argv[], int *retcode,
75 const bt_interrupter *interrupter)
c1870f57 76{
9009cc24 77 return bt_config_cli_args_create(argc, argv, retcode, false, false,
3dae1685 78 NULL, interrupter);
c1870f57
JG
79}
80
81#endif /* BT_SET_DEFAULT_IN_TREE_CONFIGURATION */
This page took 0.063163 seconds and 4 git commands to generate.