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

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

Issue 1644043003: SkMojo: test linking Skia against the Mojo SDK (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
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright 2016 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8 import hashlib
9 import os
10 import subprocess
11 import urllib2
12 import stat
13
14 def sha1hash(path):
15 hasher = hashlib.sha1()
16 if os.path.isfile(path):
17 with open(path, 'r') as f:
18 hasher.update(f.read())
19 return hasher.hexdigest()
20
21 os.chdir(os.path.dirname(__file__))
22
23 arg = 'Skia.mojom'
24
25 bindings_dir = '../../third_party/externals/mojo/public/tools/bindings'
26 xdir = os.path.join(bindings_dir, '/mojom_parser/bin/linux64')
27 exe = os.abspath(os.path.join(bindings_dir, 'mojom_bindings_generator.py'))
28 bin_dir = os.path.join(bindings_dir, 'mojom_parser/bin/linux64')
29 sha_path = os.path.join(bin_dir, 'mojom_parser.sha1')
30 parser = os.path.join(bin_dir, 'mojom_parser')
31 url = 'https://storage.googleapis.com/mojo/mojom_parser/linux64/%s'
32
33 assert os.path.isfile(arg)
34 assert os.path.isfile(exe)
35 assert os.path.isfile(sha_path)
36
37 with open(sha_path, 'r') as f:
38 sha = f.read(40)
39
40 if sha1hash(parser) != sha:
41 with open(parser, 'w') as o:
42 o.write(urllib2.urlopen(url % sha).read())
43 rxrxrx = (stat.S_IRUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP |
44 stat.S_IROTH | stat.S_IXOTH)
45 os.chmod(parser, rxrxrx)
46 assert sha1hash(parser) == sha
47
48 subprocess.check_call([exe, arg])
49
50 os.chdir('../../third_party/externals/mojo/public/interfaces/bindings')
51 subprocess.check_call([exe, 'interface_control_messages.mojom'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698