Update build dependencies and add a copy of the gtk-sharp parser from trunk

This enables us to build with gtk-sharp 2.12.9.90 instead of current
trunk (which will be released together with GNOME 3.0 or similar).
This commit is contained in:
Sebastian Dröge 2009-05-28 10:19:19 +02:00
parent daf6d826c2
commit 5de4ca65e6
6 changed files with 1653 additions and 14 deletions

View file

@ -1,7 +1,7 @@
AC_INIT(README)
AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(gstreamer-sharp, 0.9.5.99)
AM_INIT_AUTOMAKE(gstreamer-sharp, 0.9.0)
AM_MAINTAINER_MODE
AC_PROG_CC
@ -11,7 +11,7 @@ AC_HEADER_STDC
PACKAGE_VERSION=gstreamer-sharp-0.10
AC_SUBST(PACKAGE_VERSION)
MONO_REQUIRED_VERSION=1.1
MONO_REQUIRED_VERSION=2.4
AC_SUBST(MONO_REQUIRED_VERSION)
PKG_CHECK_MODULES(MONO_DEPENDENCY, mono >= $MONO_REQUIRED_VERSION, has_mono=true, has_mono=false)
@ -87,7 +87,7 @@ MONODOC_SOURCESDIR=`pkg-config --variable=sourcesdir monodoc`
AC_SUBST(MONODOC_SOURCESDIR)
## Versions of dependencies
GLIBSHARP_REQUIRED_VERSION=2.13.90
GLIBSHARP_REQUIRED_VERSION=2.12.9.90
PKG_CHECK_MODULES(GLIBSHARP, glib-sharp-2.0 >= $GLIBSHARP_REQUIRED_VERSION)
AC_SUBST(GLIBSHARP_LIBS)
@ -99,8 +99,8 @@ PKG_CHECK_MODULES(GLIB,
AC_SUBST(GLIB_LIBS)
AC_SUBST(GLIB_CFLAGS)
GSTREAMER_REQUIRED_VERSION=0.10.22.1
GSTREAMER_PLUGINS_REQUIRED_VERSION=0.10.22.1
GSTREAMER_REQUIRED_VERSION=0.10.23
GSTREAMER_PLUGINS_REQUIRED_VERSION=0.10.23
AC_SUBST(GSTREAMER_REQUIRED_VERSION)
AC_SUBST(GSTREAMER_PLUGINS_REQUIRED_VERSION)
PKG_CHECK_MODULES(GST,
@ -123,11 +123,6 @@ AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_monodoc" = "xyes")
## Check for the gapi programs
PKG_CHECK_MODULES(GAPI, gapi-2.0 >= $GLIBSHARP_REQUIRED_VERSION)
AC_PATH_PROG(GAPI_PARSER, gapi2-parser, no)
if test "x$GAPI_PARSER" = "xno"; then
AC_MSG_ERROR([You need to install gtk-sharp-gapi])
fi
PKG_CHECK_MODULES(MONO_NUNIT, mono-nunit >= 1.0, do_tests="yes", do_tests="no")
AC_SUBST(MONO_NUNIT_LIBS)
AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")

View file

@ -1,4 +1,4 @@
TARGETS = gst-gapi-fixup.exe gst-generate-tags.exe
TARGETS = gst-gapi-fixup.exe gst-generate-tags.exe gst-gapi-parser.exe
DEBUGS = $(addsuffix .mdb, $(TARGETS))
all: $(TARGETS)
@ -9,13 +9,18 @@ gst-gapi-fixup.exe: $(srcdir)/gst-gapi-fixup.cs
gst-generate-tags.exe: $(srcdir)/gst-generate-tags.cs
$(CSC) -out:$@ $(srcdir)/gst-generate-tags.cs
gst-gapi-parser.exe: $(srcdir)/gapi-parser.cs
$(CSC) -out:$@ $(srcdir)/gapi-parser.cs
noinst_SCRIPTS = $(TARGETS)
noinst_SCRIPTS = $(TARGETS) gapi_pp.pl gapi2xml.pl
CLEANFILES = $(TARGETS) $(DEBUGS)
MAINTAINERCLEANFILES = Makefile.in
EXTRA_DIST = \
gst-gapi-fixup.cs \
gst-generate-tags.cs
gst-generate-tags.cs \
gapi_pp.pl \
gapi2xml.pl

170
parser/gapi-parser.cs Normal file
View file

@ -0,0 +1,170 @@
// gapi-parser.cs - parsing driver application.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2005 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// 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., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Parsing {
using System;
using System.Collections;
using System.IO;
using System.Runtime.InteropServices;
using System.Xml;
public class Parser {
[DllImport ("libc")]
static extern int system (string command);
public static int Main (string[] args)
{
if (args.Length != 1) {
Console.WriteLine ("Usage: gapi2-parser <filename>");
return 0;
}
XmlDocument src_doc = new XmlDocument ();
try {
using (Stream stream = File.OpenRead (args [0]))
src_doc.Load (stream);
} catch (XmlException e) {
Console.WriteLine ("Couldn't open source file.");
Console.WriteLine (e);
return 1;
}
XmlNode root = src_doc.DocumentElement;
if (root.Name != "gapi-parser-input") {
Console.WriteLine ("Improperly formatted input file: " + args [0]);
return 1;
}
foreach (XmlNode apinode in root.ChildNodes) {
if (apinode.Name != "api")
continue;
string outfile = (apinode as XmlElement).GetAttribute ("filename");
string prefile = outfile + ".pre";
if (File.Exists (prefile))
File.Delete (prefile);
foreach (XmlNode libnode in apinode.ChildNodes) {
if (libnode.Name != "library")
continue;
string lib = (libnode as XmlElement).GetAttribute ("name");
foreach (XmlNode nsnode in libnode.ChildNodes) {
if (nsnode.Name != "namespace")
continue;
string ns = (nsnode as XmlElement).GetAttribute ("name");
ArrayList files = new ArrayList ();
Hashtable excludes = new Hashtable ();
foreach (XmlNode srcnode in nsnode.ChildNodes) {
if (!(srcnode is XmlElement))
continue;
XmlElement elem = srcnode as XmlElement;
switch (srcnode.Name) {
case "dir":
string dir = elem.InnerXml;
Console.Write ("<dir {0}> ", dir);
DirectoryInfo di = new DirectoryInfo (dir);
foreach (FileInfo file in di.GetFiles ("*.c"))
files.Add (dir + Path.DirectorySeparatorChar + file.Name);
foreach (FileInfo file in di.GetFiles ("*.h"))
files.Add (dir + Path.DirectorySeparatorChar + file.Name);
break;
case "file":
string incfile = elem.InnerXml;
Console.Write ("<file {0}> ", incfile);
files.Add (incfile);
break;
case "exclude":
string excfile = elem.InnerXml;
Console.Write ("<exclude {0}> ", excfile);
excludes [excfile] = 1;
break;
case "directory":
string dir_path = elem.GetAttribute ("path");
Console.Write ("<directory {0}: excluding ", dir_path);
Hashtable excs = new Hashtable ();
foreach (XmlNode exc_node in srcnode.ChildNodes) {
if (exc_node.Name != "exclude")
continue;
string excfilename = (exc_node as XmlElement).InnerXml;
Console.Write (excfilename + " ");
excs [excfilename] = 1;
}
DirectoryInfo dinfo = new DirectoryInfo (dir_path);
foreach (FileInfo file in dinfo.GetFiles ("*.c")) {
if (excs.Contains (file.Name))
continue;
files.Add (dir_path + Path.DirectorySeparatorChar + file.Name);
}
foreach (FileInfo file in dinfo.GetFiles ("*.h")) {
if (excs.Contains (file.Name))
continue;
files.Add (dir_path + Path.DirectorySeparatorChar + file.Name);
}
Console.Write ("> ");
break;
default:
Console.WriteLine ("Invalid source: " + srcnode.Name);
break;
}
}
Console.WriteLine ();
if (files.Count == 0)
continue;
ArrayList realfiles = new ArrayList ();
foreach (string file in files) {
string trimfile = file.TrimEnd ();
if (excludes.Contains (trimfile))
continue;
realfiles.Add (trimfile);
}
string[] filenames = (string[]) realfiles.ToArray (typeof (string));
string pp_args = String.Join (" ", filenames);
system ("gapi_pp.pl " + pp_args + " | gapi2xml.pl " + ns + " " + prefile + " " + lib);
}
}
XmlDocument final = new XmlDocument ();
final.Load (prefile);
XmlTextWriter writer = new XmlTextWriter (outfile, null);
writer.Formatting = Formatting.Indented;
final.Save (writer);
File.Delete (prefile);
}
return 0;
}
}
}

1197
parser/gapi2xml.pl Executable file

File diff suppressed because it is too large Load diff

271
parser/gapi_pp.pl Executable file
View file

@ -0,0 +1,271 @@
#!/usr/bin/perl
#
# gapi_pp.pl : A source preprocessor for the extraction of API info from a
# C library source directory.
#
# Authors: Mike Kestner <mkestner@speakeasy.net>
# Martin Willemoes Hansen <mwh@sysrq.dk>
#
# Copyright (c) 2001 Mike Kestner
# Copyright (c) 2003 Martin Willemoes Hansen
# Copyright (c) 2003-2004 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# 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., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
$private_regex = '^#if.*(ENABLE_BACKEND|ENABLE_ENGINE)';
$eatit_regex = '^#if(.*(__cplusplus|DEBUG|DISABLE_COMPAT|ENABLE_BROKEN)|\s+0\s*$)';
$ignoreit_regex = '^\s+\*|#ident|#error|#\s*include|#\s*else|#\s*undef|G_(BEGIN|END)_DECLS|GDKVAR|GTKVAR|GTKMAIN_C_VAR|GTKTYPEUTILS_VAR|VARIABLE|GTKTYPEBUILTIN';
foreach $arg (@ARGV) {
if (-d $arg && -e $arg) {
@hdrs = (@hdrs, `ls $arg/*.h`);
@srcs = (@srcs, `ls $arg/*.c`);
} elsif (-f $arg && -e $arg) {
@hdrs = (@hdrs, $arg) if ($arg =~ /\.h$/);
@srcs = (@srcs, $arg) if ($arg =~ /\.c$/);
} else {
die "unable to process arg: $arg";
}
}
foreach $fname (@hdrs) {
if ($fname =~ /test|private|internals|gtktextlayout|gtkmarshalers/) {
@privhdrs = (@privhdrs, $fname);
next;
}
open(INFILE, $fname) || die "Could open $fname\n";
$braces = 0;
$deprecated = -1;
$ifdeflevel = 0;
$prepend = "";
while ($line = <INFILE>) {
$braces++ if ($line =~ /{/ and $line !~ /}/);
$braces-- if ($line =~ /}/ and $line !~ /{/);
next if ($line =~ /$ignoreit_regex/);
$line =~ s/\/\*[^<].*?\*\///g;
next if ($line !~ /\S/);
$line = $prepend . $line;
$prepend = "";
while ($line =~ /(.*)\\$/) { $line = $1 . <INFILE>; }
if ($line =~ /#\s*define\s+\w+\s+\"/) {
$def = $line;
while ($def !~ /\".*\"/) {$def .= ($line = <INFILE>);}
print $def;
} elsif ($line =~ /#\s*define\s+\w+\s*\D+/) {
$def = $line;
while ($line =~ /\\\n/) {$def .= ($line = <INFILE>);}
if ($def =~ /_CHECK_\w*CAST|INSTANCE_GET_INTERFACE/) {
$def =~ s/\\\n//g;
print $def;
}
} elsif ($line =~ /^\s*\/\*[^<]/) {
while ($line !~ /\*\//) {$line = <INFILE>;}
} elsif ($line =~ /^extern/) {
while ($line !~ /;/) {$line = <INFILE>;}
} elsif ($line =~ /^#ifndef\s+\w+_H_*\b/) {
while ($line !~ /#define|#endif/) {$line = <INFILE>;}
} elsif ($line =~ /$private_regex/) {
$nested = 0;
while ($line = <INFILE>) {
last if (!$nested && ($line =~ /#else|#endif/));
if ($line =~ /#if/) {
$nested++;
} elsif ($line =~ /#endif/) {
$nested--
}
next if ($line !~ /^struct/);
print "private$line";
do {
$line = <INFILE>;
print $line;
} until ($line =~ /^\}/);
}
} elsif ($line =~ /$eatit_regex/) {
$nested = 0;
while ($line = <INFILE>) {
last if (!$nested && ($line =~ /#else|#endif/));
if ($line =~ /#if/) {
$nested++;
} elsif ($line =~ /#endif/) {
$nested--
}
}
} elsif ($line =~ /^#\s*ifn?\s*\!?def/) {
$ifdeflevel++;
#print "#ifn?def ($ifdeflevel): $line\n";
if ($line =~ /#ifndef.*DISABLE_DEPRECATED/) {
$deprecated = $ifdeflevel;
} elsif ($line =~ /#if !defined.*DISABLE_DEPRECATED/) {
$deprecated = $ifdeflevel;
}
} elsif ($line =~ /^#\s*endif/) {
#print "#endif ($ifdeflevel): $line\n";
if ($deprecated == $ifdeflevel) {
$deprecated = -1;
}
$ifdeflevel--;
} elsif ($line =~ /typedef struct\s*\{?\s*$/) {
while ($line !~ /{/) {
chomp ($line);
$line .= <INFILE>;
}
my $first_line = $line;
my @lines = ();
$line = <INFILE>;
while ($line !~ /^}\s*(\w+);/) {
if ($line =~ /\(.*\).*\(/) {
while ($line !~ /;/) {
chomp ($line);
$nxt = <INFILE>;
$nxt =~ s/^\s+/ /;
$line .= $nxt;
}
}
push @lines, $line;
$line = <INFILE>;
}
$line =~ /^}\s*(\w+);/;
my $name = $1;
print "typedef struct _$name $name;\n";
print "struct _$name {\n";
foreach $line (@lines) {
if ($line =~ /(\s*.+\;)/) {
$field = $1;
$field =~ s/(\w+) const/const $1/;
print "$field\n";
}
}
print "};\n";
} elsif ($line =~ /^enum\s+\{/) {
while ($line !~ /^};/) {$line = <INFILE>;}
} elsif ($line =~ /^(typedef\s+)?union/) {
next if ($line =~ /^typedef\s+union\s+\w+\s+\w+;/);
while ($line !~ /^};/) {$line = <INFILE>;}
} elsif ($line =~ /(\s+)union\s*{/) {
# this is a hack for now, but I need it for the fields to work
$indent = $1;
$do_print = 1;
while ($line !~ /^$indent}\s*\w+;/) {
$line = <INFILE>;
next if ($line !~ /;/);
print $line if $do_print;
$do_print = 0;
}
} else {
if ($braces or $line =~ /;|\/\*/) {
if ($deprecated == -1) {
print $line;
} else {
print "deprecated$line";
}
} else {
$prepend = $line;
$prepend =~ s/\n/ /g;
}
}
}
}
foreach $fname (@srcs, @privhdrs) {
open(INFILE, $fname) || die "Could open $fname\n";
if ($fname =~ /builtins_ids/) {
while ($line = <INFILE>) {
next if ($line !~ /\{/);
chomp($line);
$builtin = "BUILTIN" . $line;
$builtin .= <INFILE>;
print $builtin;
}
next;
}
while ($line = <INFILE>) {
next if ($line !~ /^(struct|\w+_class_init|\w+_base_init|\w+_get_type\b|G_DEFINE_TYPE_WITH_CODE)/);
if ($line =~ /^G_DEFINE_TYPE_WITH_CODE/) {
my $macro;
my $parens = 0;
do {
chomp ($line);
$line =~ s/(.*)\\$/\1/;
$line =~ s/^\s+(.*)/ \1/;
$macro .= $line;
foreach $chr (split (//, $line)) {
if ($chr eq "(") {
$parens++;
} elsif ($chr eq ")") {
$parens--;
}
}
$line = <INFILE>;
} while ($parens > 0);
print "$macro\n";
next if ($line !~ /^(struct|\w+_class_init|\w+_base_init)/);
}
if ($line =~ /^struct/) {
# need some of these to parse out parent types
print "private";
if ($line =~ /;/) {
print $line;
next;
}
}
$comment = 0;
$begin = 0;
$end = 0;
do {
# Following ifs strips out // and /* */ C comments
if ($line =~ /\/\*/) {
$comment = 1;
$begin = 1;
}
if ($comment != 1) {
$line =~ s/\/\/.*//;
print $line;
}
if ($line =~ /\*\//) {
$comment = 0;
$end = 1;
}
if ($begin == 1 && $end == 1) {
$line =~ s/\/\*.*\*\///;
print $line;
}
$begin = 0;
$end = 0;
} until (($line = <INFILE>) =~ /^}/);
print $line;
}
}

View file

@ -1,7 +1,8 @@
MAINTAINERCLEANFILES = Makefile.in
api:
$(GAPI_PARSER) gstreamer-sharp-source.xml
$(MONO) $(top_builddir)/parser/gst-gapi-parser.exe \
gstreamer-sharp-source.xml
grep -v "public const string " \
$(top_srcdir)/gstreamer-sharp/Tag.custom \
> $(top_srcdir)/gstreamer-sharp/Tag.custom.tmp