Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added preliminary (incomplete) parts to a launcher.

 * A new launcher with support for dependency management will be created.  It
   will use a library shared by the amsterdam kernel for launching, which
   constructs an awk commandline.  It's bootstrapped by a shell script so
   exec(1) can be used (delegates to exec(3)).
 * The shared library will be used by the kernel to identify dependencies of
   dynamically loaded modules.  The program flow will be as follows:
   1. bootstrap calls runawk.awk to parse kernel.awk and build dependency graph.
   2. bootstrap exec's awk, running the amsterdam kernel, which uses runawk.awk
      as a dependency.
   3. kernel.awk loads all modules, parsing their dependencies using the code
      from runawk.awk

 * This will eliminate any dependencies in runawk.awk, and even dependencies of
   runawk.awk can be simply "known" by the runawk bootstrap.

TODO: Rename runawk to a name that isn't already taken.
  • Loading branch information...
commit 5325a60b54295872a5a7bd0689f21d7652fd24b3 1 parent 1f976de
@ssmccoy authored
Showing with 84 additions and 0 deletions.
  1. +19 −0 bin/runawk
  2. +65 −0 src/runawk.awk
View
19 bin/runawk
@@ -0,0 +1,19 @@
+#!/bin/sh
+# A wrapper which executes runawk.
+
+if [ -z $RUNAWK_HOME ]
+then
+ bindir=`dirname $0`
+ RUNAWK_HOME=`dirname $bindir`
+fi
+
+if [ -z $AWKPATH ] || [ $# -lt 1 ]
+then
+ echo <<USAGE
+ Usage: $0 <awk command line>
+
+ For $0 to work properly, a GNU compatible AWKPATH must be set.
+USAGE
+fi
+
+echo BUILD_COMMAND=1 awk -f $RUNAWK_HOME/src/runawk.awk "$@"
View
65 src/runawk.awk
@@ -0,0 +1,65 @@
+# A simple runawk-style boot strapper.
+# -----------------------------------------------------------------------------
+# "THE BEER-WARE LICENSE" (Revision 43) borrowed from FreeBSD's jail.c:
+# <tag@cpan.org> wrote this file. As long as you retain this notice you
+# can do whatever you want with this stuff. If we meet some day, and you think
+# this stuff is worth it, you can buy me a beer in return. Scott S. McCoy
+# -----------------------------------------------------------------------------
+
+# This utility (which can either be bootstrapped by a shell script, called from
+# the commandline or used as a dependency) is intended to eliminate the
+# duplication in the AMS kernel, by using a run-awk style bootstrapping method.
+# This allows the kernel itself to use other parts of the codebase as
+# dependencies, and still allows this very dependency handling code to be used
+# by the kernel itself.
+
+function readable (file ,result,x) {
+ result = getline x < file
+ close(file)
+
+ return result >= 0
+}
+
+function find (filename ,r,i) {
+ for (i = 1; i <= pathc; i++) {
+ r = pathv[i] "/" filename
+
+ if (readable(r)) {
+ return r
+ }
+ }
+
+ print "error: unable to find file " filename >> "/dev/stderr"
+ exit 1
+}
+
+## Parse a file and determine all of it's dependencies, and theirs,
+# recursively.
+function dependencies (filename ,loaded,input,df,depends) {
+ loaded[filename] = 1
+
+ depends = ""
+
+ while ((getline input < filename) > 0) {
+ if (input ~ /^#use/) {
+ split(input, words, /[\t ][\t ]*/)
+ print "loading module " words[2] >> "/dev/stderr"
+ df = find(words[2])
+
+ if (loaded[df] != 1) {
+ depends = depends " -f " df
+ depends = depends dependencies(df, loaded)
+ }
+ }
+ }
+
+ close(filename)
+
+ return depends
+}
+
+BEGIN {
+ if (ENVIRON["BUILD_COMMAND"]) {
+
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.