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

Side by Side Diff: experimental/mojo/generate.py

Issue 1660043004: SkMojo: generate on Darwin/x86_64 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « no previous file | gyp/skmojo.gyp » ('j') | gyp/skmojo.gyp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright 2016 Google Inc. 3 # Copyright 2016 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 import hashlib 8 import hashlib
9 import os 9 import os
10 import platform
11 import stat
10 import subprocess 12 import subprocess
13 import sys
11 import urllib2 14 import urllib2
12 import stat
13 15
14 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) 16 THIS_DIR = os.path.abspath(os.path.dirname(__file__))
15 MOJO_DIR = os.path.abspath(os.path.join(THIS_DIR, '../../third_party/externals/m ojo')) 17 MOJO_DIR = os.path.abspath(os.path.join(THIS_DIR, '../../third_party/externals/m ojo'))
16 18
17 def GetFile(filename, bucket_directory): 19 def GetFile(filename, bucket_directory):
18 def sha1hash(path): 20 def sha1hash(path):
19 hasher = hashlib.sha1() 21 hasher = hashlib.sha1()
20 if os.path.isfile(path): 22 if os.path.isfile(path):
21 with open(path, 'r') as f: 23 with open(path, 'r') as f:
22 hasher.update(f.read()) 24 hasher.update(f.read())
23 return hasher.hexdigest() 25 return hasher.hexdigest()
24 sha_path = filename + '.sha1' 26 sha_path = filename + '.sha1'
25 assert os.path.isfile(sha_path) 27 assert os.path.isfile(sha_path)
26 with open(sha_path, 'r') as f: 28 with open(sha_path, 'r') as f:
27 sha = f.read(40) 29 sha = f.read(40)
28 if sha1hash(filename) == sha: 30 if sha1hash(filename) == sha:
29 return 31 return
30 url = 'https://storage.googleapis.com/%s/%s' % (bucket_directory, sha) 32 url = 'https://storage.googleapis.com/%s/%s' % (bucket_directory, sha)
33 print url
mtklein 2016/02/03 20:59:34 leftover debugging?
hal.canary 2016/02/03 21:23:42 fixed.
31 with open(filename, 'w') as o: 34 with open(filename, 'w') as o:
32 o.write(urllib2.urlopen(url).read()) 35 o.write(urllib2.urlopen(url).read())
33 os.chmod(filename, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | 36 os.chmod(filename, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
34 stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) 37 stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
35 assert sha1hash(filename) == sha 38 assert sha1hash(filename) == sha
36 39
37 def GenerateBindings(path, cdir=None): 40 def GenerateBindings(path, cdir=None):
38 GetFile(os.path.join(MOJO_DIR, 41 system = (platform.machine(), platform.system())
39 'public/tools/bindings/mojom_parser/bin/linux64/mojom_p arser'), 42 if ('x86_64', 'Darwin') == system:
40 'mojo/mojom_parser/linux64') 43 parser = 'public/tools/bindings/mojom_parser/bin/mac64/mojom_parser'
44 bucket_directory = 'mojo/mojom_parser/mac64'
45 elif ('x86_64', 'Linux') == system:
46 parser = 'public/tools/bindings/mojom_parser/bin/linux64/mojom_parser'
47 bucket_directory = 'mojo/mojom_parser/linux64'
48 else:
49 assert False
50 GetFile(os.path.join(MOJO_DIR, parser), bucket_directory)
41 assert os.path.isfile(path) 51 assert os.path.isfile(path)
42 path = os.path.abspath(path) 52 path = os.path.abspath(path)
43 exe = os.path.join( 53 exe = os.path.join(
44 MOJO_DIR, 'public/tools/bindings/mojom_bindings_generator.py') 54 MOJO_DIR, 'public/tools/bindings/mojom_bindings_generator.py')
45 assert os.path.isfile(exe) 55 assert os.path.isfile(exe)
46 if cdir is None: 56 if cdir is None:
47 cdir = os.path.dirname(path) 57 cdir = os.path.dirname(path)
48 assert os.path.isdir(cdir) 58 assert os.path.isdir(cdir)
49 cwd = os.getcwd() 59 cwd = os.getcwd()
50 os.chdir(cdir) 60 os.chdir(cdir)
51 subprocess.check_call([exe, os.path.relpath(path, cdir)]) 61 subprocess.check_call([exe, os.path.relpath(path, cdir)])
52 os.chdir(cwd) 62 os.chdir(cwd)
53 63
54 for f in [ 64 if __name__ == '__main__':
55 'public/interfaces/bindings/interface_control_messages.mojom', 65 if 1 == len(sys.argv):
56 'public/interfaces/application/service_provider.mojom', 66 for f in [
57 'public/interfaces/bindings/tests/ping_service.mojom', 67 'public/interfaces/bindings/interface_control_messages.mojom',
58 'public/interfaces/application/application.mojom', 68 'public/interfaces/application/service_provider.mojom',
59 ]: 69 'public/interfaces/bindings/tests/ping_service.mojom',
60 GenerateBindings(os.path.join(MOJO_DIR, f), os.path.join(MOJO_DIR, os.pardir )) 70 'public/interfaces/application/application.mojom',
61 71 ]:
62 GenerateBindings(os.path.join(THIS_DIR, 'SkMojo.mojom')) 72 GenerateBindings(os.path.join(MOJO_DIR, f), os.path.join(MOJO_DIR, o s.pardir))
73 else:
74 for arg in sys.argv[1:]:
75 GenerateBindings(arg)
OLDNEW
« no previous file with comments | « no previous file | gyp/skmojo.gyp » ('j') | gyp/skmojo.gyp » ('J')

Powered by Google App Engine
This is Rietveld 408576698