Kaydet (Commit) dab82360 authored tarafından Michael Stahl's avatar Michael Stahl

gbuild: add consistent directory dependencies for LinkTargets

- StaticLibrary and CppunitTest have all files in one directory
- Executable may have the executable itself in a different one
- Library may have files in up to 3 directories

... so create 2 directories (which may be the same) in
gb_LinkTarget_LinkTarget and a 3rd one in gb_Library__Library_impl.

This allows to get rid of the "mkdir LinkTarget/pdb/..." thing in
the header target rule, which was always ugly since it did not
get rebuilt when deleting it (or whole LinkTarget dir) from workdir.

Oh and the pattern dependency causes trouble:

$(WORKDIR)/LinkTarget/% : $(call gb_LinkTarget_get_headers_target,%)

... for files in ExtensionLibrary; it would be possible to put
ExtensionLibrary somewhere else of course but actually this pattern
dependency is unnecessary since we get the same thing whenever any
object is added to a link target and there shouldn't be link targets
without objects anyway.

Furthermore directory dependencies must be on the headers_target because
MSVC will write a PDB file when compiling objects.

Change-Id: Icd92e8768d6aafb094a4144f90165aa5ff233647
üst 3f0ee22e
......@@ -63,9 +63,6 @@ define gb_Executable__Executable_impl
$(call gb_LinkTarget_LinkTarget,$(2),Executable_$(1),$(call gb_Executable_get_layer,$(1)))
$(call gb_LinkTarget_set_targettype,$(2),Executable)
$(call gb_LinkTarget_add_libs,$(2),$(gb_STDLIBS))
$(call gb_Executable_get_target,$(1)) : \
| $(dir $(call gb_Executable_get_target,$(1))).dir \
$(gb_Executable_BINDIR)/.dir
$(call gb_Executable_get_runtime_target,$(1)) :| $(dir $(call gb_Executable_get_runtime_target,$(1))).dir
$(call gb_Executable_get_runtime_target,$(1)) : $(call gb_Executable_get_target_for_build,$(1))
$(call gb_Executable_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
......
......@@ -76,6 +76,13 @@ $(call gb_Package_add_file,Library_Copy_$(1),$(2),$(2))
$(OUTDIR)/lib/$(notdir $(2)) : $(gb_INSTROOT)/$(2)
endef
# Note: there may be targets in 3 different directories: the library itself,
# the exports target (and other misc. MSVC files) (always in
# $(WORKDIR)/LinkTarget), and the import library, which may be in SDK;
# the first 2 are always created by gb_LinkTarget_LinkTarget
# Also: the directory dependencies must be on the headers_target because
# MSVC will write a PDB file when compiling objects.
#
# call gb_Library__Library_impl,library,linktarget
define gb_Library__Library_impl
$(call gb_LinkTarget_LinkTarget,$(2),Library_$(1),$(call gb_Library_get_layer,$(1)))
......@@ -86,10 +93,8 @@ $(call gb_LinkTarget_add_defs,$(2),\
)
$(call gb_Library__get_final_target,$(1)) : $(call gb_Library_get_target,$(1))
$(call gb_Library_get_exports_target,$(1)) : $(call gb_Library_get_target,$(1))
$(call gb_Library_get_target,$(1)) : \
| $(dir $(call gb_Library_get_target,$(1))).dir \
$(dir $(call gb_Library_get_ilib_target,$(1))).dir \
$(gb_Library_DLLDIR)/.dir
$(call gb_LinkTarget_get_headers_target,$(2)) : \
| $(dir $(call gb_Library_get_ilib_target,$(1))).dir
$(call gb_Library_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
$(call gb_Library_get_clean_target,$(1)) : AUXTARGETS :=
$(call gb_Library_Library_platform,$(1),$(2),$(call gb_Library_get_ilib_target,$(1)))
......
......@@ -448,7 +448,7 @@ $(WORKDIR)/LinkTarget/Library/%.exports :
# This recipe actually also builds the dep-target as a side-effect, which
# is an optimization to reduce incremental build time.
# (with exception for concat-dep executable itself which does not exist yet...)
$(WORKDIR)/LinkTarget/% : $(call gb_LinkTarget_get_headers_target,%) $(gb_Helper_MISCDUMMY)
$(WORKDIR)/LinkTarget/% : $(gb_Helper_MISCDUMMY)
$(call gb_LinkTarget__command_impl,$@,$*)
# call gb_LinkTarget__make_installed_rule,linktarget
......@@ -494,11 +494,15 @@ define gb_LinkTarget__get_headers_check
ifneq ($$(SELF),$$*)
$$(eval $$(call gb_Output_info,LinkTarget $$* not defined: Assuming headers to be there!,ALL))
endif
$$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, mkdir -p $$(dir $$@) && touch $$@ && mkdir -p $(WORKDIR)/LinkTarget/pdb/$$(dir $$*))
$$@ : COMMAND := $$(call gb_Helper_abbreviate_dirs, touch $$@)
endef
$(call gb_LinkTarget_get_headers_target,%) :
$(WORKDIR)/Headers/%/.dir :
$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
# sadly because of the subdirectories can't have pattern deps on .dir here
$(WORKDIR)/Headers/% :
$(eval $(gb_LinkTarget__get_headers_check))
$(COMMAND)
......@@ -542,6 +546,10 @@ define gb_LinkTarget_LinkTarget
$(call gb_LinkTarget_get_clean_target,$(1)) : LINKTARGET := $(1)
$(call gb_LinkTarget_get_clean_target,$(1)) : AUXTARGETS :=
$(call gb_LinkTarget_get_headers_target,$(1)) : SELF := $(call gb_LinkTarget__get_workdir_linktargetname,$(1))
$(call gb_LinkTarget_get_headers_target,$(1)) : \
| $(dir $(call gb_LinkTarget_get_headers_target,$(1))).dir \
$(dir $(call gb_LinkTarget_get_target,$(1))).dir \
$(dir $(WORKDIR)/LinkTarget/$(call gb_LinkTarget__get_workdir_linktargetname,$(1))).dir
$(call gb_LinkTarget_get_target,$(1)) : ILIBTARGET :=
$(call gb_LinkTarget_get_clean_target,$(1)) \
$(call gb_LinkTarget_get_target,$(1)) : COBJECTS :=
......
......@@ -42,8 +42,6 @@ endef
define gb_StaticLibrary__StaticLibrary_impl
$(call gb_LinkTarget_LinkTarget,$(2),StaticLibrary_$(1),NONE)
$(call gb_LinkTarget_set_targettype,$(2),StaticLibrary)
$(call gb_StaticLibrary_get_target,$(1)) : \
| $(dir $(call gb_StaticLibrary_get_target,$(1))).dir
$(call gb_StaticLibrary_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(2))
$(call gb_StaticLibrary_get_clean_target,$(1)) : AUXTARGETS :=
$(call gb_StaticLibrary_StaticLibrary_platform,$(1),$(2))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment