Ignore:
Timestamp:
Jan 4, 2019, 6:08:23 PM (7 years ago)
Author:
bird
Message:

kmk,footer-pass2-compiling-targets.kmk: Optimize def_target_source_rule and the associated kb-src-one function. This ditches the .obj aliases, so use .o instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kBuild/footer-pass2-compiling-targets.kmk

    r3256 r3278  
    3737#
    3838
    39 ## wrapper the compile command dependency check.
     39ifndef 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
     72else # 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
     102endif # 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
    40112ifndef NO_COMPILE_CMDS_DEPS
    41113 if1of ($(KMK_FEATURES),dot-must-make)
     
    49121endif
    50122
    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.
    53124# for building a source file.
    54125# @param    $(obj)    The object file.
     
    60131_OUT_FILES += $(outbase).koc
    61132$(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)
    72135        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
    73136else
    74137$(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)
    85140        %$$(call MSG_COMPILE,$(target),$(source),$$@,$(type))
    86141ifndef TOOL_$(tool)_COMPILE_$(type)_DONT_PURGE_OUTPUT
     
    106161
    107162$(basename $(notdir $(obj))).o: $(obj)
    108 $(basename $(notdir $(obj))).obj: $(obj)
    109163
    110164## @todo make this 'local cmds,output,output_maybe,depend and depord' in 0.2.x or when a new kb-src-one is added.
     
    116170endef # def_target_source_rule
    117171$(eval-opt-var def_target_source_rule)
     172##
     173## Legacy legacy legacy - end
     174
    118175
    119176
     
    213270define def_src_handler_c
    214271local type := C
    215  $(kb-src-one 2)
     272 $(kb-src-one 3)
    216273endef
    217274
    218275define def_src_handler_cxx
    219276local type := CXX
    220  $(kb-src-one 2)
     277 $(kb-src-one 3)
    221278endef
    222279
    223280define def_src_handler_objc
    224281local type := OBJC
    225  $(kb-src-one 2)
     282 $(kb-src-one 3)
    226283endef
    227284
    228285define def_src_handler_objcxx
    229286local type := OBJCXX
    230  $(kb-src-one 2)
     287 $(kb-src-one 3)
    231288endef
    232289
    233290define def_src_handler_asm
    234291local type := AS
    235  $(kb-src-one 2)
     292 $(kb-src-one 3)
    236293endef
    237294
    238295define def_src_handler_rc
    239296local type := RC
    240  $(kb-src-one 2)
     297 $(kb-src-one 3)
    241298endef
    242299
     
    490547$(target)_2_OBJS  :=
    491548
     549# kObjCache.
     550ifdef KBUILD_USE_KOBJCACHE
     551 ifneq ($($(target)_KOBJCACHE),)
     552local use_objcache := 1
     553 else
     554local use_objcache :=
     555 endif
     556local use_objcache :=
     557endif
     558
     559# target level intermediates
     560local 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
    492570# Do units pre source callouts.
    493571local units       := \
     
    499577$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre))
    500578$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre_2))
    501 
    502 # kObjCache.
    503 ifdef KBUILD_USE_KOBJCACHE
    504  ifneq ($($(target)_KOBJCACHE),)
    505 local use_objcache := 1
    506  else
    507 local use_objcache :=
    508  endif
    509 local use_objcache :=
    510 endif
    511579
    512580# source -> object
     
    705773$(target)_2_OBJS  :=
    706774
     775# kObjCache.
     776ifdef KBUILD_USE_KOBJCACHE
     777 ifneq ($($(target)_KOBJCACHE),)
     778local use_objcache := 1
     779 else
     780local use_objcache :=
     781 endif
     782local use_objcache :=
     783endif
     784
     785# target level intermediates
     786local 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
    707796# Do units pre source callouts.
    708797local units       := \
     
    714803$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre))
    715804$(foreach unit,$(units),$(evalvalctx def_unit_$(unit)_target_pre_2))
    716 
    717 # kObjCache.
    718 ifdef KBUILD_USE_KOBJCACHE
    719  ifneq ($($(target)_KOBJCACHE),)
    720 local use_objcache := 1
    721  else
    722 local use_objcache :=
    723  endif
    724 local use_objcache :=
    725 endif
    726805
    727806# source -> object
Note: See TracChangeset for help on using the changeset viewer.