Commits

shl...@7081e830-ea04-0410-ae62-fb6148e2d9db  committed fc03560

Fixed p9_slice.

  • Participants
  • Parent commits c417c4a
  • Branches conversion-to-cmake

Comments (0)

Files changed (3)

File src/wml_backend/p9_slice/CMakeLists.txt

 SET(BASENAME "slice")
 SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${BASENAME}_main.pl")
+SET(intermediate "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}.pre.pl")
 SET(dest "${CMAKE_CURRENT_BINARY_DIR}/${BASENAME}.pl")
 
 ADD_CUSTOM_COMMAND(
-    OUTPUT "${dest}"
+    OUTPUT "${intermediate}"
     COMMAND "${PERL_EXECUTABLE}"
     ARGS "${CMAKE_CURRENT_SOURCE_DIR}/etc/expand.pl"
          "${src}"
-         "${dest}"
+         "${intermediate}"
     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
     DEPENDS "${src}"
 )
+
 ADD_CUSTOM_TARGET(
-    "${BASENAME}_preproc" ALL
-    DEPENDS "${dest}"
+    "${BASENAME}_preproc_2" ALL
+    DEPENDS "${intermediate}"
+)
+
+PREPROCESS_PATH_PERL(
+    "${BASENAME}_preproc" "${intermediate}" "${dest}"
 )
 
 SET(INST_BASE "wml_p9_${BASENAME}")

File src/wml_backend/p9_slice/etc/expand.pl

 
 my ($input_fn, $output_fn) = @ARGV;
 
-open my $out_fh, ">", $output_fn
-    or die "Could not open '$output_fn' for writing";
-
-ProcessFile($input_fn);
-
-close($out_fh);
+my $out_buf = "";
 
 sub ProcessFile {
     my ($filename) = @_;
 
     open(my $fh, "<", $filename)
-        or die "Could not open filename.";
+        or die "Could not open filename '$filename'.";
 
+    LINES:
     while(my $l = <$fh>) {
         #   include a file
         if (my ($pre, $new_fn, $suf) = 
-            $l =~ m|^(.*)require[ \"\(]+([^ \"\(]+)[ \"\)]+;(.*)$|) {
-            print {$out_fh} $pre;
+            $l =~ m|^(.*)require[ \"\(]+([^ \"\(]+)[ \"\)];(.*)$|) {
+            $out_buf .= $pre;
             ProcessFile($new_fn);
-            print {$out_fh} $suf;
+            $out_buf .= $suf;
+            next LINES;
+        }
+
+        if (my ($req) = $l =~ m{\Arequire\s+(\w+);\s*\z}ms)
+        {
+            ProcessFile("${req}.pm");
+            next LINES;
         }
         #   remove a require result code
         if ($l =~ m|^1;$|) {
-            next;
+            next LINES;
         }
-        print {$out_fh} $l;
+        $out_buf .= $l;
     }
     close($fh);
 }
 
+ProcessFile($input_fn);
+
+open my $out_fh, ">", $output_fn
+    or die "Could not open '$output_fn' for writing";
+
+print {$out_fh} $out_buf;
+
+close($out_fh);
+
 
 ##EOF##

File src/wml_backend/p9_slice/slice_main.pl

 eval 'exec @PATH_PERL@ -S $0 ${1+"$@"}'
     if $running_under_some_shell;
 
-use strict;
-use warnings;
-
 use vars qw($CFG);
 
 BEGIN { $^W = 0; } # get rid of nasty warnings