1. Shlomi Fish
  2. Website Meta Language

Commits

shl...@7081e830-ea04-0410-ae62-fb6148e2d9db  committed 39f0684

Add the CMake code for wml_include.

  • Participants
  • Parent commits 81b74e2
  • Branches conversion-to-cmake

Comments (0)

Files changed (4)

File src/CMakeLists.txt

View file
  • Ignore whitespace
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
 # TODO:
-# add wml_test , 
-# wml_include , wml_misc , wml_test
+# wml_misc , wml_test
 SUBDIRS (
     wml_aux 
     wml_backend  
     wml_docs
     wml_frontend
     wml_test
+    wml_include
      )

File src/Common.cmake

View file
  • Ignore whitespace
     )
 ENDMACRO(RUN_POD2MAN)
 
+MACRO(INST_RENAME_POD2MAN TARGET_NAME SOURCE DEST SECTION INSTNAME)
+   RUN_POD2MAN("${TARGET_NAME}" "${SOURCE}" "${DEST}.${SECTION}"
+       "${SECTION}"
+       "EN Tools" "EN Tools"
+   )
+   INSTALL_RENAME_MAN ("${DEST}.${SECTION}" "${SECTION}" "${INSTNAME}")
+ENDMACRO(INST_RENAME_POD2MAN)
 
 # Finds libm and puts the result in the MATH_LIB_LIST variable.
 # If it cannot find it, it fails with an error.
     )
 ENDMACRO(INSTALL_MAN)
 
+MACRO(INSTALL_RENAME_MAN SOURCE SECTION INSTNAME)
+    INSTALL(
+        FILES
+            "${SOURCE}"
+        DESTINATION
+            "share/man/man${SECTION}"
+        RENAME
+            "${INSTNAME}.${SECTION}"
+    )
+ENDMACRO(INSTALL_RENAME_MAN)
+
 MACRO(INSTALL_CAT_MAN SOURCE SECTION)
     INSTALL(
         FILES

File src/wml_include/CMakeLists.txt

View file
  • Ignore whitespace
+SET (myfiles
+    des/all
+    des/gfont
+    des/imgbg
+    des/imgdot
+    des/lowsrc
+    des/navbar
+    des/preload
+    des/rollover
+    des/space
+    des/typography
+    fmt/all
+    fmt/isolatin
+    fmt/pod
+    fmt/sdf
+    fmt/text
+    fmt/url
+    fmt/verbatim
+    fmt/xtable
+    imp/all
+    imp/csmap
+    imp/fsview
+    imp/generic
+    mod/all
+    mod/MakeMaker
+    mod/version
+    std/all
+    std/box
+    std/case
+    std/grid
+    std/href
+    std/info
+    std/label
+    std/lang
+    std/logo
+    std/page
+    std/tags
+    std/toc
+    sup/all
+    sup/hextriple
+    sup/path
+    sys/all
+    sys/bootp4
+    sys/compat1
+)
+
+FOREACH (base ${myfiles})
+    SET (destbase "${base}.wml")
+    SET (dest "${CMAKE_CURRENT_BINARY_DIR}/${destbase}")
+    SET (src "${CMAKE_CURRENT_SOURCE_DIR}/${base}.src")
+    SET (manname "${CMAKE_CURRENT_BINARY_DIR}/${base}")
+
+    STRING (REPLACE "/" "__" target_base "${base}")
+
+    ADD_CUSTOM_COMMAND(
+        OUTPUT "${dest}"
+        COMMAND "${PATH_PERL}"
+        ARGS "${CMAKE_CURRENT_SOURCE_DIR}/preprocess-perl-source.pl"
+            "--input" "${src}"
+            "--output" "${dest}"
+        DEPENDS "${src}"
+    )
+    ADD_CUSTOM_TARGET(
+        "preprocess_perl_include_${target_base}" ALL
+        DEPENDS "${dest}"
+    )
+    INSTALL (FILES "${dest}" DESTINATION "lib/include/${destbase}")
+    STRING (REPLACE "/" "::" dest_man "wml/${base}")
+
+    INST_RENAME_POD2MAN(
+        "include_${target_base}_pod"
+        "${src}"
+        "${manname}"
+        "3"
+        "${dest_man}"
+    )
+ENDFOREACH(base)
+

File src/wml_include/preprocess-perl-source.pl

View file
  • Ignore whitespace
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Getopt::Long;
+
+my @params;
+
+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;
+}
+