mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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.
This commit is contained in:
parent
205ab9f778
commit
7d7cde505f
35
sdk/BUILD.gn
35
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",
|
||||
]
|
||||
}
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user