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

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

Issue 1693963005: bin/sync-and-gyp: start using gclient (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-02-16 (Tuesday) 12:14:21 EST Created 4 years, 10 months 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 | « .gitignore ('k') | 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 #!/usr/bin/env python 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 dependencies 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: Python, and Git. 11 # Depends on: Python, Git, and depot_tools.
12 # 12 #
13 # Example usage: 13 # Example usage:
14 # 14 #
15 # git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
16 # export PATH="${PWD}/depot_tools:${PATH}"
15 # git clone https://skia.googlesource.com/skia 17 # git clone https://skia.googlesource.com/skia
16 # cd skia 18 # cd skia
17 # python bin/sync-and-gyp 19 # python bin/sync-and-gyp
18 # ninja -C out/Debug && out/Debug/dm 20 # ninja -C out/Debug && out/Debug/dm
19 # 21 #
20 # Once changes are made to DEPS or gyp/ or the source, call: 22 # Once changes are made to DEPS or gyp/ or the source, call:
21 # 23 #
22 # python bin/sync-and-gyp 24 # python bin/sync-and-gyp
23 25
24 import fnmatch 26 import fnmatch
25 import hashlib 27 import hashlib
26 import subprocess 28 import subprocess
27 import os 29 import os
28 30
29 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir) 31 skia_dir = os.path.join(os.path.dirname(__file__), os.pardir)
30 32
31 skia_out = os.environ.get("SKIA_OUT") 33 skia_out = os.environ.get("SKIA_OUT")
32 if skia_out: 34 if skia_out:
33 skia_out = os.path.abspath(skia_out) 35 skia_out = os.path.abspath(skia_out)
34 hash_path = os.path.join(skia_out, 'gyp_hash') 36 hash_path = os.path.join(skia_out, 'gyp_hash')
35 else: 37 else:
36 hash_path = os.path.join('out', 'gyp_hash') 38 hash_path = os.path.join('out', 'gyp_hash')
37 39
38 os.chdir(skia_dir) 40 os.chdir(skia_dir)
39 41
40 if not os.path.isfile('DEPS'): 42 if not os.path.isfile('DEPS'):
41 sys.stderr.write('DEPS file missing') 43 sys.stderr.write('DEPS file missing')
42 exit(1) 44 exit(1)
43 45
44 env = os.environ.copy() 46 deps_hasher = hashlib.sha1()
45 env["GIT_SYNC_DEPS_QUIET"] = "1" 47 with open('DEPS', 'r') as f:
46 subprocess.call(['python', 'tools/git-sync-deps'], env=env) 48 deps_hasher.update(f.read())
49 deps_hash = deps_hasher.hexdigest()
50 current_deps_hash = None
51 if os.path.isfile('.deps_sha1'):
52 with open('.deps_sha1', 'r') as f:
53 current_deps_hash = f.read().strip()
54
55 default_gclient_config = '''
56 solutions = [
57 { "name" : ".",
58 "url" : "https://skia.googlesource.com/skia.git",
59 "deps_file" : "DEPS",
60 "managed" : False,
61 "custom_deps" : {
62 },
63 "safesync_url": "",
64 },
65 ]
66 cache_dir = None
67 '''
68 if current_deps_hash != deps_hash:
69 # `gclient sync` is very slow, so skip whenever we can.
70 if not os.path.isfile('.gclient'):
71 with open('.gclient', 'w') as o:
72 o.write(default_gclient_config)
73 try:
74 subprocess.check_call(['gclient', 'sync'])
75 except:
76 sys.stderr.write('\n`gclient sync` failed.\n')
kjlubick 2016/02/17 13:57:04 Drive by comment, sys is not defined.
77 os.remove('.deps_sha1') # Unknown state.
78 exit(1)
79 # Only write hash after a successful sync.
80 with open('.deps_sha1', 'w') as o:
81 o.write(deps_hash)
47 82
48 hasher = hashlib.sha1() 83 hasher = hashlib.sha1()
49 84
50 for var in ['AR', 'AR_host', 'AR_target', 85 for var in ['AR', 'AR_host', 'AR_target',
51 'CC', 'CC_host', 'CC_target', 86 'CC', 'CC_host', 'CC_target',
52 'CFLAGS', 'CFLAGS_host', 87 'CFLAGS', 'CFLAGS_host',
53 'CPPFLAGS', 'CPPFLAGS_host', 88 'CPPFLAGS', 'CPPFLAGS_host',
54 'CXX', 'CXX_host', 'CXX_target', 89 'CXX', 'CXX_host', 'CXX_target',
55 'GYP_DEFINES', 'GYP_GENERATORS', 90 'GYP_DEFINES', 'GYP_GENERATORS',
56 'NM', 'NM_host', 'NM_target', 91 'NM', 'NM_host', 'NM_target',
(...skipping 22 matching lines...) Expand all
79 return f.read() 114 return f.read()
80 return '' 115 return ''
81 116
82 if cat_if_exists(hash_path).strip() != gyp_hash: 117 if cat_if_exists(hash_path).strip() != gyp_hash:
83 env = os.environ.copy() 118 env = os.environ.copy()
84 if skia_out: 119 if skia_out:
85 env['SKIA_OUT'] = skia_out 120 env['SKIA_OUT'] = skia_out
86 subprocess.call(['python', './gyp_skia'], env=env) 121 subprocess.call(['python', './gyp_skia'], env=env)
87 with open(hash_path, 'w') as o: 122 with open(hash_path, 'w') as o:
88 o.write(gyp_hash) 123 o.write(gyp_hash)
OLDNEW
« no previous file with comments | « .gitignore ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698