提交 8d34daf0 编写于 作者: R Richard Levitte

Build system: add include directories and dependencies for generators

In the case of generating a file like this:

    GENERATE[foo.S]=mkfoo.pl arg1 arg2

the 'mkfoo.pl' generator itself might need to include other files,
such as perl modules within our source tree.  We can reuse already
existing syntax for it, like this:

    INCLUDE[mkfoo.pl]=module/path

or:

    DEPEND[mkfoo.pl]=modules/mymodule.pm

This change implements the support for such constructs, and for the
DEPEND statement, for any value that indicates a perl module (.pm
file), it will automatically infer an INCLUDE statement for its
directory, just like it does for C header files, so you won't have do
write this:

    DEPEND[mkfoo.pl]=modules/mymodule.pm
    INCLUDE[mkfoo.pl]=modules
Reviewed-by: NEmilia Käsper <emilia@openssl.org>
上级 79356a83
......@@ -42,8 +42,11 @@
my $bin = shift;
my %opts = @_;
if ($unified_info{generate}->{$src}) {
my $script = $unified_info{generate}->{$src}->[0];
$OUT .= generatesrc(src => $src,
generator => $unified_info{generate}->{$src},
generator_incs => $unified_info{includes}->{$script},
generator_deps => $unified_info{depends}->{$script},
deps => $unified_info{depends}->{$src},
incs => [ @{$unified_info{includes}->{$bin}},
@{$unified_info{includes}->{$obj}} ],
......
......@@ -441,12 +441,13 @@ configdata.pm : {- join(" ", sourcefile("Configurations", "descrip.mms.tmpl"), s
sub generatesrc {
my %args = @_;
my $generator = join(" ", @{$args{generator}});
my $deps = join(", -\n\t\t", @{$args{deps}});
my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
if ($args{src} !~ /\.[sS]$/) {
return <<"EOF";
$args{src} : $args{generator}->[0] $deps
\$(PERL) $generator > \$@
\$(PERL)$generator_incs $generator > \$@
EOF
} else {
die "No method to generate assembler source present.\n";
......
......@@ -808,19 +808,20 @@ configdata.pm: $(SRCDIR)/Configurations/unix-Makefile.tmpl $(SRCDIR)/Configurati
sub generatesrc {
my %args = @_;
my $generator = join(" ", @{$args{generator}});
my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
my $incs = join("", map { " -I".$_ } @{$args{incs}});
my $deps = join(" ", @{$args{deps}});
my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
if ($args{src} !~ /\.[sS]$/) {
return <<"EOF";
$args{src}: $args{generator}->[0] $deps
\$(PERL) $generator > \$@
\$(PERL)$generator_incs $generator > \$@
EOF
} else {
if ($args{generator}->[0] =~ /\.pl$/) {
$generator = 'CC="$(CC)" $(PERL) '.$generator;
$generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
} elsif ($args{generator}->[0] =~ /\.m4$/) {
$generator = 'm4 -B 8192 '.$generator.' >'
$generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
} elsif ($args{generator}->[0] =~ /\.S$/) {
$generator = undef;
} else {
......
......@@ -252,17 +252,18 @@ configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
my %args = @_;
(my $target = $args{src}) =~ s/\.[sS]$/.asm/;
my $generator = join(" ", @{$args{generator}});
my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
my $incs = join("", map { " /I ".$_ } @{$args{incs}});
my $deps = join(" ", @{$args{deps}});
my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
if ($target !~ /\.asm$/) {
return <<"EOF";
$target: $args{generator}->[0] $deps
\$(PERL) $generator > \$@
\$(PERL)$generator_incs $generator > \$@
EOF
} else {
if ($args{generator}->[0] =~ /\.pl$/) {
$generator = '$(PERL) '.$generator;
$generator = '$(PERL)'.$generator_incs.' '.$generator;
} elsif ($args{generator}->[0] =~ /\.S$/) {
$generator = undef;
} else {
......
......@@ -1612,9 +1612,15 @@ EOF
foreach (keys %depends) {
my $dest = $_;
my $ddest = cleanfile($buildd, $_, $blddir);
if ($unified_info{rename}->{$ddest}) {
$ddest = $unified_info{rename}->{$ddest};
my $ddest = cleanfile($sourced, $_, $blddir);
# If the destination doesn't exist in source, it can only be
# a generated file in the build tree.
if (! -f $ddest) {
$ddest = cleanfile($buildd, $_, $blddir);
if ($unified_info{rename}->{$ddest}) {
$ddest = $unified_info{rename}->{$ddest};
}
}
foreach (@{$depends{$dest}}) {
my $d = cleanfile($sourced, $_, $blddir);
......@@ -1635,9 +1641,9 @@ EOF
$d = $unified_info{rename}->{$d};
}
$unified_info{depends}->{$ddest}->{$d} = 1;
# If we depend on a header file, let's make sure it
# can get included
if ($d =~ /\.h$/) {
# If we depend on a header file or a perl module, let's make
# sure it can get included
if ($d =~ /\.(h|pm)$/) {
my $i = dirname($d);
push @{$unified_info{includes}->{$ddest}}, $i
unless grep { $_ eq $i } @{$unified_info{includes}->{$ddest}};
......@@ -1647,9 +1653,15 @@ EOF
foreach (keys %includes) {
my $dest = $_;
my $ddest = cleanfile($buildd, $_, $blddir);
if ($unified_info{rename}->{$ddest}) {
$ddest = $unified_info{rename}->{$ddest};
my $ddest = cleanfile($sourced, $_, $blddir);
# If the destination doesn't exist in source, it can only be
# a generated file in the build tree.
if (! -f $ddest) {
$ddest = cleanfile($buildd, $_, $blddir);
if ($unified_info{rename}->{$ddest}) {
$ddest = $unified_info{rename}->{$ddest};
}
}
foreach (@{$includes{$dest}}) {
my $i = cleandir($sourced, $_, $blddir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册