From bd9ba0040a55a4dfd0b5a2e9ae46fc26e54d01c7 Mon Sep 17 00:00:00 2001
From: Takanori MATSUURA <t.matsuu@gmail.com>
Date: Fri, 6 Apr 2012 14:06:52 -0400
Subject: [PATCH] Bug 737006 - Use internal ply only if needed. r=khuey

---
 config/config.mk               |  5 +++++
 config/rules.mk                |  4 ++--
 dom/bindings/Makefile.in       | 24 +++++++++++++-----------
 ipc/ipdl/Makefile.in           | 12 ++++++------
 ipc/ipdl/test/ipdl/Makefile.in |  2 +-
 js/src/config/config.mk        |  5 +++++
 js/src/config/rules.mk         |  4 ++--
 js/xpconnect/src/Makefile.in   | 20 ++++++++++----------
 xpcom/idl-parser/Makefile.in   |  4 ++--
 9 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/config/config.mk b/config/config.mk
index f9fd8b273d368..1e2bafe356979 100644
--- a/config/config.mk
+++ b/config/config.mk
@@ -837,3 +837,8 @@ EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 endif
 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
+
+# Include internal ply only if needed
+ifndef MOZ_SYSTEM_PLY
+PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
+endif
diff --git a/config/rules.mk b/config/rules.mk
index 5eae4ccc24c1a..6358c1edbf86d 100644
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1444,7 +1444,7 @@ xpidl-preqs = \
 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
 	$(REPORT_BUILD)
 	$(PYTHON_PATH) \
-	  -I$(topsrcdir)/other-licenses/ply \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(topsrcdir)/xpcom/idl-parser/header.py --cachedir=$(DEPTH)/xpcom/idl-parser $(XPIDL_FLAGS) $(_VPATH_SRCS) -d $(MDDEPDIR)/$(@F).pp -o $@
 	@if test -n "$(findstring $*.h, $(EXPORTS))"; \
@@ -1456,7 +1456,7 @@ ifndef NO_GEN_XPT
 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
 	$(REPORT_BUILD)
 	$(PYTHON_PATH) \
-	  -I$(topsrcdir)/other-licenses/ply \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  -I$(topsrcdir)/xpcom/typelib/xpt/tools \
 	  $(topsrcdir)/xpcom/idl-parser/typelib.py --cachedir=$(DEPTH)/xpcom/idl-parser $(XPIDL_FLAGS) $(_VPATH_SRCS) -d $(MDDEPDIR)/$(@F).pp -o $@
diff --git a/dom/bindings/Makefile.in b/dom/bindings/Makefile.in
index 42a124b845f45..9754c097ef909 100644
--- a/dom/bindings/Makefile.in
+++ b/dom/bindings/Makefile.in
@@ -1,6 +1,6 @@
 # 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/.
+# 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/.
 
 DEPTH            = ../..
 topsrcdir        = @top_srcdir@
@@ -75,18 +75,20 @@ bindinggen_dependencies := \
 $(binding_header_files): %Binding.h: $(bindinggen_dependencies) \
                                      $(webidl_base)/%.webidl \
                                      $(NULL)
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-    -I$(topsrcdir)/other-licenses/ply -I$(srcdir)/parser \
-    $(srcdir)/BindingGen.py $(ACCESSOR_OPT) header $(srcdir)/Bindings.conf $*Binding \
-    $(webidl_base)/$*.webidl
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) -I$(srcdir)/parser \
+    	  $(srcdir)/BindingGen.py $(ACCESSOR_OPT) header \
+	  $(srcdir)/Bindings.conf $*Binding \
+	  $(webidl_base)/$*.webidl
 
 $(binding_cpp_files): %Binding.cpp: $(bindinggen_dependencies) \
                                     $(webidl_base)/%.webidl \
                                     $(NULL)
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-    -I$(topsrcdir)/other-licenses/ply -I$(srcdir)/parser \
-    $(srcdir)/BindingGen.py $(ACCESSOR_OPT) cpp $(srcdir)/Bindings.conf $*Binding \
-    $(webidl_base)/$*.webidl
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) -I$(srcdir)/parser \
+	  $(srcdir)/BindingGen.py $(ACCESSOR_OPT) cpp \
+	  $(srcdir)/Bindings.conf $*Binding \
+	  $(webidl_base)/$*.webidl
 
 $(globalgen_targets): ParserResults.pkl
 
