2016-08-10 14:23:51 +00:00
|
|
|
#!/usr/bin/env 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.
|
|
|
|
|
|
|
|
|
|
|
|
"""Create the asset."""
|
|
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import common
|
|
|
|
import subprocess
|
|
|
|
import os
|
2016-09-15 16:33:08 +00:00
|
|
|
import shutil
|
2016-08-10 14:23:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
SVG_TOOLS = os.path.join(common.INFRA_BOTS_DIR, os.pardir, os.pardir, 'tools',
|
|
|
|
'svg')
|
2017-07-19 13:30:53 +00:00
|
|
|
SVG_GS_BUCKET = 'gs://skia-svgs'
|
2016-08-10 14:23:51 +00:00
|
|
|
|
|
|
|
|
2017-07-19 13:30:53 +00:00
|
|
|
def create_asset(target_dir):
|
2016-08-10 14:23:51 +00:00
|
|
|
"""Create the asset."""
|
|
|
|
target_dir = os.path.realpath(target_dir)
|
|
|
|
|
|
|
|
if not os.path.exists(target_dir):
|
|
|
|
os.makedirs(target_dir)
|
|
|
|
|
2016-09-15 16:33:08 +00:00
|
|
|
# Download the SVGs specified in tools/svg/svgs.txt
|
2016-08-10 14:23:51 +00:00
|
|
|
download_svgs_cmd = [
|
|
|
|
'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'),
|
|
|
|
'--output_dir', target_dir,
|
2017-08-16 14:30:40 +00:00
|
|
|
'--svgs_file', os.path.join(SVG_TOOLS, 'svgs.txt'),
|
2016-08-10 14:23:51 +00:00
|
|
|
]
|
|
|
|
subprocess.check_call(download_svgs_cmd)
|
|
|
|
|
2017-08-16 14:30:40 +00:00
|
|
|
# Download the SVGs specified in tools/svg/svgs_parse_only.txt with a prefix.
|
|
|
|
download_svgs_parse_only_cmd = [
|
|
|
|
'python', os.path.join(SVG_TOOLS, 'svg_downloader.py'),
|
|
|
|
'--output_dir', target_dir,
|
|
|
|
'--svgs_file', os.path.join(SVG_TOOLS, 'svgs_parse_only.txt'),
|
|
|
|
'--prefix', 'svgparse_',
|
|
|
|
]
|
|
|
|
subprocess.check_call(download_svgs_parse_only_cmd)
|
|
|
|
|
|
|
|
# Download SVGs from Google storage.
|
|
|
|
# The Google storage bucket will either contain private SVGs or SVGs which we
|
|
|
|
# cannot download over the internet using svg_downloader.py.
|
|
|
|
for skbug in ['skbug4713', 'skbug6918']:
|
|
|
|
subprocess.check_call([
|
|
|
|
'gsutil', '-m', 'cp', os.path.join(SVG_GS_BUCKET, skbug, '*'),
|
|
|
|
target_dir
|
|
|
|
])
|
2016-09-15 16:33:08 +00:00
|
|
|
|
2016-08-10 14:23:51 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument('--target_dir', '-t', required=True)
|
|
|
|
args = parser.parse_args()
|
2017-07-19 13:30:53 +00:00
|
|
|
create_asset(args.target_dir)
|
2016-08-10 14:23:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|