Index: tools/mb/mb.py |
diff --git a/tools/mb/mb.py b/tools/mb/mb.py |
index f2af24c332c12d5f667485a2e5afc4b0aac184e9..f30fc3a1240742a9b01338575205fee309362fb0 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,13 @@ 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 = None |
+ if vals['gyp_crosscompile']: |
+ if self.args.verbose: |
+ self.Print('Setting GYP_CROSSCOMPILE=1 in the environment') |
+ env = os.environ.copy() |
+ env['GYP_CROSSCOMPILE'] = '1' |
+ ret, _, _ = self.Run(cmd, env=env) |
return ret |
def RunGYPAnalyze(self, vals): |
@@ -752,13 +763,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 +777,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 |