@@ -108,7 +110,7 @@ $(CACHE_DIR)/.done:
 ParserResults.pkl: $(globalgen_dependencies) \
                    $(addprefix $(webidl_base)/, $(webidl_files))
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-    -I$(topsrcdir)/other-licenses/ply -I$(srcdir)/parser \
+    $(PLY_INCLUDE) -I$(srcdir)/parser \
     $(srcdir)/GlobalGen.py $(ACCESSOR_OPT) $(srcdir)/Bindings.conf $(webidl_base) \
     --cachedir=$(CACHE_DIR) \
     $(webidl_files)
diff --git a/ipc/ipdl/Makefile.in b/ipc/ipdl/Makefile.in
index 156ac1a151ae0..327b1d6ac43bf 100644
--- a/ipc/ipdl/Makefile.in
+++ b/ipc/ipdl/Makefile.in
@@ -115,12 +115,12 @@ include $(topsrcdir)/config/rules.mk
 # NB: the IPDL compiler manages .ipdl-->.h/.cpp dependencies itself,
 # which is why we don't have explicit .h/.cpp targets here
 export:: $(ALL_IPDLSRCS)
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py	\
-	  -I$(topsrcdir)/other-licenses/ply		\
-	  $(srcdir)/ipdl.py				\
-	  --outheaders-dir=_ipdlheaders			\
-	  --outcpp-dir=.				\
-	  $(IPDLDIRS:%=-I$(topsrcdir)/%)		\
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) \
+	  $(srcdir)/ipdl.py \
+	  --outheaders-dir=_ipdlheaders \
+	  --outcpp-dir=. \
+	  $(IPDLDIRS:%=-I$(topsrcdir)/%) \
 	  $^
 
 # We #include some things in the dom/plugins/ directory that rely on
diff --git a/ipc/ipdl/test/ipdl/Makefile.in b/ipc/ipdl/test/ipdl/Makefile.in
index 8d9d2bdc5705c..8172f406bc89b 100644
--- a/ipc/ipdl/test/ipdl/Makefile.in
+++ b/ipc/ipdl/test/ipdl/Makefile.in
@@ -49,7 +49,7 @@ check::
 	@$(PYTHON) $(srcdir)/runtests.py  \
 		$(srcdir)/ok $(srcdir)/error  \
 		$(PYTHON) $(topsrcdir)/config/pythonpath.py  \
-		-I$(topsrcdir)/other-licenses/ply  \
+		$(PLY_INCLUDE)  \
 		$(topsrcdir)/ipc/ipdl/ipdl.py  \
 		OKTESTS $(OKTESTS)  \
 		ERRORTESTS $(ERRORTESTS)
diff --git a/js/src/config/config.mk b/js/src/config/config.mk
index f9fd8b273d368..1e2bafe356979 100644
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -837,3 +837,8 @@ EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 endif
 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
+
+# Include internal ply only if needed
+ifndef MOZ_SYSTEM_PLY
+PLY_INCLUDE = -I$(topsrcdir)/other-licenses/ply
+endif
diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk
index 5eae4ccc24c1a..6358c1edbf86d 100644
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -1444,7 +1444,7 @@ xpidl-preqs = \
 $(XPIDL_GEN_DIR)/%.h: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
 	$(REPORT_BUILD)
 	$(PYTHON_PATH) \
-	  -I$(topsrcdir)/other-licenses/ply \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(topsrcdir)/xpcom/idl-parser/header.py --cachedir=$(DEPTH)/xpcom/idl-parser $(XPIDL_FLAGS) $(_VPATH_SRCS) -d $(MDDEPDIR)/$(@F).pp -o $@
 	@if test -n "$(findstring $*.h, $(EXPORTS))"; \
@@ -1456,7 +1456,7 @@ ifndef NO_GEN_XPT
 $(XPIDL_GEN_DIR)/%.xpt: %.idl $(XPIDL_DEPS) $(xpidl-preqs)
 	$(REPORT_BUILD)
 	$(PYTHON_PATH) \
