From 9477594f80d0851423d842993b7a658f33ace03b Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 8 Feb 2022 20:59:38 +0100 Subject: [PATCH] Move version handling to a separate file This will avoid to include all dependencies headers from main.c. --- app/meson.build | 1 + app/src/main.c | 24 ++---------------------- app/src/version.c | 29 +++++++++++++++++++++++++++++ app/src/version.h | 9 +++++++++ 4 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 app/src/version.c create mode 100644 app/src/version.h diff --git a/app/meson.build b/app/meson.build index a9b39b1e..6557c3b8 100644 --- a/app/meson.build +++ b/app/meson.build @@ -26,6 +26,7 @@ src = [ 'src/scrcpy.c', 'src/screen.c', 'src/server.c', + 'src/version.c', 'src/video_buffer.c', 'src/util/acksync.c', 'src/util/file.c', diff --git a/app/src/main.c b/app/src/main.c index 8a8c029c..2d1575f8 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -15,27 +15,7 @@ #include "scrcpy.h" #include "usb/scrcpy_otg.h" #include "util/log.h" - -static void -print_version(void) { - printf("\ndependencies:\n"); - printf(" - SDL %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, - SDL_PATCHLEVEL); - printf(" - libavcodec %d.%d.%d\n", LIBAVCODEC_VERSION_MAJOR, - LIBAVCODEC_VERSION_MINOR, - LIBAVCODEC_VERSION_MICRO); - printf(" - libavformat %d.%d.%d\n", LIBAVFORMAT_VERSION_MAJOR, - LIBAVFORMAT_VERSION_MINOR, - LIBAVFORMAT_VERSION_MICRO); - printf(" - libavutil %d.%d.%d\n", LIBAVUTIL_VERSION_MAJOR, - LIBAVUTIL_VERSION_MINOR, - LIBAVUTIL_VERSION_MICRO); -#ifdef HAVE_V4L2 - printf(" - libavdevice %d.%d.%d\n", LIBAVDEVICE_VERSION_MAJOR, - LIBAVDEVICE_VERSION_MINOR, - LIBAVDEVICE_VERSION_MICRO); -#endif -} +#include "version.h" int main(int argc, char *argv[]) { @@ -71,7 +51,7 @@ main(int argc, char *argv[]) { } if (args.version) { - print_version(); + scrcpy_print_version(); return 0; } diff --git a/app/src/version.c b/app/src/version.c new file mode 100644 index 00000000..d0e93481 --- /dev/null +++ b/app/src/version.c @@ -0,0 +1,29 @@ +#include "version.h" + +#include +#include +#include +#ifdef HAVE_V4L2 +# include +#endif + +void +scrcpy_print_version(void) { + printf("\ndependencies:\n"); + printf(" - SDL %d.%d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, + SDL_PATCHLEVEL); + printf(" - libavcodec %d.%d.%d\n", LIBAVCODEC_VERSION_MAJOR, + LIBAVCODEC_VERSION_MINOR, + LIBAVCODEC_VERSION_MICRO); + printf(" - libavformat %d.%d.%d\n", LIBAVFORMAT_VERSION_MAJOR, + LIBAVFORMAT_VERSION_MINOR, + LIBAVFORMAT_VERSION_MICRO); + printf(" - libavutil %d.%d.%d\n", LIBAVUTIL_VERSION_MAJOR, + LIBAVUTIL_VERSION_MINOR, + LIBAVUTIL_VERSION_MICRO); +#ifdef HAVE_V4L2 + printf(" - libavdevice %d.%d.%d\n", LIBAVDEVICE_VERSION_MAJOR, + LIBAVDEVICE_VERSION_MINOR, + LIBAVDEVICE_VERSION_MICRO); +#endif +} diff --git a/app/src/version.h b/app/src/version.h new file mode 100644 index 00000000..920360e8 --- /dev/null +++ b/app/src/version.h @@ -0,0 +1,9 @@ +#ifndef SC_VERSION_H +#define SC_VERSION_H + +#include "common.h" + +void +scrcpy_print_version(void); + +#endif