Skip to content

Commit

Permalink
Initial Project
Browse files Browse the repository at this point in the history
Change-Id: I7f07f2777aa2f7b78415bb32aa4e02b54d5aaa49
  • Loading branch information
mochangming committed Oct 3, 2016
0 parents commit 697ded4
Show file tree
Hide file tree
Showing 25 changed files with 2,138 additions and 0 deletions.
107 changes: 107 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#
# Copyright (C) 2016 The Miui Patchrom
#

include $(PORT_BUILD)/localvar.mk

ifeq ($(USE_ANDROID_OUT),true)
# Prebuilt dirs
PREBUILT_SYS_DIR := $(ANDROID_OUT)/system
PREBUILT_DATA_DIR := $(ANDROID_OUT)/data
PREBUILT_CUST_DIR := $(ANDROID_OUT)/cust_variants_intermedia
PREBUILT_RES_DIR := $(PREBUILT_SYS_DIR)/framework
PREBUILT_BOOT_DIR := $(ANDROID_OUT)/root

# Release dirs
RELEASE_DIR := $(PORT_ROOT)/miui
RELEASE_SYS_DIR := $(RELEASE_DIR)/system
RELEASE_JAR_DIR := $(RELEASE_SYS_DIR)/framework
RELEASE_RES_DIR := $(RELEASE_SYS_DIR)/framework-res/$(RELEASE_DENSITY)
RELEASE_APP_DIR := $(RELEASE_SYS_DIR)/app
RELEASE_APP_APK_DIR := $(RELEASE_APP_DIR)/$(RELEASE_DENSITY)
RELEASE_APP_LIB_DIR := $(RELEASE_APP_DIR)/$(RELEASE_BIT)
RELEASE_PRIV_APP_DIR := $(RELEASE_SYS_DIR)/priv-app
RELEASE_PRIV_APP_APK_DIR := $(RELEASE_PRIV_APP_DIR)/$(RELEASE_DENSITY)
RELEASE_PRIV_APP_LIB_DIR := $(RELEASE_PRIV_APP_DIR)/$(RELEASE_BIT)
RELEASE_BIN_DIR := $(RELEASE_SYS_DIR)/bin/$(RELEASE_BIT)
RELEASE_XBIN_DIR := $(RELEASE_SYS_DIR)/xbin/$(RELEASE_BIT)
RELEASE_LIB_DIR := $(RELEASE_SYS_DIR)/lib
RELEASE_LIB64_DIR := $(RELEASE_SYS_DIR)/lib64
RELEASE_ETC_DIR := $(RELEASE_SYS_DIR)/etc
RELEASE_MEDIA_DIR := $(RELEASE_SYS_DIR)/media/$(RELEASE_DENSITY)
RELEASE_FONTS_DIR := $(RELEASE_SYS_DIR)/fonts
RELEASE_BOOT_DIR := $(RELEASE_DIR)/boot


# Src dirs
MIUI_SRC_DIR := $(ANDROID_TOP)/miui
else
# Prebuilt dirs
PREBUILT_SYS_DIR := $(PORT_ROOT)/miui/system
PREBUILT_DATA_DIR := $(PORT_ROOT)/miui/data
PREBUILT_CUST_DIR := $(PORT_ROOT)/miui/cust
PREBUILT_RES_DIR := $(PREBUILT_SYS_DIR)/framework-res/$(PREBUILT_DENSITY)
PREBUILT_BOOT_DIR := $(PORT_ROOT)/miui/boot

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

# Prebuilt dirs
PREBUILT_JAR_DIR := $(PREBUILT_SYS_DIR)/framework
PREBUILT_LIB_DIR := $(PREBUILT_SYS_DIR)/lib
PREBUILT_LIB64_DIR := $(PREBUILT_SYS_DIR)/lib64
PREBUILT_BIN_DIR := $(PREBUILT_SYS_DIR)/bin/$(PREBUILT_BIT)
PREBUILT_XBIN_DIR := $(PREBUILT_SYS_DIR)/xbin/$(PREBUILT_BIT)
PREBUILT_APP_DIR := $(PREBUILT_SYS_DIR)/app
PREBUILT_APP_APK_DIR := $(PREBUILT_APP_DIR)/$(PREBUILT_DENSITY)
PREBUILT_APP_LIB_DIR := $(PREBUILT_APP_DIR)/$(PREBUILT_BIT)
PREBUILT_PRIV_APP_DIR := $(PREBUILT_SYS_DIR)/priv-app
PREBUILT_PRIV_APP_APK_DIR := $(PREBUILT_PRIV_APP_DIR)/$(PREBUILT_DENSITY)
PREBUILT_PRIV_APP_LIB_DIR := $(PREBUILT_PRIV_APP_DIR)/$(PREBUILT_BIT)
PREBUILT_ETC_DIR := $(PREBUILT_SYS_DIR)/etc
PREBUILT_MEDIA_DIR := $(PREBUILT_SYS_DIR)/media/$(PREBUILT_DENSITY)
PREBUILT_FONTS_DIR := $(PREBUILT_SYS_DIR)/fonts

