diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2006-03-16 20:02:31 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:57:32 -0500 |
commit | ecf0dd6bafaa95692c3ece94b6f71446cd54ebdc (patch) | |
tree | a71646d5f1554d33dc21130fe1a99a4e9e1938b9 /source4/pidl | |
parent | d3087451c4ec25171ba956fe2cd4e1d0f64f7edc (diff) | |
download | samba-ecf0dd6bafaa95692c3ece94b6f71446cd54ebdc.tar.gz samba-ecf0dd6bafaa95692c3ece94b6f71446cd54ebdc.tar.xz samba-ecf0dd6bafaa95692c3ece94b6f71446cd54ebdc.zip |
r14488: Install more headers.
Generate different #include lines in pidl depending on whether
we're building inside or outside of the Samba tree (useful for
3rd-party projects).
(This used to be commit 0c188833154c1fe565cb1735909e408a4a1a6049)
Diffstat (limited to 'source4/pidl')
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4.pm | 32 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm | 17 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm | 18 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/Header.pm | 5 | ||||
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm | 31 | ||||
-rwxr-xr-x | source4/pidl/pidl | 40 |
6 files changed, 96 insertions, 47 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba4.pm b/source4/pidl/lib/Parse/Pidl/Samba4.pm new file mode 100644 index 00000000000..0a284aa85b8 --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/Samba4.pm @@ -0,0 +1,32 @@ +################################################### +# Common Samba4 functions +# Copyright jelmer@samba.org 2006 +# released under the GNU GPL + +package Parse::Pidl::Samba4; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(is_intree choose_header); + +use Parse::Pidl::Util qw(has_property); +use strict; + +use vars qw($VERSION); +$VERSION = '0.01'; + +sub is_intree() +{ + return -f "include/smb.h"; +} + +# Return an #include line depending on whether this build is an in-tree +# build or not. +sub choose_header($$) +{ + my ($in,$out) = @_; + return "#include \"$in\"" if (is_intree()); + return "#include <$out>"; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm index 83df9afe885..85dab372464 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm @@ -117,19 +117,22 @@ sub ParseCoClass($) return $res; } -sub Parse($) +sub Parse($$) { - my $idl = shift; + my ($idl,$ndr_header) = @_; my $res = ""; - foreach my $x (@{$idl}) + $res .= "#include \"librpc/gen_ndr/orpc.h\"\n" . + "#include \"$ndr_header\"\n\n"; + + foreach (@{$idl}) { - if ($x->{TYPE} eq "INTERFACE" && has_property($x, "object")) { - $res.=ParseInterface($x); + if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) { + $res.=ParseInterface($_); } - if ($x->{TYPE} eq "COCLASS") { - $res.=ParseCoClass($x); + if ($_->{TYPE} eq "COCLASS") { + $res.=ParseCoClass($_); } } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm index c0d460fe090..e6366f0f3d1 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm @@ -196,17 +196,21 @@ sub RegistrationFunction($$) return $res; } -sub Parse($) +sub Parse($$) { - my $pidl = shift; + my ($pidl,$comh_filename) = @_; my $res = ""; - foreach my $x (@{$pidl}) { - next if ($x->{TYPE} ne "INTERFACE"); - next if has_property($x, "local"); - next unless has_property($x, "object"); + $res .= "#include \"includes.h\"\n" . + "#include \"lib/com/dcom/dcom.h\"\n" . + "#include \"$comh_filename\"\n"; - $res .= ParseInterface($x); + foreach (@{$pidl}) { + next if ($_->{TYPE} ne "INTERFACE"); + next if has_property($_, "local"); + next unless has_property($_, "object"); + + $res .= ParseInterface($_); } return $res; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 46caba731a4..54e410f7168 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -10,6 +10,7 @@ use strict; use Parse::Pidl::Typelist qw(mapType); use Parse::Pidl::Util qw(has_property is_constant); use Parse::Pidl::NDR qw(GetNextLevel GetPrevLevel); +use Parse::Pidl::Samba4 qw(is_intree); use vars qw($VERSION); $VERSION = '0.01'; @@ -349,6 +350,10 @@ sub Parse($) $res = ""; %headerstructs = (); pidl "/* header auto-generated by pidl */\n\n"; + if (!is_intree()) { + pidl "#include <core.h>"; + } + foreach (@{$idl}) { ($_->{TYPE} eq "INTERFACE") && HeaderInterface($_); } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 972368195b4..f4672e93e97 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -11,6 +11,7 @@ use strict; use Parse::Pidl::Typelist qw(hasType getType mapType); use Parse::Pidl::Util qw(has_property ParseExpr print_uuid); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred); +use Parse::Pidl::Samba4 qw(is_intree choose_header); use vars qw($VERSION); $VERSION = '0.01'; @@ -2237,16 +2238,16 @@ sub HeaderInterface($) my $count = 0; - pidl_hdr "#include \"librpc/ndr/libndr.h\""; + pidl_hdr choose_header("librpc/ndr/libndr.h", "ndr.h"); if (has_property($interface, "object")) { - pidl "#include \"librpc/gen_ndr/ndr_orpc.h\""; + pidl choose_header("librpc/gen_ndr/ndr_orpc.h", "ndr/orpc.h"); } if (defined $interface->{PROPERTIES}->{depends}) { my @d = split / /, $interface->{PROPERTIES}->{depends}; foreach my $i (@d) { - pidl "#include \"librpc/gen_ndr/ndr_$i\.h\""; + pidl choose_header("librpc/gen_ndr/ndr_$i\.h", "gen_ndr/ndr_$i.h"); } } @@ -2311,7 +2312,7 @@ sub ParseInterface($$) pidl_hdr ""; if ($needed->{"compression"}) { - pidl "#include \"librpc/ndr/ndr_compression.h\""; + pidl choose_header("librpc/ndr/ndr_compression.h", "ndr/compression.h"); } HeaderInterface($interface); @@ -2347,9 +2348,9 @@ sub ParseInterface($$) ##################################################################### # parse a parsed IDL structure back into an IDL file -sub Parse($$) +sub Parse($$$) { - my($ndr,$basename) = @_; + my($ndr,$gen_header,$ndr_header) = @_; $tabs = ""; $res = ""; @@ -2357,9 +2358,27 @@ sub Parse($$) $res_hdr = ""; pidl_hdr "/* header auto-generated by pidl */"; pidl_hdr ""; + pidl_hdr "#include \"$gen_header\""; + pidl_hdr ""; pidl "/* parser auto-generated by pidl */"; pidl ""; + if (is_intree()) { + pidl "#include \"includes.h\""; + } else { + pidl "#define _GNU_SOURCE"; + pidl "#include <stdint.h>"; + pidl "#include <stdlib.h>"; + pidl "#include <stdio.h>"; + pidl "#include <stdarg.h>"; + pidl "#include <string.h>"; + } + pidl choose_header("libcli/util/nterr.h", "core/nterr.h"); + pidl choose_header("librpc/gen_ndr/ndr_misc.h", "gen_ndr/ndr_misc.h"); + pidl choose_header("librpc/gen_ndr/ndr_dcerpc.h", "gen_ndr/ndr_dcerpc.h"); + pidl "#include \"$ndr_header\""; + pidl choose_header("librpc/rpc/dcerpc.h", "dcerpc.h"); #FIXME: This shouldn't be here! + pidl ""; my %needed = (); diff --git a/source4/pidl/pidl b/source4/pidl/pidl index 1cfc005c2f4..d913e84e7d5 100755 --- a/source4/pidl/pidl +++ b/source4/pidl/pidl @@ -613,27 +613,22 @@ sub process_file($) unlink($tempfile); } + + my $comh_filename = ($opt_com_header or "$outputdir/com_$basename.h"); if (defined($opt_com_header)) { require Parse::Pidl::Samba4::COM::Header; - my $res = Parse::Pidl::Samba4::COM::Header::Parse($pidl); + my $res = Parse::Pidl::Samba4::COM::Header::Parse($pidl,"$outputdir/ndr_$basename.h"); if ($res) { - my $comh_filename = ($opt_com_header or "$outputdir/com_$basename.h"); - FileSave($comh_filename, - "#include \"librpc/gen_ndr/ndr_orpc.h\"\n" . - "#include \"$outputdir/ndr_$basename.h\"\n" . - $res); + FileSave($comh_filename, $res); } } if (defined($opt_dcom_proxy)) { require Parse::Pidl::Samba4::COM::Proxy; - my $res = Parse::Pidl::Samba4::COM::Proxy::Parse($pidl); + my $res = Parse::Pidl::Samba4::COM::Proxy::Parse($pidl,$comh_filename); if ($res) { my ($client) = ($opt_dcom_proxy or "$outputdir/$basename\_p.c"); - FileSave($client, - "#include \"includes.h\"\n" . - "#include \"$outputdir/com_$basename.h\"\n" . - "#include \"lib/com/dcom/dcom.h\"\n" .$res); + FileSave($client, $res); } } @@ -690,12 +685,12 @@ sub process_file($) require Parse::Pidl::Samba4::NDR::Server; my $dcom = ""; - foreach my $x (@{$pidl}) { - next if ($x->{TYPE} ne "INTERFACE"); + foreach (@{$pidl}) { + next if ($_->{TYPE} ne "INTERFACE"); - if (Parse::Pidl::Util::has_property($x, "object")) { + if (Parse::Pidl::Util::has_property($_, "object")) { require Parse::Pidl::Samba4::COM::Stub; - $dcom .= Parse::Pidl::Samba4::COM::Stub::ParseInterface($x); + $dcom .= Parse::Pidl::Samba4::COM::Stub::ParseInterface($_); } } @@ -717,25 +712,16 @@ $dcom if (defined($opt_ndr_parser)) { my $parser_fname = ($opt_ndr_parser or "$outputdir/ndr_$basename.c"); require Parse::Pidl::Samba4::NDR::Parser; - my $header_fname = $parser_fname; - $header_fname =~ s/\.c$/\.h/; - my ($header,$parser) = Parse::Pidl::Samba4::NDR::Parser::Parse($ndr, $basename); - - my $baseheader = $h_filename; $baseheader =~ s/\/ndr_/\//; - $header = "#include \"$baseheader\"\n$header"; + my ($header,$parser) = Parse::Pidl::Samba4::NDR::Parser::Parse($ndr, $gen_header, $h_filename); - $parser = "#include \"includes.h\"\n" - . "#include \"librpc/gen_ndr/ndr_misc.h\"\n" - . "#include \"librpc/gen_ndr/ndr_dcerpc.h\"\n" - . "#include \"$header_fname\"\n\n$parser"; FileSave($parser_fname, $parser); - FileSave($header_fname, $header); + FileSave($h_filename, $header); if (defined($opt_swig)) { require Parse::Pidl::Samba4::SWIG; my($filename) = ($opt_swig or "$outputdir/$basename.i"); - Parse::Pidl::Samba4::SWIG::RewriteHeader($pidl, $header_fname, $filename); + Parse::Pidl::Samba4::SWIG::RewriteHeader($pidl, $h_filename, $filename); } } |