BuildRoot - Understanding how to rebuild packages(try know why)

本文深入探讨了在BuildRoot系统中如何重建包,通过解析内部使用到的stamp文件来追踪已完成与待完成的步骤,以及如何通过删除特定文件触发包的重新编译过程。重点解释了stamp_configured文件的作用,当该文件被移除时,如何导致从配置步骤开始的重新编译。同时,阐述了Make工作原理中关于依赖关系和重新构建的机制,为开发者提供了解决重建包问题的关键思路。
摘要由CSDN通过智能技术生成

In BuildRoot document 3.5.2 Understanding how to rebuild packages, there are statements:

Internally, to keep track of which steps have been done andwhich steps remain to be done, Buildroot maintains stamp files (emptyfiles that just tell whether this or that action has been done):

  • output/build/<package>-<version>/.stamp_configured. If removed, Buildroot will trigger the recompilation of the package from the configuration step (execution of./configure).
  • output/build/<package>-<version>/.stamp_built. If removed, Buildroot will trigger the recompilation of the package from the compilation step (execution ofmake).
I want figure out why rm output/build/<package>-<version>/.stamp_configured, the package will recompile from the configuration step.

Look at build/package/pkg-generic.c

$(BUILD_DIR)/%/.stamp_configured:
        $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
        @$(call MESSAGE,"Configuring")
        $($(PKG)_CONFIGURE_CMDS)
        $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
        $(Q)touch $@

$(2)_TARGET_CONFIGURE =         $$($(2)_DIR)/.stamp_configured

$(1)-configure:         $(1)-patch $(1)-depends \
                        $$($(2)_TARGET_CONFIGURE)

$(1)-build:             $(1)-configure \
                        $$($(2)_TARGET_BUILD)

$(1)-install-target:    $(1)-build \
                        $$($(2)_TARGET_INSTALL_TARGET)

$(1)-install:           $(1)-install-staging $(1)-install-target $(1)-install-images

 

$(1):                   $(1)-install

every package/<package>/<package>.mk, there will be one statement:

 

$(eval $(autotools-package))
or

$(eval $(generic-package))

It owns dependency on each other:

if .stamp_configured file be removed, then $(1)-configure can't find its prerequisite it will call $$($(2)_TARGET_CONFIGURE)'s recipe, that is do the configure work.

if .stamp_configured file is not removed and not changed, then $(1)-configure find its prerequisite have existed, so it will not call $$($(2)_TARGET_CONFIGURE)'s recipe.

The reason why make works like this, can refer to cmake's manual 4.3 Types of prerequisite:

There are actually two different types of prerequisites understood byGNU make: normal prerequisites such as described in theprevious section, and order-only prerequisites. A normalprerequisite makes two statements: first, it imposes an order in whichrecipes will be invoked: the recipes for all prerequisites of a targetwill be completed before the recipe for the target is run. Second, itimposes a dependency relationship: if any prerequisite is newer thanthe target, then the target is considered out-of-date and must berebuilt.

that while .stamp_configured file not removed, it is same new as its target $(2)_TARGET_CONFIGURE, so not need rebuild. but if .stamp_configured file removed, it will be created and it is newer than its target $(2)_TARGET_CONFIGURE, so $$($(2)_TARGET_CONFIGURE)'s recipe will be executed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值