-	  -I$(topsrcdir)/other-licenses/ply \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  -I$(topsrcdir)/xpcom/typelib/xpt/tools \
 	  $(topsrcdir)/xpcom/idl-parser/typelib.py --cachedir=$(DEPTH)/xpcom/idl-parser $(XPIDL_FLAGS) $(_VPATH_SRCS) -d $(MDDEPDIR)/$(@F).pp -o $@
diff --git a/js/xpconnect/src/Makefile.in b/js/xpconnect/src/Makefile.in
index 7814dda3cfb91..2f7c566650999 100644
--- a/js/xpconnect/src/Makefile.in
+++ b/js/xpconnect/src/Makefile.in
@@ -150,8 +150,8 @@ dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \
                     $(topsrcdir)/xpcom/idl-parser/header.py \
                     $(topsrcdir)/xpcom/idl-parser/xpidl.py \
                     $(DEPTH)/js/src/js-confdefs.h
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/other-licenses/ply \
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(srcdir)/qsgen.py \
 	  --idlpath=$(DEPTH)/dist/idl \
@@ -171,8 +171,8 @@ dombindings_gen.h: $(srcdir)/dombindings.conf \
                    $(topsrcdir)/xpcom/idl-parser/header.py \
                    $(topsrcdir)/xpcom/idl-parser/xpidl.py \
                    $(DEPTH)/js/src/js-confdefs.h
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/other-licenses/ply \
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(srcdir)/dombindingsgen.py \
 	  --idlpath=$(DEPTH)/dist/idl \
@@ -188,8 +188,8 @@ dombindings_gen.cpp: $(srcdir)/dombindings.conf \
                      $(topsrcdir)/xpcom/idl-parser/header.py \
                      $(topsrcdir)/xpcom/idl-parser/xpidl.py \
                      $(DEPTH)/js/src/js-confdefs.h
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/other-licenses/ply \
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(srcdir)/dombindingsgen.py \
 	  --idlpath=$(DEPTH)/dist/idl \
@@ -207,8 +207,8 @@ DictionaryHelpers.h: $(srcdir)/dictionary_helper_gen.conf \
                      $(topsrcdir)/xpcom/idl-parser/header.py \
                      $(topsrcdir)/xpcom/idl-parser/xpidl.py \
                      $(DEPTH)/js/src/js-confdefs.h
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/other-licenses/ply \
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(srcdir)/dictionary_helper_gen.py \
 	  -I $(DEPTH)/dist/idl \
@@ -222,8 +222,8 @@ DictionaryHelpers.cpp: $(srcdir)/dictionary_helper_gen.conf \
                        $(topsrcdir)/xpcom/idl-parser/header.py \
                        $(topsrcdir)/xpcom/idl-parser/xpidl.py \
                        $(DEPTH)/js/src/js-confdefs.h
-	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
-	  -I$(topsrcdir)/other-licenses/ply \
+	$(PYTHON_PATH) \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(srcdir)/dictionary_helper_gen.py \
 	  -I $(DEPTH)/dist/idl \
diff --git a/xpcom/idl-parser/Makefile.in b/xpcom/idl-parser/Makefile.in
index f5ff17816a462..4f578a199e14d 100644
--- a/xpcom/idl-parser/Makefile.in
+++ b/xpcom/idl-parser/Makefile.in
@@ -59,13 +59,13 @@ include $(topsrcdir)/config/rules.mk
 # Generate the PLY lexer and parser.
 export:: $(PARSER_SRCS) $(PLY_PROGS)
 	$(PYTHON_PATH) \
-	  -I$(topsrcdir)/other-licenses/ply \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(topsrcdir)/xpcom/idl-parser/header.py --cachedir=. --regen
 
 check::
 	$(PYTHON_PATH) \
-	  -I$(topsrcdir)/other-licenses/ply \
+	  $(PLY_INCLUDE) \
 	  -I$(topsrcdir)/xpcom/idl-parser \
 	  $(topsrcdir)/xpcom/idl-parser/runtests.py
 
-- 
GitLab