diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index cac0fbe933..44626c514a 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -149,26 +149,20 @@ ADD_CUSTOM_COMMAND( ${CMAKE_SOURCE_DIR}/tools/ncp2222.py ) -ADD_CUSTOM_COMMAND( - OUTPUT - x11-dissector -# x11-declarations.h -# x11-enum.h -# x11-extension-errors.h -# x11-extension-implementation.h -# x11-fields -# x11-glx-render-enum.h -# x11-register-info.h +add_custom_target(x11-dissector COMMAND ${PERL_EXECUTABLE} - ${CMAKE_SOURCE_DIR}/tools/process-x11-fields.pl - x11-declarations.h") || die; -open(REG, ">x11-register-info.h") || die; +use File::Spec; + +my $srcdir = shift; +die "'$srcdir' is not a directory" unless -d $srcdir; + +open(DECL, "> $srcdir/x11-declarations.h") || die; +open(REG, "> $srcdir/x11-register-info.h") || die; + +my $script_name = File::Spec->abs2rel ($0, $srcdir); sub add_generated_header { my ($out) = @_; print $out <catfile('xcbproto', 'src', '*.xml'); +my $srcdir = shift; +die "'$srcdir' is not a directory" unless -d $srcdir; + +my @reslist = grep {!/xproto\.xml$/} glob File::Spec->catfile($srcdir, 'xcbproto', 'src', '*.xml'); my @register; +my $script_name = File::Spec->abs2rel ($0, $srcdir); + my %basictype = ( char => { size => 1, encoding => 'ENC_ASCII|ENC_NA', type => 'FT_STRING', base => 'BASE_NONE', get => 'VALUE8', list => 'listOfByte', }, void => { size => 1, encoding => 'ENC_NA', type => 'FT_BYTES', base => 'BASE_NONE', get => 'VALUE8', list => 'listOfByte', }, @@ -167,9 +172,9 @@ my $error; my $enum; # Mesa API definitions keep moving -my @mesas = ('mesa/src/mapi/glapi/gen', # 2010-04-26 - 'mesa/src/mesa/glapi/gen', # 2010-02-22 - 'mesa/src/mesa/glapi'); # 2004-05-18 +my @mesas = ($srcdir . '/mesa/src/mapi/glapi/gen', # 2010-04-26 + $srcdir . '/mesa/src/mesa/glapi/gen', # 2010-02-22 + $srcdir . '/mesa/src/mesa/glapi'); # 2004-05-18 my $mesadir = (grep { -d } @mesas)[0]; sub mesa_category_start { @@ -913,19 +918,19 @@ sub dissect_element($$$$$;$$) } } - if (@test > 1) { - # We have more than one conditional, add parentheses to them. - # We don't add parentheses to all the conditionals because - # clang complains about the extra parens if you do "if ((x == y))". - my @tests_with_parens; - foreach my $conditional (@test) { - push @tests_with_parens, "($conditional)"; - } + if (@test > 1) { + # We have more than one conditional, add parentheses to them. + # We don't add parentheses to all the conditionals because + # clang complains about the extra parens if you do "if ((x == y))". + my @tests_with_parens; + foreach my $conditional (@test) { + push @tests_with_parens, "($conditional)"; + } - @test = @tests_with_parens; - } + @test = @tests_with_parens; + } - my $list = join ' || ', @test; + my $list = join ' || ', @test; say $impl $indent."if ($list) {"; my $vp = $varpat; @@ -1601,7 +1606,7 @@ sub include end_tag_handlers => { 'xcb' => \&include_end, }); - $xml->parsefile("xcbproto/src/$include.xml") or die ("Cannot open $include.xml\n"); + $xml->parsefile("$srcdir/xcbproto/src/$include.xml") or die ("Cannot open $include.xml\n"); $t->purge; } @@ -1730,9 +1735,11 @@ sub add_generated_header { my ($out, $using) = @_; my $ver = find_version($using); + $using = File::Spec->abs2rel ($using, $srcdir); + print $out < x11-extension-implementation.h' - or die ("Cannot open x11-extension-implementation.h for writing\n"); -$error = new IO::File '> x11-extension-errors.h' - or die ("Cannot open x11-extension-errors.h for writing\n"); +$impl = new IO::File "> $srcdir/x11-extension-implementation.h" + or die ("Cannot open $srcdir/x11-extension-implementation.h for writing\n"); +$error = new IO::File "> $srcdir/x11-extension-errors.h" + or die ("Cannot open $srcdir/x11-extension-errors.h for writing\n"); -add_generated_header($impl, 'xcbproto'); -add_generated_header($error, 'xcbproto'); +add_generated_header($impl, $srcdir . '/xcbproto'); +add_generated_header($error, $srcdir . '/xcbproto'); # Open the files generated by process-x11-fields.pl for appending -$reg = new IO::File '>> x11-register-info.h' - or die ("Cannot open x11-register-info.h for appending\n"); -$decl = new IO::File '>> x11-declarations.h' - or die ("Cannot open x11-declarations.h for appending\n"); +$reg = new IO::File ">> $srcdir/x11-register-info.h" + or die ("Cannot open $srcdir/x11-register-info.h for appending\n"); +$decl = new IO::File ">> $srcdir/x11-declarations.h" + or die ("Cannot open $srcdir/x11-declarations.h for appending\n"); -print $reg "\n/* Generated by $0 below this line */\n"; -print $decl "\n/* Generated by $0 below this line */\n"; +print $reg "\n/* Generated by $script_name below this line */\n"; +print $decl "\n/* Generated by $script_name below this line */\n"; # Mesa for glRender if (-e "$mesadir/gl_API.xml") { - $enum = new IO::File '> x11-glx-render-enum.h' - or die ("Cannot open x11-glx-render-enum.h for writing\n"); - add_generated_header($enum, 'mesa'); + $enum = new IO::File "> $srcdir/x11-glx-render-enum.h" + or die ("Cannot open $srcdir/x11-glx-render-enum.h for writing\n"); + add_generated_header($enum, $srcdir . '/mesa'); print $enum "static const value_string mesa_enum[] = {\n"; print $impl '#include "x11-glx-render-enum.h"'."\n\n"; @@ -1879,9 +1886,9 @@ eot print $impl " }\n}\n"; } -$enum = new IO::File '> x11-enum.h' - or die ("Cannot open x11-enum.h for writing\n"); -add_generated_header($enum, 'xcbproto'); +$enum = new IO::File "> $srcdir/x11-enum.h" + or die ("Cannot open $srcdir/x11-enum.h for writing\n"); +add_generated_header($enum, $srcdir . '/xcbproto'); print $impl '#include "x11-enum.h"'."\n\n"; # XCB