[PATCH 4/4] compositor: Add --config-overrides command-line option
Bryce Harrington
bryce at osg.samsung.com
Tue Jan 20 15:30:32 PST 2015
From: "Bryce Harrington" <bryce at osg.samsung.com>
This provides a way to run weston with a modified configuration, such as
for testing purposes.
Signed-off-by: Bryce Harrington (http://osg.samsung.com) <bryce at osg.samsung.com>
Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
man/weston.man | 9 +++++++++
src/compositor.c | 24 +++++++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/man/weston.man b/man/weston.man
index 735235f..5062edb 100644
--- a/man/weston.man
+++ b/man/weston.man
@@ -136,6 +136,15 @@ Do not read
for the compositor. Avoids e.g. loading compositor modules via the
configuration file, which is useful for unit tests.
.TP
+.BR \-\-config\-overrides
+A comma-separated list of configuration parameters that will be set
+and take precidence over the loaded
+.I weston.ini
+file (if any). No changes are written to the
+.I weston.ini
+on disk. Parameters are formatted as 'section.key=value'; all three of
+section, key, and value must be specified.
+.TP
\fB\-\^S\fR\fIname\fR, \fB\-\-socket\fR=\fIname\fR
Weston will listen in the Wayland socket called
.IR name .
diff --git a/src/compositor.c b/src/compositor.c
index b84658a..b2403bc 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4571,6 +4571,7 @@ usage(int error_code)
" --modules\t\tLoad the comma-separated list of modules\n"
" --log=FILE\t\tLog to the given file\n"
" --no-config\t\tDo not read weston.ini\n"
+ " --config-override\tComma-separated list of sect.key=val config params\n"
" -h, --help\t\tThis help message\n\n");
#if defined(BUILD_DRM_COMPOSITOR)
@@ -4774,6 +4775,7 @@ int main(int argc, char *argv[])
char *socket_name = NULL;
int32_t version = 0;
int32_t noconfig = 0;
+ char *config_overrides = NULL;
int32_t numlock_on;
struct weston_config *config = NULL;
struct weston_config_section *section;
@@ -4791,6 +4793,7 @@ int main(int argc, char *argv[])
{ WESTON_OPTION_BOOLEAN, "help", 'h', &help },
{ WESTON_OPTION_BOOLEAN, "version", 0, &version },
{ WESTON_OPTION_BOOLEAN, "no-config", 0, &noconfig },
+ { WESTON_OPTION_STRING, "config-overrides", 0, &config_overrides },
};
parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv);
@@ -4834,6 +4837,7 @@ int main(int argc, char *argv[])
goto out_signals;
}
+ /* Load configuration */
if (noconfig == 0)
config = weston_config_parse("weston.ini");
if (config != NULL) {
@@ -4842,8 +4846,26 @@ int main(int argc, char *argv[])
} else {
weston_log("Starting with no config file.\n");
}
- section = weston_config_get_section(config, "core", NULL, NULL);
+ /* Modify config based on command line options */
+ if (config_overrides) {
+ if (config == NULL)
+ config = weston_config_create();
+ if (config == NULL) {
+ ret = EXIT_FAILURE;
+ goto out_signals;
+ }
+
+ if (!weston_config_update(config, config_overrides)) {
+ weston_log("Could not update config with overrides '%s'.\n",
+ config_overrides);
+ ret = EXIT_FAILURE;
+ goto out_signals;
+ }
+ }
+
+ /* Set backend */
+ section = weston_config_get_section(config, "core", NULL, NULL);
if (!backend) {
weston_config_section_get_string(section, "backend", &backend,
NULL);
--
1.9.1
More information about the wayland-devel
mailing list