# Target dirs
TARGET_OUT_DIR := out
TARGET_SYS_DIR := $(TARGET_OUT_DIR)/ZIP/system
TARGET_DATA_DIR := $(TARGET_OUT_DIR)/ZIP/data
TARGET_APP_DIR := $(TARGET_SYS_DIR)/app
TARGET_PRIV_APP_DIR := $(TARGET_SYS_DIR)/priv-app
TARGET_FRAMEWORK_DIR := $(TARGET_SYS_DIR)/framework
TARGET_LIB_DIR := $(TARGET_SYS_DIR)/lib
TARGET_LIB64_DIR := $(TARGET_SYS_DIR)/lib64
TARGET_BIN_DIR := $(TARGET_SYS_DIR)/bin
TARGET_XBIN_DIR := $(TARGET_SYS_DIR)/xbin
TARGET_ETC_DIR := $(TARGET_SYS_DIR)/etc
TARGET_MEDIA_DIR := $(TARGET_SYS_DIR)/media
TARGET_FONTS_DIR := $(TARGET_SYS_DIR)/fonts
TARGET_BOOT_DIR := $(TARGET_OUT_DIR)/boot

# Tools
TOOLS_DIR := $(PORT_ROOT)/tools
AAPT := $(TOOLS_DIR)/$(HOST_OS)-x86/aapt
UNPACKBOOTIMG := $(TOOLS_DIR)/$(HOST_OS)-x86/unpackbootimg
MKBOOTFS := $(TOOLS_DIR)/$(HOST_OS)-x86/mkbootfs
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

# Config files
BUILD_PROP := $(TARGET_SYS_DIR)/build.prop
MIUI_PROP := $(PORT_BUILD)/miui.prop
KEYS_CONF := $(TOOLS_DIR)/keys.conf

# Apktool include
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 \
$(PREBUILT_APP_APK_DIR)/miuisystem/miuisystem.apk
72 changes: 72 additions & 0 deletions definitions.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#
# Copyright (C) 2016 The Miui Patchrom
#

# $(1): app list
# $(2): source apps dir
# $(3): destination apps dir
define copy-apks-lib
$(foreach app_name, $(1), \
$(shell rm -rf $(3)/$(app_name)/lib; \
if [ -d $(2)/$(app_name)/lib ];then \
mkdir -p $(3)/$(app_name); \
cp -rfp $(2)/$(app_name)/lib $(3)/$(app_name)/; \
fi \
)\
)
endef

# $(1): app list
# $(2): source apps dir
# $(3): destination apps dir
define copy-apks-to-target
$(foreach app_name, $(1), \
$(eval $(call copy-one-file,$(2)/$(app_name)/$(app_name).apk,$(3)/$(app_name)/$(app_name).apk)))
endef

# Define a rule to copy a file. For use via $(eval).
# $(1): source file
# $(2): destination file
define copy-one-file
$(2): $(1)
@echo "Copy: $$< to $$@"
@mkdir -p $$(dir $$@)
$(hide) cp -fp $$< $$@
endef


