Skip to content

Commit

Permalink
Update mk files
Browse files Browse the repository at this point in the history
Change-Id: I6d0fed46d803b15b6e67d1d70dcf875a0711ea5f
  • Loading branch information
mochangming committed Oct 27, 2016
1 parent 697ded4 commit b61c3c8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 132 deletions.
64 changes: 64 additions & 0 deletions apps.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

#
# Copyright (C) 2016 The Miui Patchrom
#

MIUI_APP_BLACKLIST += InputDevices MusicFX SharedStorageBackup OneTimeInitializer ProxyHandler GooglePinyinIME \
Shell FusedLocation BackupRestoreConfirmation ExternalStorageProvider PhotoTable PrintSpooler \
WAPPushManager MagicSmokeWallpapers VisualizationWallpapers BasicDreams PhaseBeam HoloSpiralWallpaper \
Bluetooth Galaxy4 LiveWallpapers PicoTts CertInstaller KeyChain NoiseField PacProcessor Camera2 \
TrafficControl


ALL_MIUI_PRIV_APPS :=
$(foreach app, $(subst .apk,,$(shell find $(PREBUILT_PRIV_APP_APK_DIR) -name "*.apk" -exec basename {} \;)), \
$(eval ALL_MIUI_PRIV_APPS += $(app)))

MIUI_PRIV_APPS := $(filter-out $(MIUI_APP_BLACKLIST),$(ALL_MIUI_PRIV_APPS))


ALL_MIUI_APPS :=
$(foreach app, $(subst .apk,,$(shell find $(PREBUILT_APP_APK_DIR) -name "*.apk" -exec basename {} \;)), \
$(eval ALL_MIUI_APPS += $(app)))

MIUI_APPS := $(filter-out $(MIUI_APP_BLACKLIST),$(ALL_MIUI_APPS))

TARGET_APPS := $(foreach app_name, $(MIUI_APPS),$(TARGET_APP_DIR)/$(app_name)/$(app_name).apk) \
$(foreach app_name, $(MIUI_PRIV_APPS),$(TARGET_PRIV_APP_DIR)/$(app_name)/$(app_name).apk) \

# Define a rule to modify miui app. For use via $(eval).
# $1: the apk name, such as LogsProvider
define miui_app_mod_template
ifeq ($(wildcard $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk),)
prebuilt-apk-path := $(PREBUILT_PRIV_APP_APK_DIR)/$(1)/$(1).apk
else
prebuilt-apk-path := $(PREBUILT_APP_APK_DIR)/$(1)/$(1).apk
endif
source-files-for-$(1) := $$(call all-files-under-dir,$(1))
apkcert := $$(shell $(GET_APK_CERT) $(1).apk $(MIUI_APK_CERT_TXT))

$(TARGET_OUT_DIR)/$(1): $$(prebuilt-apk-path) $$(source-files-for-$(1)) $(APKTOOL_INCLUDE_MIUI_RES) $(APKTOOL_INCLUDE_VENDOR_RES)
$(APKTOOL) d -p $(TARGET_OUT_DIR)/apktool -t miui -f $$< -o $(TARGET_OUT_DIR)/$(1)
$(hide) sed -i "/tag:/d" $$@/apktool.yml
$(hide) sed -i "s/isFrameworkApk: true/isFrameworkApk: false/g" $$@/apktool.yml
$(hide) sed -i "s/package=\"com.miui.core\"/package=\"miui\"/g" $$@/AndroidManifest.xml
$(PATCH_MIUI_APP) $(1) $$@

$(TARGET_OUT_DIR)/$(1).apk: $(TARGET_OUT_DIR)/$(1)
@echo ">>> build $$@..."
ifneq ($(wildcard $(1)),)
$(hide) cp -r $(1) $(TARGET_OUT_DIR)
endif
$(APKTOOL) b -p $(TARGET_OUT_DIR)/apktool -a $(AAPT) $(TARGET_OUT_DIR)/$(1) -o $$@
@echo "9Patch png fix $$@..."
$(FIX_9PATCH_PNG) $(1) $$(dir $$(prebuilt-apk-path)) $(TARGET_OUT_DIR) $(1)/res
@echo "sign $$(apkcert) key for $$@..."
$(hide) java -jar $(TOOLS_DIR)/signapk.jar $(CERTIFICATE_DIR)/$$(apkcert).x509.pem $(CERTIFICATE_DIR)/$$(apkcert).pk8 $$@ $$@.signed
$(hide) mv $$@.signed $$@
@echo "<<< build $$@ completed!"

