BuildSystem.
mk
SPEAKERS
Rémy Gottschalk Charles-Henry Prunier
● SoftAtHome : 3 years - ● Archos : 3 years - ROM
Linux System for HGW cooking for Archos
and STB devices (Archos 5 IT -
GEN 10)
● Genymobile : 2 years - ● Genymobile : 2 years -
ROM cooking ROM cooking
AGENDA
01 02 03 04
How to make Device [Link] One last bite
definition
HOW TO MAKE
source, lunch, make !
HOW TO MAKE
# source ./build/[Link]
#
# head -n 15 build/[Link]
function hmm() {
cat <<EOF
Invoke ". build/[Link]" 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 ?
DEVICE DEFINITION
[Link], [Link]
[Link]
add_lunch_combo TARGETNAME-TYPE
Lunch entry point
TYPE = eng | userdebug | release
PRODUCT_MAKEFILES = [Link] [Link]
The first makefile
DEVICE DEFINITION
[Link], [Link]
# tail -n1 device/lge/hammerhead/[Link]
add_lunch_combo aosp_hammerhead-userdebug
#
# tail -n3 device/lge/hammerhead/[Link]
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/aosp_hammerhead.mk \
$(LOCAL_DIR)/full_hammerhead.mk
DEVICE DEFINITION
[Link]
[Link]
A bunch of
Define your Can include other
specific
device hardware [Link]
defines
DEVICE DEFINITION
[Link]
# cat device/lge/hammerhead/[Link] | 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 [Link]=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
[Link]
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/[Link]
BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE := $(TARGET_BOARD_PLATFORM)
TARGET_NO_RPC := true
BOARD_EGL_CFG := device/lge/hammerhead/[Link]
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
[Link]
TARGET_RECOVERY_FSTAB = device/lge/hammerhead/[Link]
TARGET_RELEASETOOLS_EXTENSIONS := device/lge/hammerhead
PDK_PLATFORM_ZIP_PRODUCT_BINARIES := device/lge/hammerhead-kernel/vmlinux.bz2
BOARD_HAL_STATIC_LIBRARIES := [Link]
BOARD_SEPOLICY_DIRS := \
device/lge/hammerhead/sepolicy
BOARD_SEPOLICY_UNION := \
[Link] \
[Link] \
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/[Link]
DEVICE DEFINITION
[Link]
[Link]
Define your No specific Heavy use of
device software naming inheritance
DEVICE DEFINITION
[Link]
INHERIT BASE DEVICE
INHERIT OVERLAY
INHERIT VENDOR STUFF
INHERIT PRODUCT VARIATION
DEVICE DEFINITION
[Link]
Name your device
PRODUCT_NAME
PRODUCT_MODEL
PRODUCT_DEVICE
PRODUCT_MANUFACTURER
PRODUCT_BRAND
DEVICE DEFINITION
[Link]
Include software
PRODUCT_PACKAGES
PRODUCT_PACKAGES_DEBUG
PRODUCT_PACKAGES_ENG
PRODUCT_PACKAGES_TESTS
PRODUCT_COPY_FILES
DEVICE DEFINITION
[Link]
Customize
PRODUCT_PROPERTY_OVERRIDES
PRODUCT_DEFAULT_PROPERTY_OVERRIDES
PRODUCT_RESTRICT_VENDOR_FILES
PRODUCT_PACKAGE_OVERLAYS
DEVICE_PACKAGE_OVERLAYS
DEVICE DEFINITION
[Link]
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/[Link]
DEVICE DEFINITION
[Link]
# cat device/lge/hammerhead/[Link] | magic_summarize
LOCAL_KERNEL := $(TARGET_PREBUILT_KERNEL)
PRODUCT_COPY_FILES := \
$(LOCAL_KERNEL):kernel
PRODUCT_COPY_FILES += \
device/lge/hammerhead/[Link]:root/[Link] \
device/lge/hammerhead/[Link]:root/[Link] \
device/lge/hammerhead/[Link]:root/[Link]
# Input device files for hammerhead
PRODUCT_COPY_FILES += \
device/lge/hammerhead/[Link]:system/usr/keylayout/[Link] \
device/lge/hammerhead/[Link]:system/usr/keychars/[Link] \
[...] device/lge/hammerhead/[Link]:system/etc/thermal-
[Link]
PRODUCT_TAGS += [Link]-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
[Link]
PRODUCT_PACKAGES += \
gralloc.msm8974 \
libgenlock \
hwcomposer.msm8974 \
[...]
flp.msm8974
PRODUCT_PROPERTY_OVERRIDES += \
[Link].texture_cache_size=72 \
[Link]=w \
[Link]=w \
[...]
[Link].libsensor1=w
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
[Link]=/system/lib/[Link]
# Camera configuration
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
camera.disable_zsl_mode=1
# Input resampling configuration
PRODUCT_PROPERTY_OVERRIDES += \
[Link]=1
# setup dalvik vm configs.
$(call inherit-product, frameworks/native/build/[Link])
$(call inherit-product-if-exists, hardware/qcom/msm8x74/[Link])
$(call inherit-product-if-exists, vendor/qcom/gpu/msm8x74/[Link])
$(call inherit-product-if-exists,
hardware/broadcom/wlan/bcmdhd/firmware/bcm4339/[Link])
[Link]
A piece of Android
[Link]
[Link], [Link] everywhere
[Link], [Link] everywhere
Define a component
# find ./ -name [Link] | wc -l
2242
[Link]
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
[Link]
Common content
Any component needs
A type
include BUILD_something
Usually, some source files
LOCAL_SRC_FILES= files
A tag
LOCAL_MODULE_TAGS := tag
[Link]
Component types
Many types of components
# cat build/core/[Link]
[...]
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)/[Link]
BUILD_RAW_EXECUTABLE:= $(BUILD_SYSTEM)/raw_executable.mk
BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
BUILD_PACKAGE:= $(BUILD_SYSTEM)/[Link]
BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
BUILD_PREBUILT:= $(BUILD_SYSTEM)/[Link]
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)/[Link]
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
[...]
[Link]
Keywords (linking)
Some useful keywords
For linking
LOCAL_SHARED_LIBRARY
LOCAL_STATIC_LIBRARY
LOCAL_JAVA_LIBRARY
LOCAL_STATIC_JAVA_LIBRARY
[Link]
Keywords (signing)
Some useful keywords
For signing
LOCAL_CERTIFICATE
LOCAL_PRIVILEGED_MODULE
[Link]
Keywords (native)
Some useful keywords
For native code
LOCAL_CFLAGS
LOCAL_CPPFLAGS
[Link]
Keywords (java)
Some useful keywords
For java stuff
LOCAL_PROGUARD_FLAG_FILES
LOCAL_PROGUARD_ENABLED
LOCAL_AAPT_FLAGS
[Link]
Keywords (dependency)
Some useful keywords
For dependency handling
LOCAL_REQUIRED_MODULES
LOCAL_PACKAGE_OVERRIDES
[Link]
Keywords (full list)
Some useful keywords
And even more
Full list in build/core/clear_vars.mk
[Link]
Functions
Many useful functions
in build/core/[Link]
all-java-files-under
all-files-under
all-makefiles-under
and many more
[Link]
packages/apps/Settings/[Link]
# cat packages/apps/Settings/[Link]
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/[Link]
LOCAL_PACKAGE_NAME := Settings
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_PROGUARD_FLAG_FILES := [Link]
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
[Link]
[Link]
One last bite
Even more makefiles
Even more makefiles
The build system itself
build/core/[Link]
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 ?
Charles-Henry Prunier Rémy Gottschalk
0682079415
rgottschalk@[Link]
chprunier@[Link]
@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
#
# [Link]
#
# 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.
#