Commits

Anonymous committed c417c4a

Fix some installation problems. Related to the preprocessing etc.

Comments (0)

Files changed (5)

 ENDMACRO(CHECK_MULTI_FUNCTIONS_EXISTS)
 
 MACRO(PREPROCESS_PATH_PERL TARGET_NAME SOURCE DEST)
-    SET(PATH_PERL ${PERL_EXECUTABLE})
     ADD_CUSTOM_COMMAND(
-        OUTPUT ${DEST}
-        COMMAND ${PATH_PERL} 
-        ARGS "-e" 
-        "open I, qq{<\$ARGV[0]}; open O, qq{>\$ARGV[1]}; while(<I>){s{\\@PATH_PERL\\@}{\$ARGV[2]}g;print O \$_;} close(I); close(O);"
-        ${SOURCE}
-        ${DEST}
-        ${PATH_PERL}
-        COMMAND chmod ARGS "a+x" ${DEST}
-        DEPENDS ${SOURCE}
-        VERBATIM
+        OUTPUT "${DEST}"
+        COMMAND "${PERL_EXECUTABLE}"
+        ARGS "${CMAKE_SOURCE_DIR}/cmake/preprocess-path-perl.pl" 
+            "--input" "${SOURCE}"
+            "--output" "${DEST}"
+            "--subst" "PATH_PERL=${PERL_EXECUTABLE}"
+        COMMAND chmod ARGS "a+x" "${DEST}"
+        DEPENDS "${SOURCE}"
     )
     # The custom command needs to be assigned to a target.
     ADD_CUSTOM_TARGET(

src/cmake/preprocess-path-perl.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+
+my @params = (qw(
+    PATH_PERL
+    ));
+
+my %substitutions;
+
+my $input_fn;
+my $output_fn;
+
+GetOptions
+(
+    "subst=s" => \%substitutions,
+    "input=s" => \$input_fn,
+    "output=s" => \$output_fn,
+);
+
+if (!defined($input_fn))
+{
+    die "Input filename not specified!";
+}
+
+if (!defined($output_fn))
+{
+    die "Output filename not specified!";
+}
+
+verify_all_keys(
+        [sort { $a cmp $b } @params],
+        [sort { $a cmp $b } keys(%substitutions)]
+    );
+
+my $subst_keys_re = join("|", map { quotemeta($_) } @params);
+
+open my $in_fh, "<", $input_fn
+    or die "Could not open '$input_fn'";
+
+open my $out_fh, ">", $output_fn
+    or die "Could not open '$output_fn'";
+
+LINES:
+while (my $line = <$in_fh>)
+{
+    if ($line =~ /\A__END__/)
+    {
+        last LINES;
+    }
+    elsif ($line =~ /^=head1/)
+    {
+        DISCARD_POD:
+        while ($line = <$in_fh>)
+        {
+            if ($line =~ /^=cut/)
+            {
+                last DISCARD_POD;
+            }
+        }
+    }
+    else
+    {
+        $line =~ s{\@($subst_keys_re)\@}[$substitutions{$1}]eg;
+        print {$out_fh} $line;
+    }
+}
+close($in_fh);
+close($out_fh);
+
+chmod(0755, $output_fn);
+
+exit(0);
+
+sub verify_all_keys
+{
+    my ($want, $have) = @_;
+
+    for my $idx (0 .. $#$want)
+    {
+        if ($want->[$idx] ne $have->[$idx])
+        {
+            die "Substitution $want->[$idx] is missing!";
+        }       
+    }
+
+    if (@$have != @$want)
+    {
+        die "Extra keys in substitution: "
+            .  join(",", @{$have}[@$want .. $#$have]) . " !";
+    }
+
+    return;
+}
+
+

src/wml_docs/CMakeLists.txt

-INCLUDE("../Common.cmake")
-
 SET (STDS
     "wml_barebone"
     "wml_std_css1"

src/wml_frontend/preprocess-perl-source.pl

 {
     my ($want, $have) = @_;
 
-    for my $idx (0 .. @$want)
+    for my $idx (0 .. $#$want)
     {
         if ($want->[$idx] ne $have->[$idx])
         {

src/wml_include/preprocess-perl-source.pl

 
 use Getopt::Long;
 
-my @params;
+my @params = ();
 
 my %substitutions;
 
 {
     my ($want, $have) = @_;
 
-    for my $idx (0 .. @$want)
+    for my $idx (0 .. $#$want)
     {
         if ($want->[$idx] ne $have->[$idx])
         {