mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: generate_product_makefiles: Unify in python
- Contains exception for rising
This commit is contained in:
parent
714f374f2f
commit
6c5dca1a28
3 changed files with 76 additions and 52 deletions
|
|
@ -1,14 +1,79 @@
|
||||||
import os
|
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:
|
def writeln(f, txt):
|
||||||
common = f'vendor/{vendor}/config/common.mk'
|
print(txt, file=f)
|
||||||
if os.path.isfile(common) and vendor not in blacklist:
|
|
||||||
print('vendor name is', vendor)
|
def check_exist_mk(path, mk):
|
||||||
with open("device/samsung/universal7885-common/vendor_name", 'w') as f:
|
ret = exists(path)
|
||||||
f.write(vendor)
|
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
|
break
|
||||||
|
if not ok:
|
||||||
|
raise RuntimeError(EX_RUNTIME_STR)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
|
||||||
|
|
@ -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 <vendor>_${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
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
UNIVERSAL="device/samsung/universal7885-common"
|
|
||||||
|
|
||||||
if [ ! -e .repo/local_manifests/eureka_deps.xml ]; then
|
if [ ! -e .repo/local_manifests/eureka_deps.xml ]; then
|
||||||
git clone https://github.com/eurekadevelopment/local_manifests .repo/local_manifests
|
git clone https://github.com/eurekadevelopment/local_manifests .repo/local_manifests
|
||||||
echo "Run repo sync again"
|
echo "Run repo sync again"
|
||||||
fi
|
fi
|
||||||
python3 ${UNIVERSAL}/generate_product_makefiles.py
|
|
||||||
for dev in a10dd a10 a20 a20e a30 a30s a40; do
|
python3 device/samsung/universal7885-common/generate_product_makefiles.py
|
||||||
echo "Generating ${dev} Makefiles..."
|
|
||||||
bash ${UNIVERSAL}/setup.sh "$dev"
|
|
||||||
done
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue