]> rtime.felk.cvut.cz Git - novaboot.git/commitdiff
Implement run keyword
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Feb 2014 18:41:02 +0000 (19:41 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 28 Feb 2014 18:41:02 +0000 (19:41 +0100)
This allows to run arbitrary commands during file generation phase.

README.md
examples/linux-test
novaboot
tests/parser.wv

index 29fb2dfb00c35c49ef0b6d8c864efd5b4c293205..0910549ec08270105b809ce8c8cf7aa0ff45958b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -229,8 +229,9 @@ running `scons` or `make`.
 
 - \--no-file-gen
 
-    Do not generate files on the fly (i.e. "<" syntax) except for the
-    files generated via "<<WORD" syntax.
+    Do not run external commands to generate files (i.e. "<" syntax and
+    `run` keyword). This switch does not influence generation of files
+    specified with "<<WORD" syntax.
 
 - \-p, --pulsar\[=mac\]
 
@@ -476,10 +477,17 @@ that line. The SRCDIR variable in CMD's environment is set to the
 absolute path of the directory containing the interpreted novaboot
 script.
 
+Lines starting with `run` keyword contain shell commands that are run
+during file generation phase. This is the same as the "< CMD" syntax
+for `load` keyboard except that the command's output is not
+redirected to a file. The ordering of commands is the same as they
+appear in the novaboot script.
+
 Example (Linux):
 
     #!/usr/bin/env novaboot
     load bzImage console=ttyS0,115200
+    run  make -C buildroot
     load rootfs.cpio < gen_cpio buildroot/images/rootfs.cpio "myapp->/etc/init.d/S99myapp"
 
 Example (NOVA User Land - NUL):
index 5b0dd3c72822d9ee80d7600e9ef7311d97beb74f..2b159b5798c69476060fe62179ddf3a0b02d92ad 100755 (executable)
@@ -1,11 +1,8 @@
 #!/usr/bin/env novaboot
 # -*-sh-*-
 
-# Before this example can be run, you need to build the images refered
-# to below. Simply run:
-#
-#   git submodule update --init
-#   make -C build/buildroot.
+run git submodule update --init
+run make -C build/buildroot
 
 load build/buildroot/images/bzImage console=ttyS0,115200
 load build/buildroot/images/rootfs.cpio.gz
index 58ff4d322c8fcdf3e429925508ca10ca8de4e87c..d9412ad1d3918c7e0d2b74254dbe8e7a4bf3c814 100755 (executable)
--- a/novaboot
+++ b/novaboot
@@ -288,6 +288,10 @@ while (!$skip_reading && ($_ = <>)) {
        push @$modules, $_;
        next;
     }
+    if (/^run (.*)/) {         # run line
+       push @$generated, {command => $1};
+       next;
+    }
 
     die("novaboot: Cannot parse script '$last_fn' line $.. Didn't you forget 'load' keyword?\n");
 }
@@ -339,7 +343,11 @@ sub generate_configs($$$) {
        print "novaboot: Created $fn\n";
       } elsif (exists $$g{command} && ! $no_file_gen) {
        $ENV{SRCDIR} = dirname(File::Spec->rel2abs( $filename, $invocation_dir ));
-       system_verbose("( $$g{command} ) > $$g{filename}");
+       if (exists $$g{filename}) {
+           system_verbose("( $$g{command} ) > $$g{filename}");
+       } else {
+           system_verbose($$g{command});
+       }
       }
     }
 }
@@ -707,7 +715,7 @@ foreach my $script (@scripts) {
     {
        my @files = map({ ($file) = m/([^ ]*)/; $file; } @$modules);
        # Filter-out generated files
-       my @to_build = grep({ my $file = $_; !scalar(grep($file eq $$_{filename}, @$generated)) } @files);
+       my @to_build = grep({ my $file = $_; !scalar(grep($file eq ($$_{filename} || ''), @$generated)) } @files);
 
        system_verbose($scons || $CFG::scons." ".join(" ", @to_build)) if (defined $scons);
        system_verbose($make  || $CFG::make ." ".join(" ", @to_build)) if (defined $make);
@@ -1202,8 +1210,9 @@ server directory where the boot files are copied to.
 
 =item --no-file-gen
 
-Do not generate files on the fly (i.e. "<" syntax) except for the
-files generated via "<<WORD" syntax.
+Do not run external commands to generate files (i.e. "<" syntax and
+C<run> keyword). This switch does not influence generation of files
+specified with "<<WORD" syntax.
 
 =item -p, --pulsar[=mac]
 
@@ -1470,10 +1479,17 @@ that line. The SRCDIR variable in CMD's environment is set to the
 absolute path of the directory containing the interpreted novaboot
 script.
 
+Lines starting with C<run> keyword contain shell commands that are run
+during file generation phase. This is the same as the "< CMD" syntax
+for C<load> keyboard except that the command's output is not
+redirected to a file. The ordering of commands is the same as they
+appear in the novaboot script.
+
 Example (Linux):
 
   #!/usr/bin/env novaboot
   load bzImage console=ttyS0,115200
+  run  make -C buildroot
   load rootfs.cpio < gen_cpio buildroot/images/rootfs.cpio "myapp->/etc/init.d/S99myapp"
 
 Example (NOVA User Land - NUL):
index c9e50018bf4a7923e6dd7ca52f4fac0ee04ccef9..4825d776b2725d9ca665bee61d321840cda31ba8 100755 (executable)
@@ -85,3 +85,7 @@ load <<XXX
 inside heredoc
 XXX
 EOF
+
+WVSTART Run keyword
+WVPASS bash -c "echo run echo ahoj|novaboot -t '' > output"
+WVPASS grep "^ahoj$" output