Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: bin/sync-and-gyp

Issue 1425593011: bin/sync-and-gyp: sh->py (make more cross-platform) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-11-09 (Monday) 11:13:02 EST Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/usr/bin/env python
2 2
3 # Copyright 2015 Google Inc. 3 # Copyright 2015 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 # This script will update Skia's dependenciess as necessary and run 8 # This script will update Skia's dependencies as necessary and run
9 # gyp if needed. 9 # gyp if needed.
10 10
11 # Depends on: Posix-compliant shell, Python, and Git. 11 # Depends on: Python, and Git.
12 # 12 #
13 # Example usage: 13 # Example usage:
14 # 14 #
15 # git clone https://skia.googlesource.com/skia 15 # git clone https://skia.googlesource.com/skia
16 # cd skia 16 # cd skia
17 # bin/sync-and-gyp 17 # python bin/sync-and-gyp
18 # ninja -C out/Debug && out/Debug/dm 18 # ninja -C out/Debug && out/Debug/dm
19 # 19 #
20 # Once changes are made to DEPS or gyp/ or the source, call: 20 # Once changes are made to DEPS or gyp/ or the source, call:
21 # 21 #
22 # bin/sync-and-gyp 22 # python bin/sync-and-gyp
23 23
24 if [ "$SKIA_OUT" ]; then 24 import fnmatch
25 mkdir -p "$SKIA_OUT" || exit 25 import hashlib
26 # get non-relative path of $SKIA_OUT before changing directory. 26 import subprocess
27 SKIA_OUT="$(cd "$SKIA_OUT"; pwd)" 27 import os
28 fi
29 28
30 cd "$(dirname "$0")/.." 29 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir)
31 30
32 if ! [ -f DEPS ]; then 31 skia_out = os.environ.get("SKIA_OUT")
33 echo DEPS file missing >&2 32 if skia_out:
34 exit 1 33 skia_out = os.path.abspath(skia_out)
35 fi 34 hash_path = os.path.join(skia_out, 'gyp_hash')
35 else:
36 hash_path = os.path.join('out', 'gyp_hash')
36 37
37 GIT_SYNC_DEPS_QUIET=1 python tools/git-sync-deps || exit 38 os.chdir(skia_dir)
38 39
39 catifexists() { if [ -f "$1" ]; then cat "$1"; fi; } 40 if not os.path.isfile('DEPS'):
41 sys.stderr.write('DEPS file missing')
42 exit(1)
40 43
41 gyp_hasher() { 44 env = os.environ.copy()
42 { 45 env["GIT_SYNC_DEPS_QUIET"] = "1"
43 echo "$CC" 46 subprocess.call(['python', 'tools/git-sync-deps'], env=env)
44 echo "$CXX"
45 echo "$GYP_GENERATORS"
46 echo "$GYP_DEFINES"
47 find gyp -type f -print -exec git hash-object {} \;
48 find bench gm tests -name '*.c*' | LANG= sort
49 } | git hash-object --stdin
50 }
51 47
52 : ${SKIA_OUT:=out} 48 hasher = hashlib.sha1()
53 GYP_HASH=$(gyp_hasher) 49
54 HASH_PATH="${SKIA_OUT}/gyp_hash" 50 for var in ['AR', 'AR_host', 'AR_target',
55 if [ "$GYP_HASH" != "$(catifexists "$HASH_PATH")" ]; then 51 'CC', 'CC_host', 'CC_target',
56 python ./gyp_skia || exit 52 'CFLAGS', 'CFLAGS_host',
57 echo "$GYP_HASH" > "$HASH_PATH" 53 'CPPFLAGS', 'CPPFLAGS_host',
58 fi 54 'CXX', 'CXX_host', 'CXX_target',
55 'GYP_DEFINES', 'GYP_GENERATORS',
56 'NM', 'NM_host', 'NM_target',
57 'READELF', 'READELF_host', 'READELF_target']:
58 hasher.update(os.environ.get(var, '') + '\n')
59
60 def listfiles(folder, matchfilter):
61 for root, folders, files in os.walk(folder):
62 for filename in files:
63 if fnmatch.fnmatch(filename, matchfilter):
64 yield os.path.join(root, filename)
65
66 for filename in sorted(listfiles('gyp', '*')):
67 with open(filename, 'r') as f:
68 hasher.update(f.read())
69
70 for dir in ['bench', 'gm', 'tests']:
71 for filename in sorted(listfiles(dir, '*.c*')):
72 hasher.update(filename + '\n')
73
74 gyp_hash = hasher.hexdigest()
75
76 def cat_if_exists(path):
77 if os.path.exists(path):
78 with open(path, 'r') as f:
79 return f.read()
80 return ''
81
82 if cat_if_exists(hash_path).strip() != gyp_hash:
83 env = os.environ.copy()
84 if skia_out:
85 env['SKIA_OUT'] = skia_out
86 subprocess.call(['python', './gyp_skia'], env=env)
87 with open(hash_path, 'w') as o:
88 o.write(gyp_hash)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698