aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/deps-and-gyp
blob: f39fc69135946a7b88993ce44d0e414301e81eaa (plain)
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
#!/bin/sh

# Copyright 2015 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# This script will update Skia's dependenciess as necessary and run
# gyp if needed.

# Depends on: Posix-compliant shell, Python, and Git.
#
# Example usage:
#
#   git clone https://skia.googlesource.com/skia
#   cd skia
#   bin/deps-and-gyp
#   ninja -C out/Debug && out/Debug/dm
#
# Once changes are made to DEPS or gyp/ or the source, call:
#
#   bin/deps-and-gyp

if [ "$SKIA_OUT" ]; then
    mkdir -p "$SKIA_OUT" || exit
    # get non-relative path of $SKIA_OUT before changing directory.
    SKIA_OUT="$(cd "$SKIA_OUT"; pwd)"
fi

cd "$(dirname "$0")/.."

if ! [ -f DEPS ]; then
    echo DEPS file missing >&2
    exit 1
fi

if [ "$(git hash-object DEPS)" != "$(git config sync-deps.last)" ] ; then
    GIT_SYNC_DEPS_QUIET=1 python tools/git-sync-deps || exit
    git config sync-deps.last "$(git hash-object DEPS)"
fi

catifexists() { if [ -f "$1" ]; then cat "$1"; fi; }

gyp_hasher() {
    {
        echo "$CC"
        echo "$CXX"
        echo "$GYP_GENERATORS"
        echo "$GYP_DEFINES"
        find gyp -type f -print -exec git hash-object {} \;
        find bench gm tests -name '*.c*' | LANG= sort
    } | git hash-object --stdin
}

: ${SKIA_OUT:=out}
GYP_HASH=$(gyp_hasher)
HASH_PATH="${SKIA_OUT}/gyp_hash"
if [ "$GYP_HASH" != "$(catifexists "$HASH_PATH")" ]; then
    python ./gyp_skia || exit
    echo "$GYP_HASH" > "$HASH_PATH"
fi