|
@@ -36,29 +36,10 @@ build1() {
|
36
|
36
|
local srcpath dstpath
|
37
|
37
|
srcpath=$1
|
38
|
38
|
dstpath=${srcpath%.skel}
|
39
|
|
- perl -pe "
|
40
|
|
- s|__FFOO_DIR__|$shrdir|;
|
41
|
|
- s|__VERSION__|$(get_version)|;
|
42
|
|
- " < $srcpath > $dstpath
|
|
39
|
+ expand_variables < $srcpath > $dstpath
|
43
|
40
|
if grep -qe '.md$' <<<"$dstpath";
|
44
|
41
|
then
|
45
|
|
- perl -we '
|
46
|
|
- use strict;
|
47
|
|
- my $text;
|
48
|
|
- while (<>) {
|
49
|
|
- chomp;
|
50
|
|
- if (m/<!-- include4: (\S+) -->/) {
|
51
|
|
- open my $fh, $1 or warn "cannot find: $1";
|
52
|
|
- my $text = do { local($/); <$fh> };
|
53
|
|
- close $fh;
|
54
|
|
- $text =~ s/^(.)/ $1/gm;
|
55
|
|
- chomp $text;
|
56
|
|
- print "$text\n";
|
57
|
|
- } else {
|
58
|
|
- print "$_\n";
|
59
|
|
- }
|
60
|
|
- }
|
61
|
|
- ' < $srcpath > $dstpath
|
|
42
|
+ expand_includes < $srcpath > $dstpath
|
62
|
43
|
fi
|
63
|
44
|
echo $dstpath >> built.list
|
64
|
45
|
}
|
|
@@ -100,6 +81,41 @@ dist() {
|
100
|
81
|
rm -rf $dirname
|
101
|
82
|
}
|
102
|
83
|
|
|
84
|
+expand_includes() {
|
|
85
|
+ #
|
|
86
|
+ # Expand include directives
|
|
87
|
+ #
|
|
88
|
+ # Expand e.g. `<!-- include4: foo.sh -->` to include code of foo.sh
|
|
89
|
+ #
|
|
90
|
+ perl -we '
|
|
91
|
+ use strict;
|
|
92
|
+ my $text;
|
|
93
|
+ while (<>) {
|
|
94
|
+ chomp;
|
|
95
|
+ if (m/<!-- include4: (\S+) -->/) {
|
|
96
|
+ open my $fh, $1 or warn "cannot find: $1";
|
|
97
|
+ my $text = do { local($/); <$fh> };
|
|
98
|
+ close $fh;
|
|
99
|
+ $text =~ s/^(.)/ $1/gm;
|
|
100
|
+ chomp $text;
|
|
101
|
+ print "$text\n";
|
|
102
|
+ } else {
|
|
103
|
+ print "$_\n";
|
|
104
|
+ }
|
|
105
|
+ }
|
|
106
|
+ '
|
|
107
|
+}
|
|
108
|
+
|
|
109
|
+expand_variables() {
|
|
110
|
+ #
|
|
111
|
+ # Expand variable values
|
|
112
|
+ #
|
|
113
|
+ perl -pe "
|
|
114
|
+ s|__FFOO_DIR__|$shrdir|;
|
|
115
|
+ s|__VERSION__|$(get_version)|;
|
|
116
|
+ "
|
|
117
|
+}
|
|
118
|
+
|
103
|
119
|
install() {
|
104
|
120
|
mkdir -vp $bindir \
|
105
|
121
|
$docdir \
|