diff --git a/universal7885-common/generate_product_makefiles.py b/universal7885-common/generate_product_makefiles.py index e859cd2..ed6439f 100644 --- a/universal7885-common/generate_product_makefiles.py +++ b/universal7885-common/generate_product_makefiles.py @@ -1,14 +1,79 @@ import os +from os.path import isfile as exists +from os.path import dirname, basename -blacklist = ["qcom", "nxp","pixel-framework", "lawnchair" ,"support", "overlay","samsung", "gapps", "google", "gms", "codeaurora", "addons", "overlays", "xtras", "themes"] +debug = True +DEVICE_BASE = 'device/samsung' +HD_DEVICES=['a10dd', 'a10', 'a20', 'a20e'] +EX_RUNTIME_STR = 'Vendor config makefile was not found' -vendors = os.listdir('vendor') +def log(x): + if (debug): + print(x) -for vendor in vendors: - common = f'vendor/{vendor}/config/common.mk' - if os.path.isfile(common) and vendor not in blacklist: - print('vendor name is', vendor) - with open("device/samsung/universal7885-common/vendor_name", 'w') as f: - f.write(vendor) - break +def writeln(f, txt): + print(txt, file=f) +def check_exist_mk(path, mk): + ret = exists(path) + if ret: + writeln(mk, f'$(call inherit-product, {path})') + return ret + +def write_one_dev_makefile(device, vendor): + device_path = f'{DEVICE_BASE}/{device}' + log(f'Write entry => {device_path}') + with open(f'{device_path}/AndroidProducts.mk', 'w') as ap: + writeln(ap, f'# Auto-Generated by {__file__}') + writeln(ap, f'PRODUCT_MAKEFILES += $(LOCAL_DIR)/{vendor}_{device}.mk') + with open(f'{device_path}/{vendor}_{device}.mk', 'w') as mk: + writeln(mk, f'# Auto-Generated by {__file__}') + writeln(mk, f'$(call inherit-product, {device_path}/full_{device}.mk)') + existed = False + existed |= check_exist_mk(f'vendor/{vendor}/config/common_full_phone.mk', mk) + existed |= check_exist_mk(f'vendor/{vendor}/config/common.mk', mk) + existed |= check_exist_mk(f'vendor/{vendor}/config/rising.mk', mk) + if not existed: + raise RuntimeError(EX_RUNTIME_STR) + writeln(mk, '') + writeln(mk, f'PRODUCT_NAME := {vendor}_{device}') + writeln(mk, '') + if device in HD_DEVICES: + writeln(mk, 'TARGET_BOOT_ANIMATION_RES := 720') + else: + writeln(mk, 'TARGET_BOOT_ANIMATION_RES := 1080') + writeln(mk, 'TARGET_USES_MINI_GAPPS := true') + log(f'Write entry <= {device_path}') + +def check_makefile(mk, vendor): + devices = os.listdir(DEVICE_BASE) + + log(f'Check MK => {mk}') + if exists(mk): + log(f'Check MK <= {mk} exist') + for i in devices: + if not i[:1] == 'a': + log(f'Skip entry: {i}') + continue + write_one_dev_makefile(i, vendor) + return True + return False + +def main(): + vendors = os.listdir('vendor') + ok = False + + if 'rising' in vendors: + mk = 'vendor/rising/config/rising.mk' + ok |= check_makefile(mk, 'rising') + else: + for vendor in vendors: + mk = f'vendor/{vendor}/config/common.mk' + ok |= check_makefile(mk, vendor) + if ok: + break + if not ok: + raise RuntimeError(EX_RUNTIME_STR) + +if __name__ == '__main__': + main() diff --git a/universal7885-common/setup.sh b/universal7885-common/setup.sh deleted file mode 100755 index 253153e..0000000 --- a/universal7885-common/setup.sh +++ /dev/null @@ -1,36 +0,0 @@ -DEVICE=$1 -BASE="device/samsung" -UNI="${BASE}/universal7885-common" -DEV="${BASE}/${DEVICE}" -if [ -z "$DEVICE" ]; then - echo "Something went wrong while generating makefiles!" - exit 1 -fi -VENDOR=$(cat ${UNI}/vendor_name) -if [ ! $VENDOR ]; then - VENDOR=aosp -fi -# Generate AndroidProducts.mk -echo "# Auto-Generated by ${DEV}/setup.sh" >${DEV}/AndroidProducts.mk -echo "PRODUCT_MAKEFILES += \$(LOCAL_DIR)/"$VENDOR"_${DEVICE}.mk" >>${DEV}/AndroidProducts.mk - -# Generate _${DEVICE}.mk -echo "# Auto-Generated by ${DEV}/setup.sh" >${DEV}/"$VENDOR"_${DEVICE}.mk -echo "\$(call inherit-product, ${DEV}/full_${DEVICE}.mk)" >>${DEV}/"$VENDOR"_${DEVICE}.mk -if test -f vendor/"$VENDOR"/config/common_full_phone.mk && echo "common_full_phone"; then - echo "\$(call inherit-product, vendor/"$VENDOR"/config/common_full_phone.mk)" >>${DEV}/"$VENDOR"_${DEVICE}.mk -elif test -f vendor/"$VENDOR"/config/common.mk && echo "common"; then - echo "\$(call inherit-product, vendor/"$VENDOR"/config/common.mk)" >>${DEV}/"$VENDOR"_${DEVICE}.mk -fi -echo "PRODUCT_NAME := "$VENDOR"_${DEVICE}" >>${DEV}/"$VENDOR"_${DEVICE}.mk -echo "" >>${DEV}/"$VENDOR"_${DEVICE}.mk -echo "# Additional Props" >>${DEV}/"$VENDOR"_${DEVICE}.mk -echo "TARGET_FACE_UNLOCK_SUPPORTED := true" >>${DEV}/"$VENDOR"_${DEVICE}.mk - -HD_DEV="a10dd a10 a20 a20e" -if echo $HD_DEV | grep $DEVICE 2>&1 >/dev/null; then - echo "TARGET_BOOT_ANIMATION_RES := 720" >>${DEV}/"$VENDOR"_${DEVICE}.mk -else - echo "TARGET_BOOT_ANIMATION_RES := 1080" >>${DEV}/"$VENDOR"_${DEVICE}.mk -fi -echo "TARGET_USES_MINI_GAPPS := true" >>${DEV}/"$VENDOR"_${DEVICE}.mk diff --git a/universal7885-common/vendorsetup.sh b/universal7885-common/vendorsetup.sh index 6941f5f..97cb22d 100755 --- a/universal7885-common/vendorsetup.sh +++ b/universal7885-common/vendorsetup.sh @@ -1,11 +1,6 @@ -UNIVERSAL="device/samsung/universal7885-common" - if [ ! -e .repo/local_manifests/eureka_deps.xml ]; then git clone https://github.com/eurekadevelopment/local_manifests .repo/local_manifests echo "Run repo sync again" fi -python3 ${UNIVERSAL}/generate_product_makefiles.py -for dev in a10dd a10 a20 a20e a30 a30s a40; do - echo "Generating ${dev} Makefiles..." - bash ${UNIVERSAL}/setup.sh "$dev" -done + +python3 device/samsung/universal7885-common/generate_product_makefiles.py