Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/libecc/scripts/crossrun.sh
2065 views
1
#/*
2
# * Copyright (C) 2017 - This file is part of libecc project
3
# *
4
# * Authors:
5
# * Ryad BENADJILA <[email protected]>
6
# * Arnaud EBALARD <[email protected]>
7
# * Jean-Pierre FLORI <[email protected]>
8
# *
9
# * Contributors:
10
# * Nicolas VIVET <[email protected]>
11
# * Karim KHALFALLAH <[email protected]>
12
# *
13
# * This software is licensed under a dual BSD and GPL v2 license.
14
# * See LICENSE file at the root folder of the project.
15
# */
16
#!/bin/sh
17
18
run_triplet_wordsize(){
19
triplet=$1
20
wordsize=$2
21
echo "======== RUNNING RELEASE FOR $triplet / $wordsize"
22
if [ "$triplet" != "i386-apple-darwin" ] && [ "$triplet" != "x86_64-apple-darwin" ] && [ "$triplet" != "x86_64h-apple-darwin" ] && [ "$triplet" != "i686-w64-mingw32" ] && [ "$triplet" != "x86_64-w64-mingw32" ]; then
23
echo " [X] Using QEMU static"
24
$CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static vectors
25
$CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_debug_static vectors
26
#$CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static rand
27
fi
28
if [ "$triplet" = "i386-apple-darwin" ] || [ "$triplet" = "x86_64-apple-darwin" ] || [ "$triplet" = "x86_64h-apple-darwin" ]; then
29
echo " [X] Testing MAC-OS binaries is futur work!"
30
fi
31
if [ "$triplet" = "i686-w64-mingw32" ] || [ "$triplet" = "x86_64-w64-mingw32" ]; then
32
echo " [X] Using WINE"
33
wine $CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static vectors
34
wine $CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_debug_static vectors
35
#wine $CROSSBUILD_OUTPUT/"$triplet"/word"$wordsize"/ec_self_tests_"$triplet"_word"$wordsize"_static rand
36
fi
37
}
38
39
40
print_help(){
41
echo "$0 uses qemu-static and wine to run self tests"
42
echo "with multiple word sizes (16, 32 and 64)."
43
echo "The produced binaries are expected to be in the 'crossbuild_out' folder."
44
echo "Supported platform triplets are:"
45
echo "arm-linux-gnueabi / arm-linux-gnueabihf / powerpc64le-linux-gnu / aarch64-linux-gnu /"
46
echo "mipsel-linux-gnu / i386-apple-darwin / x86_64-apple-darwin / i686-w64-mingw32 / x86_64-w64-mingw32."
47
}
48
49
50
######### Script main
51
SRC_DIR=`dirname "$(readlink -f "$0")"`/..
52
CROSSBUILD_OUTPUT=$SRC_DIR/scripts/crossbuild_out/
53
54
# Check for the qemu-static command line
55
for arch in i386 x86_64 arm ppc64 aarch64 mipsel;
56
do
57
QEMU_CHECK=$(qemu-$arch-static -h)
58
if [ $? -ne 0 ]; then
59
echo "qemu-$arch-static is not installed ... Please install it! (usually in qemu-user-static)"
60
exit
61
fi
62
done
63
64
WINE_CHECK=$(wine --help)
65
if [ $? -ne 0 ]; then
66
echo "wine is not installed ... Please install it!"
67
exit
68
fi
69
70
WINE64_CHECK=$(wine64 --help)
71
if [ $? -ne 0 ]; then
72
echo "wine64 is not installed ... Please install it!"
73
exit
74
fi
75
76
# Print help if asked
77
if [ "$1" = "-h" ]
78
then
79
print_help $0
80
exit
81
fi
82
83
# If we have arguments, just execute subcommand
84
if [ "$1" = "-triplet" ]
85
then
86
# If no specific word size has been given, do all the sizes
87
if [ "$3" = "" ]
88
then
89
for wordsize in 16 32 64;
90
do
91
run_triplet_wordsize $2 $wordsize
92
done
93
else
94
run_triplet_wordsize $2 $3
95
fi
96
exit
97
fi
98
99
ALL_CHECKS=""
100
for wordsize in 16 32 64;
101
do
102
for triplet in arm-linux-gnueabi arm-linux-gnueabihf powerpc64le-linux-gnu aarch64-linux-gnu mipsel-linux-gnu i386-apple-darwin x86_64-apple-darwin x86_64h-apple-darwin i686-w64-mingw32 x86_64-w64-mingw32;
103
do
104
ALL_CHECKS="$ALL_CHECKS\n-triplet $triplet $wordsize"
105
done
106
done
107
108
if [ "$1" = "-cpu" ]
109
then
110
if [ "$3" = "-triplet" ]
111
then
112
echo "-cpu and -triplet are not compatible ..."
113
exit
114
else
115
# User defined number of CPUs
116
NCPU=$2
117
fi
118
else
119
# Get number of CPUs for parallel processing
120
NCPU=`getconf _NPROCESSORS_ONLN`
121
fi
122
echo "Parallelizing on $NCPU processors"
123
# Unleash the kraken
124
echo $ALL_CHECKS | xargs -n 4 -P $NCPU sh `readlink -f "$0"`
125
126