File: _init

package info (click to toggle)
scrcpy 3.3.4-1
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 2,832 kB
  • sloc: ansic: 22,489; java: 10,142; sh: 953; xml: 94; makefile: 30
file content (76 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (3)
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
# This file is intended to be sourced by other scripts, not executed

process_args() {
    if [[ $# != 3 ]]
    then
        # <host>: linux, macos, win32 or win64
        # <build_type>: native or cross
        # <link_type>: static or shared
        echo "Syntax: $0 <host> <build_type> <link_type>" >&2
        exit 1
    fi

    HOST="$1"
    BUILD_TYPE="$2"
    LINK_TYPE="$3"
    DIRNAME="$HOST-$BUILD_TYPE-$LINK_TYPE"

    if [[ "$BUILD_TYPE" != native && "$BUILD_TYPE" != cross ]]
    then
        echo "Unsupported build type (expected native or cross): $BUILD_TYPE" >&2
        exit 1
    fi

    if [[ "$LINK_TYPE" != static && "$LINK_TYPE" != shared ]]
    then
        echo "Unsupported link type (expected static or shared): $LINK_TYPE" >&2
        exit 1
    fi

    if [[ "$BUILD_TYPE" == cross ]]
    then
        if [[ "$HOST" = win32 ]]
        then
            HOST_TRIPLET=i686-w64-mingw32
        elif [[ "$HOST" = win64 ]]
        then
            HOST_TRIPLET=x86_64-w64-mingw32
        else
            echo "Unsupported cross-build to host: $HOST" >&2
            exit 1
        fi
    fi
}

DEPS_DIR=$(dirname ${BASH_SOURCE[0]})
cd "$DEPS_DIR"

PATCHES_DIR="$PWD/patches"

WORK_DIR="$PWD/work"
SOURCES_DIR="$WORK_DIR/sources"
BUILD_DIR="$WORK_DIR/build"
INSTALL_DIR="$WORK_DIR/install"

mkdir -p "$INSTALL_DIR" "$SOURCES_DIR" "$WORK_DIR"

checksum() {
    local file="$1"
    local sum="$2"
    echo "$file: verifying checksum..."
    echo "$sum  $file" | shasum -a256 -c
}

get_file() {
    local url="$1"
    local file="$2"
    local sum="$3"
    if [[ -f "$file" ]]
    then
        echo "$file: found"
    else
        echo "$file: not found, downloading..."
        wget "$url" -O "$file"
    fi
    checksum "$file" "$sum"
}