Win32: let mingw_execve() return an int
[git/mingw/4msysgit.git] / contrib / buildsystems / Generators.pm
blob408ef714b8f0dcd0328dcef0055cc92f7737babb
1 package Generators;
2 require Exporter;
4 use strict;
5 use File::Basename;
6 no strict 'refs';
7 use vars qw($VERSION @AVAILABLE);
9 our $VERSION = '1.00';
10 our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE);
11 @ISA = qw(Exporter);
13 BEGIN {
14 local(*D);
15 my $me = $INC{"Generators.pm"};
16 die "Couldn't find myself in \@INC, which is required to load the generators!" if ("$me" eq "");
17 $me = dirname($me);
18 if (opendir(D,"$me/Generators")) {
19 foreach my $gen (readdir(D)) {
20 next if ($gen =~ /^\.\.?$/);
21 require "${me}/Generators/$gen";
22 $gen =~ s,\.pm,,;
23 push(@AVAILABLE, $gen);
25 closedir(D);
26 my $gens = join(', ', @AVAILABLE);
29 push @EXPORT_OK, qw(available);
32 sub available {
33 return @AVAILABLE;
36 sub generate {
37 my ($gen, $git_dir, $out_dir, $rel_dir, %build_structure) = @_;
38 return eval("Generators::${gen}::generate(\$git_dir, \$out_dir, \$rel_dir, \%build_structure)") if grep(/^$gen$/, @AVAILABLE);
39 die "Generator \"${gen}\" is not available!\nAvailable generators are: @AVAILABLE\n";