From: Alexandros Frantzis alexandros.frantzis@collabora.com
Wayland protocol descriptions are distributed as source XML files that need to be transformed to C source and header files with a version of the wayland-scanner tool compatible with the used libwayland library.
This commit enhances the makedep build tool to support building such Wayland protocol XML files. Components can use the WAYLAND_PROTOCOL_SRCS build variable to add protocol XML files to their build.
Signed-off-by: Alexandros Frantzis alexandros.frantzis@collabora.com --- tools/makedep.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/tools/makedep.c b/tools/makedep.c index 49a7514c9f0..8f7c7389526 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -100,6 +100,7 @@ struct incl_file #define FLAG_C_IMPLIB 0x040000 /* file is part of an import library */ #define FLAG_C_UNIX 0x080000 /* file is part of a Unix library */ #define FLAG_SFD_FONTS 0x100000 /* sfd file generated bitmap fonts */ +#define FLAG_WAYLAND_PROTO 0x200000 /* generates wayland protocol .c/.h files */
static const struct { @@ -157,6 +158,7 @@ static const char *icotool; static const char *msgfmt; static const char *ln_s; static const char *sed_cmd; +static const char *wayland_scanner; /* per-architecture global variables */ static const char *arch_dirs[MAX_ARCHS]; static const char *arch_pe_dirs[MAX_ARCHS]; @@ -1176,6 +1178,25 @@ static void parse_sfd_file( struct file *source, FILE *file ) }
+/******************************************************************* + * parse_xml_file + */ +static void parse_xml_file( struct file *source, FILE *file ) +{ + char *buffer; + + input_line = 0; + while ((buffer = get_line( file ))) + { + if (strstr( buffer, "<protocol name=" )) + { + source->flags |= FLAG_WAYLAND_PROTO; + break; + } + } +} + + static const struct { const char *ext; @@ -1193,7 +1214,8 @@ static const struct { ".idl", parse_idl_file }, { ".rc", parse_rc_file }, { ".in", parse_in_file }, - { ".sfd", parse_sfd_file } + { ".sfd", parse_sfd_file }, + { ".xml", parse_xml_file } };
/******************************************************************* @@ -1428,6 +1450,7 @@ static struct file *open_include_file( const struct makefile *make, struct incl_ if ((file = open_local_generated_file( make, pFile, ".cur", ".svg" ))) return file; if ((file = open_local_generated_file( make, pFile, ".ico", ".svg" ))) return file; } + if ((file = open_local_generated_file( make, pFile, "-client-protocol.h", ".xml" ))) return file;
/* check for extra targets */ if (strarray_exists( &make->extra_targets, pFile->name )) @@ -1915,6 +1938,21 @@ static void add_generated_sources( struct makefile *make ) strarray_addall_uniq( &make->extra_imports, get_expanded_file_local_var( make, obj, "IMPORTS" )); } + if (source->file->flags & FLAG_WAYLAND_PROTO) + { + char *code_name = replace_extension ( source->name , ".xml", "-protocol.c" ); + char *header_name = replace_extension ( source->name , ".xml", "-client-protocol.h" ); + + file = add_generated_source( make, code_name, NULL, 0 ); + file->file->flags |= FLAG_C_UNIX; + file->use_msvcrt = 0; + file = add_generated_source( make, header_name, NULL, 0 ); + file->file->flags |= FLAG_C_UNIX; + file->use_msvcrt = 0; + + free( code_name ); + free( header_name ); + } } if (make->testdll) { @@ -3101,6 +3139,16 @@ static void output_source_spec( struct makefile *make, struct incl_file *source, } }
+static void output_source_xml( struct makefile *make, struct incl_file *source, const char *obj ) +{ + if ((source->file->flags & FLAG_WAYLAND_PROTO) && wayland_scanner) + { + output( "%s-protocol.c: %s\n", obj_dir_path( make, obj ), source->filename ); + output( "\t%s%s private-code $< $@\n", cmd_prefix( "WAYLAND_SCANNER" ), wayland_scanner ); + output( "%s-client-protocol.h: %s\n", obj_dir_path( make, obj ), source->filename ); + output( "\t%s%s client-header $< $@\n", cmd_prefix( "WAYLAND_SCANNER" ), wayland_scanner); + } +}
/******************************************************************* * output_source_one_arch @@ -3240,6 +3288,7 @@ static const struct { "in", output_source_in }, { "x", output_source_x }, { "spec", output_source_spec }, + { "xml", output_source_xml }, { NULL, output_source_default } };
@@ -4054,6 +4103,7 @@ static void output_silent_rules(void) "MSG", "SED", "TEST", + "WAYLAND_SCANNER", "WIDL", "WMC", "WRC" @@ -4153,6 +4203,7 @@ static void load_sources( struct makefile *make ) "IN_SRCS", "PO_SRCS", "MANPAGES", + "WAYLAND_PROTOCOL_SRCS", NULL }; const char **var; @@ -4383,6 +4434,7 @@ int main( int argc, char *argv[] ) msgfmt = get_expanded_make_variable( top_makefile, "MSGFMT" ); sed_cmd = get_expanded_make_variable( top_makefile, "SED_CMD" ); ln_s = get_expanded_make_variable( top_makefile, "LN_S" ); + wayland_scanner = get_expanded_make_variable( top_makefile, "WAYLAND_SCANNER" );
if (root_src_dir && !strcmp( root_src_dir, "." )) root_src_dir = NULL; if (tools_dir && !strcmp( tools_dir, "." )) tools_dir = NULL;