Index: chrome/browser/resources/safe_browsing/push_file_type_proto.py |
diff --git a/chrome/browser/resources/safe_browsing/push_file_type_proto.py b/chrome/browser/resources/safe_browsing/push_file_type_proto.py |
index 0256ee8e92b76868599414771ff407f3476c7494..131414c77fb40e1800daf6a111cc535e94156972 100755 |
--- a/chrome/browser/resources/safe_browsing/push_file_type_proto.py |
+++ b/chrome/browser/resources/safe_browsing/push_file_type_proto.py |
@@ -3,50 +3,67 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
-# Push the {vers}/{plaform}/download_file_types.pb files to GCS so |
+# Build and push the {vers}/{platform}/download_file_types.pb files to GCS so |
# that the component update system will pick them up and push them |
# to users. See README.md before running this. |
+# |
+# Requires ninja and gsutil to be in the user's path. |
import optparse |
import os |
+import shutil |
import subprocess |
import sys |
DEST_BUCKET = 'gs://chrome-component-file-type-policies' |
+RESOURCE_SUBDIR = 'chrome/browser/resources/safe_browsing' |
def main(): |
parser = optparse.OptionParser() |
parser.add_option('-d', '--dir', |
- help='The directory containing ' |
- '{vers}/{platform}/download_file_types.pb files.') |
+ help='An up-to-date GN/Ninja build directory, ' |
+ 'such as ./out/Debug') |
vakh (use Gerrit instead)
2016/06/07 23:36:31
`out-gn` to be consistent?
|
(opts, args) = parser.parse_args() |
if opts.dir is None: |
parser.print_help() |
return 1 |
- os.chdir(opts.dir) |
+ # Clear out the target dir before we build so we can be sure we've got |
+ # the freshest version. |
+ all_dir = os.path.join(opts.dir, "gen", RESOURCE_SUBDIR, 'all') |
+ if os.path.isdir(all_dir): |
+ shutil.rmtree(all_dir) |
+ |
+ gn_command = ['ninja', |
+ '-C', opts.dir, |
+ RESOURCE_SUBDIR + ':make_all_file_types_protobuf'] |
+ print "Running the following" |
+ print " " + (' '.join(gn_command)) |
+ if subprocess.call(gn_command): |
+ print "Ninja failed." |
+ return 1 |
+ |
+ os.chdir(all_dir) |
# Sanity check that we're in the right place |
- assert opts.dir.endswith('/all'), '--dir should end with /all' |
dirs = os.listdir('.') |
- assert (len(dirs) == 1 and dirs[0].isdigit()), ( |
- 'Should be exactly one version directory. Please delete the contents ' |
- 'of the target dir and regenerate the protos.') |
+ assert len(dirs) == 1 and dirs[0].isdigit(), ( |
+ "Confused by lack of single versioned dir under " + all_dir) |
# Push the files with their directories, in the form |
# {vers}/{platform}/download_file_types.pb |
- # Don't overwrite existing files, incase we forgot to increment the |
+ # Don't overwrite existing files, in case we forgot to increment the |
# version. |
vers_dir = dirs[0] |
command = ['gsutil', 'cp', '-Rn', vers_dir, DEST_BUCKET] |
- print 'Going to run the following command' |
+ print '\nGoing to run the following command' |
print ' ', ' '.join(command) |
print '\nIn directory' |
- print ' ', opts.dir |
+ print ' ', all_dir |
print '\nWhich should push the following files' |
expected_files = [os.path.join(dp, f) for dp, dn, fn in |
os.walk(vers_dir) for f in fn] |