TARGET_APPS += $(TARGET_OUT_DIR)/$(1).apk
endef

$(foreach app, $(MOD_MIUI_APPS) , \
$(eval $(call miui_app_mod_template,$(app))))
11 changes: 9 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ RELEASE_BOOT_DIR := $(RELEASE_DIR)/boot

# Src dirs
MIUI_SRC_DIR := $(ANDROID_TOP)/miui

# Miui apk cert txt
MIUI_APK_CERT_TXT := $(shell find $ANDROID_OUT/obj/PACKAGING/apkcerts_intermediates/ -name "*.txt" | head -n 1)
else
# Prebuilt dirs
PREBUILT_SYS_DIR := $(PORT_ROOT)/miui/system
Expand All @@ -45,6 +48,9 @@ PREBUILT_BOOT_DIR := $(PORT_ROOT)/miui/boot

# Src dirs
MIUI_SRC_DIR := $(PORT_ROOT)/miui/src

# Miui apk cert txt
MIUI_APK_CERT_TXT := $(PORT_ROOT)/miui/metadata/apkcert.txt
endif

# Prebuilt dirs
Expand Down Expand Up @@ -88,6 +94,9 @@ MKBOOTIMG := $(TOOLS_DIR)/$(HOST_OS)-x86/mkbootimg
APKTOOL := $(TOOLS_DIR)/apktool $(APK_VERBOSE)
PATCH_BOOTIMG_SH := $(TOOLS_DIR)/patch_bootimg.sh
UNIQ_FIRST_PY := $(TOOLS_DIR)/uniq_first.py
GET_APK_CERT := $(TOOLS_DIR)/get_apk_cert.py
PATCH_MIUI_APP := $(TOOLS_DIR)/patch_miui_app.sh $(VERBOSE)
FIX_9PATCH_PNG := $(TOOLS_DIR)/fix_9patch_png.sh $(VERBOSE)

# Config files
BUILD_PROP := $(TARGET_SYS_DIR)/build.prop
Expand All @@ -99,8 +108,6 @@ APKTOOL_INCLUDE_RES_DIR := $(TARGET_OUT_DIR)/apktool
APKTOOL_INCLUDE_VENDOR_RES := $(APKTOOL_INCLUDE_RES_DIR)/1.apk
APKTOOL_INCLUDE_MIUI_RES := $(APKTOOL_INCLUDE_RES_DIR)/1-miui.apk

include $(PORT_BUILD)/miui_apps.mk

MIUI_JARS := framework services telephony-common wifi-service
MIUI_EXT_RES_APKS := $(PREBUILT_APP_APK_DIR)/miui/miui.apk \
$(PREBUILT_RES_DIR)/framework-ext-res/framework-ext-res.apk \
Expand Down
6 changes: 3 additions & 3 deletions localvar.mk
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ ifeq ($(OUT_ZIP_FILE),)
OUT_ZIP_FILE:= update.zip
endif

APPS := $(strip $(local-modified-apps))
MIUI_MOD_APPS := $(strip $(local-miui-modified-apps))
MIUI_APPS_BLACKLIST := $(MIUI_MOD_APPS) $(strip $(local-miui-removed-apps))
MOD_APPS := $(strip $(local-modified-apps))
MOD_MIUI_APPS := $(strip $(local-miui-modified-apps))
MIUI_APPS_BLACKLIST := $(MOD_MIUI_APPS) $(strip $(local-miui-removed-apps))

PHONE_JARS := $(strip $(local-modified-jars))

Expand Down
21 changes: 0 additions & 21 deletions miui_apps.mk

This file was deleted.

109 changes: 3 additions & 106 deletions porting.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include $(PORT_BUILD)/config.mk
include $(PORT_BUILD)/definitions.mk
include $(PORT_BUILD)/apps.mk
include $(PORT_BUILD)/release.mk
include $(PORT_BUILD)/prebuilt.mk

Expand Down Expand Up @@ -45,6 +46,7 @@ OVERLAY_RES := overlay/framework-res/res $(MIUI_OVERLAY_RES)

