summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-27 23:55:24 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-27 23:55:24 +0000
commit38a2105e70e7d761a216b62e1f74ece981c703cb (patch)
tree8e20d1f939f814981458913f438bf2e5400188f7 /tools
parentb3df752d515a2bf10b3df9c8c1b0a3df88632d9e (diff)
downloadchromium_src-38a2105e70e7d761a216b62e1f74ece981c703cb.zip
chromium_src-38a2105e70e7d761a216b62e1f74ece981c703cb.tar.gz
chromium_src-38a2105e70e7d761a216b62e1f74ece981c703cb.tar.bz2
Properly handle errors in GRIT in the scons build.
This lets the child process exit even if there are errors and causes the main scons process to identify these errors as build failures. Review URL: http://codereview.chromium.org/28282 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10652 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/grit/grit/scons.py66
1 files changed, 37 insertions, 29 deletions
diff --git a/tools/grit/grit/scons.py b/tools/grit/grit/scons.py
index 09eb4e5..733583e 100644
--- a/tools/grit/grit/scons.py
+++ b/tools/grit/grit/scons.py
@@ -12,6 +12,8 @@
import os
import types
+import SCons.Errors
+
def _IsDebugEnabled():
return 'GRIT_DEBUG' in os.environ and os.environ['GRIT_DEBUG'] == '1'
@@ -45,36 +47,42 @@ def _Builder(target, source, env):
# fork, we can use multiple processes and processors.
pid = os.fork()
if pid != 0:
- os.waitpid(pid, 0)
+ pid, exit_code = os.waitpid(pid, 0)
+ if exit_code != 0:
+ raise SCons.Errors.BuildError(errstr="see grit error")
return
- from grit import grit_runner
- from grit.tool import build
- options = grit_runner.Options()
- # This sets options to default values.
- options.ReadOptions(['-v'])
- options.input = _SourceToFile(source)
-
- # TODO(joi) Check if we can get the 'verbose' option from the environment.
-
- builder = build.RcBuilder()
-
- # Get the CPP defines from the environment.
- for flag in env.get('RCFLAGS', []):
- if flag.startswith('/D'):
- flag = flag[2:]
- name, val = build.ParseDefine(flag)
- # Only apply to first instance of a given define
- if name not in builder.defines:
- builder.defines[name] = val
-
- # To ensure that our output files match what we promised SCons, we
- # use the list of targets provided by SCons and update the file paths in
- # our .grd input file with the targets.
- builder.scons_targets = [str(t) for t in target]
- builder.Run(options, [])
-
- # Exit the child process.
- os._exit(0)
+ try:
+ child_exit_code = 0
+ from grit import grit_runner
+ from grit.tool import build
+ options = grit_runner.Options()
+ # This sets options to default values.
+ options.ReadOptions(['-v'])
+ options.input = _SourceToFile(source)
+
+ # TODO(joi) Check if we can get the 'verbose' option from the environment.
+
+ builder = build.RcBuilder()
+
+ # Get the CPP defines from the environment.
+ for flag in env.get('RCFLAGS', []):
+ if flag.startswith('/D'):
+ flag = flag[2:]
+ name, val = build.ParseDefine(flag)
+ # Only apply to first instance of a given define
+ if name not in builder.defines:
+ builder.defines[name] = val
+
+ # To ensure that our output files match what we promised SCons, we
+ # use the list of targets provided by SCons and update the file paths in
+ # our .grd input file with the targets.
+ builder.scons_targets = [str(t) for t in target]
+ builder.Run(options, [])
+ except:
+ child_exit_code = -1
+ finally:
+ # Exit the child process.
+ os._exit(child_exit_code)
def _Emitter(target, source, env):