Debian Codegraph @

app/deps/_init

raw
1 # This file is intended to be sourced by other scripts, not executed
2
3 process_args() {
4 if [[ $# != 3 ]]
5 then
6 # <host>: linux, macos, win32 or win64
7 # <build_type>: native or cross
8 # <link_type>: static or shared
9 echo "Syntax: $0 <host> <build_type> <link_type>" >&2
10 exit 1
11 fi
12
13 HOST="$1"
14 BUILD_TYPE="$2"
15 LINK_TYPE="$3"
16 DIRNAME="$HOST-$BUILD_TYPE-$LINK_TYPE"
17
18 if [[ "$BUILD_TYPE" != native && "$BUILD_TYPE" != cross ]]
19 then
20 echo "Unsupported build type (expected native or cross): $BUILD_TYPE" >&2
21 exit 1
22 fi
23
24 if [[ "$LINK_TYPE" != static && "$LINK_TYPE" != shared ]]
25 then
26 echo "Unsupported link type (expected static or shared): $LINK_TYPE" >&2
27 exit 1
28 fi
29
30 if [[ "$BUILD_TYPE" == cross ]]
31 then
32 if [[ "$HOST" = win32 ]]
33 then
34 HOST_TRIPLET=i686-w64-mingw32
35 elif [[ "$HOST" = win64 ]]
36 then
37 HOST_TRIPLET=x86_64-w64-mingw32
38 else
39 echo "Unsupported cross-build to host: $HOST" >&2
40 exit 1
41 fi
42 fi
43 }
44
45 DEPS_DIR=$(dirname ${BASH_SOURCE[0]})
46 cd "$DEPS_DIR"
47
48 PATCHES_DIR="$PWD/patches"
49
50 WORK_DIR="$PWD/work"
51 SOURCES_DIR="$WORK_DIR/sources"
52 BUILD_DIR="$WORK_DIR/build"
53 INSTALL_DIR="$WORK_DIR/install"
54
55 mkdir -p "$INSTALL_DIR" "$SOURCES_DIR" "$WORK_DIR"
56
57 checksum() {
58 local file="$1"
59 local sum="$2"
60 echo "$file: verifying checksum..."
61 echo "$sum $file" | shasum -a256 -c
62 }
63
64 get_file() {
65 local url="$1"
66 local file="$2"
67 local sum="$3"
68 if [[ -f "$file" ]]
69 then
70 echo "$file: found"
71 else
72 echo "$file: not found, downloading..."
73 wget "$url" -O "$file"
74 fi
75 checksum "$file" "$sum"
76 }