MIUI_RES := overlay/framework-ext-res/res \
$(MIUI_SRC_DIR)/miui/device/xiaomi/patchrom/overlay/miui/frameworks/base/core/res/res \
$(addsuffix /miui/frameworks/base/core/res/res, $(addprefix $(MIUI_SRC_DIR)/config-overlay/v6/platform/, $(PLATFORM_OVERLAY))) \
$(addsuffix /miui/frameworks/base/core/res/res, $(addprefix $(MIUI_SRC_DIR)/I18N_res/v6/platform/, $(PLATFORM_OVERLAY))) \
$(MIUI_SRC_DIR)/I18N_res/v6/common/miui/frameworks/base/core/res/res \
$(MIUI_SRC_DIR)/frameworks/base/core/res/res \
Expand Down Expand Up @@ -130,41 +132,6 @@ $(TARGET_OUT_DIR)/$(1).jar: $$(source-files-for-$(1)) | $(TARGET_OUT_DIR)

endef

#
# To apktool build one apk from the decoded dirctory under .build
# $1: the apk name, such as LogsProvider
# $2: the dir name, might be different from apk name
# $3: to specify if the smali files should be decoded from MIUI first
# $4: to specify app dir, for kitkat only
define APP_template
source-files-for-$(2) := $$(call all-files-under-dir,$(2))
$(TARGET_OUT_DIR)/$(1).apk: $$(source-files-for-$(2)) $(3) | $(TARGET_OUT_DIR)
@echo ">>> build $$@..."
ifneq ($(wildcard $(2)),)
$(hide) cp -r $(2) $(TARGET_OUT_DIR)
$(hide) find $(TARGET_OUT_DIR)/$(2) -name "*.part" -exec rm {} \;
$(hide) find $(TARGET_OUT_DIR)/$(2) -name "*.smali.method" -exec rm {} \;
endif
$(APKTOOL) b -p $(TARGET_OUT_DIR)/apktool -a $(AAPT) $(TARGET_OUT_DIR)/$(2) -o $$@
#@echo "9Patch png fix $$@..."
#ifeq ($(3),)
# $(FIX_9PATCH_PNG) $(1) $(STOCKROM_DIR)/system/$(4) $(TARGET_OUT_DIR)
#else
# $(FIX_9PATCH_PNG) $(1) $(OUT_APK_PATH:app=$(4)) $(TARGET_OUT_DIR) $(1)/res
#endif
@echo "fix $$@ completed!"
@echo "<<< build $$@ completed!"

$(3): $(OUT_APK_PATH:app=$(4))/$(1)/$(1).apk $(TARGET_OUT_DIR)/apktool
$(hide) rm -rf $(3)
$(APKTOOL) d -p $(TARGET_OUT_DIR)/apktool -t miui -f $$< -o $(3)
$(hide) sed -i "/tag:/d" $(3)/apktool.yml
$(hide) sed -i "s/isFrameworkApk: true/isFrameworkApk: false/g" $(3)/apktool.yml
$(hide) sed -i "s/package=\"com.miui.core\"/package=\"miui\"/g" $(3)/AndroidManifest.xml
$(PATCH_MIUI_APP) $(2) $(3)

endef

# Target to build framework-res.apk
# copy the framework-res, add the miui overlay then build
#TODO need to add changed files for all related, and re-install framework-res.apk make sense?
Expand Down Expand Up @@ -203,66 +170,6 @@ $(1): $(ZIP_FILE)
$(hide) rm -f $(TARGET_OUT_DIR)/system/$(2)/$(1).apk
endef

# To decide dir of the apk
# $1 the apk name
define MOD_DIR_template
ifeq ($(USE_ANDROID_OUT),true)
ifeq ($(wildcard $(ANDROID_OUT)/system/priv-app/$(1).apk),$(wildcard $(STOCKROM_DIR)/system/priv-app/$(1).apk))
$(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/app/$(1).apk)
else
$(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/priv-app/$(1).apk)
endif
else
ifeq ($(wildcard $(RELEASE_DIR)/$(DENSITY)/system/priv-app/$(1).apk),$(wildcard $(STOCKROM_DIR)/system/priv-app/$(1).apk))
$(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/app/$(1).apk)
else
$(call SIGN_template,$(TARGET_OUT_DIR)/$(1).apk,/system/priv-app/$(1).apk)
endif
endif
endef

