compositor: add option to specify a weston.ini

Add a command line option to specify a file to be read instead of
weston.ini.

IVI-shell testing will at least temporarily need to specify a config
file, because it cannot run without. That is why this is being added,
but should be convenient for everybody, too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
dev
Pekka Paalanen 10 years ago
parent 6c71aaeec5
commit 8a0e0ba66a
  1. 12
      man/weston.man
  2. 27
      src/compositor.c

@ -111,6 +111,18 @@ or you can pass an absolute path. The default backend is
unless the environment suggests otherwise, see unless the environment suggests otherwise, see
.IR DISPLAY " and " WAYLAND_DISPLAY . .IR DISPLAY " and " WAYLAND_DISPLAY .
.TP .TP
\fB\-\^c\fR\fIconfig.ini\fR, \fB\-\-config\fR=\fIconfig.ini\fR
Load
.IR config.ini " instead of " weston.ini .
The argument can also be an absolute path starting with a
.IR / .
If the path is not absolute, it will be searched in the normal config
paths, see
.BR weston.ini (5).
If also
.B --no-config
is given, no configuration file will be read.
.TP
.BR \-\-version .BR \-\-version
Print the program version. Print the program version.
.TP .TP

@ -5213,24 +5213,38 @@ weston_transform_to_string(uint32_t output_transform)
} }
static int static int
load_configuration(struct weston_config **config, int32_t noconfig) load_configuration(struct weston_config **config, int32_t noconfig,
const char *config_file)
{ {
const char *file = "weston.ini";
const char *full_path; const char *full_path;
*config = NULL; *config = NULL;
if (config_file)
file = config_file;
if (noconfig == 0) if (noconfig == 0)
*config = weston_config_parse("weston.ini"); *config = weston_config_parse(file);
if (*config) { if (*config) {
full_path = weston_config_get_full_path(*config); full_path = weston_config_get_full_path(*config);
weston_log("Using config file '%s'\n", full_path); weston_log("Using config file '%s'\n", full_path);
setenv(WESTON_CONFIG_FILE_ENV_VAR, full_path, 1); setenv(WESTON_CONFIG_FILE_ENV_VAR, full_path, 1);
} else {
return 0;
}
if (config_file && noconfig == 0) {
weston_log("fatal: error opening or reading config file"
" '%s'.\n", config_file);
return -1;
}
weston_log("Starting with no config file.\n"); weston_log("Starting with no config file.\n");
setenv(WESTON_CONFIG_FILE_ENV_VAR, "", 1); setenv(WESTON_CONFIG_FILE_ENV_VAR, "", 1);
}
return 0; return 0;
} }
@ -5259,6 +5273,7 @@ int main(int argc, char *argv[])
int32_t version = 0; int32_t version = 0;
int32_t noconfig = 0; int32_t noconfig = 0;
int32_t numlock_on; int32_t numlock_on;
char *config_file = NULL;
struct weston_config *config; struct weston_config *config;
struct weston_config_section *section; struct weston_config_section *section;
struct wl_client *primary_client; struct wl_client *primary_client;
@ -5275,6 +5290,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help }, { WESTON_OPTION_BOOLEAN, "help", 'h', &help },
{ WESTON_OPTION_BOOLEAN, "version", 0, &version }, { WESTON_OPTION_BOOLEAN, "version", 0, &version },
{ WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig }, { WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig },
{ WESTON_OPTION_STRING, "config", 'c', &config_file },
}; };
parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv); parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
@ -5316,7 +5332,7 @@ int main(int argc, char *argv[])
if (!signals[0] || !signals[1] || !signals[2] || !signals[3]) if (!signals[0] || !signals[1] || !signals[2] || !signals[3])
goto out_signals; goto out_signals;
if (load_configuration(&config, noconfig) < 0) if (load_configuration(&config, noconfig, config_file) < 0)
goto out_signals; goto out_signals;
section = weston_config_get_section(config, "core", NULL, NULL); section = weston_config_get_section(config, "core", NULL, NULL);
@ -5436,6 +5452,7 @@ out_signals:
weston_log_file_close(); weston_log_file_close();
free(config_file);
free(backend); free(backend);
free(shell); free(shell);
free(socket_name); free(socket_name);

Loading…
Cancel
Save