From d1fba489d9b1068007487bcaa5813b10243bc837 Mon Sep 17 00:00:00 2001 From: dpranke Date: Tue, 14 Apr 2015 13:54:51 -0700 Subject: Explicitly specify the path to GN in mb.py. Previously we were (a) assuming it was in the path and (b) not accounting for it being called 'gn.exe' on windows. TBR=phajdan.jr@chromium.org BUG=454413 CQ_EXTRA_TRYBOTS=tryserver.chromium.mac:mac_chromium_gn_dbg Review URL: https://codereview.chromium.org/1082353002 Cr-Commit-Position: refs/heads/master@{#325116} --- tools/mb/mb.py | 24 +++++++++++++++++------- tools/mb/mb_unittest.py | 4 +++- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/mb/mb.py b/tools/mb/mb.py index 1b7bbb9..2a9941b 100755 --- a/tools/mb/mb.py +++ b/tools/mb/mb.py @@ -35,6 +35,7 @@ class MetaBuildWrapper(object): self.chromium_src_dir = p.normpath(d(d(d(p.abspath(__file__))))) self.default_config = p.join(self.chromium_src_dir, 'tools', 'mb', 'mb_config.pyl') + self.platform = sys.platform self.args = argparse.Namespace() self.configs = {} self.masters = {} @@ -131,7 +132,7 @@ class MetaBuildWrapper(object): def CmdLookup(self): vals = self.GetConfig() if vals['type'] == 'gn': - cmd = self.GNCmd('', vals['gn_args']) + cmd = self.GNCmd('gen', '', vals['gn_args']) elif vals['type'] == 'gyp': cmd = self.GYPCmd('', vals['gyp_defines'], vals['gyp_config']) else: @@ -309,13 +310,22 @@ class MetaBuildWrapper(object): return vals def RunGNGen(self, path, vals): - cmd = self.GNCmd(path, vals['gn_args']) + cmd = self.GNCmd('gen', path, vals['gn_args']) ret, _, _ = self.Run(cmd) return ret - def GNCmd(self, path, gn_args): - # TODO(dpranke): Find gn explicitly in the path ... - cmd = ['gn', 'gen', path] + def GNCmd(self, subcommand, path, gn_args=''): + if self.platform == 'linux2': + gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'linux64', + 'gn') + elif self.platform == 'darwin': + gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'mac', + 'gn') + else: + gn_path = os.path.join(self.chromium_src_dir, 'buildtools', 'win', + 'gn.exe') + + cmd = [gn_path, subcommand, path] gn_args = gn_args.replace("$(goma_dir)", self.args.goma_dir) if gn_args: cmd.append('--args=%s' % gn_args) @@ -408,8 +418,8 @@ class MetaBuildWrapper(object): all_needed_targets = set() for f in inp['files']: - cmd = ['gn', 'refs', self.args.path[0], '//' + f, - '--type=executable', '--all', '--as=output'] + cmd = self.GNCmd('refs', self.args.path[0]) + [ + '//' + f, '--type=executable', '--all', '--as=output'] ret, out, _ = self.Run(cmd) if ret: self.WriteFailureAndRaise('gn refs returned %d: %s' % (ret, out), diff --git a/tools/mb/mb_unittest.py b/tools/mb/mb_unittest.py index 19cd87f..5613df6 100644 --- a/tools/mb/mb_unittest.py +++ b/tools/mb/mb_unittest.py @@ -18,6 +18,7 @@ class FakeMBW(mb.MetaBuildWrapper): self.calls = [] self.out = '' self.err = '' + self.platform = 'linux2' self.chromium_src_dir = '/fake_src' self.default_config = '/fake_src/tools/mb/mb_config.pyl' @@ -151,7 +152,8 @@ class UnitTest(unittest.TestCase): out=("python build/gyp_chromium -G 'output_dir=' " "-G config=Release -D goma=1 -D gomadir=/foo\n")) self.check(['lookup', '-c', 'gn_rel_bot', '-g', '/foo'], ret=0, - out=("gn gen '' '--args=is_debug=false use_goma=true " + out=("/fake_src/buildtools/linux64/gn gen '' " + "'--args=is_debug=false use_goma=true " "goma_dir=\"/foo\"'\n" )) def test_help(self): -- cgit v1.1