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

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

Issue 1204863002: Fix various windows-isms in the MB gen code paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mb_mkdir
Patch Set: s/\\/os.sep/ Created 5 years, 5 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 | no next file » | no next file with comments »
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 """
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 # Since GN hasn't run yet, the build directory may not even exist. 344 # Since GN hasn't run yet, the build directory may not even exist.
345 self.MaybeMakeDirectory(self.ToAbsPath(path)) 345 self.MaybeMakeDirectory(self.ToAbsPath(path))
346 346
347 self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n') 347 self.WriteFile(gn_runtime_deps_path, '\n'.join(gn_labels) + '\n')
348 cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path) 348 cmd.append('--runtime-deps-list-file=%s' % gn_runtime_deps_path)
349 349
350 ret, _, _ = self.Run(cmd) 350 ret, _, _ = self.Run(cmd)
351 351
352 for target in swarming_targets: 352 for target in swarming_targets:
353 deps_path = self.ToAbsPath(path, target + '.runtime_deps') 353 if sys.platform == 'win32':
354 deps_path = self.ToAbsPath(path, target + '.exe.runtime_deps')
355 else:
356 deps_path = self.ToAbsPath(path, target + '.runtime_deps')
354 if not self.Exists(deps_path): 357 if not self.Exists(deps_path):
355 raise MBErr('did not generate %s' % deps_path) 358 raise MBErr('did not generate %s' % deps_path)
356 359
357 command, extra_files = self.GetIsolateCommand(target, vals) 360 command, extra_files = self.GetIsolateCommand(target, vals)
358 361
359 runtime_deps = self.ReadFile(deps_path).splitlines() 362 runtime_deps = self.ReadFile(deps_path).splitlines()
360 363
361 isolate_path = self.ToAbsPath(path, target + '.isolate') 364 isolate_path = self.ToAbsPath(path, target + '.isolate')
362 self.WriteFile(isolate_path, 365 self.WriteFile(isolate_path,
363 pprint.pformat({ 366 pprint.pformat({
364 'variables': { 367 'variables': {
365 'command': command, 368 'command': command,
366 'files': sorted(runtime_deps + extra_files), 369 'files': sorted(runtime_deps + extra_files),
367 'read_only': 1, 370 'read_only': 1,
368 } 371 }
369 }) + '\n') 372 }) + '\n')
370 373
371 self.WriteJSON( 374 self.WriteJSON(
372 { 375 {
373 'args': [ 376 'args': [
374 '--isolated', 377 '--isolated',
375 self.ToSrcRelPath('%s/%s.isolated' % (path, target)), 378 self.ToSrcRelPath('%s%s%s.isolated' % (path, os.sep, target)),
376 '--isolate', 379 '--isolate',
377 self.ToSrcRelPath('%s/%s.isolate' % (path, target)), 380 self.ToSrcRelPath('%s%s%s.isolate' % (path, os.sep, target)),
378 ], 381 ],
379 'dir': self.chromium_src_dir, 382 'dir': self.chromium_src_dir,
380 'version': 1, 383 'version': 1,
381 }, 384 },
382 isolate_path + 'd.gen.json', 385 isolate_path + 'd.gen.json',
383 ) 386 )
384 387
385 388
386 return ret 389 return ret
387 390
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 553
551 def ToAbsPath(self, build_path, *comps): 554 def ToAbsPath(self, build_path, *comps):
552 return os.path.join(self.chromium_src_dir, 555 return os.path.join(self.chromium_src_dir,
553 self.ToSrcRelPath(build_path), 556 self.ToSrcRelPath(build_path),
554 *comps) 557 *comps)
555 558
556 def ToSrcRelPath(self, path): 559 def ToSrcRelPath(self, path):
557 """Returns a relative path from the top of the repo.""" 560 """Returns a relative path from the top of the repo."""
558 # TODO: Support normal paths in addition to source-absolute paths. 561 # TODO: Support normal paths in addition to source-absolute paths.
559 assert(path.startswith('//')) 562 assert(path.startswith('//'))
560 return path[2:] 563 return path[2:].replace('/', os.sep)
561 564
562 def ParseGYPConfigPath(self, path): 565 def ParseGYPConfigPath(self, path):
563 rpath = self.ToSrcRelPath(path) 566 rpath = self.ToSrcRelPath(path)
564 output_dir, _, config = rpath.rpartition('/') 567 output_dir, _, config = rpath.rpartition('/')
565 self.CheckGYPConfigIsSupported(config, path) 568 self.CheckGYPConfigIsSupported(config, path)
566 return output_dir, config 569 return output_dir, config
567 570
568 def CheckGYPConfigIsSupported(self, config, path): 571 def CheckGYPConfigIsSupported(self, config, path):
569 if config not in ('Debug', 'Release'): 572 if config not in ('Debug', 'Release'):
570 if (sys.platform in ('win32', 'cygwin') and 573 if (sys.platform in ('win32', 'cygwin') and
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 780
778 if __name__ == '__main__': 781 if __name__ == '__main__':
779 try: 782 try:
780 sys.exit(main(sys.argv[1:])) 783 sys.exit(main(sys.argv[1:]))
781 except MBErr as e: 784 except MBErr as e:
782 print(e) 785 print(e)
783 sys.exit(1) 786 sys.exit(1)
784 except KeyboardInterrupt: 787 except KeyboardInterrupt:
785 print("interrupted, exiting", stream=sys.stderr) 788 print("interrupted, exiting", stream=sys.stderr)
786 sys.exit(130) 789 sys.exit(130)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698