diff options
author | Marius Vlad <marius.vlad@collabora.com> | 2021-04-20 14:19:08 +0300 |
---|---|---|
committer | Marius Vlad <marius.vlad@collabora.com> | 2021-04-20 15:51:50 +0300 |
commit | 65361f9f797905679c6c58c58733036911d54f7e (patch) | |
tree | 69ff3c4045ac548678cae302521cb3c2d4c017f8 | |
parent | ccda88821b5bd9a7eb82aafc59823709f453c091 (diff) |
main: Copy cmd line args and print them
This makes it really easy to spot on what arguments have been passed to
the compositor. When a test client will run the compositor this will be
helpful to verify that we pass the correct arguments.
Fixes a small typo along the way.
Bug-AGL: SPEC-3880
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: Ia4198ce6bff465f479cf9a0a87c17998c5548868
-rw-r--r-- | src/main.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -1520,8 +1520,9 @@ usage(int error_code) "Usage: agl-compositor [OPTIONS]\n" "\n" "This is " PACKAGE_STRING ", the reference compositor for\n" - "Automotive Grade Linux. Weston-ivi supports multiple backends, and depending\n" - "on which backend is in use different options will be accepted.\n" + "Automotive Grade Linux. " PACKAGE_STRING " supports multiple " + "backends,\nand depending on which backend is in use different " + "options will be accepted.\n" "\n" "Core options:\n" "\n" @@ -1541,9 +1542,30 @@ usage(int error_code) exit(error_code); } +static char * +copy_command_line(int argc, char * const argv[]) +{ + FILE *fp; + char *str = NULL; + size_t size = 0; + int i; + + fp = open_memstream(&str, &size); + if (!fp) + return NULL; + + fprintf(fp, "%s", argv[0]); + for (i = 1; i < argc; i++) + fprintf(fp, " %s", argv[i]); + fclose(fp); + + return str; +} + int main(int argc, char *argv[]) { struct ivi_compositor ivi = { 0 }; + char *cmdline; struct wl_display *display = NULL; struct wl_event_loop *loop; struct wl_event_source *signals[3] = { 0 }; @@ -1588,6 +1610,7 @@ int main(int argc, char *argv[]) /* Prevent any clients we spawn getting our stdin */ os_fd_set_cloexec(STDIN_FILENO); + cmdline = copy_command_line(argc, argv); parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv); if (help) @@ -1614,6 +1637,9 @@ int main(int argc, char *argv[]) logger = weston_log_subscriber_create_log(logfile); weston_log_subscribe(log_ctx, logger, "log"); + weston_log("Command line: %s\n", cmdline); + free(cmdline); + if (load_config(&ivi.config, no_config, config_file) < 0) goto error_signals; section = weston_config_get_section(ivi.config, "core", NULL, NULL); |