mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2026-04-06 07:15:47 -04:00
scanner: Add version argument to wayland-scanner
This adds a command line argument to print wayland-scanner version.
It also makes wayland-scanner emit a comment with wayland library
version to every file it generates.
v2: separate variable definitions into their own lines and remove
old style "version" argument
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Tested-by: Yong Bakos <ybakos@humanoriented.com>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
parent
08bda63ac4
commit
721c91c54a
1 changed files with 24 additions and 2 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "wayland-version.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
@ -64,12 +65,21 @@ usage(int ret)
|
||||||
"headers, server headers, or protocol marshalling code.\n\n");
|
"headers, server headers, or protocol marshalling code.\n\n");
|
||||||
fprintf(stderr, "options:\n");
|
fprintf(stderr, "options:\n");
|
||||||
fprintf(stderr, " -h, --help display this help and exit.\n"
|
fprintf(stderr, " -h, --help display this help and exit.\n"
|
||||||
|
" -v, --version print the wayland library version that\n"
|
||||||
|
" the scanner was built against.\n"
|
||||||
" -c, --include-core-only include the core version of the headers,\n"
|
" -c, --include-core-only include the core version of the headers,\n"
|
||||||
" that is e.g. wayland-client-core.h instead\n"
|
" that is e.g. wayland-client-core.h instead\n"
|
||||||
" of wayland-client.h.\n");
|
" of wayland-client.h.\n");
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
scanner_version(int ret)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "wayland-scanner %s\n", WAYLAND_VERSION);
|
||||||
|
exit(ret);
|
||||||
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
is_dtd_valid(FILE *input, const char *filename)
|
is_dtd_valid(FILE *input, const char *filename)
|
||||||
{
|
{
|
||||||
|
|
@ -1457,6 +1467,8 @@ emit_header(struct protocol *protocol, enum side side)
|
||||||
const char *s = (side == SERVER) ? "SERVER" : "CLIENT";
|
const char *s = (side == SERVER) ? "SERVER" : "CLIENT";
|
||||||
char **p, *prev;
|
char **p, *prev;
|
||||||
|
|
||||||
|
printf("/* Generated by wayland-scanner %s */\n\n", WAYLAND_VERSION);
|
||||||
|
|
||||||
printf("#ifndef %s_%s_PROTOCOL_H\n"
|
printf("#ifndef %s_%s_PROTOCOL_H\n"
|
||||||
"#define %s_%s_PROTOCOL_H\n"
|
"#define %s_%s_PROTOCOL_H\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
@ -1658,6 +1670,8 @@ emit_code(struct protocol *protocol)
|
||||||
struct wl_array types;
|
struct wl_array types;
|
||||||
char **p, *prev;
|
char **p, *prev;
|
||||||
|
|
||||||
|
printf("/* Generated by wayland-scanner %s */\n\n", WAYLAND_VERSION);
|
||||||
|
|
||||||
if (protocol->copyright)
|
if (protocol->copyright)
|
||||||
format_text_to_comment(protocol->copyright, true);
|
format_text_to_comment(protocol->copyright, true);
|
||||||
|
|
||||||
|
|
@ -1735,7 +1749,9 @@ int main(int argc, char *argv[])
|
||||||
char *input_filename = NULL;
|
char *input_filename = NULL;
|
||||||
int len;
|
int len;
|
||||||
void *buf;
|
void *buf;
|
||||||
bool help = false, core_headers = false;
|
bool help = false;
|
||||||
|
bool core_headers = false;
|
||||||
|
bool version = false;
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
int opt;
|
int opt;
|
||||||
enum {
|
enum {
|
||||||
|
|
@ -1746,12 +1762,13 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
|
{ "version", no_argument, NULL, 'v' },
|
||||||
{ "include-core-only", no_argument, NULL, 'c' },
|
{ "include-core-only", no_argument, NULL, 'c' },
|
||||||
{ 0, 0, NULL, 0 }
|
{ 0, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
opt = getopt_long(argc, argv, "hc", options, NULL);
|
opt = getopt_long(argc, argv, "hvc", options, NULL);
|
||||||
|
|
||||||
if (opt == -1)
|
if (opt == -1)
|
||||||
break;
|
break;
|
||||||
|
|
@ -1760,6 +1777,9 @@ int main(int argc, char *argv[])
|
||||||
case 'h':
|
case 'h':
|
||||||
help = true;
|
help = true;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
version = true;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
core_headers = true;
|
core_headers = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -1774,6 +1794,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (help)
|
if (help)
|
||||||
usage(EXIT_SUCCESS);
|
usage(EXIT_SUCCESS);
|
||||||
|
else if (version)
|
||||||
|
scanner_version(EXIT_SUCCESS);
|
||||||
else if ((argc != 1 && argc != 3) || fail)
|
else if ((argc != 1 && argc != 3) || fail)
|
||||||
usage(EXIT_FAILURE);
|
usage(EXIT_FAILURE);
|
||||||
else if (strcmp(argv[0], "help") == 0)
|
else if (strcmp(argv[0], "help") == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue