diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-06-16 05:01:45 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2013-06-18 10:06:51 +0200 |
commit | 66a0713dc9c676182fcd7aa1e21f8dc25c05be5e (patch) | |
tree | 3e4fd4107c94aa148b1ca0e0edccfe64f80062f7 /solenv | |
parent | 88085a5b79eb7e11c0609b832c316b63146f4976 (diff) |
handle missing dep files in concat-deps
* this and Ib4762f5a260035f00b5e68cf45b687fdf02e9c02 reduces a default
build on my machine from 2min25sec to 2min12sec
* without unitchecks, its down to 1min50sec now
* it reduces the build time on a i7-4770 Windows tinderbox from 99min to
89min
* by now it also takes care of avoiding most string copying, although
this can certainly be considered overeager given that the file
creation on Windows took ~250ms per file before and still will take a
lot longer than any string operation with this change
Change-Id: I515432bdefe2b055c78b6ba97868adbde65d9165
Diffstat (limited to 'solenv')
-rw-r--r-- | solenv/bin/concat-deps.c | 115 | ||||
-rw-r--r-- | solenv/gbuild/AllLangResTarget.mk | 3 | ||||
-rw-r--r-- | solenv/gbuild/LinkTarget.mk | 40 | ||||
-rw-r--r-- | solenv/gbuild/SdiTarget.mk | 3 | ||||
-rw-r--r-- | solenv/gbuild/UnoApiTarget.mk | 3 |
5 files changed, 132 insertions, 32 deletions
diff --git a/solenv/bin/concat-deps.c b/solenv/bin/concat-deps.c index 36139466a225..c60beeb5babd 100644 --- a/solenv/bin/concat-deps.c +++ b/solenv/bin/concat-deps.c @@ -118,6 +118,7 @@ int internal_boost = 0; static char* base_dir; static char* work_dir; +int work_dir_len; #ifdef __GNUC__ #define clz __builtin_clz @@ -864,6 +865,44 @@ static inline char * eat_space_at_end(char * end) return real_end; } +static char* phony_content_buffer; +static inline char* generate_phony_line(char* phony_target, char* extension) +{ +char* src; +char* dest; +char* last_dot; + //fprintf(stderr, "generate_phony_line called with phony_target %s and extension %s\n", phony_target, extension); + for(dest = phony_content_buffer+work_dir_len, src = phony_target; *src != 0; ++src, ++dest) + { + *dest = *src; + if(*dest == '.') + { + last_dot = dest; + } + } + //fprintf(stderr, "generate_phony_line after phony_target copy: %s\n", phony_content_buffer); + for(dest = last_dot+1, src = extension; *src != 0; ++src, ++dest) + { + *dest = *src; + } + //fprintf(stderr, "generate_phony_line after extension add: %s\n", phony_content_buffer); + strcpy(dest, ": $(gb_Helper_PHONY)\n"); + //fprintf(stderr, "generate_phony_line after phony add: %s\n", phony_content_buffer); + return phony_content_buffer; +} + +static inline int generate_phony_file(char* fn, char* content) +{ +FILE* depfile; + depfile = fopen(fn, "w"); + if(depfile) + { + fputs(content, depfile); + fclose(depfile); + } + return !depfile; +} + static int _process(struct hash* dep_hash, char* fn) { int rc; @@ -872,6 +911,8 @@ char* end; char* cursor; char* cursor_out; char* base; +char* created_line; +char* src_relative; int continuation = 0; char last_ns = 0; off_t size; @@ -985,6 +1026,75 @@ off_t size; } } } + else + { + if(strncmp(fn, work_dir, work_dir_len) == 0) + { + if(strncmp(fn+work_dir_len, "/Dep/", 5) == 0) + { + src_relative = fn+work_dir_len+5; + // cases ordered by frequency + if(strncmp(src_relative, "CxxObject/", 10) == 0) + { + created_line = generate_phony_line(src_relative+10, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(fn+work_dir_len+5, "UnoApiPartTarget/", 17) == 0) + { + created_line = generate_phony_line(src_relative+17, "urd"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(fn+work_dir_len+5, "SrsPartTarget/", 14) == 0) + { + created_line = generate_phony_line(src_relative+14, ""); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "GenCxxObject/", 13) == 0) + { + created_line = generate_phony_line(src_relative+13, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "CObject/", 8) == 0) + { + created_line = generate_phony_line(src_relative+8, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "GenCObject/", 11) == 0) + { + created_line = generate_phony_line(src_relative+11, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "SdiObject/", 10) == 0) + { + created_line = generate_phony_line(src_relative+10, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "AsmObject/", 10) == 0) + { + created_line = generate_phony_line(src_relative+10, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "ObjCxxObject/", 13) == 0) + { + created_line = generate_phony_line(src_relative+13, "o"); + rc = generate_phony_file(fn, created_line); + } + else if(strncmp(src_relative, "ObjCObject/", 11) == 0) + { + created_line = generate_phony_line(src_relative+11, "o"); + rc = generate_phony_file(fn, created_line); + } + else + { + fprintf(stderr, "no magic for %s(%s) in %s\n", fn, src_relative, work_dir); + } + } + if(!rc) + { + puts(created_line); + } + } + } return rc; } @@ -994,6 +1104,7 @@ static void _usage(void) } #define kDEFAULT_HASH_SIZE 4096 +#define PHONY_TARGET_BUFFER 4096 static int get_var(char **var, const char *name) { @@ -1023,6 +1134,10 @@ const char *env_str; } if(get_var(&base_dir, "SRCDIR") || get_var(&work_dir, "WORKDIR")) return 1; + work_dir_len = strlen(work_dir); + phony_content_buffer = malloc(PHONY_TARGET_BUFFER); + strcpy(phony_content_buffer, work_dir); + phony_content_buffer[work_dir_len] = '/'; env_str = getenv("SYSTEM_BOOST"); internal_boost = !env_str || strcmp(env_str,"TRUE"); diff --git a/solenv/gbuild/AllLangResTarget.mk b/solenv/gbuild/AllLangResTarget.mk index 9b7afbfa2270..0791f0175a82 100644 --- a/solenv/gbuild/AllLangResTarget.mk +++ b/solenv/gbuild/AllLangResTarget.mk @@ -102,8 +102,7 @@ $(call gb_SrsPartTarget_get_target,%) : $(SRCDIR)/% $(gb_Helper_MISCDUMMY) \ ifeq ($(gb_FULLDEPS),$(true)) $(call gb_SrsPartTarget_get_dep_target,%) : $(SRCDIR)/% $(gb_Helper_MISCDUMMY) $(call gb_Helper_abbreviate_dirs,\ - mkdir -p $(dir $@) && \ - echo "$(call gb_SrsPartTarget_get_target,$*) : $(gb_Helper_PHONY)" > $@) + mkdir -p $(dir $@)) endif diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk index 63f0f1184fd3..626db2752f0a 100644 --- a/solenv/gbuild/LinkTarget.mk +++ b/solenv/gbuild/LinkTarget.mk @@ -98,18 +98,6 @@ endef # dep file as a side effect. # In the dep file rule just touch it so it's newer than the object. -# The gb_Object__command_dep generates an "always rebuild" dep file; -# It is used on first build and in case the user deletes the object dep file. -ifeq ($(gb_FULLDEPS),$(true)) -define gb_Object__command_dep - echo "$(2) : $(gb_Helper_PHONY)" > $(1) - -endef -else -gb_Object__command_dep = \ - $(call gb_Output_error,gb_Object__command_dep is only for gb_FULLDEPS) -endif - ifneq ($(FORCE_COMPILE_ALL),) # This one only exists to force .c/.cxx "rebuilds" when running a compiler tool. .PHONY: force_compile_all_target @@ -133,8 +121,7 @@ endif ifeq ($(gb_FULLDEPS),$(true)) $(call gb_CObject_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_CObject_get_target,$*))) + $(if $(wildcard $@),touch $@) endif @@ -191,8 +178,7 @@ $(dir $(call gb_CxxObject_get_dep_target,%))%/.dir : $(call gb_CxxObject_get_dep_target,%) : $(if $(wildcard $@),touch $@,\ - $(eval $(gb_CxxObject__set_pchflags))\ - $(call gb_Object__command_dep,$@,$(call gb_CxxObject_get_target,$*))) + $(eval $(gb_CxxObject__set_pchflags))) endif @@ -209,8 +195,7 @@ $(call gb_GenCObject_get_target,%) : ifeq ($(gb_FULLDEPS),$(true)) $(call gb_GenCObject_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_GenCObject_get_target,$*))) + $(if $(wildcard $@),touch $@) endif @@ -229,8 +214,7 @@ $(call gb_GenCxxObject_get_target,%) : ifeq ($(gb_FULLDEPS),$(true)) $(call gb_GenCxxObject_get_dep_target,%) : $(if $(wildcard $@),touch $@,\ - $(eval $(gb_CxxObject__set_pchflags))\ - $(call gb_Object__command_dep,$@,$(call gb_GenCxxObject_get_target,$*))) + $(eval $(gb_CxxObject__set_pchflags))) endif @@ -312,8 +296,7 @@ $(call gb_ObjCxxObject_get_target,%) : $(call gb_ObjCxxObject_get_source,$(SRCDI ifeq ($(gb_FULLDEPS),$(true)) $(call gb_ObjCxxObject_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_ObjCxxObject_get_target,$*))) + $(if $(wildcard $@),touch $) endif endif @@ -336,8 +319,7 @@ $(call gb_ObjCObject_get_target,%) : $(call gb_ObjCObject_get_source,$(SRCDIR),% ifeq ($(gb_FULLDEPS),$(true)) $(call gb_ObjCObject_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_ObjCObject_get_target,$*))) + $(if $(wildcard $@),touch $@) endif endif @@ -353,9 +335,14 @@ $(call gb_AsmObject_get_target,%) : $(call gb_AsmObject_get_source,$(SRCDIR),%) $(call gb_AsmObject__command,$@,$*,$<,$(call gb_AsmObject_get_dep_target,$*)) ifeq ($(gb_FULLDEPS),$(true)) +$(dir $(call gb_AsmObject_get_dep_target,%)).dir : + $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) + +$(dir $(call gb_AsmObject_get_dep_target,%))%/.dir : + $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) + $(call gb_AsmObject_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_AsmObject_get_target,$*))) + $(if $(wildcard $@),touch $@) endif @@ -1000,6 +987,7 @@ $(call gb_AsmObject_get_target,$(2)) : \ ifeq ($(gb_FULLDEPS),$(true)) $(call gb_LinkTarget_get_dep_target,$(1)) : ASMOBJECTS += $(2) $(call gb_LinkTarget_get_dep_target,$(1)) : $(call gb_AsmObject_get_dep_target,$(2)) +$(call gb_AsmObject_get_dep_target,$(2)) :| $(dir $(call gb_AsmObject_get_dep_target,$(2))).dir endif endef diff --git a/solenv/gbuild/SdiTarget.mk b/solenv/gbuild/SdiTarget.mk index 881614d1abeb..549671e1d6cd 100644 --- a/solenv/gbuild/SdiTarget.mk +++ b/solenv/gbuild/SdiTarget.mk @@ -54,8 +54,7 @@ $(dir $(call gb_SdiObject_get_dep_target,%))%/.dir : $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) $(call gb_SdiTarget_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_SdiTarget_get_target,$*))) + $(if $(wildcard $@),touch $@) endif .PHONY : $(call gb_SdiTarget_get_clean_target,%) diff --git a/solenv/gbuild/UnoApiTarget.mk b/solenv/gbuild/UnoApiTarget.mk index 45096b343552..59a2fc2b6249 100644 --- a/solenv/gbuild/UnoApiTarget.mk +++ b/solenv/gbuild/UnoApiTarget.mk @@ -72,8 +72,7 @@ $(dir $(call gb_UnoApiPartTarget_get_dep_target,%))%/.dir : $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@)) $(call gb_UnoApiPartTarget_get_dep_target,%) : - $(if $(wildcard $@),touch $@,\ - $(call gb_Object__command_dep,$@,$(call gb_UnoApiPartTarget_get_target,$*.urd))) + $(if $(wildcard $@),touch $@) endif |