blob: 925094773637fd78d583647109c3a8f1a7a35491 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/bin/rc
. ./config.rc
flag e +
fn usage {
echo 'usage: '$0' [dir]' >[1=2]
exit 2
}
if(! ~ $#* 0 1) usage
. ./ninja.rc
fn subgen {
subninja '$dir'/$1/local.ninja
gen_inputs=($gen_inputs phony/'$dir'/$1/ninja)
tree_inputs=($tree_inputs '$outdir'/$1/root.tree)
perms_inputs=($perms_inputs '$outdir'/$1/root.perms)
if(~ $recurse 1 || ! [ -f $1/local.ninja ]) @ gen $1 &
status=()
}
fn gen {
if(~ $dir '' .) dir=$1
if not dir=$dir/$1
cd $1
tree_perms=()
perms_inputs=()
tree_inputs=()
gen_inputs=()
absdir=`{pwd}
{
set dir $dir
if(~ $dir .) set outdir '$builddir'
if not set outdir '$builddir/$dir'
if([ -d src ]) {
cd src
if(~ $dir .) set srcdir src
if not set srcdir '$dir/src'
}
. $absdir/gen.rc
build '$dir/local.ninja' gen '|' setup.rc config.rc ninja.rc '$dir/gen.rc'
phony ninja '$dir/local.ninja' $gen_inputs
if(! ~ $#tree_perms 0) {
printf '%s\n' $tree_perms | sort >$absdir/local.perms
perms_inputs=($perms_inputs '$dir'/local.perms)
}
if(~ $#perms_inputs 0) build '$outdir/root.perms' empty
if not build '$outdir/root.perms' mergeperms $perms_inputs
if(~ $#tree_inputs 0) build '$outdir/root.tree' empty
if not build '$outdir/root.tree' cat $tree_inputs
} >local.ninja.tmp
mv $absdir/^(local.ninja.tmp local.ninja)
echo 'generated '$dir >[1=2]
wait
}
if(! ~ $#* 0) { gen $1 ; exit }
recurse=1
@ gen .
|