# $(1): source dir
# $(2): destination dir
# $(3): type
define copy-prebuilt-files
$(hide) for file in `find $(1) -type f`; do \
path=$${file##$(1)}; \
if [ "$${path:0:1}" == "/" ];then \
grep "$(3)$$path" $(PORT_ROOT)/build/filelist.txt > /dev/null; \
else \
grep "$(3)/$$path" $(PORT_ROOT)/build/filelist.txt > /dev/null; \
fi; \
if [ $$? -eq 1 ];then \
source_file="$(1)/$$path"; \
target_file="$(2)/$$path"; \
mkdir -p $$(dirname $$target_file); \
cp -f $$source_file $$target_file; \
fi \
done
endef


define all-files-under-dir
$(shell find $(1) -type f 2>/dev/null)
endef

define get-key-in-mac-perms
$(strip \
$(foreach item,$(filter %"><seinfo value="$(2)"%,$(shell more $(1))),\
$(if $(filter value="$(2)"%,$(item)),\
$(patsubst signature="%"><seinfo,%,$(sig)),\
$(eval sig := $(item))\
)\
)\
)
endef
5 changes: 5 additions & 0 deletions device_features.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<features>
<!--whether the device is port by patchrom-->
<bool name="is_patchrom">true</bool>
</features>
Binary file added empty-res/16.apk
Binary file not shown.
Binary file added empty-res/17.apk
Binary file not shown.
Binary file added empty-res/18.apk
Binary file not shown.
89 changes: 89 additions & 0 deletions envsetup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
#
# usage:
# under the porting workspace, run:
# $. /path/to/envsetup.sh [android_build_top] [android_product_out]
#
# description:
# If android build environment has been setup (i.e. lunch'ed), the value of
# android_build_top and android_product_out specified here would not be used.
# If android_build_top or android_product_out is empty, then ?

set -- `getopt "a:l:b:h:p:" "$@"`
android_top=
android_lunch=
ANDROID_BRANCH=
PORT_PRODUCT="Unknown"
help=
while :
do
case "$1" in
-a) shift; android_top="$1" ;;
-l) shift; android_lunch="$1";;
-b) shift; ANDROID_BRANCH="$1";;
-p) shift; PORT_PRODUCT="$1";;
-h) help=1;;
--) break ;;
esac
shift
done
shift

if [ -n "$help" ]; then
echo "Usage: . /path/to/envsetup [-a android-top [-l lunch-option] [-b android-branch]]"
return
fi

if [ -n "$android_top" ]; then
if [ ! -d "$android_top" ]; then
echo "Failed: $android_top does not exist"
return
fi
cd $android_top
. build/envsetup.sh
lunch $android_lunch
USE_ANDROID_OUT=true
export USE_ANDROID_OUT
cd -
else
ANDROID_BRANCH=
fi

TOPFILE=build/porting.mk
if [ -f $TOPFILE ] ; then
PORT_ROOT=$PWD
else
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
cd .. > /dev/null
done
if [ -f $PWD/$TOPFILE ]; then
PORT_ROOT=$PWD
else
echo "Failed! run me under you porting workspace"
return
fi
fi

if [ -n "$PORT_ROOT" ]; then
PORT_BUILD=$PORT_ROOT/build
ANDROID_TOP=${ANDROID_BUILD_TOP:=$1}
ANDROID_OUT=${ANDROID_PRODUCT_OUT:=$2}
PATCHROM_BRANCH=$(grep -rn "BRANCH" $PORT_ROOT/android/README | cut -d'=' -f2)
ANDROID_PLATFORM=$(grep -rn "PLATFORM" $PORT_ROOT/android/README | cut -d'=' -f2)
HOST_OS=$(uname -s | tr '[A-Z]' '[a-z]')
export PORT_ROOT PORT_BUILD ANDROID_TOP ANDROID_OUT ANDROID_BRANCH PORT_PRODUCT PATCHROM_BRANCH ANDROID_PLATFORM HOST_OS
export PATH=$PORT_ROOT/tools/${HOST_OS}-x86:$PORT_ROOT/tools:$PATH
echo "PATCHROM_BRANCH = $PATCHROM_BRANCH"
echo "ANDROID_PLATFORM = $ANDROID_PLATFORM"
echo "PORT_ROOT = $PORT_ROOT"
echo "ANDROID_TOP = $ANDROID_TOP"
echo "ANDROID_OUT = $ANDROID_OUT"
echo "PORT_PRODUCT = $PORT_PRODUCT"
echo "USE_ANDROID_OUT = $USE_ANDROID_OUT"
echo "ANDROID_BRANCH = $ANDROID_BRANCH"
echo "HOST_OS = $HOST_OS"
fi

# Tell python not to spam the source tree with .pyc files. This
# only has an effect on python 2.6 and above.
export PYTHONDONTWRITEBYTECODE=1
Loading

0 comments on commit 697ded4

Please sign in to comment.