When do we need to do a make clean

2,211 views
Skip to first unread message

Maxime Ripard

unread,
Sep 2, 2011, 5:16:32 AM9/2/11
to android-...@googlegroups.com
Hi,

I was wondering how dependencies were evaluated in the build system ?

Obviously, changing a source file will force the rebuild of the specific
part affected, but what about changing device overlays, initrc files or
resources for example ?

Do we need to do a whole "make clean" or is a more specific target
availaible ?


--
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

Karim Yaghmour

unread,
Sep 6, 2011, 10:57:20 AM9/6/11
to android-...@googlegroups.com, Maxime Ripard

Salut Maxime,

On 11-09-02 05:16 AM, Maxime Ripard wrote:
> I was wondering how dependencies were evaluated in the build system ?

Android's build system is fairly complex ... but it is modular. So once
you get the overall picture it's rather easy to dig further in one
direction or another.

> Obviously, changing a source file will force the rebuild of the specific
> part affected, but what about changing device overlays, initrc files or
> resources for example ?

For overlays and resources, have a look at build/core/package.mk. More
specifically, here are the relevant snippets:

LOCAL_RESOURCE_DIR := \
$(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
$(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
$(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
$(LOCAL_RESOURCE_DIR)
...
all_resources := $(strip \
$(foreach dir, $(LOCAL_RESOURCE_DIR), \
$(addprefix $(dir)/, \
$(patsubst res/%,%, \
$(call find-subdir-assets,$(dir)) \
) \
) \
))
...
all_res_assets := $(strip $(all_assets) $(all_resources))
...
$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(AAPT) | $(ACP)

So, basically, if you change a resource, whether it be an overlay or
not, it should trigger the rebuilding of the encompassing package.

For initrc files, it depends how it's getting included I guess. For the
main init.rc file in system/core/rootdir/init.rc, the corresponding mk
(system/core/rootdir/Android.mk) has this snippet:
ifneq ($(TARGET_PROVIDES_INIT_RC),true)
file := $(TARGET_ROOT_OUT)/init.rc
$(file) : $(LOCAL_PATH)/init.rc | $(ACP)
$(transform-prebuilt-to-target)
ALL_PREBUILT += $(file)
$(INSTALLED_RAMDISK_TARGET): $(file)
endif

INSTALLED_RAMDISK_TARGET is what generates the RAM disk image, and it's
made here to depend on init.rc. So if you touch this file, it will cause
the RAM disk image to be regenerated.

As you can see, though, the dependencies aren't centralized.

> Do we need to do a whole "make clean" or is a more specific target
> availaible ?

There's a "make installclean" which will wipe out just the stuff that
changes from one make target to another (i.e. if you switch from "make
droid" (a.k.a. plain "make") to "make sdk".) Here's what it actually
does (from build/core/cleanbuild.mk):
installclean_files := \
$(HOST_OUT)/obj/NOTICE_FILES \
$(HOST_OUT)/sdk \
$(PRODUCT_OUT)/*.img \
$(PRODUCT_OUT)/*.txt \
$(PRODUCT_OUT)/*.xlb \
$(PRODUCT_OUT)/*.zip \
$(PRODUCT_OUT)/data \
$(PRODUCT_OUT)/obj/APPS \
$(PRODUCT_OUT)/obj/NOTICE_FILES \
$(PRODUCT_OUT)/obj/PACKAGING \
$(PRODUCT_OUT)/recovery \
$(PRODUCT_OUT)/root \
$(PRODUCT_OUT)/system \
$(PRODUCT_OUT)/dex_bootjars \
$(PRODUCT_OUT)/obj/JAVA_LIBRARIES
...
installclean: FILES := $(installclean_files)
installclean: dataclean
$(hide) rm -rf $(FILES)
@echo "Deleted images and staging directories."

In other words, that list up there gets nucked every time you switch
make targets. My only regret is that there isn't an "imagesclean" target
which just wipes out $(PRODUCT_OUT)/*.img and corresponding source dirs
($(PRODUCT_OUT)/{root,system,data}).

Hope this helps,

--
Karim Yaghmour
CEO - Opersys inc. / www.opersys.com
http://twitter.com/karimyaghmour

Karim Yaghmour

unread,
Sep 6, 2011, 11:00:03 AM9/6/11
to android-...@googlegroups.com, Maxime Ripard

On 11-09-02 05:16 AM, Maxime Ripard wrote:
> Do we need to do a whole "make clean" or is a more specific target
> availaible ?

You can also clean modules one at a time:
$ make clean-Launcher2
This will clean just the Launcher2 app.

Maxime Ripard

unread,
Sep 8, 2011, 4:28:26 AM9/8/11
to android-...@googlegroups.com, Karim Yaghmour
Hi Karim,

This helps a lot, thanks :)

Maxime


--

Reply all
Reply to author
Forward
0 new messages