Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: tools/mb/mb.py

Issue 1204793002: Fix errors in MB when run for the first time on a new builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch for review Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/mb/mb_unittest.py » ('j') | tools/mb/mb_unittest.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """MB - the Meta-Build wrapper around GYP and GN 6 """MB - the Meta-Build wrapper around GYP and GN
7 7
8 MB is a wrapper script for GYP and GN that can be used to generate build files 8 MB is a wrapper script for GYP and GN that can be used to generate build files
9 for sets of canned configurations and analyze them. 9 for sets of canned configurations and analyze them.
10 """ 10 """
11 11
12 from __future__ import print_function 12 from __future__ import print_function
13 13
14 import argparse 14 import argparse
15 import ast 15 import ast
16 import errno
16 import json 17 import json
17 import os 18 import os
18 import pipes 19 import pipes
19 import pprint 20 import pprint
20 import shlex 21 import shlex
21 import shutil 22 import shutil
22 import sys 23 import sys
23 import subprocess 24 import subprocess
24 import tempfile 25 import tempfile
25 26
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 ninja_targets_to_labels = ast.literal_eval(self.ReadFile(os.path.join( 333 ninja_targets_to_labels = ast.literal_eval(self.ReadFile(os.path.join(
333 self.chromium_src_dir, 'testing', 'buildbot', 'ninja_to_gn.pyl'))) 334 self.chromium_src_dir, 'testing', 'buildbot', 'ninja_to_gn.pyl')))
334 gn_labels = [] 335 gn_labels = []
335 for target in swarming_targets: 336 for target in swarming_targets:
336 if not target in ninja_targets_to_labels: 337 if not target in ninja_targets_to_labels:
337 raise MBErr('test target "%s" not found in %s' % 338 raise MBErr('test target "%s" not found in %s' %
338 (target, '//testing/buildbot/ninja_to_gn.pyl')) 339 (target, '//testing/buildbot/ninja_to_gn.pyl'))
339 gn_labels.append(ninja_targets_to_labels[target]) 340 gn_labels.append(ninja_targets_to_labels[target])
340 341
341 gn_runtime_deps_path = self.ToAbsPath(path, 'runtime_deps') 342 gn_runtime_deps_path = self.ToAbsPath(path, 'runtime_deps')
343
344 # Since GN hasn't run yet, the build directory may not even exist.
345 self.MaybeMakeDirectory(self.ToAbsPath(path))
346
342 self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n') 347 self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n')
343 cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path) 348 cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path)
344 349
345 ret, _, _ = self.Run(cmd) 350 ret, _, _ = self.Run(cmd)
346 351
347 for target in swarming_targets: 352 for target in swarming_targets:
348 deps_path = self.ToAbsPath(path, target + '.runtime_deps') 353 deps_path = self.ToAbsPath(path, target + '.runtime_deps')
349 if not self.Exists(deps_path): 354 if not self.Exists(deps_path):
350 raise MBErr('did not generate %s' % deps_path) 355 raise MBErr('did not generate %s' % deps_path)
351 356
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 return p.returncode, out, err 736 return p.returncode, out, err
732 737
733 def ExpandUser(self, path): 738 def ExpandUser(self, path):
734 # This function largely exists so it can be overridden for testing. 739 # This function largely exists so it can be overridden for testing.
735 return os.path.expanduser(path) 740 return os.path.expanduser(path)
736 741
737 def Exists(self, path): 742 def Exists(self, path):
738 # This function largely exists so it can be overridden for testing. 743 # This function largely exists so it can be overridden for testing.
739 return os.path.exists(path) 744 return os.path.exists(path)
740 745
746 def MaybeMakeDirectory(self, path):
747 try:
748 os.makedirs(path)
749 except OSError, e:
750 if e.errno != errno.EEXIST:
751 raise
752
741 def ReadFile(self, path): 753 def ReadFile(self, path):
742 # This function largely exists so it can be overriden for testing. 754 # This function largely exists so it can be overriden for testing.
743 with open(path) as fp: 755 with open(path) as fp:
744 return fp.read() 756 return fp.read()
745 757
746 def RemoveFile(self, path): 758 def RemoveFile(self, path):
747 # This function largely exists so it can be overriden for testing. 759 # This function largely exists so it can be overriden for testing.
748 os.remove(path) 760 os.remove(path)
749 761
750 def TempFile(self, mode='w'): 762 def TempFile(self, mode='w'):
(...skipping 14 matching lines...) Expand all
765 777
766 if __name__ == '__main__': 778 if __name__ == '__main__':
767 try: 779 try:
768 sys.exit(main(sys.argv[1:])) 780 sys.exit(main(sys.argv[1:]))
769 except MBErr as e: 781 except MBErr as e:
770 print(e) 782 print(e)
771 sys.exit(1) 783 sys.exit(1)
772 except KeyboardInterrupt: 784 except KeyboardInterrupt:
773 print("interrupted, exiting", stream=sys.stderr) 785 print("interrupted, exiting", stream=sys.stderr)
774 sys.exit(130) 786 sys.exit(130)
OLDNEW
« no previous file with comments | « no previous file | tools/mb/mb_unittest.py » ('j') | tools/mb/mb_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698