Bug 1455892 - Use a tracking stub file rather than a phony target to speed up ipdl in incremental builds. r=froydnj draft
authorChris Manchester <cmanchester@mozilla.com>
Thu, 03 May 2018 12:54:21 -0700
changeset 791266 5e250cd2dd57b8591db700a3d79ec36c88fa4dd4
parent 790721 f877359308b17e691209e1afb7193b8e86f175ce
push id108767
push userbmo:cmanchester@mozilla.com
push dateThu, 03 May 2018 21:46:21 +0000
reviewersfroydnj
bugs1455892
milestone61.0a1
Bug 1455892 - Use a tracking stub file rather than a phony target to speed up ipdl in incremental builds. r=froydnj This commit removes some mtime checking logic in ipdl.py that is made redundant with make's logic to re-invoke ipdl.py when dependencies have changed. MozReview-Commit-ID: FJuYIZv5uym
ipc/ipdl/Makefile.in
ipc/ipdl/ipdl.py
--- a/ipc/ipdl/Makefile.in
+++ b/ipc/ipdl/Makefile.in
@@ -1,33 +1,38 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 GARBAGE_DIRS += _ipdlheaders
-GARBAGE += ipdl_lextab.py ipdl_yacctab.py $(wildcard *.pyc $(srcdir)/ipdl/*.pyc $(srcdir)/ipdl/cxx/*.pyc)
+GARBAGE += ipdl_lextab.py ipdl_yacctab.py $(wildcard *.pyc $(srcdir)/ipdl/*.pyc $(srcdir)/ipdl/cxx/*.pyc) ipdl.track
 
 ifdef COMPILE_ENVIRONMENT
 
 # This file is generated by the moz.build backend.
 include ipdlsrcs.mk
 
 include $(topsrcdir)/config/rules.mk
 
+ipdl_py_deps := \
+    $(wildcard $(srcdir)/*.py) \
+    $(wildcard $(srcdir)/ipdl/*.py) \
+    $(wildcard $(srcdir)/ipdl/cxx/*.py) \
+    $(wildcard $(topsrcdir)/other-licenses/ply/ply/*.py) \
+    $(NULL)
 
 # NB: the IPDL compiler manages .ipdl-->.h/.cpp dependencies itself,
 # which is why we don't have explicit .h/.cpp targets here
-ipdl: $(ALL_IPDLSRCS)
+ipdl.track: $(ALL_IPDLSRCS) $(srcdir)/sync-messages.ini $(srcdir)/message-metadata.ini $(ipdl_py_deps)
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
 	  $(PLY_INCLUDE) \
 	  $(srcdir)/ipdl.py \
 	  --sync-msg-list=$(srcdir)/sync-messages.ini \
 	  --msg-metadata=$(srcdir)/message-metadata.ini \
 	  --outheaders-dir=_ipdlheaders \
 	  --outcpp-dir=. \
 	  $(IPDLDIRS:%=-I%) \
-	  $^
+	  $(ALL_IPDLSRCS)
+	touch $@
 
-.PHONY: ipdl
-
-export:: ipdl
+export:: ipdl.track
 endif
 
--- a/ipc/ipdl/ipdl.py
+++ b/ipc/ipdl/ipdl.py
@@ -1,17 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import optparse, os, re, sys
 from cStringIO import StringIO
-from mozbuild.pythonutil import iter_modules_in_path
 import mozpack.path as mozpath
-import itertools
 from ConfigParser import RawConfigParser
 
 import ipdl
 
 def log(minv, fmt, *args):
     if _verbosity >= minv:
         print fmt % args
 
@@ -49,70 +47,16 @@ cppdir = options.cppdir
 includedirs = [ os.path.abspath(incdir) for incdir in options.includedirs ]
 
 if not len(files):
     op.error("No IPDL files specified")
 
 ipcmessagestartpath = os.path.join(headersdir, 'IPCMessageStart.h')
 ipc_msgtype_name_path = os.path.join(cppdir, 'IPCMessageTypeName.cpp')
 
-# Compiling the IPDL files can take a long time, even on a fast machine.
-# Check to see whether we need to do any work.
-latestipdlmod = max(os.stat(f).st_mtime
-                    for f in itertools.chain(files,
-                                             iter_modules_in_path(mozpath.dirname(__file__))))
-
-def outputModTime(f):
-    # A non-existant file is newer than everything.
-    if not os.path.exists(f):
-        return 0
-    return os.stat(f).st_mtime
-
-# Because the IPDL headers are placed into directories reflecting their
-# namespace, collect a list here so we can easily map output names without
-# parsing the actual IPDL files themselves.
-headersmap = {}
-for (path, dirs, headers) in os.walk(headersdir):
-    for h in headers:
-        base = os.path.basename(h)
-        if base in headersmap:
-            root, ext = os.path.splitext(base)
-            print >>sys.stderr, 'A protocol named', root, 'exists in multiple namespaces'
-            sys.exit(1)
-        headersmap[base] = os.path.join(path, h)
-
-def outputfiles(f):
-    base = os.path.basename(f)
-    root, ext = os.path.splitext(base)
-
-    suffixes = ['']
-    if ext == '.ipdl':
-        suffixes += ['Child', 'Parent']
-
-    for suffix in suffixes:
-        yield os.path.join(cppdir, "%s%s.cpp" % (root, suffix))
-        header = "%s%s.h" % (root, suffix)
-        # If the header already exists on disk, use that.  Otherwise,
-        # just claim that the header is found in headersdir.
-        if header in headersmap:
-            yield headersmap[header]
-        else:
-            yield os.path.join(headersdir, header)
-
-def alloutputfiles():
-    for f in files:
-        for s in outputfiles(f):
-            yield s
-    yield ipcmessagestartpath
-
-earliestoutputmod = min(outputModTime(f) for f in alloutputfiles())
-
-if latestipdlmod < earliestoutputmod:
-    sys.exit(0)
-
 log(2, 'Generated C++ headers will be generated relative to "%s"', headersdir)
 log(2, 'Generated C++ sources will be generated in "%s"', cppdir)
 
 allmessages = {}
 allmessageprognames = []
 allprotocols = []
 
 def normalizedFilename(f):