Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: pylib/gyp/generator/make.py

Issue 150166: Make dependencies standalone. Doesn't actually work because of autogenerated... Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pylib/gyp/generator/make.py
===================================================================
--- pylib/gyp/generator/make.py (revision 528)
+++ pylib/gyp/generator/make.py (working copy)
@@ -94,6 +94,7 @@
# so we can't end up with a broken dep file.
depfile = $@.d
DEPFLAGS = -MMD -MF $(depfile).tmp
+DEPFLAGS2 = -MM
# We have to fixup the deps output in a few ways.
# First, the file output should to mention the proper .o file.
@@ -115,10 +116,20 @@
r"""
define fixup_dep
sed -i -e "s|^$(notdir $@)|$@|" $(depfile).tmp
+sed -i -e "s|^$@:|$@ $(depfile):|" $(depfile).tmp
sed -e "s|^[^:]*: *||" -e "s| *\\\\$$||" -e 's|^ *||' \
-e "/./s|$$|:|" $(depfile).tmp >> $(depfile).tmp
mv $(depfile).tmp $(depfile)
endef
+
+define fixup_dep2
+echo 1 = $(1)
+sed -i -e "s|^$(notdir $(1))|$(1)|" $@.tmp
+sed -i -e "s|^$(1):|$(1) $@:|" $@.tmp
+sed -e "s|^[^:]*: *||" -e "s| *\\\\$$||" -e 's|^ *||' \
+ -e "/./s|$$|:|" $@.tmp >> $@.tmp
+mv $@.tmp $@
+endef
"""
"""
# Command definitions:
@@ -128,9 +139,15 @@
quiet_cmd_cc = CC $@
cmd_cc = $(CC) $(CFLAGS) $(DEPFLAGS) -c -o $@ $<
+quiet_cmd_cc_deps = CC_DEPS $@
+cmd_cc_deps = $(CC) $(CFLAGS) $(DEPFLAGS2) -E $< > $@.tmp
+
quiet_cmd_cxx = CXX $@
cmd_cxx = $(CXX) $(CXXFLAGS) $(DEPFLAGS) -c -o $@ $<
+quiet_cmd_cxx_deps = CXX_DEPS $@
+cmd_cxx_deps = $(CXX) $(CXXFLAGS) $(DEPFLAGS2) -E $< > $@.tmp
+
quiet_cmd_ar = AR $@
cmd_ar = $(AR) rc $@ $(filter %.o,$^)
@@ -189,6 +206,16 @@
$(obj)/%.o: $(obj)/%.cpp
$(call do_cmd,cxx)
@$(fixup_dep)
+
+# Build dependencies
+$(obj)/%.o.d: %.c
+ $(call do_cmd,cc_deps)
+ $(call fixup_dep2,$(patsubst %.d,%,$@))
+
+$(obj)/%.o.d: %.cc
+ $(call do_cmd,cxx_deps)
+ $(call fixup_dep2,$(patsubst %.d,%,$@))
+
""")
# This gets added to the very beginning of the Makefile, setting the root
@@ -204,7 +231,13 @@
# our tree. First, only consider targets that already have been
# built, as unbuilt targets will be built regardless of dependency
# info:
-all_targets := $(wildcard $(sort $(all_targets)))
+# *** THIS IS A BAD IDEA - GENERATED DEPENDENCIES WILL NOT BE BUILT IF
+# YOU DO THIS ***
+#all_targets := $(wildcard $(sort $(all_targets)))
+
+# A target to make dependencies
+deps: $(all_deps)
+
# Of those, only consider the ones with .d (dependency) info:
d_files := $(wildcard $(foreach f,$(all_targets),$(f).d))
ifneq ($(d_files),)
@@ -442,10 +475,13 @@
sources = filter(Compilable, sources)
objs = map(Objectify, map(self.Absolutify, map(Target, sources)))
self.WriteList(objs, 'OBJS')
+ self.WriteLn('DEPS := $(foreach o,$(OBJS),$(o).d)')
+ self.WriteLn();
self.WriteLn('# Add to the list of files we specially track '
'dependencies for.')
self.WriteLn('all_targets += $(OBJS)')
+ self.WriteLn('all_deps += $(DEPS)');
self.WriteLn()
# Make sure our dependencies are built first.
@@ -475,6 +511,12 @@
self.WriteLn("$(OBJS): CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) "
"$(CFLAGS_CC_$(BUILDTYPE)) "
"$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))")
+ self.WriteLn("$(DEPS): CFLAGS := $(CFLAGS_$(BUILDTYPE)) "
+ "$(CFLAGS_C_$(BUILDTYPE)) "
+ "$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))")
+ self.WriteLn("$(DEPS): CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) "
+ "$(CFLAGS_CC_$(BUILDTYPE)) "
+ "$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))")
self.WriteLn()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698