pidl: handle hyper attribute for wireshark
[kai/samba-autobuild/.git] / pidl / lib / Parse / Pidl / ODL.pm
index ad8c76f62263634ca92836551fee72488e939629..74d9ac7c04d9642c7e2d5138e2b8a125963439b8 100644 (file)
@@ -8,6 +8,7 @@ use Parse::Pidl qw(error);
 use Parse::Pidl::IDL;
 use Parse::Pidl::Util qw(has_property unmake_str);
 use Parse::Pidl::Typelist qw(hasType getType);
+use File::Basename;
 use strict;
 
 use vars qw($VERSION);
@@ -57,11 +58,23 @@ sub ODL2IDL
                if ($x->{TYPE} eq "IMPORT") {
                        foreach my $idl_file (@{$x->{PATHS}}) {
                                $idl_file = unmake_str($idl_file);
-                               my $podl = Parse::Pidl::IDL::parse_file("$basedir/$idl_file", $opt_incdirs);
+                               my $idl_path = undef;
+                               foreach ($basedir, @$opt_incdirs) {
+                                       if (-f "$_/$idl_file") {
+                                               $idl_path = "$_/$idl_file";
+                                               last;
+                                       }
+                               }
+                               unless ($idl_path) {
+                                       error($x, "Unable to open include file `$idl_file'");
+                                       next;
+                               }
+                               my $podl = Parse::Pidl::IDL::parse_file($idl_path, $opt_incdirs);
                                if (defined(@$podl)) {
                                        require Parse::Pidl::Typelist;
+                                       my $basename = basename($idl_path, ".idl");
 
-                                       Parse::Pidl::Typelist::LoadIdl($podl);
+                                       Parse::Pidl::Typelist::LoadIdl($podl, $basename);
                                        my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs);
 
                                        foreach my $y (@$pidl) {
@@ -70,7 +83,7 @@ sub ODL2IDL
                                                }
                                        }
                                } else {
-                                       error($x, "Failed to parse $idl_file");
+                                       error($x, "Failed to parse $idl_path");
                                }
                        }
                }