Changeset 3278 in kBuild
- Timestamp:
- Jan 4, 2019 5:08:23 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kBuild/footer-pass2-compiling-targets.kmk
r3256 r3278 37 37 # 38 38 39 ## wrapper the compile command dependency check. 39 ifndef NO_COMPILE_CMDS_DEPS 40 ## Generates the rules for building a specific object and the aliases. 41 # for building a source file. 42 # @param $(obj) The object file. 43 define def_target_source_rule_v3plus 44 $$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE) 45 $$(obj) + $$(kbsrc_output) +| $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars) 46 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) 47 ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT 48 $$(QUIET)$$(RM) -f -- $(dep) $(obj) $(kbsrc_output) $(kbsrc_output_maybe) 49 endif 50 51 $(kbsrc_cmds) 52 53 %$$(QUIET2)$$(APPEND) -in '$(dep)' '' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' '--insert-command=$(obj)' 'endef' 54 $$(basename $$(notdir $$(obj))).o: $$(obj) 55 endef # def_target_source_rule_v3plus 56 57 ## Generates the rules for building a specific object and the aliases, kObjCache variant. 58 # for building a source file. 59 # @param $(obj) The object file. 60 define def_target_source_rule_v3plus_objcache 61 $$(obj): .MUST_MAKE = $$(comp-cmds-ex $$($(target)_$(subst :,_,$(source))_CMDS_PREV_),$$(commands $$@),FORCE) 62 _OUT_FILES += $(outbase).koc 63 $$(outbase).koc +| $$(obj) $$(kbsrc_output) $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars) 64 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) 65 66 $(kbsrc_cmds) 67 68 %$$(QUIET2)$$(APPEND) -in '$(dep)' '' 'define $(target)_$(subst :,_,$(source))_CMDS_PREV_' '--insert-command=$(obj)' 'endef' 69 $$(basename $$(notdir $$(obj))).o: $$(obj) 70 endef # def_target_source_rule_v3plus_objcache 71 72 else # NO_COMPILE_CMDS_DEPS 73 74 ## Generates the rules for building a specific object and the aliases. 75 # for building a source file. 76 # @param $(obj) The object file. 77 define def_target_source_rule_v3plus 78 $$(obj) + $$(kbsrc_output) +| $$(kbsrc_output_maybe) : $$(kbsrc_depend) | $$(kbsrc_depord) $(target_intermediate_vars) 79 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) 80 ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT 81 $$(QUIET)$$(RM) -f -- $(dep) $(obj) $(kbsrc_output) $(kbsrc_output_maybe) 82 endif 83 84 $(kbsrc_cmds) 85 86 $$(basename $$(notdir $$(obj))).o: $$(obj) 87 endef # def_target_source_rule_v3plus 88 89 ## Generates the rules for building a specific object and the aliases, kObjCache variant. 90 # for building a source file. 91 # @param $(obj) The object file. 92 define def_target_source_rule_v3plus_objcache 93 _OUT_FILES += $(outbase).koc 94 $(outbase).koc +| $(obj) $(kbsrc_output) $(kbsrc_output_maybe) : $(kbsrc_depend) | $(kbsrc_depord) $(target_intermediate_vars) 95 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) 96 97 $(kbsrc_cmds) 98 99 $$(basename $$(notdir $$(obj))).o: $$(obj) 100 endef # def_target_source_rule_v3plus_objcache 101 102 endif # NO_COMPILE_CMDS_DEPS 103 $(eval-opt-var def_target_source_rule_v3plus) 104 $(eval-opt-var def_target_source_rule_v3plus_objcache) 105 106 107 ## 108 ## Legacy legacy legacy - start 109 ## 110 111 ## Wrapper 40 112 ifndef NO_COMPILE_CMDS_DEPS 41 113 if1of ($(KMK_FEATURES),dot-must-make) … … 49 121 endif 50 122 51 52 ## Generates the rules for building a specific object, and the aliases 123 ## Generates the rules for building a specific object, and the aliases - legacy version. 53 124 # for building a source file. 54 125 # @param $(obj) The object file. … … 60 131 _OUT_FILES += $(outbase).koc 61 132 $(outbase).koc +| $(obj) $($(target)_$(source)_OUTPUT_) $($(target)_$(source)_OUTPUT_MAYBE_) : \ 62 $($(target)_$(source)_DEPEND_) \ 63 $(value _DEP_COMPILE_CMDS) \ 64 | \ 65 $($(target)_$(source)_DEPORD_) \ 66 $$$$($(target)_INTERMEDIATES) \ 67 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \ 68 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \ 69 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \ 70 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \ 71 $$$$($(target)_INTERMEDIATES.$(bld_type)) 133 $($(target)_$(source)_DEPEND_) $(value _DEP_COMPILE_CMDS) \ 134 | $($(target)_$(source)_DEPORD_) $(target_intermediate_vars) 72 135 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) 73 136 else 74 137 $(obj) + $($(target)_$(source)_OUTPUT_) +| $($(target)_$(source)_OUTPUT_MAYBE_) : \ 75 $($(target)_$(source)_DEPEND_) \ 76 $(value _DEP_COMPILE_CMDS) \ 77 | \ 78 $($(target)_$(source)_DEPORD_) \ 79 $$$$($(target)_INTERMEDIATES) \ 80 $$$$($(target)_INTERMEDIATES.$(bld_trg)) \ 81 $$$$($(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch)) \ 82 $$$$($(target)_INTERMEDIATES.$(bld_trg_arch)) \ 83 $$$$($(target)_INTERMEDIATES.$(bld_trg_cpu)) \ 84 $$$$($(target)_INTERMEDIATES.$(bld_type)) 138 $($(target)_$(source)_DEPEND_) $(value _DEP_COMPILE_CMDS) 139 | $($(target)_$(source)_DEPORD_) $(target_intermediate_vars) 85 140 %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type)) 86 141 ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT … … 106 161 107 162 $(basename $(notdir $(obj))).o: $(obj) 108 $(basename $(notdir $(obj))).obj: $(obj)109 163 110 164 ## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added. … … 116 170 endef # def_target_source_rule 117 171 $(eval-opt-var def_target_source_rule) 172 ## 173 ## Legacy legacy legacy - end 174 118 175 119 176 … … 213 270 define def_src_handler_c 214 271 local type := C 215 $(kb-src-one 2)272 $(kb-src-one 3) 216 273 endef 217 274 218 275 define def_src_handler_cxx 219 276 local type := CXX 220 $(kb-src-one 2)277 $(kb-src-one 3) 221 278 endef 222 279 223 280 define def_src_handler_objc 224 281 local type := OBJC 225 $(kb-src-one 2)282 $(kb-src-one 3) 226 283 endef 227 284 228 285 define def_src_handler_objcxx 229 286 local type := OBJCXX 230 $(kb-src-one 2)287 $(kb-src-one 3) 231 288 endef 232 289 233 290 define def_src_handler_asm 234 291 local type := AS 235 $(kb-src-one 2)292 $(kb-src-one 3) 236 293 endef 237 294 238 295 define def_src_handler_rc 239 296 local type := RC 240 $(kb-src-one 2)297 $(kb-src-one 3) 241 298 endef 242 299 … … 490 547 $(target)_2_OBJS := 491 548 549 # kObjCache. 550 ifdef KBUILD_USE_KOBJCACHE 551 ifneq ($($(target)_KOBJCACHE),) 552 local use_objcache := 1 553 else 554 local use_objcache := 555 endif 556 local use_objcache := 557 endif 558 559 # target level intermediates 560 local target_intermediate_vars := $(foreach var, \ 561 $(target)_INTERMEDIATES \ 562 $(target)_INTERMEDIATES.$(bld_trg) \ 563 $(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch) \ 564 $(target)_INTERMEDIATES.$(bld_trg_arch) \ 565 $(target)_INTERMEDIATES.$(bld_trg_cpu) \ 566 $(target)_INTERMEDIATES.$(bld_type) \ 567 ,$(if-expr defined($(var)),$$$$($(var)),)) 568 #$(info target_intermediate_vars=$(target_intermediate_vars)) 569 492 570 # Do units pre source callouts. 493 571 local units := \ … … 499 577 $(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre)) 500 578 $(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre_2)) 501 502 # kObjCache.503 ifdef KBUILD_USE_KOBJCACHE504 ifneq ($($(target)_KOBJCACHE),)505 local use_objcache := 1506 else507 local use_objcache :=508 endif509 local use_objcache :=510 endif511 579 512 580 # source -> object … … 705 773 $(target)_2_OBJS := 706 774 775 # kObjCache. 776 ifdef KBUILD_USE_KOBJCACHE 777 ifneq ($($(target)_KOBJCACHE),) 778 local use_objcache := 1 779 else 780 local use_objcache := 781 endif 782 local use_objcache := 783 endif 784 785 # target level intermediates 786 local target_intermediate_vars := $(foreach var, \ 787 $(target)_INTERMEDIATES \ 788 $(target)_INTERMEDIATES.$(bld_trg) \ 789 $(target)_INTERMEDIATES.$(bld_trg).$(bld_trg_arch) \ 790 $(target)_INTERMEDIATES.$(bld_trg_arch) \ 791 $(target)_INTERMEDIATES.$(bld_trg_cpu) \ 792 $(target)_INTERMEDIATES.$(bld_type) \ 793 ,$(if-expr defined($(var)),$$$$($(var)),)) 794 #$(info target_intermediate_vars=$(target_intermediate_vars)) 795 707 796 # Do units pre source callouts. 708 797 local units := \ … … 714 803 $(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre)) 715 804 $(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre_2)) 716 717 # kObjCache.718 ifdef KBUILD_USE_KOBJCACHE719 ifneq ($($(target)_KOBJCACHE),)720 local use_objcache := 1721 else722 local use_objcache :=723 endif724 local use_objcache :=725 endif726 805 727 806 # source -> object -
trunk/src/kmk/kbuild.c
r3251 r3278 2007 2007 #endif 2008 2008 struct variable *pObj = kbuild_set_object_name_and_dep_and_dirdep_and_PATH_target_source(pTarget, pSource, pOutBase, pObjSuff, "obj", &pDep, &pDirDep); 2009 int fInstallOld Vars= 0;2009 int fInstallOldObjsVar = 0; 2010 2010 char *pszDstVar, *pszDst, *pszSrcVar, *pszSrc, *pszVal, *psz; 2011 2011 char *pszSavedVarBuf; … … 2123 2123 /** @todo Make all these local variables, if someone needs the info later it 2124 2124 * can be recalculated. (Ticket #80.) */ 2125 cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_ OUTPUT_MAYBE");2125 cch = sizeof("TOOL_") + pTool->value_length + sizeof("_COMPILE_") + pType->value_length + sizeof("_USES_KOBJCACHE"); 2126 2126 if (cch < pTarget->value_length + sizeof("$(_2_OBJS)")) 2127 2127 cch = pTarget->value_length + sizeof("$(_2_OBJS)"); … … 2143 2143 memcpy(pszDst, "_CMDS_", sizeof("_CMDS_")); 2144 2144 pVar = kbuild_get_recursive_variable(pszSrcVar); 2145 do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 2146 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); 2145 if (iVer <= 2) 2146 do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 2147 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); 2147 2148 do_variable_definition_2(NILF, "kbsrc_cmds", pVar->value, pVar->value_length, 2148 2149 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); … … 2151 2152 memcpy(pszDst, "_OUTPUT_", sizeof("_OUTPUT_")); 2152 2153 pVar = kbuild_get_recursive_variable(pszSrcVar); 2153 pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 2154 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); 2154 if (iVer <= 2) 2155 pOutput = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 2156 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); 2155 2157 pOutput = do_variable_definition_2(NILF, "kbsrc_output", pVar->value, pVar->value_length, 2156 2158 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); … … 2161 2163 if (pVar) 2162 2164 { 2163 pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 2164 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); 2165 if (iVer <= 2) 2166 pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, pVar->value, pVar->value_length, 2167 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); 2165 2168 pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", pVar->value, pVar->value_length, 2166 2169 !pVar->recursive, 0, o_local, f_simple, 0 /* !target_var */); … … 2168 2171 else 2169 2172 { 2170 pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */); 2173 if (iVer <= 2) 2174 pOutputMaybe = do_variable_definition_2(NILF, pszDstVar, "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */); 2171 2175 pOutputMaybe = do_variable_definition_2(NILF, "kbsrc_output_maybe", "", 0, 1, 0, o_local, f_simple, 0 /* !target_var */); 2172 2176 } … … 2181 2185 *psz++ = ' '; 2182 2186 memcpy(psz, pSource->value, pSource->value_length + 1); 2183 do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length, 2184 !pVar->recursive && !pDeps->recursive && !pSource->recursive, 2185 NULL, o_local, f_simple, 0 /* !target_var */); 2187 if (iVer <= 2) 2188 do_variable_definition_2(NILF, pszDstVar, pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length, 2189 !pVar->recursive && !pDeps->recursive && !pSource->recursive, 2190 NULL, o_local, f_simple, 0 /* !target_var */); 2186 2191 do_variable_definition_2(NILF, "kbsrc_depend", pszVal, pVar->value_length + 1 + pDeps->value_length + 1 + pSource->value_length, 2187 2192 !pVar->recursive && !pDeps->recursive && !pSource->recursive, … … 2197 2202 *psz++ = ' '; 2198 2203 memcpy(psz, pOrderDeps->value, pOrderDeps->value_length + 1); 2199 do_variable_definition_2(NILF, pszDstVar, pszVal, 2200 pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length, 2201 !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive, 2202 NULL, o_local, f_simple, 0 /* !target_var */); 2204 if (iVer <= 2) 2205 do_variable_definition_2(NILF, pszDstVar, pszVal, 2206 pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length, 2207 !pVar->recursive && !pDirDep->recursive && !pOrderDeps->recursive, 2208 NULL, o_local, f_simple, 0 /* !target_var */); 2203 2209 do_variable_definition_2(NILF, "kbsrc_depord", pszVal, 2204 2210 pVar->value_length + 1 + pDirDep->value_length + 1 + pOrderDeps->value_length, … … 2219 2225 memcpy(pszDstVar + pTarget->value_length, "_2_OBJS", sizeof("_2_OBJS")); 2220 2226 pVar = kbuild_query_recursive_variable_n(pszDstVar, pTarget->value_length + sizeof("_2_OBJS") - 1); 2221 fInstallOld Vars|= iVer <= 2 && (!pVar || !pVar->value_length);2227 fInstallOldObjsVar |= iVer <= 2 && (!pVar || !pVar->value_length); 2222 2228 if (pVar) 2223 2229 { … … 2235 2241 2236 2242 /* 2237 * Install legacy variable s.2238 */ 2239 if (fInstallOld Vars)2243 * Install legacy variable. 2244 */ 2245 if (fInstallOldObjsVar) 2240 2246 { 2241 2247 /* $(target)_OBJS_ = $($(target)_2_OBJS)*/ … … 2259 2265 $(eval $(def_target_source_rule)) 2260 2266 */ 2261 pVar = kbuild_get_recursive_variable("def_target_source_rule"); 2262 pszVal = variable_expand_string_2 (o, pVar->value, pVar->value_length, &psz); 2267 if (iVer > 2) 2268 { 2269 /*ifneq ($(TOOL_$(tool)_COMPILE_$(type)_USES_KOBJCACHE),)*/ 2270 int fUsesObjCache = 0; 2271 memcpy(pszSrc, "_USES_KOBJCACHE", sizeof("_USES_KOBJCACHE")); 2272 pVar = lookup_variable(pszSrcVar, pszSrc + sizeof("_USES_KOBJCACHE") - 1 - pszSrcVar); 2273 if (pVar) 2274 { 2275 if ( !pVar->recursive 2276 || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar)) 2277 fUsesObjCache = pVar->value_length > 0; 2278 else 2279 { 2280 unsigned int cchTmp = 0; 2281 char *pszTmp = allocated_variable_expand_2(pVar->value, pVar->value_length, &cchTmp); 2282 free(pszTmp); 2283 fUsesObjCache = cchTmp > 0; 2284 } 2285 } 2286 if (!fUsesObjCache) 2287 pVar = kbuild_get_recursive_variable("def_target_source_rule_v3plus"); 2288 else 2289 pVar = kbuild_get_recursive_variable("def_target_source_rule_v3plus_objcache"); 2290 } 2291 else 2292 pVar = kbuild_get_recursive_variable("def_target_source_rule"); 2293 pszVal = variable_expand_string_2(o, pVar->value, pVar->value_length, &psz); 2263 2294 assert(!((size_t)pszVal & 3)); 2264 2295
Note:
See TracChangeset
for help on using the changeset viewer.