aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss.ws@gmail.com>2015-06-06 22:24:33 -0400
committerPeter Wu <peter@lekensteyn.nl>2015-11-29 11:20:39 +0000
commit3749e981aa69d7598879d50b1f099181e0929d30 (patch)
tree40f6b3b692f7eca0d88bef902d07ab2b42b7b5ef /tools
parent9b128181b9bdd8f621ba9db792cbda11c8f7d654 (diff)
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>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/process-x11-fields.pl17
-rwxr-xr-xtools/process-x11-xcb.pl77
2 files changed, 54 insertions, 40 deletions
diff --git a/tools/process-x11-fields.pl b/tools/process-x11-fields.pl
index c3a9888274..aab1ab5ba3 100755
--- a/tools/process-x11-fields.pl
+++ b/tools/process-x11-fields.pl
@@ -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
;
diff --git a/tools/process-x11-xcb.pl b/tools/process-x11-xcb.pl
index 9fb63a2710..9b7f8dac82 100755
--- a/tools/process-x11-xcb.pl
+++ b/tools/process-x11-xcb.pl
@@ -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