Chromium Code Reviews| Index: tools/mb/mb.py |
| diff --git a/tools/mb/mb.py b/tools/mb/mb.py |
| index f2af24c332c12d5f667485a2e5afc4b0aac184e9..fc993260eec5536b08ebf9c54f432f2a5098849c 100755 |
| --- a/tools/mb/mb.py |
| +++ b/tools/mb/mb.py |
| @@ -147,6 +147,8 @@ class MetaBuildWrapper(object): |
| if vals['type'] == 'gn': |
| cmd = self.GNCmd('gen', '<path>', vals['gn_args']) |
| elif vals['type'] == 'gyp': |
| + if vals['gyp_crosscompile']: |
| + self.Print('GYP_CROSSCOMPILE=1') |
| cmd = self.GYPCmd('<path>', vals['gyp_defines'], vals['gyp_config']) |
| else: |
| raise MBErr('Unknown meta-build type "%s"' % vals['type']) |
| @@ -289,6 +291,7 @@ class MetaBuildWrapper(object): |
| 'gn_args': [], |
| 'gyp_config': [], |
| 'gyp_defines': [], |
| + 'gyp_crosscompile': False, |
| } |
| visited = [] |
| @@ -314,6 +317,8 @@ class MetaBuildWrapper(object): |
| vals['gn_args'] = mixin_vals['gn_args'] |
| if 'gyp_config' in mixin_vals: |
| vals['gyp_config'] = mixin_vals['gyp_config'] |
| + if 'gyp_crosscompile' in mixin_vals: |
| + vals['gyp_crosscompile'] = mixin_vals['gyp_crosscompile'] |
| if 'gyp_defines' in mixin_vals: |
| if vals['gyp_defines']: |
| vals['gyp_defines'] += ' ' + mixin_vals['gyp_defines'] |
| @@ -426,7 +431,12 @@ class MetaBuildWrapper(object): |
| 'GYP configuration specified in the config (%s), and ' |
| 'it does not.' % (gyp_config, vals['gyp_config'])) |
| cmd = self.GYPCmd(output_dir, vals['gyp_defines'], config=gyp_config) |
| - ret, _, _ = self.Run(cmd) |
| + env = os.environ.copy() |
| + if vals['gyp_crosscompile']: |
| + if self.args.verbose: |
| + self.Print('Setting GYP_CROSSCOMPILE=1 in the environment') |
| + env['GYP_CROSSCOMPILE'] = '1' |
|
Nico
2015/08/14 00:14:30
Hm, this copy-env-and-set pattern has caused me tr
Dirk Pranke
2015/08/14 00:19:17
I'm not sure why that would make a difference, but
|
| + ret, _, _ = self.Run(cmd, env=env) |
| return ret |
| def RunGYPAnalyze(self, vals): |
| @@ -752,13 +762,13 @@ class MetaBuildWrapper(object): |
| # This function largely exists so it can be overridden for testing. |
| print(*args, **kwargs) |
| - def Run(self, cmd): |
| + def Run(self, cmd, env=None): |
| # This function largely exists so it can be overridden for testing. |
| if self.args.dryrun or self.args.verbose: |
| self.PrintCmd(cmd) |
| if self.args.dryrun: |
| return 0, '', '' |
| - ret, out, err = self.Call(cmd) |
| + ret, out, err = self.Call(cmd, env=env) |
| if self.args.verbose: |
| if out: |
| self.Print(out, end='') |
| @@ -766,9 +776,10 @@ class MetaBuildWrapper(object): |
| self.Print(err, end='', file=sys.stderr) |
| return ret, out, err |
| - def Call(self, cmd): |
| + def Call(self, cmd, env=None): |
| p = subprocess.Popen(cmd, shell=False, cwd=self.chromium_src_dir, |
| - stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| + stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| + env=env) |
| out, err = p.communicate() |
| return p.returncode, out, err |