diff options
| -rw-r--r-- | gen.rc | 91 | ||||
| -rw-r--r-- | ninja.rc | 137 | ||||
| -rwxr-xr-x | setup.rc | 41 |
3 files changed, 138 insertions, 131 deletions
@@ -1,94 +1,3 @@ -fn stamp { - build '$outdir/stamp' stamp '$outdir'/$* -} - -fn cflags { - set cflags '$cflags' $* -} - -fn cc { - src=$1 obj=$src.o { - shift - if(! ~ $src '$'*) { - src='$srcdir'/src/$src - obj='$outdir'/$obj - } - build $obj cc $src $* - } -} - -fn link { - out='$outdir'/$1 objs=() { - shift - for(obj in $*) { - if(! ~ $obj '$'*) obj='$outdir'/$obj - objs=( $objs $obj ) - } - build $out link $objs - } -} - -fn ar { - out='$outdir'/$1 objs=() { - shift - for(obj in $*) { - if(! ~ $obj '$'*) obj='$outdir'/$obj - objs=( $objs $obj ) - } - build $out ar $objs - } -} - -fn static_lib { - out=$1 { - shift - for(src) cc $src - ar $out $*.o - } -} - -fn exe { - out=$1 objs=() { - shift - for(src) { - if(~ $src *.c) { - cc $src - obj=$src.o - } - if not obj=$src - objs=( $objs $obj ) - } - link $out $objs - } -} - -fn yacc { - outs='$outdir'/$1.tab.^( c h ) { - let yaccflags '-d -b '$1 -- build $"outs yacc $2 - } -} - -fn file { - out='$hash_root'/$1 - let args 100$3' '$1 --\ - build $out githash $2 '|' '$repo.stamp' '$root_srcdir/scripts/hash.rc' - root_inputs=( $root_inputs $out ) - - if(! ~ $3 755 644) root_perms=( $root_perms 100$3' '$1 ) - status=() -} - -fn dir { - root_perms=( $root_perms '010'$2' '$1 ) -} - -fn sym { - out='$hash_root'/$1 - let args 120000' '$1' '$2 --\ - build $out githash '| $repo.stamp' '$root_srcdir/scripts/hash.rc' - root_inputs=( $root_inputs $out ) -} - root_inputs=() root_perms=() diff --git a/ninja.rc b/ninja.rc new file mode 100644 index 00000000..13d83ec1 --- /dev/null +++ b/ninja.rc @@ -0,0 +1,137 @@ +# ninja constructs + +fn set { + var=$1 { + shift + printf '%s = %s\n' $var $"* + } +} + +fn let { + vars=() { + while(! ~ $1 --) { + vars=( $vars $1' = '$2 ) + shift 2 + } + shift + $* + printf ' %s\n' $vars + } +} + +fn subninja { + echo subninja $* +} + +fn include { + echo include $* +} + +fn rule { + name=$1 { + shift + let command $"* -- echo rule $name + } +} + +fn build { + out=$1 rule=$2 { + shift 2 + echo build $out: $rule $* + } +} + +# higher-level rules + +fn stamp { + build '$outdir/stamp' stamp '$outdir'/$* +} + +fn cflags { + set cflags '$cflags' $* +} + +fn cc { + src=$1 obj=$src.o { + shift + if(! ~ $src '$'*) { + src='$srcdir'/src/$src + obj='$outdir'/$obj + } + build $obj cc $src $* + } +} + +fn link { + out='$outdir'/$1 objs=() { + shift + for(obj in $*) { + if(! ~ $obj '$'*) obj='$outdir'/$obj + objs=( $objs $obj ) + } + build $out link $objs + } +} + +fn ar { + out='$outdir'/$1 objs=() { + shift + for(obj in $*) { + if(! ~ $obj '$'*) obj='$outdir'/$obj + objs=( $objs $obj ) + } + build $out ar $objs + } +} + +fn static_lib { + out=$1 { + shift + for(src) cc $src + ar $out $*.o + } +} + +fn exe { + out=$1 objs=() { + shift + for(src) { + if(~ $src *.c) { + cc $src + obj=$src.o + } + if not obj=$src + objs=( $objs $obj ) + } + link $out $objs + } +} + +fn yacc { + outs='$outdir'/$1.tab.^( c h ) { + let yaccflags '-d -b '$1 -- build $"outs yacc $2 + } +} + +# packaging rules + +fn file { + out='$repo.hash'/$1 + let args 100$3' '$1 --\ + build $out githash $2 '|' '$repo.stamp' '$root_srcdir/scripts/hash.rc' + root_inputs=( $root_inputs $out ) + + if(! ~ $3 755 644) root_perms=( $root_perms 100$3' '$1 ) + status=() +} + +fn dir { + root_perms=( $root_perms '010'$2' '$1 ) +} + +fn sym { + out='$repo.hash'/$1 + let args 120000' '$1' '$2 --\ + build $out githash '| $repo.stamp' '$root_srcdir/scripts/hash.rc' + root_inputs=( $root_inputs $out ) +} @@ -42,46 +42,7 @@ root_outdir=$abs_outdir setup_outs=( build.ninja ) setup_ins=() -fn set { - var=$1 { - shift - printf '%s = %s\n' $var $"* - } -} - -fn let { - vars=() { - while(! ~ $1 --) { - vars=( $vars $1' = '$2 ) - shift 2 - } - shift - $* - printf ' %s\n' $vars - } -} - -fn subninja { - echo subninja $* -} - -fn include { - echo include $* -} - -fn rule { - name=$1 { - shift - let command $"* -- echo rule $name - } -} - -fn build { - out=$1 rule=$2 { - shift 2 - echo build $out: $rule $* - } -} +. ./ninja.rc fn subgen { olddir=$dir |
