diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 23:38:04 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 23:38:04 +0000 |
commit | 3244d1f880a132681a190d9096aeeea85bfcbf19 (patch) | |
tree | 744787ba06d7a18c9cb89eae5f05aec32f68d998 | |
parent | 13f351535a767ab35ea91b74eb6909612786de1a (diff) | |
download | chromium_src-3244d1f880a132681a190d9096aeeea85bfcbf19.zip chromium_src-3244d1f880a132681a190d9096aeeea85bfcbf19.tar.gz chromium_src-3244d1f880a132681a190d9096aeeea85bfcbf19.tar.bz2 |
Allow grit to run in parallel with scons by forking child processes
for each grit builder. This speeds up the build a bit.
Review URL: http://codereview.chromium.org/27118
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | tools/grit/grit/scons.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/grit/grit/scons.py b/tools/grit/grit/scons.py index 946c72c..9a88216 100644 --- a/tools/grit/grit/scons.py +++ b/tools/grit/grit/scons.py @@ -39,6 +39,14 @@ def _SourceToFile(source): def _Builder(target, source, env): + # We fork GRIT into a separate process so we can use more processes between + # scons and GRIT. This already runs as separate threads, but because of the + # python GIL, all these threads have to share the same process. By using + # fork, we can use multiple processes and processors. + pid = os.fork() + if pid != 0: + os.waitpid(pid, 0) + return from grit import grit_runner from grit.tool import build options = grit_runner.Options() @@ -65,6 +73,9 @@ def _Builder(target, source, env): builder.scons_targets = [str(t) for t in target] builder.Run(options, []) + # Exit the child process. + os._exit(0) + def _Emitter(target, source, env): '''A SCons emitter for .grd files, which modifies the list of targes to @@ -111,10 +122,6 @@ def _Emitter(target, source, env): if _IsDebugEnabled(): print "GRIT: Added target %s" % path - # GRIT is not thread safe so we should only build one grit target at a time. - # We tell scons about this by making a fake side effect target. - env.SideEffect('grit_lock', target) - # return target and source lists return (target, source) |