aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2016-02-03 11:53:18 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-03 11:53:19 -0800
commit7a76f9c8f4de11e51b3495eec0d76be88a12adfa (patch)
tree83c20c951d1268988cf4f2c9ba37dde0e29771be /experimental
parent84de5c86f9189bef758118dc12e1d6e62d06cd38 (diff)
SkMojo: test linking Skia against the Mojo SDK
TODO: build on systems other than Linux. Add mojo_skd to the DEPS. Add a DM::Via called `mojo-`. everything is hidden behind the gyp variable `skia_mojo`. GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1644043003 Review URL: https://codereview.chromium.org/1644043003
Diffstat (limited to 'experimental')
-rw-r--r--experimental/mojo/.gitignore6
-rw-r--r--experimental/mojo/SkMojo.mojom10
-rwxr-xr-xexperimental/mojo/generate.py62
3 files changed, 78 insertions, 0 deletions
diff --git a/experimental/mojo/.gitignore b/experimental/mojo/.gitignore
new file mode 100644
index 0000000000..6ac4a17c82
--- /dev/null
+++ b/experimental/mojo/.gitignore
@@ -0,0 +1,6 @@
+*.mojom-*
+*.mojom.*
+*_mojom.*
+dart-gen
+go
+
diff --git a/experimental/mojo/SkMojo.mojom b/experimental/mojo/SkMojo.mojom
new file mode 100644
index 0000000000..85b46cc54d
--- /dev/null
+++ b/experimental/mojo/SkMojo.mojom
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2016 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+module SkMojo;
+
+struct FlattenedPicture { array<uint8> data; };
diff --git a/experimental/mojo/generate.py b/experimental/mojo/generate.py
new file mode 100755
index 0000000000..a32afbba80
--- /dev/null
+++ b/experimental/mojo/generate.py
@@ -0,0 +1,62 @@
+#!/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
+
+THIS_DIR = os.path.abspath(os.path.dirname(__file__))
+MOJO_DIR = os.path.abspath(os.path.join(THIS_DIR, '../../third_party/externals/mojo'))
+
+def GetFile(filename, bucket_directory):
+ def sha1hash(path):
+ hasher = hashlib.sha1()
+ if os.path.isfile(path):
+ with open(path, 'r') as f:
+ hasher.update(f.read())
+ return hasher.hexdigest()
+ sha_path = filename + '.sha1'
+ assert os.path.isfile(sha_path)
+ with open(sha_path, 'r') as f:
+ sha = f.read(40)
+ if sha1hash(filename) == sha:
+ return
+ url = 'https://storage.googleapis.com/%s/%s' % (bucket_directory, sha)
+ with open(filename, 'w') as o:
+ o.write(urllib2.urlopen(url).read())
+ os.chmod(filename, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
+ stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
+ assert sha1hash(filename) == sha
+
+def GenerateBindings(path, cdir=None):
+ GetFile(os.path.join(MOJO_DIR,
+ 'public/tools/bindings/mojom_parser/bin/linux64/mojom_parser'),
+ 'mojo/mojom_parser/linux64')
+ assert os.path.isfile(path)
+ path = os.path.abspath(path)
+ exe = os.path.join(
+ MOJO_DIR, 'public/tools/bindings/mojom_bindings_generator.py')
+ assert os.path.isfile(exe)
+ if cdir is None:
+ cdir = os.path.dirname(path)
+ assert os.path.isdir(cdir)
+ cwd = os.getcwd()
+ os.chdir(cdir)
+ subprocess.check_call([exe, os.path.relpath(path, cdir)])
+ os.chdir(cwd)
+
+for f in [
+ 'public/interfaces/bindings/interface_control_messages.mojom',
+ 'public/interfaces/application/service_provider.mojom',
+ 'public/interfaces/bindings/tests/ping_service.mojom',
+ 'public/interfaces/application/application.mojom',
+ ]:
+ GenerateBindings(os.path.join(MOJO_DIR, f), os.path.join(MOJO_DIR, os.pardir))
+
+GenerateBindings(os.path.join(THIS_DIR, 'SkMojo.mojom'))