Support building the X11 dissector outside the source tree.

Use relative path names for the script names and mesa/xcbproto directories so
different paths (from different users) don't cause deltas.

Also, with help from Peter Wu and Graham, get generation of the X11 dissector
working from cmake.

Change-Id: I95cd2a0f973dcbc67f457ff94c28e46a666afb74
Reviewed-on: https://code.wireshark.org/review/12213
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
Jeff Morriss 2015-06-06 22:24:33 -04:00 committed by Peter Wu
parent 9b128181b9
commit 3749e981aa
4 changed files with 64 additions and 56 deletions

View File

@ -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
<dissectors/x11-fields
${CMAKE_SOURCE_DIR}/tools/process-x11-fields.pl ${CMAKE_CURRENT_SOURCE_DIR}/dissectors
< ${CMAKE_CURRENT_SOURCE_DIR}/dissectors/x11-fields
COMMAND ${PERL_EXECUTABLE}
${CMAKE_SOURCE_DIR}/tools/process-x11-xcb.pl
${CMAKE_SOURCE_DIR}/tools/process-x11-xcb.pl ${CMAKE_CURRENT_SOURCE_DIR}/dissectors
DEPENDS
dissectors/x11-fields
${CMAKE_SOURCE_DIR}/tools/process-x11-fields.pl
${CMAKE_SOURCE_DIR}/tools/process-x11-xcb.pl
${CMAKE_CURRENT_SOURCE_DIR}/dissectors/xcbproto
${CMAKE_CURRENT_SOURCE_DIR}/dissectors/mesa
)
set_target_properties(x11-dissector PROPERTIES FOLDER "Generated Dissectors/X11")
# Note that some dissectors are added in dissectors/dcerpc/CMakeLists.txt
set(PIDL_DISSECTOR_SRC

View File

@ -62,9 +62,9 @@ packet-ncp2222.c : $(top_srcdir)/tools/ncp2222.py
# Target to rebuild the X11 dissector header files.
# See README.X11 before using this--it requires the xcb and mesa source.
x11-dissector: $(top_srcdir)/tools/process-x11-fields.pl x11-fields $(top_srcdir)/tools/process-x11-xcb.pl
$(PERL) $(top_srcdir)/tools/process-x11-fields.pl < x11-fields
$(PERL) $(top_srcdir)/tools/process-x11-xcb.pl
x11-dissector: $(top_srcdir)/tools/process-x11-fields.pl $(srcdir)/x11-fields $(top_srcdir)/tools/process-x11-xcb.pl
$(PERL) $(top_srcdir)/tools/process-x11-fields.pl $(srcdir) < $(srcdir)/x11-fields
$(PERL) $(top_srcdir)/tools/process-x11-xcb.pl $(srcdir)
#
# Build register.c, which contains a function register_all_protocols()

View File

@ -16,26 +16,33 @@
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
open(DECL, ">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 <<eot
/* Do not modify this file. */
/* It was automatically generated by $0. */
/* It was automatically generated by $script_name. */
eot
;

View File

@ -47,9 +47,14 @@ use XML::Twig;
use File::Spec;
my @reslist = grep {!/xproto\.xml$/} glob File::Spec->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 <<eot
/* Do not modify this file. */
/* It was automatically generated by $0
/* It was automatically generated by $script_name
using $using version $ver */
eot
;
@ -1770,28 +1777,28 @@ eot
#system('./process-x11-fields.pl < x11-fields');
# Extension implementation
$impl = new IO::File '> 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