forked from part-cw/lambdanative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·1797 lines (1700 loc) · 46 KB
/
make.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# LambdaNative - a cross-platform Scheme framework
# Copyright (c) 2009-2020, University of British Columbia
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the
# following conditions are met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# * Neither the name of the University of British Columbia nor
# the names of its contributors may be used to endorse or
# promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# make_debug=yes
dmsg_make()
{
if [ ! "X$scm_debug" = X ]; then
echo "MAKE_DEBUG: $@"
fi
}
# application building, packaging and installation
. ./scripts/tmpdir.sh
. ./scripts/assert.sh
. ./scripts/locate.sh
. ./scripts/compile.sh
. $SYS_TMPDIR/config.cache
setupfile=`locatefile SETUP`
assertfile "$setupfile"
. "$setupfile"
evallog="$SYS_TMPDIR/eval.log"
if [ -f $evallog ]; then
rm $evallog
fi
. ./scripts/package.sh
. ./scripts/verbose.sh
#########################
# general functions
getparam()
{
if [ "$1" = "1" ]; then echo "$2"; fi
if [ "$1" = "2" ]; then echo "$3"; fi
if [ "$1" = "3" ]; then echo "$4"; fi
if [ "$1" = "4" ]; then echo "$5"; fi
if [ "$1" = "5" ]; then echo "$6"; fi
}
rmifexists()
{
if [ ! "X$1" = "X" ]; then
if [ -e "$1" ]; then
if [ ! "X$2" = "Xsilent" ]; then
vecho " => removing old $1.."
fi
rm -rf "$1"
fi
fi
}
string_contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"; then
echo yes
else
echo no
fi
}
string_append_uniq() {
string="$1"
newstring="$2"
if test "${string#*$newstring}" != "$string"; then
echo "$string"
else
echo "$string $newstring"
fi
}
###############################
# keep track of state to reset partial builds
statefile="$SYS_TMPDIR/make.state"
setstate()
{
echo "state=$1" > $statefile
rmifexists $evallog
}
resetstate()
{
state=
if [ -f $statefile ]; then
. $statefile
rm $statefile
fi
if [ ! "X$state" = "X" ]; then
echo " ** WARNING: previous build aborted unexpectantly in state: $state"
case $state in
ARTWORK)
file=`locatefile apps/$SYS_APPNAME/artwork.eps silent`
if [ -f $file ]; then
touch $file
fi
;;
STRINGS)
if [ -d "$SYS_PREFIXROOT/build/$SYS_APPNAME/strings" ]; then
rm "$SYS_PREFIXROOT/build/$SYS_APPNAME/strings/*.scm"
fi
;;
FONTS)
if [ -d "$SYS_PREFIXROOT/build/$SYS_APPNAME/fonts" ]; then
rm "$SYS_PREFIXROOT/build/$SYS_APPNAME/fonts/*.scm"
fi
;;
TEXTURES)
if [ -d "$SYS_PREFIXROOT/build/$SYS_APPNAME/textures" ]; then
rm "$SYS_PREFIXROOT/build/$SYS_APPNAME/textures/*.scm"
fi
;;
esac
fi
}
#################################
# misc file and directory support
stringhash()
{
echo "$1" | cksum | cut -f 1 -d " "
}
isnewer()
{
result=no
if [ ! -e "$2" ]; then
result=yes
else
if `test "$1" -nt "$2"`; then
result=yes
fi
fi
echo $result
}
newersourceindir()
{
result="no"
tgt="$2"
dir=`dirname $1`
srcfiles=
for l in $languages; do
srcfiles="$srcfiles "`ls -1 $dir/*.$l 2> /dev/null`
done
for src in $srcfiles; do
if `test "$src" -nt "$tgt"`; then
result="yes"
fi
done
echo $result
}
newerindir()
{
result="no"
if [ ! -e "$2" ]; then
result=yes
else
tgt="$2"
if [ -d $1 ]; then
dir=$1
else
dir=`dirname $1`
fi
srcfiles=`ls -1 $dir/*`
for src in $srcfiles; do
if `test "$src" -nt "$tgt"`; then
result="yes"
fi
done
fi
echo $result
}
#################################
# autoconf-like parameter substitution
ac_cache="$SYS_TMPDIR/tmp.subst"
ac_reset()
{
if [ -f $ac_cache ]; then
rm $ac_cache
fi
}
ac_subst()
{
ac_tool=$SYS_HOSTPREFIX/bin/subtool
if [ "X$2" = "X" ]; then
paramcmd="echo \"\$${1}\""
substcmd="$ac_tool $ac_cache $1 \"`eval $paramcmd`\""
else
substcmd="$ac_tool $ac_cache $1 \"$2\""
fi
eval $substcmd
}
ac_output()
{
ac_tool=$SYS_HOSTPREFIX/bin/subtool
infile=`echo "${1}" | sed 's/\.in$//'`.in
if [ "X$2" = "X" ]; then
outfile=$1
else
outfile=$2
fi
assertfile $infile "substitution source file $infile not found"
cat $infile | $ac_tool $ac_cache > $outfile
asserterror $? "substitution failed on $infile"
}
#################################
# misc source code checks
has_module()
{
res=no
for a in $@; do
for m in $modules; do
if [ $m = $a ]; then
res=yes
fi
done
done
echo $res
}
is_gui_app()
{
res=`has_module ln_glcore glcore hybridapp hybridapp-xwalk`
echo $res
}
is_standalone_app()
{
neg=`has_module eventloop`
if [ $neg = no ]; then
neg=`has_module hybridapp hybridapp-xwalk`
if [ $neg = no ]; then
neg=yes
else
neg=no
fi
else
neg=no
fi
echo $neg
}
#################################
# conditional include/exclude filter
# first argument is the filter applied to the remaining arguments
filter_entries()
{
filter=$1
entries=`echo "$@ " | cut -f 2- -d " "`
if [ "X$entries" = "X" ] || [ "X$filter" = "X" ]; then
echo ""
fi
res=
for e in $entries; do
entry=`echo "$e" | cut -f 1 -d "!" | cut -f 1 -d "+" `
includes=`echo "$e+" | cut -f 2- -d "+"`
if [ ! "X$includes" = "X" ]; then
included=no
for tmp in `echo "$includes" | tr '+' ' '`; do
if [ "X$tmp" = "X$filter" ]; then
included=yes
fi
done
if [ $included = yes ]; then
res="$res $entry"
fi
fi
excludes=`echo "$e!" | cut -f 2- -d "!"`
if [ ! "X$excludes" = "X" ]; then
excluded=no
for tmp in `echo "$excludes" | tr '!' ' '`; do
if [ "X$tmp" = "X$filter" ]; then
excluded=yes
fi
done
if [ $excluded = no ]; then
res="$res $entry"
fi
fi
if [ "X$includes" = "X" ] && [ "X$excludes" = "X" ]; then
res="$res $entry"
fi
done
echo $res
}
###########################
# general compiler functions
compile_payload()
{
dmsg_make "entering compile_payload [$@]"
payload_cdefs=
payload_objs=
payload_libs="$libraries"
#--------
# register global macros
globalmacrofile="${SYS_HOSTPREFIX}/lib/global-macros.scm"
rmifexists "$globalmacrofile"
for m in $modules; do
modpath=`locatedir modules/$m silent`
if [ -f "$modpath/global-macros.scm" ]; then
cat "$modpath/global-macros.scm" >> "$globalmacrofile"
fi
done
if [ -f "$appsrcdir/global-macros.scm" ]; then
cat "$appsrcdir/global-macros.scm" >> "$globalmacrofile"
fi
# enable all global macros to be visible using ln_repl
defineglobalmacrofile="${SYS_HOSTPREFIX}/lib/define-global-macros.scm"
echo "(define global-macros \`(" > $defineglobalmacrofile
if [ -f "$globalmacrofile" ]; then
cat "$globalmacrofile" >> $defineglobalmacrofile
fi
echo "))" >> $defineglobalmacrofile
#--------
# step 1: compile and assemble the payload objs
for lng in $languages; do
dmsg_make "running compile_payload_${lng}.."
compile_payload_$lng
done
#--------
# generate the hook
echo " => generating hook.."
hookhash=`stringhash "apps/$SYS_APPNAME/hook.c"`
hctgt="$SYS_PREFIX/build/$hookhash.c"
hotgt=`echo "$hctgt" | sed 's/c$/o/'`
rmifexists "$hotgt"
cp loaders/hook/hook.c "$hctgt"
veval "$SYS_ENV $SYS_CC $payload_cdefs $languages_def -c -o $hotgt $hctgt -I$SYS_PREFIX/include"
assertfile $hotgt
payload_objs="$payload_objs $hotgt"
#--------
# add the library objects
for payload_lib in $payload_libs; do
tmp_objs=`ls -1 $SYS_PREFIX/build/$payload_lib/*.o 2> /dev/null | tr '\n' ' '`
payload_objs="$tmp_objs $payload_objs"
done
#--------
# generate the final payload
tgtlib="$SYS_PREFIX/lib/libpayload.a"
echo " => assembling payload.."
rmifexists "$tgtlib"
vecho "$SYS_AR rc $tgtlib $payload_objs"
$SYS_AR rc $tgtlib $payload_objs 2> /dev/null
vecho "$SYS_RANLIB $tgtlib"
$SYS_RANLIB $tgtlib 2> /dev/null
assertfile "$tgtlib"
echo " == $tgtlib"
dmsg_make "payload : $tgtlib"
dmsg_make "leaving compile_payload"
}
##################################
# extract object files from static library
explode_library()
{
dmsg_make "entering explode_library [$@]"
libname=$1
libfile="$SYS_PREFIX/lib/$libname.a"
libdir="$SYS_PREFIX/build/$libname"
if [ -f $libfile ]; then
if [ `isnewer $libfile $libdir` = "yes" ]; then
rmifexists "$libdir"
echo " => exploding library $libname.."
mkdir -p "$libdir"
here=`pwd`
cd "$libdir"
$SYS_AR -x $libfile
cd "$here"
fi
else
if [ ! -d "$SYS_PREFIX/lib/$libname" ]; then
assert "could not find library $libname"
fi
fi
dmsg_make "leaving explode_library"
}
###################################
# artwork & texture generation
make_artwork()
{
setstate ARTWORK
echo "==> creating artwork needed for $SYS_APPNAME.."
mkdir -p "$SYS_PREFIX/build"
mkdir -p "$SYS_PREFIXROOT/build/$SYS_APPNAME"
pngtgt="$SYS_PREFIXROOT/build/$SYS_APPNAME/artwork.png"
svgsrc=`locatefile "apps/$SYS_APPNAME/artwork.svg" silent`
objsrc=`locatefile "apps/$SYS_APPNAME/artwork.obj" silent`
epssrc=`locatefile "apps/$SYS_APPNAME/artwork.eps" silent`
pngsrc=`locatefile "apps/$SYS_APPNAME/artwork.png" silent`
if [ "X$pngsrc" = "X" ]; then
if [ ! "X$svgsrc" = "X" ]; then
if [ `isnewer $svgsrc $pngtgt` = "yes" ]; then
echo " => generating master pixmap from SVG.."
inkscape=inkscape
if [ $SYS_HOSTPLATFORM = macosx ]; then
if [ -f /Applications/Inkscape.app/Contents/Resources/bin/inkscape ]; then
inkscape=/Applications/Inkscape.app/Contents/Resources/bin/inkscape
elif [ -f /Applications/Inkscape.app/Contents/MacOS/inkscape ]; then
inkscape=/Applications/Inkscape.app/Contents/MacOS/inkscape
veval "$inkscape -z $svgsrc -w 1200 -o $pngtgt"
fi
fi
asserttool $inkscape
veval "$inkscape -z $svgsrc -w 1200 -e $pngtgt"
fi
else
if [ "X$epssrc" = "X" ]; then
if [ "X$objsrc" = "X" ]; then
echo "ERROR: artwork not found"
exit 1
fi
assertfile $objsrc
epssrc=`echo $objsrc | sed 's/obj$/eps/'`
fi
if [ `isnewer $objsrc $epssrc` = "yes" ]; then
if [ ! "X$objsrc" = "X" ]; then
assertfile $objsrc
echo " => generating eps artwork.."
asserttool tgif
tgif -print -stdout -eps -color $objsrc > $epssrc
fi
fi
assertfile $epssrc
tmpfile="$SYS_PREFIXROOT/build/$SYS_APPNAME/tmp.png"
if [ `isnewer $epssrc $pngtgt` = "yes" ]; then
echo " => generating master pixmap from EPS.."
gspostfix=
if [ $SYS_HOSTPLATFORM = win32 ]; then
gspostfix=win32
fi
asserttool gs${gspostfix}
veval "gs${gspostfix} -r600 -dNOPAUSE -sDEVICE=png16m -dEPSCrop -sOutputFile=$tmpfile $epssrc quit.ps"
assertfile $tmpfile
asserttool convert
veval "convert $tmpfile -trim -transparent \"#00ff00\" $pngtgt"
rm $tmpfile
fi
fi
else
assertfile $pngsrc
cp $pngsrc $pngtgt
fi
assertfile $pngtgt
if [ -s targets/$SYS_PLATFORM/icon-sizes ]; then
. targets/$SYS_PLATFORM/icon-sizes
for s in $sizes; do
tgt="$SYS_PREFIXROOT/build/$SYS_APPNAME/artwork-$s.png"
if [ `isnewer $epssrc $tgt` = "yes" ]; then
echo " => generating "$s"x"$s" pixmap.."
veval "$SYS_HOSTPREFIX/bin/pngtool scale $pngtgt $s $tgt"
assertfile $tgt
fi
done
fi
setstate
}
make_texturedir()
{
srcdir=$1
prefix=$2
if [ -d "$srcdir" ]; then
images=`ls -1 "$srcdir"/*.png 2> /dev/null`
for imgfile in $images; do
scmfile=$SYS_PREFIXROOT/build/$SYS_APPNAME/textures/"$prefix"`basename $imgfile | sed 's/png$/scm/'`
texture_srcs="$texture_srcs $scmfile"
if [ `isnewer $imgfile $scmfile` = "yes" ]; then
echo " => $imgfile.."
$SYS_HOSTPREFIX/bin/pngtool png2scm "$imgfile" > "$scmfile"
fi
done
fi
}
make_textures()
{
setstate TEXTURES
echo "==> creating textures needed for $SYS_APPNAME.."
tgtdir=$SYS_PREFIXROOT/build/$SYS_APPNAME/textures
mkdir -p $tgtdir
srcdir="$appsrcdir/textures"
if [ -d $srcdir ]; then
make_texturedir "$srcdir" "main-"
fi
for m in $modules; do
srcdir=`locatedir modules/$m/textures silent`
if [ ! "X$srcdir" = "X" ]; then
make_texturedir "$srcdir" "${m}-"
fi
done
setstate
}
make_fontfile()
{
srcfile=$1
prefix=$2
if [ `isnewer $srcfile $incfile` = "yes" ]; then
while read line; do
fline=`echo "$line" | sed '/^#/d'`
if [ "$fline" ]; then
fontname=`echo "$fline" | cut -f 1 -d " "`
font=`locatefile fonts/$fontname`
assertfile $font
bits=`echo "$fline" | cut -f 2 -d " "`
if [ "X$bits" = "X7" ]; then
bits=`locatefile fonts/ascii7.set`
else
if [ "X$bits" = "X8" ]; then
bits=`locatefile fonts/ascii8.set`
else
bits=`locatefile fonts/$bits`
fi
fi
sizes=`echo "$fline" | cut -f 3 -d " "`
name=`echo "$fline" | cut -f 4 -d " "`
scmfile=$tgtdir/${prefix}${name}.scm
font_srcs="$font_srcs $scmfile"
if [ `isnewer $srcfile $scmfile` = "yes" ]; then
echo " => $name using glyph set $bits.."
veval "$SYS_HOSTPREFIX/bin/ttftool fnt2scm $font \"$bits\" $sizes $name > $scmfile"
assertfile $scmfile
fi
fi
done < $srcfile
fi
}
make_fonts()
{
setstate FONTS
echo "==> creating fonts needed for $SYS_APPNAME.."
tgtdir=$SYS_PREFIXROOT/build/$SYS_APPNAME/fonts
mkdir -p $tgtdir
srcfile="$appsrcdir/FONTS"
if [ -f $srcfile ]; then
make_fontfile "$srcfile" "main-"
fi
for m in $modules; do
srcdir=`locatefile modules/$m/FONTS silent`
if [ ! "X$srcdir" = "X" ]; then
make_fontfile "$srcdir" "${m}-"
fi
done
setstate
}
make_string_gd()
{
oldpath=`pwd`
newpath=`mktemp -d $SYS_TMPDIR/tmp.XXXXXX`
cd $newpath
srcfont=$1
assertfile $srcfont
fontname=`$SYS_HOSTPREFIX/bin/ttftool fontname $srcfont`
tgtfont="$fontname".ttf
cp "$srcfont" "$tgtfont"
fontpath=`pwd`"/"
size=$2
string="$3"
name=$4
scmfile="$5"
veval "$SYS_HOSTPREFIX/bin/ttftool stringfile \"$fontpath$tgtfont\" $size \"$string\" $name.png"
assertfile $name.png
$SYS_HOSTPREFIX/bin/pngtool png2scm $name.png > $scmfile
cd $oldpath
rm -rf $newpath
}
make_string_latex()
{
oldpath=`pwd`
newpath=`mktemp -d $SYS_TMPDIR/tmp.XXXXXX`
cd $newpath
srcfont=$1
assertfile $srcfont
fontname=`$SYS_HOSTPREFIX/bin/ttftool fontname $srcfont`
tgtfont="$fontname".ttf
cp "$srcfont" "$tgtfont"
fontpath=`pwd`"/"
size=$2
string="$3"
name=$4
scmfile="$5"
opt="$6"
cat > tmp.tex << __EOF
\batchmode
\documentclass{article}
\makeatletter
\renewcommand{\Large}{\@setfontsize\Large{$size}{$size}}
\makeatother
\usepackage{fontspec}
\usepackage{xunicode}
%\fontspec [ Path = $fontpath ]{$fontname}
\setmainfont[$opt]{[$fontname.ttf]}
\usepackage[margin=0.1in, paperwidth=40in, paperheight=2in]{geometry}
\begin{document}
\thispagestyle{empty}
\noindent \Large
$string
\end{document}
__EOF
veval "xelatex tmp.tex"
assertfile tmp.pdf
if [ "X"`which pdftops 2> /dev/null` = "X" ]; then
veval "pdf2ps tmp.pdf tmp.ps"
else
veval "pdftops -paper match tmp.pdf"
fi
assertfile tmp.ps
veval "ps2eps -B -C tmp.ps"
assertfile tmp.eps
gspostfix=
if [ $SYS_HOSTPLATFORM = win32 ]; then
gspostfix=win32
fi
veval "gs${gspostfix} -r300 -dNOPAUSE -sDEVICE=pnggray -dEPSCrop -sOutputFile=$name.png tmp.eps quit.ps"
assertfile $name.png
veval "convert $name.png -bordercolor White -border 5x5 -negate -scale 25% $name.png"
$SYS_HOSTPREFIX/bin/pngtool png2scm $name.png > $scmfile
cd $oldpath
rm -rf $newpath
}
make_stringfile()
{
srcfile=$1
prefix=$2
cat $srcfile | sed '/^#/d' > $SYS_TMPDIR/tmp.STRINGS
echo >> $SYS_TMPDIR/tmp.STRINGS
while read -r fline; do
if [ "$fline" ]; then
fontname=`eval "getparam 1 $fline"`
font=`locatefile fonts/$fontname`
assertfile $font
size=`eval "getparam 2 $fline"`
label=`eval "getparam 3 $fline" | sed 's:_/:@TMP@:g;s:/:\\\\:g;s:@TMP@:/:g'`
name=`eval "getparam 4 $fline"`
opt=`eval "getparam 5 $fline"`
scmfile=$tgtdir/${prefix}${name}.scm
string_srcs="$string_srcs $scmfile"
if [ `isnewer $srcfile $scmfile` = "yes" ]; then
echo " => $name.."
if [ "$USE_XETEX" = "yes" ]; then
make_string_latex $font $size "$label" $name $scmfile $opt
else
make_string_gd $font $size "$label" $name $scmfile
fi
assertfile $scmfile
fi
fi
done < $SYS_TMPDIR/tmp.STRINGS
rm $SYS_TMPDIR/tmp.STRINGS
}
make_strings()
{
setstate STRINGS
echo "==> creating strings needed for $SYS_APPNAME.."
tgtdir=$SYS_PREFIXROOT/build/$SYS_APPNAME/strings
mkdir -p $tgtdir
srcfile="$appsrcdir/STRINGS"
if [ -f $srcfile ]; then
make_stringfile "$srcfile" "main-"
fi
for m in $modules; do
srcfile=`locatefile modules/$m/STRINGS silent`
if [ ! "X$srcfile" = "X" ]; then
make_stringfile "$srcfile" "${m}-"
fi
done
setstate
}
make_sounddir()
{
snddir=$1
make_soundfile=$2
echo " => processing sounds from $snddir..."
snds=`ls -1 $snddir/*.wav 2> /dev/null`
for snd in $snds; do
if [ -f "$snd" ]; then
echo " => $snd.."
$make_soundfile "$snd"
fi
done
snds=`ls -1 $snddir/*.ogg 2> /dev/null`
for snd in $snds; do
if [ -f "$snd" ]; then
vecho " => $snd.."
$make_soundfile "$snd"
fi
done
snds=`ls -1 $snddir/*.caf 2> /dev/null`
for snd in $snds; do
if [ -f "$snd" ]; then
vecho " => $snd.."
$make_soundfile "$snd"
fi
done
}
make_sounds()
{
make_soundfile=$1
echo " => processing sounds needed for $SYS_APPNAME.."
srcdir="$appsrcdir/sounds"
if [ -d "$srcdir" ]; then
make_sounddir "$srcdir" $make_soundfile
fi
for m in $modules; do
srcdir=`locatedir modules/$m/sounds silent`
if [ ! "X$srcdir" = "X" ]; then
make_sounddir "$srcdir" $make_soundfile
fi
done
}
###################################
# platform specific stuff
# search itemname directories for ITEMNAME to populate items
add_items()
{
lasti=
add_items_int $@
vecho "$itemname requested: $@"
vecho "$itemname identified: $items"
}
add_items_int()
{
for optnewi in `filter_entries $SYS_PLATFORM $@`; do
newi=`echo "$optnewi" | sed 's/^?//'`
idir=`locatedir $itemname/$newi silent`
if [ ! "X$idir" = "X" ]; then
isold=no
for oldi in $lasti; do
if [ $oldi = $newi ]; then
isold=yes
fi
done
for oldi in $items; do
if [ $oldi = $newi ]; then
isold=yes
fi
done
if [ $isold = no ]; then
capitemname=`echo "$itemname" | tr a-z A-Z`
xis=`locatefile $itemname/$newi/$capitemname silent`
if [ ! "X$xis" = "X" ] && [ -f "$xis" ]; then
lasti="$newi $lasti"
add_items_int `cat "$xis"`
newi=`echo $lasti | cut -d' ' -f1`
items="$items $newi"
lasti=`echo $lasti | cut -d' ' -f2-`
else
items="$items $newi"
fi
fi
else
if [ $newi = $optnewi ]; then
assert "$newi in $itemname not found"
else
echo "INFO: optional $newi in $itemname not found, skipping"
fi
fi
done
}
make_setup_profile()
{
setstate SETUP
profile=`locatefile PROFILE`
assertfile "$profile"
. "$profile"
versionfile=`locatefile apps/$SYS_APPNAME/VERSION`
assertfile $versionfile
SYS_APPVERSION=`cat $versionfile`
SYS_APPVERSIONCODE=`echo $SYS_APPVERSION | sed 's/\.//g'`
if [ ! "X$1" = "Xsilent" ]; then
echo "=== using profile $SYS_PROFILE [$profile].."
echo "=== configured to build $SYS_APPNAME version $SYS_APPVERSION for $SYS_PLATFORM on $SYS_HOSTPLATFORM in $SYS_MODE mode"
fi
if [ "$SYS_MODE" = "release" ]; then
SYS_IOSCERT="iPhone Distribution" # This is actually ignored
if [ -z "$SYS_IOSMOBILEPROVISION" ]; then
files=`find ~/Library/MobileDevice/Provisioning\ Profiles -name '*.mobileprovision'`
IFS_OLD=$IFS; IFS=$'\n'
for file in $files; do
dev=`security cms -D -i "$file" | grep -A1 "<key>get-task-allow</key>" | tail -n1 | tr -d '[:space:]'`
if [ "$dev" == "<false/>" ]; then
file=`basename "$file"`
SYS_IOSPROVISIONING="${file%.*}"
fi
done
IFS=$IFS_OLD
else
SYS_IOSPROVISIONING=$SYS_IOSMOBILEPROVISION
fi
echo "=== using provisioning profile $SYS_IOSPROVISIONING"
else
SYS_IOSCERT="iPhone Developer"
fi
SYS_IOSTEAMID=`echo "$SYS_IOSRELCERT" | cut -f 2 -d "(" | cut -f 1 -d ")"`
SYS_ROOT=`pwd`
mkdir -p $SYS_TMPDIR
SYS_PREFIXROOT=`pwd`"-cache"
if [ ! -d $SYS_PREFIXROOT ]; then
case $SYS_HOSTPLATFORM in
macosx)
SYS_PREFIXROOT=$HOME/Library/Caches/lambdanative
;;
*)
if [ "X$XDG_CACHE_HOME" = "X" ]; then
SYS_PREFIXROOT=$HOME/.cache/lambdanative
else
SYS_PREFIXROOT=$XDG_CACHE_HOME/lambdanative
fi
;;
esac
fi
SYS_LOCASEAPPNAME=`echo $SYS_APPNAME | tr A-Z a-z`
SYS_ORGSLD_TEMP=`echo $SYS_ORGSLD | sed "s/\./ /g"`
for subdomain in $SYS_ORGSLD_TEMP; do
SYS_ORGSLD_REVERSE="$subdomain $SYS_ORGSLD_REVERSE"
done
SYS_ORGSLD_REVERSE=`echo $SYS_ORGSLD_REVERSE | sed "s/ /\./g"`
SYS_ORGDOMAIN_REVERSE_DOT=$SYS_ORGTLD.$SYS_ORGSLD_REVERSE
SYS_PACKAGE_DOT=$SYS_ORGTLD.$SYS_ORGSLD_REVERSE.$SYS_LOCASEAPPNAME
SYS_PACKAGE_UNDERSCORE=`echo $SYS_PACKAGE_DOT | sed 's:\.:_:g'`
SYS_PACKAGE_SLASH=`echo $SYS_PACKAGE_DOT | sed 's:\.:/:g'`
SYS_HOSTPREFIX="$SYS_PREFIXROOT/$SYS_HOSTPLATFORM"
mkdir -p $SYS_HOSTPREFIX/bin
mkdir -p $SYS_HOSTPREFIX/lib
mkdir -p $SYS_HOSTPREFIX/include
SYS_GSC=$SYS_HOSTPREFIX/bin/gsc
SYS_DEBUGFLAG=
if [ "X$SYS_MODE" = "Xdebug" ]; then
SYS_DEBUGFLAG="-g -O0"
fi
mkdir -p $SYS_PREFIXROOT/packages
mkdir -p $SYS_PREFIXROOT/build
if [ "X$SYS_ANDROIDAPI" = "X" ]; then
SYS_ANDROIDAPI=$ANDROIDAPI
fi
SYS_ANDROIDSDK=$ANDROIDSDK
SYS_ANDROIDNDK=$ANDROIDNDK
SYS_HOSTEXEFIX=
if [ "$SYS_HOSTPLATFORM" = "win32" ]; then
SYS_HOSTEXEFIX=".exe"
fi
SYS_BUILDHASH=`echo "$SYS_BUILDHASH" | sed 's/,$//'`
echo $SYS_BUILDHASH
SYS_BUILDEPOCH=`date +"%s"`
# build the subtool
if ! `test -x $SYS_HOSTPREFIX/bin/subtool` ||
`test tools/subtool/subtool.c -nt $SYS_HOSTPREFIX/bin/subtool`; then
flags=
if [ $SYS_HOSTPLATFORM = win32 ]; then
flags=-DMINGW32
fi
gcc $flags -o $SYS_HOSTPREFIX/bin/subtool tools/subtool/subtool.c 2> /dev/null
fi
if [ ! -x $SYS_HOSTPREFIX/bin/subtool ]; then
assert "cannot build subtool. Broken gcc or insufficient permissions??"
fi
name=$SYS_APPNAME
here=`pwd`
appsrcdir=`locatedir apps/$name`
appsrcdirs=$appsrcdir
items=
itemname=modules
if [ -f "$appsrcdir/MODULES" ]; then
add_items `cat $appsrcdir/MODULES`
fi
modules=$items
items=
itemname=plugins
if [ -f "$appsrcdir/PLUGINS" ]; then
add_items `cat $appsrcdir/PLUGINS`
fi
plugins=$items
libraries=
if [ -f "$appsrcdir/LIBRARIES" ]; then
libraries=`cat $appsrcdir/LIBRARIES`
fi
for m in $modules; do
xlibs=`locatefile modules/$m/LIBRARIES silent`
if [ ! "X$xlibs" = "X" ] && [ -f "$xlibs" ]; then
libraries=$libraries" "`cat "$xlibs"`
fi
xplugs=`locatefile modules/$m/PLUGINS silent`
if [ ! "X$xplugs" = "X" ] && [ -f "$xplugs" ]; then
plugins=$plugins" "`cat "$xplugs"`
fi
appsrcdirs="$appsrcdirs modules/$m"
done
for p in $plugins; do
xlibs=`locatefile plugins/$p/LIBRARIES silent`
if [ ! "X$xlibs" = "X" ] && [ -f "$xlibs" ]; then
libraries=$libraries" "`cat "$xlibs"`
fi
appsrcdirs="$appsrcdirs plugins/$p"
done
libraries=`filter_entries $SYS_PLATFORM $libraries`
tool_libraries=
if [ "$SYS_HOSTPLATFORM" = "$SYS_PLATFORM" ]; then
tool_libraries="libgd"
fi
appsrcdirs="$appsrcdirs loaders/$SYS_PLATFORM"
# compile_target_options $appsrcdirs
setstate
}
make_setup_target()
{
setstate SETUP
setup_target=$1
assertfile $setup_target "Don't know how to setup a build for $SYS_PLATFORM on a $SYS_HOSTPLATFORM host"
ac_reset
SYS_PREFIX="${SYS_PREFIXROOT}/${SYS_PLATFORM}"
#--------
# register custom compiler/linker options
payload_spcaps=`echo $SYS_PLATFORM | tr 'a-z' 'A-Z'`
for m in $modules; do
modpath=`locatedir modules/$m silent`
if [ -f $modpath/${payload_spcaps}_CFLAG_ADDITIONS ]; then
cflag_new=`cat $modpath/${payload_spcaps}_CFLAG_ADDITIONS`
cflag_additions=`string_append_uniq "$cflag_additions" "$cflag_new"`
fi
if [ -f $modpath/${payload_spcaps}_LDFLAG_ADDITIONS ]; then
ldflag_new=`cat $modpath/${payload_spcaps}_LDFLAG_ADDITIONS`
ldflag_additions=`string_append_uniq "$ldflag_additions" "$ldflag_new"`
fi
done
if [ -f $appsrcdir/${payload_spcaps}_CFLAG_ADDITIONS ]; then
cflag_new=`cat $appsrcdir/${payload_spcaps}_CFLAG_ADDITIONS`
cflag_additions=`string_append_uniq "$cflag_additions" "$cflag_new"`
fi
if [ -f $appsrcdir/${payload_spcaps}_LDFLAG_ADDITIONS ]; then
ldflag_new=`cat $appsrcdir/${payload_spcaps}_LDFLAG_ADDITIONS`