Changeset 2537 for trunk/kBuild


Ignore:
Timestamp:
Aug 2, 2011, 9:44:43 PM (14 years ago)
Author:
bird
Message:

Quick implementation of PRE_[FILE|SYMLINK|DIRECTORY_CMDS on installs. Fixes #104.

Location:
trunk/kBuild
Files:
4 edited

Legend:

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

    r2535 r2537  
    286286$(eval-opt-var def_target_sources)
    287287
    288 
    289 ##
    290 # Function for getting the first defined propert value.
    291 #
    292 # @param   1            The property name.
    293 # @param   2            The default property name, empty if none.
    294 # @param   3            What to return if all variables are empty. (optional)
    295 # @note    Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
    296 # @returns Expanded property value.
    297 #
    298 define def_fn_prop_get_first_defined
    299 local .RETURN := $(firstdefined \
    300     $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \
    301     $(target)_$(1).$(bld_trg).$(bld_trg_arch) \
    302     $(target)_$(1).$(bld_trg).$(bld_type) \
    303     $(target)_$(1).$(bld_trg_cpu) \
    304     $(target)_$(1).$(bld_trg_arch) \
    305     $(target)_$(1).$(bld_trg) \
    306     $(target)_$(1).$(bld_type) \
    307     $(target)_$(1) \
    308 )
    309 ifeq ($(.RETURN),)
    310  ifneq ($(2),)
    311   local .RETURN := $(firstdefined \
    312     $(2).$(bld_trg).$(bld_trg_arch).$(bld_type) \
    313     $(2).$(bld_trg).$(bld_trg_arch) \
    314     $(2).$(bld_trg).$(bld_type) \
    315     $(2).$(bld_trg_cpu) \
    316     $(2).$(bld_trg_arch) \
    317     $(2).$(bld_trg) \
    318     $(2).$(bld_type) \
    319     $(2) \
    320     3 \
    321   )
    322  else
    323   local .RETURN := $(firstdefined \
    324     kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \
    325     kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch) \
    326     kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type) \
    327     kBuildGlobalDefaults_$(1).$(bld_trg_cpu) \
    328     kBuildGlobalDefaults_$(1).$(bld_trg_arch) \
    329     kBuildGlobalDefaults_$(1).$(bld_trg) \
    330     kBuildGlobalDefaults_$(1).$(bld_type) \
    331     kBuildGlobalDefaults_$(1) \
    332     3 \
    333   )
    334  endif
    335 endif
    336 local .RETURN := $(strip $($(.RETURN)))
    337 endef # def_fn_prop_get_first_defined
    338 
    339 ##
    340 # Function for getting the first property value (ignoring empty defines).
    341 #
    342 # @param   1            The property name.
    343 # @param   2            The default property name, empty if none.
    344 # @param   3            What to return if all variables are empty. (optional)
    345 # @note    Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
    346 # @returns First word.
    347 #
    348 define def_fn_prop_get_first_word
    349 local .RETURN := $(firstword \
    350     $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
    351     $($(target)_$(1).$(bld_trg).$(bld_trg_arch)) \
    352     $($(target)_$(1).$(bld_trg).$(bld_type)) \
    353     $($(target)_$(1).$(bld_trg_cpu)) \
    354     $($(target)_$(1).$(bld_trg_arch)) \
    355     $($(target)_$(1).$(bld_trg)) \
    356     $($(target)_$(1).$(bld_type)) \
    357     $($(target)_$(1)) \
    358 )
    359 ifeq ($(.RETURN),)
    360  ifneq ($(2),)
    361   local .RETURN := $(firstword \
    362     $($(2).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
    363     $($(2).$(bld_trg).$(bld_trg_arch)) \
    364     $($(2).$(bld_trg).$(bld_type)) \
    365     $($(2).$(bld_trg_cpu)) \
    366     $($(2).$(bld_trg_arch)) \
    367     $($(2).$(bld_trg)) \
    368     $($(2).$(bld_type)) \
    369     $($(2)) \
    370     $(3) \
    371   )
    372  else
    373   local .RETURN := $(firstword \
    374     $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
    375     $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch)) \
    376     $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type)) \
    377     $(kBuildGlobalDefaults_$(1).$(bld_trg_cpu)) \
    378     $(kBuildGlobalDefaults_$(1).$(bld_trg_arch)) \
    379     $(kBuildGlobalDefaults_$(1).$(bld_trg)) \
    380     $(kBuildGlobalDefaults_$(1).$(bld_type)) \
    381     $(kBuildGlobalDefaults_$(1)) \
    382     $(3) \
    383   )
    384  endif
    385 endif
    386 endef # def_fn_prop_get_first_word
    387288
    388289##
  • trunk/kBuild/footer-pass2-installs.kmk

    r2531 r2537  
    4545$(stagedst) : $(srcsrc) | $(dir $(stagedst))
    4646        %$$(call MSG_INST_FILE,$(srcsrc),$(stagedst))
     47        $(top_pre_file_cmds)
    4748        $$(QUIET)$(stagecmd)
     49        $(top_post_file_cmds)
    4850endef
    4951$(eval-opt-var def_install_src_rule_staging)
     
    5456$(instdst) : $(srcsrc) | $(dir $(instdst))
    5557        %$$(call MSG_INST_FILE,$(srcsrc),$(instdst))
     58        $(top_pre_file_cmds)
    5659        $$(QUIET)$(instcmd)
     60        $(top_post_file_cmds)
    5761endef
    5862$(eval-opt-var def_install_src_rule_installing)
     
    245249        %$$(call MSG_INST_SYM,$(stagedst),$(symdst))
    246250        $$(QUIET)$$(RM) -f -- $$@
     251        $(top_pre_sym_cmds)
    247252        $$(QUIET)$$(LN_SYMLINK) $(symdst) $(stagedst)
     253        $(top_post_sym_cmds)
    248254endef
    249255$(eval-opt-var def_install_symlink_rule_staging)
     
    254260        %$$(call MSG_INST_SYM,$(instdst),$(symdst))
    255261        $$(QUIET)$$(RM) -f -- $$@
     262        $(top_pre_sym_cmds)
    256263        $$(QUIET)$$(LN_SYMLINK) $(symdst) $(instdst)
     264        $(top_post_sym_cmds)
    257265endef
    258266$(eval-opt-var def_install_symlink_rule_installing)
     
    331339$(insdst):
    332340        %$$(call MSG_INST_DIR,$(insdst))
     341        $(top_pre_dir_cmds)
    333342        $$(QUIET)$$(INSTALL) -d \
    334343                $(if $(uid),-o $(uid))\
     
    337346                $(flags) -- \
    338347                $(insdst)
     348        $(top_post_dir_cmds)
    339349
    340350.NOTPARALLEL: $(insdst)
     
    452462
    453463ifneq ($(insttype),none)
    454  # cache top level target properties.
     464 # Cache top level target properties.
    455465 local top_mode := $(firstword \
    456466        $($(target)_MODE.$(bld_trg).$(bld_trg_arch)) \
     
    482492   local top_instfun := _INSTALL_FILE
    483493 endif
     494 # The user have to use double expansion and can only use the above locals. Not 100% optimal...
     495 local top_pre_file_cmds  := $(evalcall def_fn_prop_get_first_defined,PRE_XFILE_CMDS)
     496 local top_post_file_cmds := $(evalcall def_fn_prop_get_first_defined,POST_XFILE_CMDS)
     497 local top_pre_sym_cmds   := $(evalcall def_fn_prop_get_first_defined,PRE_SYMLINK_CMDS)
     498 local top_post_sym_cmds  := $(evalcall def_fn_prop_get_first_defined,POST_SYMLINK_CMDS)
     499 local top_pre_dir_cmds   := $(evalcall def_fn_prop_get_first_defined,PRE_DIRECTORY_CMDS)
     500 local top_post_dir_cmds  := $(evalcall def_fn_prop_get_first_defined,POST_DIRECTORY_CMDS)
    484501
    485502 $(foreach directory, \
  • trunk/kBuild/footer.kmk

    r2523 r2537  
    209209
    210210
    211 
     211##
     212# Function for getting the first defined propert value.
     213#
     214# @param   1            The property name.
     215# @param   2            The default property name, empty if none.
     216# @param   3            What to return if all variables are empty. (optional)
     217# @note    Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
     218# @returns Expanded property value.
     219#
     220define def_fn_prop_get_first_defined
     221local .RETURN := $(firstdefined \
     222    $(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \
     223    $(target)_$(1).$(bld_trg).$(bld_trg_arch) \
     224    $(target)_$(1).$(bld_trg).$(bld_type) \
     225    $(target)_$(1).$(bld_trg_cpu) \
     226    $(target)_$(1).$(bld_trg_arch) \
     227    $(target)_$(1).$(bld_trg) \
     228    $(target)_$(1).$(bld_type) \
     229    $(target)_$(1) \
     230)
     231ifeq ($(.RETURN),)
     232 ifneq ($(2),)
     233  local .RETURN := $(firstdefined \
     234    $(2).$(bld_trg).$(bld_trg_arch).$(bld_type) \
     235    $(2).$(bld_trg).$(bld_trg_arch) \
     236    $(2).$(bld_trg).$(bld_type) \
     237    $(2).$(bld_trg_cpu) \
     238    $(2).$(bld_trg_arch) \
     239    $(2).$(bld_trg) \
     240    $(2).$(bld_type) \
     241    $(2) \
     242    3 \
     243  )
     244 else
     245  local .RETURN := $(firstdefined \
     246    kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type) \
     247    kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch) \
     248    kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type) \
     249    kBuildGlobalDefaults_$(1).$(bld_trg_cpu) \
     250    kBuildGlobalDefaults_$(1).$(bld_trg_arch) \
     251    kBuildGlobalDefaults_$(1).$(bld_trg) \
     252    kBuildGlobalDefaults_$(1).$(bld_type) \
     253    kBuildGlobalDefaults_$(1) \
     254    3 \
     255  )
     256 endif
     257endif
     258local .RETURN := $(strip $($(.RETURN)))
     259endef # def_fn_prop_get_first_defined
     260
     261##
     262# Function for getting the first property value (ignoring empty defines).
     263#
     264# @param   1            The property name.
     265# @param   2            The default property name, empty if none.
     266# @param   3            What to return if all variables are empty. (optional)
     267# @note    Implicit parameters: target, bld_trg, bld_trg_arch, bld_trg_cpu, bld_type.
     268# @returns First word.
     269#
     270define def_fn_prop_get_first_word
     271local .RETURN := $(firstword \
     272    $($(target)_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
     273    $($(target)_$(1).$(bld_trg).$(bld_trg_arch)) \
     274    $($(target)_$(1).$(bld_trg).$(bld_type)) \
     275    $($(target)_$(1).$(bld_trg_cpu)) \
     276    $($(target)_$(1).$(bld_trg_arch)) \
     277    $($(target)_$(1).$(bld_trg)) \
     278    $($(target)_$(1).$(bld_type)) \
     279    $($(target)_$(1)) \
     280)
     281ifeq ($(.RETURN),)
     282 ifneq ($(2),)
     283  local .RETURN := $(firstword \
     284    $($(2).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
     285    $($(2).$(bld_trg).$(bld_trg_arch)) \
     286    $($(2).$(bld_trg).$(bld_type)) \
     287    $($(2).$(bld_trg_cpu)) \
     288    $($(2).$(bld_trg_arch)) \
     289    $($(2).$(bld_trg)) \
     290    $($(2).$(bld_type)) \
     291    $($(2)) \
     292    $(3) \
     293  )
     294 else
     295  local .RETURN := $(firstword \
     296    $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch).$(bld_type)) \
     297    $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_trg_arch)) \
     298    $(kBuildGlobalDefaults_$(1).$(bld_trg).$(bld_type)) \
     299    $(kBuildGlobalDefaults_$(1).$(bld_trg_cpu)) \
     300    $(kBuildGlobalDefaults_$(1).$(bld_trg_arch)) \
     301    $(kBuildGlobalDefaults_$(1).$(bld_trg)) \
     302    $(kBuildGlobalDefaults_$(1).$(bld_type)) \
     303    $(kBuildGlobalDefaults_$(1)) \
     304    $(3) \
     305  )
     306 endif
     307endif
     308endef # def_fn_prop_get_first_word
     309
     310
     311#
     312# The main body.
     313#
    212314include $(KBUILD_PATH)/footer-inherit-uses-tools.kmk
    213315include $(KBUILD_PATH)/footer-pass1.kmk
     
    218320include $(KBUILD_PATH)/footer-misc.kmk
    219321include $(KBUILD_PATH)/footer-passes.kmk
     322
    220323
    221324#
  • trunk/kBuild/header.kmk

    r2536 r2537  
    970970# This list of non-accumulative target properties which are or may be
    971971# functions, and thus should not be expanded until the very last moment.
    972 PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS PRE_INST_CMDS POST_INST_CMDS NAME SONAME
     972PROPS_DEFERRED := INSTFUN INSTALLER PRE_CMDS POST_CMDS PRE_INST_CMDS POST_INST_CMDS \
     973        PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS \
     974        NAME SONAME
    973975
    974976## PROPS_ACCUMULATE_R
     
    10651067## @{
    10661068PROPS_INSTALLS_SINGLE        := TOOL TEMPLATE INST NOINST BLD_TYPE BLD_TRG BLD_TRG_ARCH BLD_TRG_CPU MODE UID GID
    1067 PROPS_INSTALLS_DEFERRED      := INSTFUN INSTALLER
     1069PROPS_INSTALLS_DEFERRED      := INSTFUN INSTALLER PRE_FILE_CMDS POST_FILE_CMDS PRE_SYMLINK_CMDS POST_SYMLINK_CMDS \
     1070        PRE_DIRECTORY_CMDS POST_DIRECTORY_CMDS
    10681071PROPS_INSTALLS_ACCUMULATE_R  := DEPS ORDERDEPS GOALS INST_ONLY_GOALS STAGE_ONLY_GOALS IFFLAGS EXEC_IFFLAGS
    10691072PROPS_INSTALLS_ACCUMULATE_L  := SOURCES EXEC_SOURCES DIRS CLEAN
Note: See TracChangeset for help on using the changeset viewer.