-
Notifications
You must be signed in to change notification settings - Fork 284
/
libretro-buildbot-recipe.sh
executable file
·1706 lines (1345 loc) · 53.7 KB
/
libretro-buildbot-recipe.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/bash
# vim: set ts=3 sw=3 noet ft=sh : bash
# ----- setup -----
export LC_ALL=C
# This will use an overridden value from the command-line if provided, otherwise just use the current date
BOT="${BOT:-.}"
LOGDATE="${LOGDATE:-$(date +%Y-%m-%d)}"
TMPDIR="${TMPDIR:-/tmp}"
if [ -z "${1}" ]; then
echo 'No recipe target, exiting.' >&2
exit 1
fi
mkdir -p -- "$TMPDIR/log/${BOT}/${LOGDATE}"
ORIGPATH=$PATH
WORK=$PWD
RECIPE=$1
BRANCH=""
ENTRY_ID=""
# ----- read variables from recipe config -----
while read line; do
[ -z "${line}" ] && continue
KEY="${line%% *}"
VALUE="${line#* }"
rm -f -- "$TMPDIR/vars"
if [ "${KEY}" = "PATH" ]; then
export PATH=${VALUE}:${ORIGPATH}
echo PATH=${VALUE}:${ORIGPATH} >> $TMPDIR/vars
else
export ${KEY}="${VALUE}"
echo ${KEY}="${VALUE}" >> $TMPDIR/vars
fi
echo "Setting: ${KEY} ${VALUE}"
done < $RECIPE.conf
read_link()
{
TARGET_FILE="$1"
cd $(dirname "$TARGET_FILE")
TARGET_FILE=$(basename "$TARGET_FILE")
while [ -L "$TARGET_FILE" ]; do
TARGET_FILE=$(readlink "$TARGET_FILE")
cd $(dirname "$TARGET_FILE")
TARGET_FILE=$(basename "$TARGET_FILE")
done
PHYS_DIR=$(pwd -P)
RESULT="$PHYS_DIR/$TARGET_FILE"
echo "$RESULT"
}
convert_xmb_assets()
{
local src_dir=$1
local dst_dir=$2
local scale_icon=$3
local scale_bg=$4
# dots per inch, a value of 90 seems to produce a 64x64 resolution for most icons
local density=$5
mkdir -p "$dst_dir"
IFS_old=$IFS
IFS=$(echo -en "\n\b")
for theme in `ls $src_dir`; do
if [ -d $src_dir/$theme ] ; then
theme=`basename "$theme"`
mkdir -p "$dst_dir/$theme/png"
cp $src_dir/$theme/*.* $dst_dir/$theme/
for png in `ls $src_dir/$theme/png/*.png -d`; do
local name=`basename "$png" .png`
local src_file="$src_dir/$theme/src/$name.svg"
local is_svg=1
if [ ! -e $src_file ] ; then
src_file="$src_dir/$theme/png/$name.png"
is_svg=
fi
local dst_file="$dst_dir/$theme/png/$name.png"
if [ ! -e $src_file ] || [ $src_file -nt $dst_file ] ; then
local scale_factor=$scale_icon
if [ $name = "bg" ] ; then
scale_factor=$scale_bg
fi
if [ $is_svg ] ; then
echo convert -background none -density $density "$src_file" -resize $scale_factor "$dst_file"
convert -background none -density $density "$src_file" -resize $scale_factor "$dst_file"
else
echo convert -background none "$src_file" -resize $scale_factor "$dst_file"
convert -background none "$src_file" -resize $scale_factor "$dst_file"
fi
fi
done
fi
done
IFS=$IFS_old
}
if [ "${CORE_JOB}" == "YES" ]; then
# ----- set target -----
[[ "${ARM_NEON}" ]] && echo 'ARM NEON opts enabled...' && export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-armv-neon"
[[ "${CORTEX_A7}" ]] && echo 'Cortex A7 opts enabled...' && export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-cortexa7"
[[ "${CORTEX_A8}" ]] && echo 'Cortex A8 opts enabled...' && export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-cortexa8"
[[ "${CORTEX_A9}" ]] && echo 'Cortex A9 opts enabled...' && export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-cortexa9"
[[ "${ARM_HARDFLOAT}" ]] && echo 'ARM hardfloat ABI enabled...' && export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-hardfloat"
[[ "${ARM_SOFTFLOAT}" ]] && echo 'ARM softfloat ABI enabled...' && export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-softfloat"
[[ "${IOS}" ]] && echo 'iOS detected...'
. $WORK/libretro-config.sh
# ----- create dirs -----
SCRIPT=$(read_link "$0")
echo "SCRIPT: $SCRIPT"
BASE_DIR=$(dirname "$SCRIPT")
if [ -z "$RARCH_DIST_DIR" ]; then
RARCH_DIR="$BASE_DIR/dist"
RARCH_DIST_DIR="$RARCH_DIR/$DIST_DIR"
fi
mkdir -v -p "$RARCH_DIST_DIR"
if [ "${PLATFORM}" = "android" ]; then
if [ -n "$ABI_OVERRIDE" ]; then
echo "ABIS-pre: $TARGET_ABIS"
echo "OVERRIDE: ${ABI_OVERRIDE}"
TARGET_ABIS=${ABI_OVERRIDE}
export TARGET_ABIS=${ABI_OVERRIDE}
echo "ABIS-post: $TARGET_ABIS"
fi
IFS=' ' read -ra ABIS <<< "$TARGET_ABIS"
for a in "${ABIS[@]}"; do
echo $a
if [ -d $RARCH_DIST_DIR/${a} ]; then
echo "Directory $RARCH_DIST_DIR/${a} already exists, skipping creation..."
else
mkdir -p $RARCH_DIST_DIR/${a}
fi
done
fi
# ----- set compilers -----
if [ "$HOST_CC" ]; then
CC="${HOST_CC}-gcc"
CXX="${HOST_CC}-g++"
CXX11="${HOST_CC}-g++"
STRIP="${HOST_CC}-strip"
fi
TMP_MAKE="${HELPER} ${MAKE}"
if [ -z "${TMP_MAKE}" ]; then
if uname -s | grep -i MINGW32 > /dev/null 2>&1; then
MAKE=mingw32-make
else
if type gmake > /dev/null 2>&1; then
MAKE=gmake
else
MAKE=make
fi
fi
fi
if [ -z "$CC" ]; then
if [ $FORMAT_COMPILER_TARGET = "osx" ]; then
CC=cc
elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then
CC=mingw32-gcc
else
CC=gcc
fi
fi
if [ -z "$CXX" ]; then
if [ $FORMAT_COMPILER_TARGET = "osx" ]; then
CXX=c++
CXX11=clang++
elif uname -s | grep -i MINGW32 > /dev/null 2>&1; then
CXX=mingw32-g++f
CXX11=mingw32-g++
else
CXX=g++
CXX11=g++
fi
fi
if [ "${CC}" ] && [ "${CXX}" ]; then
COMPILER="CC="\""${CC}"\"" CXX="\""${CXX}"\"""
else
COMPILER=""
fi
RESET_FORMAT_COMPILER_TARGET=$FORMAT_COMPILER_TARGET
RESET_FORMAT_COMPILER_TARGET_ALT=$FORMAT_COMPILER_TARGET_ALT
else
SCRIPT=$(read_link "$0")
echo "SCRIPT: $SCRIPT"
BASE_DIR=$(dirname "$SCRIPT")
if [ -z "$RARCH_DIST_DIR" ]; then
RARCH_DIR="$BASE_DIR/dist"
RARCH_DIST_DIR="$RARCH_DIR/$PLATFORM"
fi
fi
# ----- set jobs -----
JOBS="${JOBS:-6}"
# ----- set forceful rebuild on/off -----
FORCE="${FORCE:-NO}"
FORCE_RETROARCH_BUILD="${FORCE_RETROARCH_BUILD:-NO}"
# ----- set release on/off -----
RELEASE="${RELEASE:-NO}"
# ----- set cleanup rules -----
CLEANUP=NO
DAY=$(date '+%d')
HOUR=$(date '+%H')
if [ "${DAY}" = 01 ] && [ "${HOUR}" = 06 ]; then
FORCE=YES
CLEANUP=NO
fi
# ----- use to keep track of built cores -----
CORES_BUILT=NO
FORCE_ORIG=$FORCE
JOBS_ORIG=$JOBS
cd "${BASE_DIR}"
buildbot_log() {
echo "buildbot message: $MESSAGE"
MESSAGE=`echo -e $1`
if [ -n "$LOGURL" ]; then
HASH=`echo -n "$MESSAGE" | openssl sha1 -hmac $SIG | cut -f 2 -d " "`
curl --max-time 30 --data "message=$MESSAGE&sign=$HASH" $LOGURL
fi
}
buildbot_handle_message() {
RET=$1
ENTRY_ID=$2
CORE_NAME=$3
jobid=$4
ERROR=$5
if [ $RET -eq 0 ]; then
if [ -n "$LOGURL" ]; then
curl -X POST -d type="finish" -d index="$ENTRY_ID" -d status="done" http://buildserver.libretro.com/build_entry/
fi
MESSAGE="$CORE_NAME: [status: done] [$jobid]"
else
if [ -n "$LOGURL" ]; then
HASTE="n/a"
if [ -n "$ERROR" ]; then
gzip -9fk $ERROR
HASTE=`curl -X POST http://paste.libretro.com/ --data-binary @${ERROR}.gz`
fi
curl -X POST -d type="finish" -d index="$ENTRY_ID" -d status="fail" -d log="$HASTE" http://buildserver.libretro.com/build_entry/
LAST_GOOD_TIME=`curl -f http://buildserver.libretro.com/last_good_build_time/$ENTRY_ID/ 2>/dev/null`
if [ -n "$LAST_GOOD_TIME" ]; then
LAST_GOOD_TIME="N/A"
fi
MESSAGE="$CORE_NAME: [status: fail] [$jobid] LOG: $HASTE Last good build: $LAST_GOOD_TIME"
else
MESSAGE="$CORE_NAME: [status: fail] [$jobid]"
fi
fi
echo "buildbot job: $MESSAGE"
buildbot_log "$MESSAGE"
# used by Travis-CI to exit immediately if a core build fails, instead of trying to build RA anyways (for static/console builds)
if [ $RET -ne 0 ] && [ "$EXIT_ON_ERROR" = "1" ]; then
exit 1
fi
}
build_libretro_generic_makefile() {
NAME="$1"
DIR="$2"
SUBDIR="$3"
MAKEFILE="$4"
PLATFORM="$5"
ARGS="$6"
CORES="${7:-$NAME}"
ENTRY_ID=""
if [ -n "$LOGURL" ]; then
ENTRY_ID=`curl -X POST -d type="start" -d master_log="$MASTER_LOG_ID" -d platform="$jobid" -d name="$NAME" http://buildserver.libretro.com/build_entry/`
fi
cd "${DIR}"
if [ "${COMMAND}" = "CMAKE" ] && [ "${SUBDIR}" != . ]; then
rm -rf -- "$SUBDIR"
mkdir -p -- "$SUBDIR"
elif [ "${COMMAND}" = "GENERIC_GL" ] && [ "${BUILD_LIBRETRO_GL}" ]; then
if [ "${ENABLE_GLES}" ]; then
export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-gles"
export FORMAT_COMPILER_TARGET_ALT="${FORMAT_COMPILER_TARGET}"
else
export FORMAT_COMPILER_TARGET="${FORMAT_COMPILER_TARGET}-opengl"
export FORMAT_COMPILER_TARGET_ALT="${FORMAT_COMPILER_TARGET}"
fi
fi
case "{$NAME}" in
*higan_sfc*|*bsnes* ) OUT="out" ;;
* ) OUT=. ;;
esac
cd "${SUBDIR}"
eval "set -- $CORES"
for i do
core="${i%:*}"
arg="${i##*:}"
if [ "$arg" != "$core" ]; then
CORE_ARGS="${ARGS} ${arg}"
else
CORE_ARGS="${ARGS}"
fi
CORE_ARGS="${CORE_ARGS#"${CORE_ARGS%%[! ]*}"}"
CORENAM="${core}_libretro${FORMAT}${LIBSUFFIX}.${FORMAT_EXT}"
if [ "${COMMAND}" = "LEIRADEL" ]; then
ARG1="${CORE_ARGS%% *}"
LOGFILE="$TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_${core}_${PLATFORM}_${ARG1}.log"
ORIGNAM="${core}_libretro.${PLATFORM}_${ARG1}.${FORMAT_EXT}"
OUTPUT="$RARCH_DIST_DIR/${DIST}/${ARG1}/${CORENAM}"
mkdir -p -- "$RARCH_DIST_DIR/${DIST}/${ARG1}"
else
LOGFILE="$TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_${core}_${PLATFORM}.log"
ORIGNAM="${CORENAM}"
OUTPUT="$RARCH_DIST_DIR/${DIST}/${CORENAM}"
fi
echo '--------------------------------------------------' | tee "$LOGFILE"
cat $TMPDIR/vars | tee -a "$LOGFILE"
echo '--------------------------------------------------' | tee -a "$LOGFILE"
if [ -z "${NOCLEAN}" ] && [ -f "${MAKEFILE}" ] && [ "${COMMAND}" != "CMAKE" ]; then
if [ "${NAME}" = "higan_sfc" ] || [ "${NAME}" = "higan_sfc_balanced" ]; then
rm -f obj/*.{o,"${FORMAT_EXT}"} 2>&1 | tee -a "$LOGFILE"
rm -f out/*.{o,"${FORMAT_EXT}"} 2>&1 | tee -a "$LOGFILE"
elif [ "${COMMAND}" = "LEIRADEL" ]; then
eval "set -- ${HELPER} ${MAKE} -f ${MAKEFILE}.${PLATFORM}_${ARG1} platform=${PLATFORM}_${CORE_ARGS} -j${JOBS} clean"
echo "CLEANUP CMD: $*" 2>&1 | tee -a "$LOGFILE"
"$@" 2>&1 | tee -a "$LOGFILE"
else
eval "set -- ${HELPER} ${MAKE} -f ${MAKEFILE} platform=${PLATFORM} -j${JOBS} ${CORE_ARGS} clean"
echo "CLEANUP CMD: $*" 2>&1 | tee -a "$LOGFILE"
"$@" 2>&1 | tee -a "$LOGFILE"
fi
if [ $? -eq 0 ]; then
echo "buildbot job: $jobid ${core} cleanup success!"
else
echo "buildbot job: $jobid ${core} cleanup failed!"
fi
fi
echo '--------------------------------------------------' | tee -a "$LOGFILE"
if [ "${COMMAND}" = "CMAKE" ]; then
case "${platform}" in
msvc2017_desktop_x86 ) EXTRAARGS="-G\"Visual Studio 15 2017\"" ;;
msvc2017_desktop_x64 ) EXTRAARGS="-G\"Visual Studio 15 2017 Win64\"" ;;
msvc2010_x86 ) EXTRAARGS="-G\"Visual Studio 10 2010\"" ;;
msvc2010_x64 ) EXTRAARGS="-G\"Visual Studio 10 2010 Win64\"" ;;
msvc2005_x86 ) EXTRAARGS="-G\"Visual Studio 8 2005\"" ;;
msvc2005_x64 ) EXTRAARGS="-G\"Visual Studio 8 2005 Win64\"" ;;
msvc2003_x86 ) EXTRAARGS="-G\"Visual Studio 7\"" ;;
android ) EXTRAARGS="-DANDROID_PLATFORM=android-${API_LEVEL} \
-DANDROID_ABI=${ABI_OVERRIDE} \
-DCMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake" ;;
3ds|ctr ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/ctr.cmake" ;;
vita ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/vita.cmake" ;;
psp|psp1 ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/psp1.cmake" ;;
libnx ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/libnx.cmake" ;;
qnx ) EXTRAARGS="-DCMAKE_TOOLCHAIN_FILE=${WORK}/cmake/blackberry.cmake" ;;
* ) EXTRAARGS="" ;;
esac
JOBS_FLAG="-j "
if [ "${MAKEFILE}" = "sln" ]; then
JOBS_FLAG=-maxcpucount:
fi
eval "set -- ${EXTRAARGS} \${CORE_ARGS} -DCMAKE_VERBOSE_MAKEFILE=ON"
echo "BUILD CMD: ${HELPER} ${CMAKE} $*" 2>&1 | tee -a "$LOGFILE"
echo "$@" .. | xargs ${HELPER} ${CMAKE} 2>&1 | tee -a "$LOGFILE"
echo "BUILD CMD: ${HELPER} ${CMAKE} --build . --target ${core}_libretro --config Release -- ${JOBS_FLAG} ${JOBS}" 2>&1 | tee -a "$LOGFILE"
${HELPER} ${CMAKE} --build . --target ${core}_libretro --config Release -- ${JOBS_FLAG}${JOBS} 2>&1 | tee -a "$LOGFILE"
find . -mindepth 2 -name "${CORENAM}" -exec cp -f "{}" . \;
elif [ "${COMMAND}" = "LEIRADEL" ]; then
eval "set -- ${HELPER} ${MAKE} -f ${MAKEFILE}.${PLATFORM}_${ARG1} platform=${PLATFORM}_${CORE_ARGS} -j${JOBS}"
echo "BUILD CMD: $*" 2>&1 | tee -a "$LOGFILE"
"$@" 2>&1 | tee -a "$LOGFILE"
elif [ "${NAME}" = "higan_sfc" ] || [ "${NAME}" = "higan_sfc_balanced" ]; then
platform=""
echo "BUILD CMD: ${HELPER} ${MAKE} -f ${MAKEFILE} -j${JOBS}" ${CORE_ARGS} 2>&1 | tee -a "$LOGFILE"
${HELPER} ${MAKE} -f ${MAKEFILE} -j${JOBS} ${CORE_ARGS} 2>&1 | tee -a "$LOGFILE"
else
eval "set -- ${HELPER} ${MAKE} -f ${MAKEFILE} platform=${PLATFORM} -j${JOBS} ${CORE_ARGS}"
echo "BUILD CMD: $*" 2>&1 | tee -a "$LOGFILE"
"$@" 2>&1 | tee -a "$LOGFILE"
fi
if [ "${MAKEPORTABLE}" == "YES" ]; then
echo "BUILD CMD $WORK/retrolink.sh ${OUT}/${CORENAM}" 2>&1 | tee -a "$LOGFILE"
$WORK/retrolink.sh ${OUT}/${CORENAM} 2>&1 | tee -a "$LOGFILE"
fi
if [ "${PLATFORM}" = "windows" ] || [ "${PLATFORM}" = "unix" ]; then
${STRIP:=strip} -s ${OUT}/${CORENAM}
elif [ "${PLATFORM}" = "android" -a ! -z "${STRIPPATH+x}" ]; then
${NDK_ROOT}/${STRIPPATH} -s ${OUT}/${CORENAM}
fi
echo "COPY CMD: cp ${OUT}/${ORIGNAM} ${OUTPUT}" 2>&1 | tee -a "$LOGFILE"
cp "${OUT}/${ORIGNAM}" "${OUTPUT}" 2>&1 | tee -a "$LOGFILE"
cp "${OUT}/${ORIGNAM}" "${OUTPUT}"
RET=$?
buildbot_handle_message "$RET" "$ENTRY_ID" "$core" "$jobid" "$LOGFILE"
done
if [ "${COMMAND}" = "GENERIC_GL" ]; then
export FORMAT_COMPILER_TARGET=$RESET_FORMAT_COMPILER_TARGET
export FORMAT_COMPILER_TARGET_ALT=$RESET_FORMAT_COMPILER_TARGET_ALT
fi
ENTRY_ID=""
}
build_libretro_android_cmake() {
NAME="$1"
DIR="$2"
SUBDIR="$3"
MAKEFILE="$4"
PLATFORM="$5"
ARGS="$6"
JOBS_FLAG=-j
EXTRAARGS="-DANDROID_PLATFORM=android-${API_LEVEL} -DCMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_static"
if [ -n "NDK_CCACHE" ]; then
EXTRAARGS="$EXTRAARGS -DCMAKE_C_COMPILER_LAUNCHER=${NDK_CCACHE} -DCMAKE_CXX_COMPILER_LAUNCHER=${NDK_CCACHE}"
fi
ENTRY_ID=""
if [ -n "$LOGURL" ]; then
ENTRY_ID=`curl -X POST -d type="start" -d master_log="$MASTER_LOG_ID" -d platform="$jobid" -d name="$NAME" http://buildserver.libretro.com/build_entry/`
fi
cd ${DIR}
mkdir -p ${SUBDIR}
cd ${SUBDIR}
CORENAM="${NAME}_libretro${FORMAT}${LIBSUFFIX}.${FORMAT_EXT}"
LOGFILE="$TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_${NAME}_${PLATFORM}.log"
echo '--------------------------------------------------' | tee "$LOGFILE"
cat $TMPDIR/vars | tee -a "$LOGFILE"
echo '--------------------------------------------------' | tee -a "$LOGFILE"
RET=0
for ABI in ${TARGET_ABIS}; do
rm -rf ${ABI}
mkdir ${ABI}
pushd ${ABI}
eval "set -- ${EXTRAARGS} \${ARGS} -DCMAKE_VERBOSE_MAKEFILE=OFF -DANDROID_ABI=${ABI}"
echo "BUILD CMD: ${CMAKE} $*" 2>&1 | tee -a "$LOGFILE"
echo "$@" ../.. | xargs ${CMAKE} 2>&1 | tee -a "$LOGFILE"
echo "BUILD CMD: ${CMAKE} --build . --target ${NAME}_libretro --config Release -- ${JOBS_FLAG} ${JOBS} " 2>&1 | tee -a "$LOGFILE"
${CMAKE} --build . --target ${NAME}_libretro --config Release -- ${JOBS_FLAG} ${JOBS} 2>&1 | tee -a "$LOGFILE"
COREPATH=$(find . -type f -name ${CORENAM})
if [ -n "${COREPATH}" ]; then
echo "COPY CMD: cp ${COREPATH} $RARCH_DIST_DIR/${ABI}/${CORENAM}" 2>&1 | tee -a "$LOGFILE"
cp ${COREPATH} $RARCH_DIST_DIR/${ABI}/${CORENAM} 2>&1 | tee -a "$LOGFILE"
if [ ! -z "${STRIPPATH+x}" ]; then
${NDK_ROOT}/${STRIPPATH} -s $RARCH_DIST_DIR/${ABI}/${CORENAM}
fi
else
echo "${CORENAM} for ${ABI} not found" 2>&1 | tee -a "$LOGFILE"
RET=1
fi
popd
done
buildbot_handle_message "$RET" "$ENTRY_ID" "$NAME" "$jobid" "$LOGFILE"
ENTRY_ID=""
}
build_libretro_generic_jni() {
NAME="$1"
DIR="$2"
SUBDIR="$3"
MAKEFILE="$4"
PLATFORM="$5"
ARGS="$6"
CORES="${7:-$NAME}"
ENTRY_ID=""
LIBNAM="libretro"
if [ -n "$LOGURL" ]; then
ENTRY_ID=`curl -X POST -d type="start" -d master_log="$MASTER_LOG_ID" -d platform="$jobid" -d name="$NAME" http://buildserver.libretro.com/build_entry/`
fi
cd ${DIR}
cd ${SUBDIR}
ABILIST=$(sed -n 's/APP_ABI *[:?]*= *//p' Application.mk)
if [ -z ${ABILIST} -o "${ABILIST}" == "all" ]; then
APPABIS=("${ABIS[@]}")
else
IFS=' ' read -ra APPABIS <<< "${ABILIST}"
fi
eval "set -- $CORES"
for i do
core="${i%:*}"
arg="${i##*:}"
if [ "$arg" != "$core" ]; then
CORE_ARGS="${arg} ${ARGS}"
else
CORE_ARGS="${ARGS}"
fi
CORENAM="${core}_libretro${FORMAT}${LIBSUFFIX}.${FORMAT_EXT}"
if [ "${NAME}" = "bsnes2014" ] || [ "${NAME}" = "bsnes_mercury" ]; then
LIBNAM="libretro_${core}"
fi
LOGFILE="$TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_${core}_${PLATFORM}.log"
echo '--------------------------------------------------' | tee "$LOGFILE"
cat $TMPDIR/vars | tee -a "$LOGFILE"
echo '--------------------------------------------------' | tee -a "$LOGFILE"
if [ -z "${NOCLEAN}" ]; then
echo "CLEANUP CMD: ${NDK} -j${JOBS} ${CORE_ARGS} clean" 2>&1 | tee -a "$LOGFILE"
${NDK} -j${JOBS} ${CORE_ARGS} clean 2>&1 | tee -a "$LOGFILE"
if [ $? -eq 0 ]; then
echo "buildbot job: $jobid $a ${core} cleanup success!"
else
echo "buildbot job: $jobid $a ${core} cleanup failed!"
fi
fi
echo '--------------------------------------------------' | tee -a "$LOGFILE"
eval "set -- ${NDK} -j${JOBS} ${CORE_ARGS}"
echo "BUILD CMD: $*" 2>&1 | tee -a "$LOGFILE"
"$@" 2>&1 | tee -a "$LOGFILE"
RET=0
for a in "${APPABIS[@]}"; do
if [ -f ../libs/${a}/$LIBNAM.${FORMAT_EXT} ]; then
echo "COPY CMD: cp ../libs/${a}/$LIBNAM.${FORMAT_EXT} $RARCH_DIST_DIR/${a}/${CORENAM}" 2>&1 | tee -a "$LOGFILE"
cp ../libs/${a}/$LIBNAM.${FORMAT_EXT} $RARCH_DIST_DIR/${a}/${CORENAM} 2>&1 | tee -a "$LOGFILE"
else
echo "$LIBNAM.${FORMAT_EXT} for ${a} not found" 2>&1 | tee -a "$LOGFILE"
RET=1
fi
done
buildbot_handle_message "$RET" "$ENTRY_ID" "$core" "$jobid" "$LOGFILE"
done
ENTRY_ID=""
}
# ----- buildbot -----
echo 'buildbot starting'
echo '--------------------------------------------------'
echo 'Variables:'
echo "CC $CC"
echo "CXX $CXX"
echo "STRIP $STRIP"
echo "DISTDIR $RARCH_DIST_DIR"
echo "JOBS $JOBS"
echo
echo
export jobid=$1
# ----- fetch a project -----
echo
echo
while read line; do
eval "set -- \$line"
NAME="$1"
DIR="$2"
URL="$3"
GIT_BRANCH="$4"
ENABLED="$5"
COMMAND="$6"
MAKEFILE="$7"
SUBDIR="$8"
ARGS=""
CORES=""
if [ -z "${SINGLE_CORE:-}" ]; then
CORE=""
elif [ "$NAME" != "$SINGLE_CORE" ]; then
continue
fi
shift 8
while [ $# -gt 0 ]; do
arg="$1"; shift
[ "$arg" = \| ] && break
ARGS="${ARGS} ${arg}"
done
for i do
if [ -z "${CORE}" ] || [ "${CORE}" = "${i%:*}" ]; then
CORES="${CORES} $i"
fi
done
ARGS="${ARGS# }"
ARGS="${ARGS%"${ARGS##*[![:space:]]}"}"
[ "${ENABLED}" != "YES" ] && { echo "${NAME} is disabled, skipping"; continue; }
echo "buildbot job started at: $(date)"
echo
echo "buildbot job: $jobid processing $NAME"
echo '--------------------------------------------------'
echo 'Variables:'
echo "URL $URL"
echo "ENABLED $ENABLED"
echo "COMMAND $COMMAND"
echo "MAKEFILE $MAKEFILE"
echo "DIR $DIR"
echo "SUBDIR $SUBDIR"
echo
echo
BUILD="NO"
BUILD_ORIG=$BUILD
FORCE_ORIG=$FORCE
if [ ! -d "${DIR}/.git" ] || [ "${CLEANUP}" = "YES" ]; then
rm -rf -- "$DIR"
echo "cloning repo $URL..."
git clone --depth=1 -b "$GIT_BRANCH" "$URL" "$DIR"
BUILD="YES"
else
if [ -f "$DIR/.forcebuild" ]; then
echo "found $DIR/.forcebuild file, building $NAME"
BUILD="YES"
fi
HEAD="$(git --work-tree="$DIR" --git-dir="$DIR/.git" rev-parse HEAD)" || \
{ echo "git directory broken, removing $DIR and skipping $NAME."; \
rm -rf -- "$DIR" && continue; }
OLDURL="$(git --work-tree="$DIR" --git-dir="$DIR/.git" config --get remote.origin.url)"
if [ "$URL" != "$OLDURL" ]; then
rm -rf -- "$DIR"
echo "cloning repo $URL..."
git clone --depth=1 -b "$GIT_BRANCH" "$URL" "$DIR"
BUILD="YES"
elif [ -z "${NOCLEAN}" ]; then
echo "fetching changes from repo $URL..."
git --work-tree="$DIR" --git-dir="$DIR/.git" fetch --depth 1 origin "${GIT_BRANCH}"
echo "resetting repo state $URL..."
git --work-tree="." --git-dir=".git" -C "$DIR" reset --hard FETCH_HEAD
git --work-tree="$DIR" --git-dir="$DIR/.git" clean -xdf -e .libretro-core-recipe
fi
if [ "$HEAD" = "$(git --work-tree="$DIR" --git-dir="$DIR/.git" rev-parse HEAD)" ] && [ "${BUILD}" != "YES" ]; then
BUILD="NO"
else
BUILD="YES"
fi
fi
if [ -f "$DIR/.libretro-core-recipe" ]; then
recipe="$(cat "$DIR/.libretro-core-recipe")"
if [ "$line" != "$recipe" ]; then
rm -f -- "$DIR/.libretro-core-recipe"
echo "$line" > "$DIR/.libretro-core-recipe"
BUILD="YES"
fi
else
echo "$line" > "$DIR/.libretro-core-recipe"
fi
CURRENT_BRANCH="$(git --work-tree="$DIR" --git-dir="$DIR/.git" rev-parse --abbrev-ref HEAD)"
if [ "${GIT_BRANCH}" != "${CURRENT_BRANCH}" ] && [ "${TRAVIS:-0}" = "0" ]; then
echo "Changing to the branch ${GIT_BRANCH} from ${CURRENT_BRANCH}"
git --work-tree="$DIR" --git-dir="$DIR/.git" remote set-branches origin "${GIT_BRANCH}"
git --work-tree="$DIR" --git-dir="$DIR/.git" fetch --depth 1 origin "${GIT_BRANCH}"
git --work-tree="$DIR" --git-dir="$DIR/.git" checkout "${GIT_BRANCH}"
git --work-tree="$DIR" --git-dir="$DIR/.git" branch -D "${CURRENT_BRANCH}"
BUILD="YES"
fi
if git config --file "$DIR/.gitmodules" --name-only --get-regexp path >/dev/null 2>&1; then
git --work-tree="." --git-dir=".git" -C "$DIR" submodule update --init --recursive
fi
if [ "${BUILD}" = "YES" ] || [ "${FORCE}" = "YES" ]; then
touch $TMPDIR/built-cores
CORES_BUILT=YES
echo "buildbot job: building $NAME"
case "${COMMAND}" in
ANDROID_CMAKE ) build_libretro_android_cmake $NAME $DIR $SUBDIR $MAKEFILE ${FORMAT_COMPILER_TARGET} "${ARGS}" ;;
CMAKE|GENERIC|GENERIC_GL )
build_libretro_generic_makefile $NAME $DIR $SUBDIR $MAKEFILE ${FORMAT_COMPILER_TARGET} "${ARGS}" "${CORES}" ;;
GENERIC_JNI ) build_libretro_generic_jni $NAME $DIR $SUBDIR $MAKEFILE ${FORMAT_COMPILER_TARGET_ALT} "${ARGS}" "${CORES}" ;;
GENERIC_ALT ) build_libretro_generic_makefile $NAME $DIR $SUBDIR $MAKEFILE ${FORMAT_COMPILER_TARGET_ALT} "${ARGS}" ;;
LEIRADEL ) build_libretro_generic_makefile $NAME $DIR $SUBDIR $MAKEFILE ${PLATFORM} "${ARGS}" "${CORES}" ;;
* ) : ;;
esac
if [ -z "${NOCLEAN}" ]; then
echo "Cleaning repo state after build $URL..."
git --work-tree="${BASE_DIR}/${DIR}" --git-dir="${BASE_DIR}/${DIR}/.git" clean -xdf -e .libretro-core-recipe
fi
else
echo "buildbot job: building $NAME up-to-date"
fi
echo
echo "buildbot job finished at: $(date)"
cd "${BASE_DIR}"
BUILD=$BUILD_ORIG
FORCE=$FORCE_ORIG
done < $RECIPE
buildbot_pull(){
[ -f "$RECIPE.ra" ] || return 0
while read line; do
eval "set -- \$line"
NAME="$1"
DIR="$2"
URL="$3"
TYPE="$4"
ENABLED="$5"
PARENTDIR="$6"
ARGS=""
shift 6
while [ $# -gt 0 ]; do
ARGS="${ARGS} ${1}"
shift
done
ARGS="${ARGS# }"
ARGS="${ARGS%"${ARGS##*[![:space:]]}"}"
if [ "${ENABLED}" = "YES" ] && [ "${TYPE}" = "PROJECT" ] || [ "${TRAVIS:-0}" = "0" ]; then
echo "buildbot job: $jobid Processing $NAME"
echo
echo "NAME: $NAME"
echo "DIR: $DIR"
echo "PARENT: $PARENTDIR"
echo "URL: $URL"
echo "REPO TYPE: $TYPE"
echo "ENABLED: $ENABLED"
if [ -d "${PARENTDIR}/${DIR}/.git" ]; then
cd $PARENTDIR
cd $DIR
if [ -f .forcebuild ]; then
echo "found .forcebuild file, building $NAME"
BUILD="YES"
fi
echo "pulling changes from repo $URL... "
HEAD="$(git rev-parse HEAD)"
git pull
if [ "${TYPE}" = "PROJECT" ]; then
RADIR=$DIR
if [ "$HEAD" = "$(git rev-parse HEAD)" ] && [ "${BUILD}" != "YES" ]; then
BUILD="NO"
else
echo "resetting repo state $URL... "
git reset --hard FETCH_HEAD
git clean -xdf
BUILD="YES"
fi
fi
cd $WORK
else
echo "cloning repo $URL..."
cd $PARENTDIR
if [ "${BRANCH}" ] && [ "${NAME}" = "retroarch" ]; then
git clone "$URL" "$DIR"
cd $DIR
git checkout "$BRANCH"
else
git clone -b "${GIT_BRANCH:-master}" "$URL" "$DIR" --depth=1
fi
cd $WORK
if [ "${TYPE}" = "PROJECT" ]; then
BUILD="YES"
RADIR=$DIR
fi
cd $WORK
fi
echo
echo "RADIR=$RADIR"
fi
done < $RECIPE.ra
cd $WORK
}
compile_filters()
{
FILTER="$1"
HELPER="$2"
MAKE="$3"
case "$FILTER" in
audio ) FILTERDIR='libretro-common/audio/dsp_filters' ;;
video ) FILTERDIR='gfx/video_filters' ;;
esac
echo "compile $FILTER filters"
echo "$FILTER filter BUILD CMD: ${HELPER} ${MAKE}"
( cd "$FILTERDIR"; ${HELPER} ${MAKE} )
if [ $? -eq 0 ]; then
echo "buildbot job: $jobid $FILTER filter build success!"
else
echo "buildbot job: $jobid $FILTER filter: [status: fail]!"
fi
}
if [ "${RA}" = "YES" ]; then
echo "buildbot job: $jobid Building Retroarch-$PLATFORM"
echo '--------------------------------------------------'
echo
BUILD=""
echo "WORKINGDIR=$PWD"
echo "RELEASE=$RELEASE"
echo "FORCE=$FORCE_RETROARCH_BUILD"
echo "RADIR=$RADIR"
echo "BRANCH=$BRANCH"
buildbot_pull
if [ "${BUILD}" = "YES" ] || [ "${FORCE}" = "YES" ] || [ "${FORCE_RETROARCH_BUILD}" = "YES" ] || [ "${CORES_BUILT}" = "YES" ]; then
cd "$RADIR"
git clean -xdf
echo "WORKINGDIR=$PWD"
echo "RADIR=$RADIR"
echo "buildbot job: $jobid Building"
echo
if [ -n "${LOGURL}" ]; then
ENTRY_ID="$(curl -X POST -d type="start" -d master_log="$MASTER_LOG_ID" -d platform="$jobid" -d name="retroarch" http://buildserver.libretro.com/build_entry/)"
fi
LOGFILE="$TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_RetroArch_${RECIPE##*/}.log"
fi
fi
if [ "${PLATFORM}" == "osx" ] && [ "${RA}" == "YES" ]; then
if [ "${BUILD}" == "YES" -o "${FORCE}" == "YES" -o "${FORCE_RETROARCH_BUILD}" == "YES" -o "${CORES_BUILT}" == "YES" ]; then
cd pkg/apple
if [ "${METAL}" == "1" ]; then
if [ "${METAL_QT}" == "1" ]; then
xcodebuild -project RetroArch_Metal.xcodeproj -target RetroArchQt -configuration Release &> "$LOGFILE"
else
xcodebuild -project RetroArch_Metal.xcodeproj -target RetroArch -configuration Release &> "$LOGFILE"
fi
else
xcodebuild -project RetroArch.xcodeproj -target RetroArch -configuration Release &> "$LOGFILE"
fi
RET=$?
buildbot_handle_message "$RET" "$ENTRY_ID" "retroarch" "$jobid" "$LOGFILE"
if [ -n "$LOGURL" ]; then
ENTRY_ID=`curl -X POST -d type="start" -d master_log="$MASTER_LOG_ID" -d platform="$jobid" -d name="retroarch" http://buildserver.libretro.com/build_entry/`
fi
if [ "${METAL}" != "1" ]; then
xcodebuild -project RetroArch.xcodeproj -target "RetroArch Cg" -configuration Release &> $TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_RetroArch_CG_${PLATFORM}.log
RET=$?
ERROR=$TMPDIR/log/${BOT}/${LOGDATE}/${LOGDATE}_RetroArch_CG_${PLATFORM}.log
buildbot_handle_message "$RET" "$ENTRY_ID" "retroarch" "$jobid" "$ERROR"
fi
cd $WORK/$RADIR
echo 'Packaging'
fi
fi
if [ "${PLATFORM}" == "ios" ] && [ "${RA}" == "YES" ]; then
if [ "${BUILD}" == "YES" -o "${FORCE}" == "YES" -o "${FORCE_RETROARCH_BUILD}" == "YES" -o "${CORES_BUILT}" == "YES" ]; then
cd pkg/apple
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -project RetroArch_iOS11.xcodeproj -configuration Release &> "$LOGFILE"
RET=$?
if [ $RET -eq 0 ]; then
touch $TMPDIR/built-frontend
fi
buildbot_handle_message "$RET" "$ENTRY_ID" "retroarch" "$jobid" "$LOGFILE"
ENTRY_ID=""
cd $WORK/$RADIR
echo 'Packaging'
fi
fi
if [ "${PLATFORM}" == "ios9" ] && [ "${RA}" == "YES" ]; then
if [ "${BUILD}" == "YES" -o "${FORCE}" == "YES" -o "${FORCE_RETROARCH_BUILD}" == "YES" -o "${CORES_BUILT}" == "YES" ]; then
cd pkg/apple
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -project RetroArch_iOS9.xcodeproj -configuration Release -target "RetroArch iOS9" &> "$LOGFILE"
RET=$?
if [ $RET -eq 0 ]; then
touch $TMPDIR/built-frontend
cd build/Release-iphoneos
security unlock-keychain -p buildbot /Users/buildbot/Library/Keychains/login.keychain
codesign -fs "buildbot" RetroArch.app
fi
buildbot_handle_message "$RET" "$ENTRY_ID" "retroarch" "$jobid" "$LOGFILE"
ENTRY_ID=""
cd $WORK/$RADIR
echo 'Packaging'
fi
fi
if [ "${PLATFORM}" = "android" ] && [ "${RA}" = "YES" ]; then
if [ "${BUILD}" = "YES" -o "${FORCE}" = "YES" -o "${FORCE_RETROARCH_BUILD}" == "YES" ]; then
#${HELPER} ${MAKE} -f Makefile.griffin shaders-convert-glsl PYTHON3=$PYTHON
echo "buildbot job: $jobid processing assets"
echo
rm -rf pkg/android/phoenix$PKG_EXTRA/assets/assets
rm -rf pkg/android/phoenix$PKG_EXTRA/assets/cores
rm -rf pkg/android/phoenix$PKG_EXTRA/assets/info
rm -rf pkg/android/phoenix$PKG_EXTRA/assets/overlays
rm -rf pkg/android/phoenix$PKG_EXTRA/assets/shaders/shaders_glsl/