SlideShare a Scribd company logo
1 of 42
Download to read offline
BuildSystem.mk
Rémy Gottschalk 
● SoftAtHome : 3 years - 
Linux System for HGW 
and STB 
● Genymobile : 2 years - 
ROM cooking 
Charles-Henry Prunier 
● Archos : 3 years - ROM 
cooking for Archos 
devices (Archos 5 IT - 
GEN 10) 
● Genymobile : 2 years - 
ROM cooking 
SPEAKERS
01 
How to make 
02 
Device 
definition 
03 
Android.mk 
04 
One last bite 
AGENDA
HOW TO MAKE 
source, lunch, make !
HOW TO MAKE 
# source ./build/envsetup.sh 
# 
# head -n 15 build/envsetup.sh 
function hmm() { 
cat <<EOF 
Invoke ". build/envsetup.sh" from your shell to add the following functions to your 
environment: 
- lunch: lunch <product_name>-<build_variant> 
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [eng|userdebug|user] 
- croot: Changes directory to the top of the tree. 
- m: Makes from the top of the tree. 
- mm: Builds all of the modules in the current directory, but not their 
dependencies. 
- mmm: Builds all of the modules in the supplied directories, but not their 
dependencies. 
- mma: Builds all of the modules in the current directory, and their 
dependencies. 
- mmma: Builds all of the modules in the supplied directories, and their 
dependencies. 
- cgrep: Greps on all local C/C++ files. 
- jgrep: Greps on all local Java files. 
- resgrep: Greps on all local res/*.xml files. 
- godir: Go to the directory containing a file. 
#
HOW TO MAKE 
lunch
HOW TO MAKE 
make 
make -j42 
It’s coffee time !
DEVICE DEFINITION 
What’s my target ?
vendorsetup.sh 
Lunch entry point 
TYPE = eng | userdebug | release 
AndroidProducts.mk 
The first makefile 
DEVICE DEFINITION 
vendorsetup.sh, AndroidProduct.mk 
add_lunch_combo TARGETNAME-TYPE 
PRODUCT_MAKEFILES = TARGETNAME.mk
DEVICE DEFINITION 
vendorsetup.sh, AndroidProduct.mk 
# tail -n1 device/lge/hammerhead/vendorsetup.sh 
add_lunch_combo aosp_hammerhead-userdebug 
# 
# tail -n3 device/lge/hammerhead/AndroidProducts.mk 
PRODUCT_MAKEFILES :=  
$(LOCAL_DIR)/aosp_hammerhead.mk  
$(LOCAL_DIR)/full_hammerhead.mk
DEVICE DEFINITION 
BoardConfig.mk 
Define your 
device hardware 
Can include other 
BoardConfig.mk 
A bunch of 
specific 
defines 
BoardConfig.mk
DEVICE DEFINITION 
BoardConfig.mk 
# cat device/lge/hammerhead/BoardConfig.mk | grep -vP "(^$|^#.*$)" 
TARGET_CPU_ABI := armeabi-v7a 
TARGET_CPU_ABI2 := armeabi 
TARGET_CPU_SMP := true 
TARGET_ARCH := arm 
TARGET_ARCH_VARIANT := armv7-a-neon 
TARGET_CPU_VARIANT := krait 
TARGET_NO_BOOTLOADER := true 
BOARD_KERNEL_BASE := 0x00000000 
BOARD_KERNEL_PAGESIZE := 2048 
BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead 
user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1 
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02900000 --tags_offset 0x02700000 
MAX_EGL_CACHE_KEY_SIZE := 12*1024 
MAX_EGL_CACHE_SIZE := 2048*1024 
BOARD_USES_ALSA_AUDIO := true 
BOARD_HAVE_BLUETOOTH := true 
BOARD_HAVE_BLUETOOTH_BCM := true 
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/lge/hammerhead/bluetooth 
WPA_SUPPLICANT_VERSION := VER_0_8_X 
BOARD_WLAN_DEVICE := bcmdhd 
BOARD_WPA_SUPPLICANT_DRIVER := NL80211 
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE) 
BOARD_HOSTAPD_DRIVER := NL80211 
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE) 
WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/bcmdhd/parameters/firmware_path"
DEVICE DEFINITION 
BoardConfig.mk 
WIFI_DRIVER_FW_PATH_AP := "/vendor/firmware/fw_bcmdhd_apsta.bin" 
WIFI_DRIVER_FW_PATH_STA := "/vendor/firmware/fw_bcmdhd.bin" 
BOARD_USES_SECURE_SERVICES := true 
TARGET_NO_RADIOIMAGE := true 
TARGET_BOARD_PLATFORM := msm8974 
TARGET_BOOTLOADER_BOARD_NAME := hammerhead 
TARGET_BOARD_INFO_FILE := device/lge/hammerhead/board-info.txt 
BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := $(TARGET_BOARD_PLATFORM) 
TARGET_NO_RPC := true 
BOARD_EGL_CFG := device/lge/hammerhead/egl.cfg 
USE_OPENGL_RENDERER := true 
VSYNC_EVENT_PHASE_OFFSET_NS := 7500000 
SF_VSYNC_EVENT_PHASE_OFFSET_NS := 5000000 
TARGET_USES_ION := true 
TARGET_USERIMAGES_USE_EXT4 := true 
BOARD_BOOTIMAGE_PARTITION_SIZE := 23068672 
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 23068672 
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1073741824 
BOARD_USERDATAIMAGE_PARTITION_SIZE := 13725837312 
BOARD_CACHEIMAGE_PARTITION_SIZE := 734003200 
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 
BOARD_FLASH_BLOCK_SIZE := 131072 
BOARD_CHARGER_DISABLE_INIT_BLANK := true 
BOARD_CHARGER_ENABLE_SUSPEND := true 
TARGET_RECOVERY_PIXEL_FORMAT := RGBX_8888 
TARGET_RECOVERY_UI_LIB := librecovery_ui_hammerhead
DEVICE DEFINITION 
BoardConfig.mk 
TARGET_RECOVERY_FSTAB = device/lge/hammerhead/fstab.hammerhead 
TARGET_RELEASETOOLS_EXTENSIONS := device/lge/hammerhead 
PDK_PLATFORM_ZIP_PRODUCT_BINARIES := device/lge/hammerhead-kernel/vmlinux.bz2 
BOARD_HAL_STATIC_LIBRARIES := libdumpstate.hammerhead 
BOARD_SEPOLICY_DIRS :=  
device/lge/hammerhead/sepolicy 
BOARD_SEPOLICY_UNION :=  
device.te  
app.te  
file_contexts 
HAVE_ADRENO_SOURCE:= false 
OVERRIDE_RS_DRIVER:= libRSDriver_adreno.so 
TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS := true 
TARGET_TOUCHBOOST_FREQUENCY:= 1200 
-include vendor/lge/hammerhead/BoardConfigVendor.mk
DEVICE DEFINITION 
device.mk 
Define your 
device software 
No specific 
naming 
Heavy use of 
inheritance 
device.mk
DEVICE DEFINITION 
device.mk 
INHERIT BASE DEVICE 
INHERIT OVERLAY 
INHERIT VENDOR STUFF 
INHERIT PRODUCT VARIATION
DEVICE DEFINITION 
device.mk 
Name your device 
PRODUCT_NAME 
PRODUCT_MODEL 
PRODUCT_DEVICE 
PRODUCT_MANUFACTURER 
PRODUCT_BRAND
DEVICE DEFINITION 
device.mk 
Include software 
PRODUCT_PACKAGES 
PRODUCT_PACKAGES_DEBUG 
PRODUCT_PACKAGES_ENG 
PRODUCT_PACKAGES_TESTS 
PRODUCT_COPY_FILES
DEVICE DEFINITION 
device.mk 
Customize 
PRODUCT_PROPERTY_OVERRIDES 
PRODUCT_DEFAULT_PROPERTY_OVERRIDES 
PRODUCT_RESTRICT_VENDOR_FILES 
PRODUCT_PACKAGE_OVERLAYS 
DEVICE_PACKAGE_OVERLAYS
DEVICE DEFINITION 
device.mk 
Some leftovers 
PRODUCT_AAPT_CONFIG 
PRODUCT_AAPT_PREF_CONFIG 
PRODUCT_OTA_PUBLIC_KEYS 
PRODUCT_EXTRA_RECOVERY_KEYS 
PRODUCT_DEFAULT_DEV_CERTIFICATE 
And more in build/core/product.mk
DEVICE DEFINITION 
device.mk 
# cat device/lge/hammerhead/device.mk | magic_summarize 
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL) 
PRODUCT_COPY_FILES :=  
$(LOCAL_KERNEL):kernel 
PRODUCT_COPY_FILES +=  
device/lge/hammerhead/init.hammerhead.rc:root/init.hammerhead.rc  
device/lge/hammerhead/fstab.hammerhead:root/fstab.hammerhead  
device/lge/hammerhead/ueventd.hammerhead.rc:root/ueventd.hammerhead.rc 
# Input device files for hammerhead 
PRODUCT_COPY_FILES +=  
device/lge/hammerhead/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl  
device/lge/hammerhead/gpio-keys.kcm:system/usr/keychars/gpio-keys.kcm  
[...] device/lge/hammerhead/thermal-engine-hammerhead.conf:system/etc/thermal-engine. 
conf 
PRODUCT_TAGS += dalvik.gc.type-precise 
# This device is xhdpi. However the platform doesn't 
# currently contain all of the bitmaps at xhdpi density so 
# we do this little trick to fall back to the hdpi version 
# if the xhdpi doesn't exist. 
PRODUCT_AAPT_CONFIG := normal hdpi xhdpi xxhdpi 
PRODUCT_AAPT_PREF_CONFIG := xxhdpi 
PRODUCT_CHARACTERISTICS := nosdcard 
DEVICE_PACKAGE_OVERLAYS :=  
device/lge/hammerhead/overlay
DEVICE DEFINITION 
device.mk 
PRODUCT_PACKAGES +=  
gralloc.msm8974  
libgenlock  
hwcomposer.msm8974  
[...] 
flp.msm8974 
PRODUCT_PROPERTY_OVERRIDES +=  
ro.hwui.texture_cache_size=72  
debug.qualcomm.sns.hal=w  
debug.qualcomm.sns.daemon=w  
[...] 
debug.qualcomm.sns.libsensor1=w 
PRODUCT_DEFAULT_PROPERTY_OVERRIDES +=  
rild.libpath=/system/lib/libril-qc-qmi-1.so 
# Camera configuration 
PRODUCT_DEFAULT_PROPERTY_OVERRIDES +=  
camera.disable_zsl_mode=1 
# Input resampling configuration 
PRODUCT_PROPERTY_OVERRIDES +=  
ro.input.noresample=1 
# setup dalvik vm configs. 
$(call inherit-product, frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk) 
$(call inherit-product-if-exists, hardware/qcom/msm8x74/msm8x74.mk) 
$(call inherit-product-if-exists, vendor/qcom/gpu/msm8x74/msm8x74-gpu-vendor.mk) 
$(call inherit-product-if-exists, 
hardware/broadcom/wlan/bcmdhd/firmware/bcm4339/device-bcm.mk)
Android.mk 
A piece of Android
Android.mk 
Android.mk, Android.mk everywhere 
Android.mk, Android.mk everywhere 
Define a component 
# find ./ -name Android.mk | wc -l 
2242
Android.mk 
Common content 
Any component needs 
A working directory 
LOCAL_PATH := $(call my-dir) 
A clean environment 
include $(CLEAR_VARS) 
A name 
LOCAL_MODULE := mymodule 
LOCAL_PACKAGE_NAME := mypackage
Android.mk 
Common content 
Any component needs 
A type 
include BUILD_something 
Usually, some source files 
LOCAL_SRC_FILES= files 
A tag 
LOCAL_MODULE_TAGS := tag
Android.mk 
Component types 
Many types of components 
# cat build/core/config.mk 
[...] 
BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk 
BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk 
BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk 
BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk 
BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk 
BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk 
BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk 
BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk 
BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk 
BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk 
BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk 
BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk 
BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk 
BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk 
BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk 
BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk 
BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk 
BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk 
BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk 
BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk 
BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk 
[...]
Android.mk 
Keywords (linking) 
Some useful keywords 
For linking 
LOCAL_SHARED_LIBRARY 
LOCAL_STATIC_LIBRARY 
LOCAL_JAVA_LIBRARY 
LOCAL_STATIC_JAVA_LIBRARY
Android.mk 
Keywords (signing) 
Some useful keywords 
For signing 
LOCAL_CERTIFICATE 
LOCAL_PRIVILEGED_MODULE
Android.mk 
Keywords (native) 
Some useful keywords 
For native code 
LOCAL_CFLAGS 
LOCAL_CPPFLAGS
Android.mk 
Keywords (java) 
Some useful keywords 
For java stuff 
LOCAL_PROGUARD_FLAG_FILES 
LOCAL_PROGUARD_ENABLED 
LOCAL_AAPT_FLAGS
Android.mk 
Keywords (dependency) 
Some useful keywords 
For dependency handling 
LOCAL_REQUIRED_MODULES 
LOCAL_PACKAGE_OVERRIDES
Android.mk 
Keywords (full list) 
Some useful keywords 
And even more 
Full list in build/core/clear_vars.mk
Android.mk 
Functions 
Many useful functions 
in build/core/definitions.mk 
all-java-files-under 
all-files-under 
all-makefiles-under 
and many more
Android.mk 
packages/apps/Settings/Android.mk 
# cat packages/apps/Settings/Android.mk 
LOCAL_PATH:= $(call my-dir) 
include $(CLEAR_VARS) 
LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt telephony-common 
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 jsr305 
LOCAL_MODULE_TAGS := optional 
LOCAL_SRC_FILES :=  
$(call all-java-files-under, src)  
src/com/android/settings/EventLogTags.logtags 
LOCAL_PACKAGE_NAME := Settings 
LOCAL_CERTIFICATE := platform 
LOCAL_PRIVILEGED_MODULE := true 
LOCAL_PROGUARD_FLAG_FILES := proguard.flags 
LOCAL_AAPT_FLAGS += -c zz_ZZ 
include $(BUILD_PACKAGE) 
# Use the folloing include to make our test apk. 
include $(call all-makefiles-under,$(LOCAL_PATH))
One last bite 
There’s always more
One last bite 
More makefiles 
More makefiles 
untold module makefiles 
CleanSpec.mk 
Application.mk
One last bite 
Even more makefiles 
Even more makefiles 
The build system itself 
build/core/main.mk 
build/core/*.mk 
Base devices 
build/target/**
One last bite 
Other tools 
Non-make stuff 
Python 
build/tool/releasetools/ 
├── build_image.py 
├── img_from_target_files 
└── ota_from_target_files
One last bite 
Other tools 
Non-make stuff 
Java 
build/tools/signapk
Thank You for your time ! 
If you have any question ? 
Rémy Gottschalk 
rgottschalk@genymobile.com 
Charles-Henry Prunier 
0682079415 
chprunier@genymobile.com 
@charly_prunier
Copyrights 
The following copyright have been stripped 
from all the examples : 
# 
# Copyright (C) 2013 The Android Open-Source Project 
# 
# Licensed under the Apache License, Version 2.0 (the "License"); 
# you may not use this file except in compliance with the License. 
# You may obtain a copy of the License at 
# 
# http://www.apache.org/licenses/LICENSE-2.0 
# 
# Unless required by applicable law or agreed to in writing, software 
# distributed under the License is distributed on an "AS IS" BASIS, 
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
# See the License for the specific language governing permissions and 
# limitations under the License. 
#

More Related Content

What's hot

Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
Opersys inc.
 

What's hot (20)

Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Android OTA updates
Android OTA updatesAndroid OTA updates
Android OTA updates
 
Android booting sequece and setup and debugging
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
Customizing AOSP For Different Embedded Devices And Integration at Applicatio...
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Is Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VIIs Android the New Embedded Linux? at AnDevCon VI
Is Android the New Embedded Linux? at AnDevCon VI
 
Tip: How to enable wireless debugging with Android?
Tip: How to enable wireless debugging with Android?Tip: How to enable wireless debugging with Android?
Tip: How to enable wireless debugging with Android?
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
How To Build Android for ARM Chip boards
How To Build Android for ARM Chip boardsHow To Build Android for ARM Chip boards
How To Build Android for ARM Chip boards
 
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
A War Story: Porting Android 4.0 to a Custom Board (ELCE 2012)
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 

Similar to Buildsystem.mk

How to Make Android's Bootable Recovery Work For You by Drew Suarez
How to Make Android's Bootable Recovery Work For You by Drew SuarezHow to Make Android's Bootable Recovery Work For You by Drew Suarez
How to Make Android's Bootable Recovery Work For You by Drew Suarez
Shakacon
 
Steps to build and run oai
Steps to build and run oaiSteps to build and run oai
Steps to build and run oai
ssuser38b887
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
Omar Reygaert
 

Similar to Buildsystem.mk (20)

Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Linux Containers From Scratch
Linux Containers From ScratchLinux Containers From Scratch
Linux Containers From Scratch
 
How to Make Android's Bootable Recovery Work For You by Drew Suarez
How to Make Android's Bootable Recovery Work For You by Drew SuarezHow to Make Android's Bootable Recovery Work For You by Drew Suarez
How to Make Android's Bootable Recovery Work For You by Drew Suarez
 
Steps to build and run oai
Steps to build and run oaiSteps to build and run oai
Steps to build and run oai
 
OpenWRT guide and memo
OpenWRT guide and memoOpenWRT guide and memo
OpenWRT guide and memo
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Study on Android Emulator
Study on Android EmulatorStudy on Android Emulator
Study on Android Emulator
 
Labs_BT_20221017.pptx
Labs_BT_20221017.pptxLabs_BT_20221017.pptx
Labs_BT_20221017.pptx
 
XPDDS18: A dive into kbuild - Cao jin, Fujitsu
XPDDS18: A dive into kbuild - Cao jin, FujitsuXPDDS18: A dive into kbuild - Cao jin, Fujitsu
XPDDS18: A dive into kbuild - Cao jin, Fujitsu
 
How to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHubHow to create a secured multi tenancy for clustered ML with JupyterHub
How to create a secured multi tenancy for clustered ML with JupyterHub
 
Dev ops
Dev opsDev ops
Dev ops
 
linux_Commads
linux_Commadslinux_Commads
linux_Commads
 
Asian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On UblAsian Spirit 3 Day Dba On Ubl
Asian Spirit 3 Day Dba On Ubl
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 
Ansible best practices
Ansible best practicesAnsible best practices
Ansible best practices
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testers
 
Beagleboard xm-setup
Beagleboard xm-setupBeagleboard xm-setup
Beagleboard xm-setup
 

Recently uploaded

Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
David Celestin
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
amilabibi1
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
raffaeleoman
 

Recently uploaded (15)

Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdfSOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 

Buildsystem.mk

  • 2. Rémy Gottschalk ● SoftAtHome : 3 years - Linux System for HGW and STB ● Genymobile : 2 years - ROM cooking Charles-Henry Prunier ● Archos : 3 years - ROM cooking for Archos devices (Archos 5 IT - GEN 10) ● Genymobile : 2 years - ROM cooking SPEAKERS
  • 3. 01 How to make 02 Device definition 03 Android.mk 04 One last bite AGENDA
  • 4. HOW TO MAKE source, lunch, make !
  • 5. HOW TO MAKE # source ./build/envsetup.sh # # head -n 15 build/envsetup.sh function hmm() { cat <<EOF Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment: - lunch: lunch <product_name>-<build_variant> - tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [eng|userdebug|user] - croot: Changes directory to the top of the tree. - m: Makes from the top of the tree. - mm: Builds all of the modules in the current directory, but not their dependencies. - mmm: Builds all of the modules in the supplied directories, but not their dependencies. - mma: Builds all of the modules in the current directory, and their dependencies. - mmma: Builds all of the modules in the supplied directories, and their dependencies. - cgrep: Greps on all local C/C++ files. - jgrep: Greps on all local Java files. - resgrep: Greps on all local res/*.xml files. - godir: Go to the directory containing a file. #
  • 6. HOW TO MAKE lunch
  • 7. HOW TO MAKE make make -j42 It’s coffee time !
  • 9. vendorsetup.sh Lunch entry point TYPE = eng | userdebug | release AndroidProducts.mk The first makefile DEVICE DEFINITION vendorsetup.sh, AndroidProduct.mk add_lunch_combo TARGETNAME-TYPE PRODUCT_MAKEFILES = TARGETNAME.mk
  • 10. DEVICE DEFINITION vendorsetup.sh, AndroidProduct.mk # tail -n1 device/lge/hammerhead/vendorsetup.sh add_lunch_combo aosp_hammerhead-userdebug # # tail -n3 device/lge/hammerhead/AndroidProducts.mk PRODUCT_MAKEFILES := $(LOCAL_DIR)/aosp_hammerhead.mk $(LOCAL_DIR)/full_hammerhead.mk
  • 11. DEVICE DEFINITION BoardConfig.mk Define your device hardware Can include other BoardConfig.mk A bunch of specific defines BoardConfig.mk
  • 12. DEVICE DEFINITION BoardConfig.mk # cat device/lge/hammerhead/BoardConfig.mk | grep -vP "(^$|^#.*$)" TARGET_CPU_ABI := armeabi-v7a TARGET_CPU_ABI2 := armeabi TARGET_CPU_SMP := true TARGET_ARCH := arm TARGET_ARCH_VARIANT := armv7-a-neon TARGET_CPU_VARIANT := krait TARGET_NO_BOOTLOADER := true BOARD_KERNEL_BASE := 0x00000000 BOARD_KERNEL_PAGESIZE := 2048 BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.hardware=hammerhead user_debug=31 maxcpus=2 msm_watchdog_v2.enable=1 BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x02900000 --tags_offset 0x02700000 MAX_EGL_CACHE_KEY_SIZE := 12*1024 MAX_EGL_CACHE_SIZE := 2048*1024 BOARD_USES_ALSA_AUDIO := true BOARD_HAVE_BLUETOOTH := true BOARD_HAVE_BLUETOOTH_BCM := true BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/lge/hammerhead/bluetooth WPA_SUPPLICANT_VERSION := VER_0_8_X BOARD_WLAN_DEVICE := bcmdhd BOARD_WPA_SUPPLICANT_DRIVER := NL80211 BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE) BOARD_HOSTAPD_DRIVER := NL80211 BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE) WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/bcmdhd/parameters/firmware_path"
  • 13. DEVICE DEFINITION BoardConfig.mk WIFI_DRIVER_FW_PATH_AP := "/vendor/firmware/fw_bcmdhd_apsta.bin" WIFI_DRIVER_FW_PATH_STA := "/vendor/firmware/fw_bcmdhd.bin" BOARD_USES_SECURE_SERVICES := true TARGET_NO_RADIOIMAGE := true TARGET_BOARD_PLATFORM := msm8974 TARGET_BOOTLOADER_BOARD_NAME := hammerhead TARGET_BOARD_INFO_FILE := device/lge/hammerhead/board-info.txt BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := $(TARGET_BOARD_PLATFORM) TARGET_NO_RPC := true BOARD_EGL_CFG := device/lge/hammerhead/egl.cfg USE_OPENGL_RENDERER := true VSYNC_EVENT_PHASE_OFFSET_NS := 7500000 SF_VSYNC_EVENT_PHASE_OFFSET_NS := 5000000 TARGET_USES_ION := true TARGET_USERIMAGES_USE_EXT4 := true BOARD_BOOTIMAGE_PARTITION_SIZE := 23068672 BOARD_RECOVERYIMAGE_PARTITION_SIZE := 23068672 BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1073741824 BOARD_USERDATAIMAGE_PARTITION_SIZE := 13725837312 BOARD_CACHEIMAGE_PARTITION_SIZE := 734003200 BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 BOARD_FLASH_BLOCK_SIZE := 131072 BOARD_CHARGER_DISABLE_INIT_BLANK := true BOARD_CHARGER_ENABLE_SUSPEND := true TARGET_RECOVERY_PIXEL_FORMAT := RGBX_8888 TARGET_RECOVERY_UI_LIB := librecovery_ui_hammerhead
  • 14. DEVICE DEFINITION BoardConfig.mk TARGET_RECOVERY_FSTAB = device/lge/hammerhead/fstab.hammerhead TARGET_RELEASETOOLS_EXTENSIONS := device/lge/hammerhead PDK_PLATFORM_ZIP_PRODUCT_BINARIES := device/lge/hammerhead-kernel/vmlinux.bz2 BOARD_HAL_STATIC_LIBRARIES := libdumpstate.hammerhead BOARD_SEPOLICY_DIRS := device/lge/hammerhead/sepolicy BOARD_SEPOLICY_UNION := device.te app.te file_contexts HAVE_ADRENO_SOURCE:= false OVERRIDE_RS_DRIVER:= libRSDriver_adreno.so TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS := true TARGET_TOUCHBOOST_FREQUENCY:= 1200 -include vendor/lge/hammerhead/BoardConfigVendor.mk
  • 15. DEVICE DEFINITION device.mk Define your device software No specific naming Heavy use of inheritance device.mk
  • 16. DEVICE DEFINITION device.mk INHERIT BASE DEVICE INHERIT OVERLAY INHERIT VENDOR STUFF INHERIT PRODUCT VARIATION
  • 17. DEVICE DEFINITION device.mk Name your device PRODUCT_NAME PRODUCT_MODEL PRODUCT_DEVICE PRODUCT_MANUFACTURER PRODUCT_BRAND
  • 18. DEVICE DEFINITION device.mk Include software PRODUCT_PACKAGES PRODUCT_PACKAGES_DEBUG PRODUCT_PACKAGES_ENG PRODUCT_PACKAGES_TESTS PRODUCT_COPY_FILES
  • 19. DEVICE DEFINITION device.mk Customize PRODUCT_PROPERTY_OVERRIDES PRODUCT_DEFAULT_PROPERTY_OVERRIDES PRODUCT_RESTRICT_VENDOR_FILES PRODUCT_PACKAGE_OVERLAYS DEVICE_PACKAGE_OVERLAYS
  • 20. DEVICE DEFINITION device.mk Some leftovers PRODUCT_AAPT_CONFIG PRODUCT_AAPT_PREF_CONFIG PRODUCT_OTA_PUBLIC_KEYS PRODUCT_EXTRA_RECOVERY_KEYS PRODUCT_DEFAULT_DEV_CERTIFICATE And more in build/core/product.mk
  • 21. DEVICE DEFINITION device.mk # cat device/lge/hammerhead/device.mk | magic_summarize LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL) PRODUCT_COPY_FILES := $(LOCAL_KERNEL):kernel PRODUCT_COPY_FILES += device/lge/hammerhead/init.hammerhead.rc:root/init.hammerhead.rc device/lge/hammerhead/fstab.hammerhead:root/fstab.hammerhead device/lge/hammerhead/ueventd.hammerhead.rc:root/ueventd.hammerhead.rc # Input device files for hammerhead PRODUCT_COPY_FILES += device/lge/hammerhead/gpio-keys.kl:system/usr/keylayout/gpio-keys.kl device/lge/hammerhead/gpio-keys.kcm:system/usr/keychars/gpio-keys.kcm [...] device/lge/hammerhead/thermal-engine-hammerhead.conf:system/etc/thermal-engine. conf PRODUCT_TAGS += dalvik.gc.type-precise # This device is xhdpi. However the platform doesn't # currently contain all of the bitmaps at xhdpi density so # we do this little trick to fall back to the hdpi version # if the xhdpi doesn't exist. PRODUCT_AAPT_CONFIG := normal hdpi xhdpi xxhdpi PRODUCT_AAPT_PREF_CONFIG := xxhdpi PRODUCT_CHARACTERISTICS := nosdcard DEVICE_PACKAGE_OVERLAYS := device/lge/hammerhead/overlay
  • 22. DEVICE DEFINITION device.mk PRODUCT_PACKAGES += gralloc.msm8974 libgenlock hwcomposer.msm8974 [...] flp.msm8974 PRODUCT_PROPERTY_OVERRIDES += ro.hwui.texture_cache_size=72 debug.qualcomm.sns.hal=w debug.qualcomm.sns.daemon=w [...] debug.qualcomm.sns.libsensor1=w PRODUCT_DEFAULT_PROPERTY_OVERRIDES += rild.libpath=/system/lib/libril-qc-qmi-1.so # Camera configuration PRODUCT_DEFAULT_PROPERTY_OVERRIDES += camera.disable_zsl_mode=1 # Input resampling configuration PRODUCT_PROPERTY_OVERRIDES += ro.input.noresample=1 # setup dalvik vm configs. $(call inherit-product, frameworks/native/build/phone-xhdpi-2048-dalvik-heap.mk) $(call inherit-product-if-exists, hardware/qcom/msm8x74/msm8x74.mk) $(call inherit-product-if-exists, vendor/qcom/gpu/msm8x74/msm8x74-gpu-vendor.mk) $(call inherit-product-if-exists, hardware/broadcom/wlan/bcmdhd/firmware/bcm4339/device-bcm.mk)
  • 23. Android.mk A piece of Android
  • 24. Android.mk Android.mk, Android.mk everywhere Android.mk, Android.mk everywhere Define a component # find ./ -name Android.mk | wc -l 2242
  • 25. Android.mk Common content Any component needs A working directory LOCAL_PATH := $(call my-dir) A clean environment include $(CLEAR_VARS) A name LOCAL_MODULE := mymodule LOCAL_PACKAGE_NAME := mypackage
  • 26. Android.mk Common content Any component needs A type include BUILD_something Usually, some source files LOCAL_SRC_FILES= files A tag LOCAL_MODULE_TAGS := tag
  • 27. Android.mk Component types Many types of components # cat build/core/config.mk [...] BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk BUILD_RAW_STATIC_LIBRARY := $(BUILD_SYSTEM)/raw_static_library.mk BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk [...]
  • 28. Android.mk Keywords (linking) Some useful keywords For linking LOCAL_SHARED_LIBRARY LOCAL_STATIC_LIBRARY LOCAL_JAVA_LIBRARY LOCAL_STATIC_JAVA_LIBRARY
  • 29. Android.mk Keywords (signing) Some useful keywords For signing LOCAL_CERTIFICATE LOCAL_PRIVILEGED_MODULE
  • 30. Android.mk Keywords (native) Some useful keywords For native code LOCAL_CFLAGS LOCAL_CPPFLAGS
  • 31. Android.mk Keywords (java) Some useful keywords For java stuff LOCAL_PROGUARD_FLAG_FILES LOCAL_PROGUARD_ENABLED LOCAL_AAPT_FLAGS
  • 32. Android.mk Keywords (dependency) Some useful keywords For dependency handling LOCAL_REQUIRED_MODULES LOCAL_PACKAGE_OVERRIDES
  • 33. Android.mk Keywords (full list) Some useful keywords And even more Full list in build/core/clear_vars.mk
  • 34. Android.mk Functions Many useful functions in build/core/definitions.mk all-java-files-under all-files-under all-makefiles-under and many more
  • 35. Android.mk packages/apps/Settings/Android.mk # cat packages/apps/Settings/Android.mk LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_JAVA_LIBRARIES := bouncycastle conscrypt telephony-common LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 android-support-v13 jsr305 LOCAL_MODULE_TAGS := optional LOCAL_SRC_FILES := $(call all-java-files-under, src) src/com/android/settings/EventLogTags.logtags LOCAL_PACKAGE_NAME := Settings LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_AAPT_FLAGS += -c zz_ZZ include $(BUILD_PACKAGE) # Use the folloing include to make our test apk. include $(call all-makefiles-under,$(LOCAL_PATH))
  • 36. One last bite There’s always more
  • 37. One last bite More makefiles More makefiles untold module makefiles CleanSpec.mk Application.mk
  • 38. One last bite Even more makefiles Even more makefiles The build system itself build/core/main.mk build/core/*.mk Base devices build/target/**
  • 39. One last bite Other tools Non-make stuff Python build/tool/releasetools/ ├── build_image.py ├── img_from_target_files └── ota_from_target_files
  • 40. One last bite Other tools Non-make stuff Java build/tools/signapk
  • 41. Thank You for your time ! If you have any question ? Rémy Gottschalk rgottschalk@genymobile.com Charles-Henry Prunier 0682079415 chprunier@genymobile.com @charly_prunier
  • 42. Copyrights The following copyright have been stripped from all the examples : # # Copyright (C) 2013 The Android Open-Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #