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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: experimental/mojo/generate.py
diff --git a/experimental/mojo/generate.py b/experimental/mojo/generate.py
new file mode 100755
index 0000000000000000000000000000000000000000..397d5454e75930ae41718b1c733228656ce6f234
--- /dev/null
+++ b/experimental/mojo/generate.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+# Copyright 2016 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import hashlib
+import os
+import subprocess
+import urllib2
+import stat
+
+def sha1hash(path):
+ hasher = hashlib.sha1()
+ if os.path.isfile(path):
+ with open(path, 'r') as f:
+ hasher.update(f.read())
+ return hasher.hexdigest()
+
+os.chdir(os.path.dirname(__file__))
+
+arg = 'Skia.mojom'
+
+bindings_dir = '../../third_party/externals/mojo/public/tools/bindings'
+xdir = os.path.join(bindings_dir, '/mojom_parser/bin/linux64')
+exe = os.abspath(os.path.join(bindings_dir, 'mojom_bindings_generator.py'))
+bin_dir = os.path.join(bindings_dir, 'mojom_parser/bin/linux64')
+sha_path = os.path.join(bin_dir, 'mojom_parser.sha1')
+parser = os.path.join(bin_dir, 'mojom_parser')
+url = 'https://storage.googleapis.com/mojo/mojom_parser/linux64/%s'
+
+assert os.path.isfile(arg)
+assert os.path.isfile(exe)
+assert os.path.isfile(sha_path)
+
+with open(sha_path, 'r') as f:
+ sha = f.read(40)
+
+if sha1hash(parser) != sha:
+ with open(parser, 'w') as o:
+ o.write(urllib2.urlopen(url % sha).read())
+ rxrxrx = (stat.S_IRUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP |
+ stat.S_IROTH | stat.S_IXOTH)
+ os.chmod(parser, rxrxrx)
+ assert sha1hash(parser) == sha
+
+subprocess.check_call([exe, arg])
+
+os.chdir('../../third_party/externals/mojo/public/interfaces/bindings')
+subprocess.check_call([exe, 'interface_control_messages.mojom'])

Powered by Google App Engine
This is Rietveld 408576698