From 7d7cde505f1c1e6bb3a69ba923332dbf056bcf0d Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Tue, 30 Jun 2015 10:32:09 -0700 Subject: [PATCH] Download material design icons using DEPS We need the material design icons at build time in order to build Sky application bundles that include the icons. Therefore, we need can't wait until runtime to download the icons. Also, rather than copying all the icons into each out directory, we just symlink to the copy in the source tree. R=eseidel@chromium.org, eseidel@google.com Review URL: https://codereview.chromium.org/1217283002. --- sdk/BUILD.gn | 35 ++++++++++++++++++++++- sdk/lib/download_material_design_icons | 39 ++++++++++++++++---------- tools/shelldb | 14 --------- 3 files changed, 58 insertions(+), 30 deletions(-) diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 0c772b50662..bb47df50410 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -4,7 +4,7 @@ import("//mojo/public/dart/rules.gni") -dart_pkg("sdk") { +dart_pkg("sky") { sources = [ "CHANGELOG.md", "bin/init.dart", @@ -144,3 +144,36 @@ dart_pkg("sdk") { sdk_ext_directory = "$root_gen_dir/sky/bindings" } + +action("material_design_icons") { + input_dir = "lib/assets/material-design-icons" + output_dir = "$root_gen_dir/dart-pkg/sky/lib/assets" + stamp = "$target_gen_dir/material_design_icons_linked" + + sources = [ + "lib/assets/material-design-icons.sha1", + ] + outputs = [ + stamp, + ] + + script = "//build/symlink.py" + args = [ + "--force", + rebase_path(input_dir, output_dir), + rebase_path(output_dir, root_build_dir), + "--touch", + rebase_path(stamp, root_build_dir), + ] + + deps = [ + ":sky", + ] +} + +group("sdk") { + deps = [ + ":sky", + ":material_design_icons", + ] +} diff --git a/sdk/lib/download_material_design_icons b/sdk/lib/download_material_design_icons index 6087c48fb89..aad130216dd 100755 --- a/sdk/lib/download_material_design_icons +++ b/sdk/lib/download_material_design_icons @@ -5,25 +5,34 @@ import os import subprocess +import sys import urllib2 -sky_lib_dir = os.path.dirname(os.path.abspath(__file__)) -assets_dir = os.path.join(sky_lib_dir, 'assets') -sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1') +def main(): + sky_lib_dir = os.path.dirname(os.path.abspath(__file__)) + assets_dir = os.path.join(sky_lib_dir, 'assets') -with open(sha1_path, 'r') as f: - sha1 = f.read() + if (os.path.isdir(os.path.join(assets_dir, 'material-design-icons'))): + return -tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz') -url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1 -response = urllib2.urlopen(url) + sha1_path = os.path.join(assets_dir, 'material-design-icons.sha1') -with open(tgz_path, 'wb') as f: - f.write(response.read()) + with open(sha1_path, 'r') as f: + sha1 = f.read() -output_path = os.path.join(assets_dir, tgz_path) -subprocess.call([ - 'tar', '-xzf', output_path, '-C', assets_dir -]) + tgz_path = os.path.join(assets_dir, 'material-design-icons.tgz') + url = 'https://storage.googleapis.com/mojo/material-design-icons/%s' % sha1 + response = urllib2.urlopen(url) -os.unlink(tgz_path) + with open(tgz_path, 'wb') as f: + f.write(response.read()) + + output_path = os.path.join(assets_dir, tgz_path) + subprocess.call([ + 'tar', '-xzf', output_path, '-C', assets_dir + ]) + + os.unlink(tgz_path) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/shelldb b/tools/shelldb index 138eb39bd25..0eb49187a79 100755 --- a/tools/shelldb +++ b/tools/shelldb @@ -126,18 +126,6 @@ def dev_packages_root(build_dir): return os.path.join(build_dir, 'gen', 'dart-pkg', 'packages') -def ensure_assets_are_downloaded(build_dir): - sky_pkg_dir = os.path.join(build_dir, 'gen', 'dart-pkg', 'sky') - sky_pkg_lib_dir = os.path.join(sky_pkg_dir, 'lib') - sky_icons_dir = \ - os.path.join(sky_pkg_lib_dir, 'assets', 'material-design-icons') - if not os.path.isdir(sky_icons_dir): - logging.info('NOTE: sky/assets/material-design-icons missing, ' - 'Running `download_material_design_icons` for you.') - subprocess.check_call( - [os.path.join(sky_pkg_lib_dir, 'download_material_design_icons')]) - - class SetBuildDir(object): def add_subparser(self, subparsers): start_parser = subparsers.add_parser('set_build_dir', @@ -198,8 +186,6 @@ class StartSky(object): print "'%s' does not exist?" % apk_path return 2 - ensure_assets_are_downloaded(args.build_dir) - packages_root = dev_packages_root(args.build_dir) sky_server = self._sky_server_for_args(args, packages_root) pids['sky_server_pid'] = sky_server.start()