# To decide dir of the apk
# $1 the apk name
# $2: to specify if the smali files should be decoded from MIUI first
define APP_DIR_template
ifeq ($(USE_ANDROID_OUT),true)
ifeq ($(wildcard $(ANDROID_OUT)/system/priv-app/$(1).apk),)
$(call APP_template,$(1),$(1),$(2),app)
else
$(call APP_template,$(1),$(1),$(2),priv-app)
endif
else
ifeq ($(wildcard $(RELEASE_DIR)/$(DENSITY)/system/priv-app/$(1).apk),)
$(call APP_template,$(1),$(1),$(2),app)
else
$(call APP_template,$(1),$(1),$(2),priv-app)
endif
endif
endef

#
# Used to sign one single file, e.g: make .build/LogsProvider.apk.sign
# for zipfile target, just to copy the unsigned file to correct ZIP-directory.
# also create a seperate target for command line, such as : make LogsProvider.apk.sign
# $1: the apk file need to be signed
# $2: the path/filename in the phone
define SIGN_template
SIGNAPKS += $(1).sign
$(notdir $(1)).sign $(1).sign: $(1)
@echo sign apk $(1) and push to phone as $(2)...
#java -jar $(TOOL_DIR)/signapk.jar $(PORT_ROOT)/build/security/platform.x509.pem $(PORT_ROOT)/build/security/platform.pk8 $(1) $(1).signed
java -jar $(TOOL_DIR)/signapk.jar $(PORT_ROOT)/build/security/testkey.x509.pem $(PORT_ROOT)/build/security/testkey.pk8 $(1) $(1).signed
$(ADB) remount
$(ADB) push $(1).signed $(2)

mark-tozip-for-$(1) := $(TARGET_OUT_DIR)/$$(shell basename $(1))-tozip
TOZIP_APKS += $$(mark-tozip-for-$(1))
$$(mark-tozip-for-$(1)) : $(1)
$(hide) mkdir -p $(shell dirname $(ZIP_DIR)$(2))
$(hide) cp $(1) $(ZIP_DIR)$(2)
@touch $$@
endef

zipone: zipfile $(ACT_AFTER_ZIP)

otapackage: metadata target_files
Expand All @@ -274,15 +181,6 @@ $(foreach jar, $(MIUI_JARS), \
$(foreach jar, $(PHONE_JARS), \
$(eval $(call JAR_PHONE_template,$(jar))))

#$(foreach app, $(APPS), \
$(eval $(call APP_DIR_template,$(app),)))

#$(foreach app, $(MIUI_APPS) , \
$(eval $(call APP_DIR_template,$(app),$(TARGET_OUT_DIR)/$(app))))

#$(foreach app, $(APPS) $(MIUI_APPS_MOD), \
$(eval $(call MOD_DIR_template,$(app))))

$(call copy-apks-to-target, $(MIUI_APPS), $(PREBUILT_APP_APK_DIR), $(TARGET_APP_DIR))
$(call copy-apks-to-target, $(MIUI_PRIV_APPS), $(PREBUILT_PRIV_APP_APK_DIR), $(TARGET_PRIV_APP_DIR))
$(eval $(call copy-one-file,$(TARGET_OUT_DIR)/framework-ext-res.apk,$(TARGET_FRAMEWORK_DIR)/framework-ext-res/framework-ext-res.apk))
Expand Down Expand Up @@ -403,8 +301,7 @@ patch-bootimg: $(PATCH_BOOTIMG_SH) $(UNPACKBOOTIMG) $(MKBOOTFS) $(MKBOOTIMG) $(T

target_files: $(STOCKROM_DIR) | $(ZIP_DIR)
target_files: add-miui-prebuilt
target_files: $(foreach app_name, $(MIUI_APPS),$(TARGET_APP_DIR)/$(app_name)/$(app_name).apk)
target_files: $(foreach app_name, $(MIUI_PRIV_APPS),$(TARGET_PRIV_APP_DIR)/$(app_name)/$(app_name).apk)
target_files: $(TARGET_APPS)
target_files: $(TARGET_FRAMEWORK_DIR)/framework-res.apk $(TARGET_FRAMEWORK_DIR)/framework-ext-res/framework-ext-res.apk
target_files: $(ZIP_BLDJARS) $(ACT_PRE_ZIP)

Expand Down

0 comments on commit b61c3c8

Please sign in to comment.