mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: generate_product_makefiles: Rework, add MikuUI VF
This commit is contained in:
parent
1ad1e7c795
commit
36df3ce4ac
1 changed files with 81 additions and 51 deletions
|
|
@ -11,17 +11,24 @@ def log(x):
|
||||||
if (debug):
|
if (debug):
|
||||||
print(x)
|
print(x)
|
||||||
|
|
||||||
def writeln(f, txt):
|
def writeln(f, txt = ''):
|
||||||
print(txt, file=f)
|
print(txt, file=f)
|
||||||
|
|
||||||
def check_exist_mk(path, mk):
|
class GenerateMK():
|
||||||
ret = exists(path)
|
def __init__(self, vendor):
|
||||||
if ret:
|
self.config_mk_path = None
|
||||||
writeln(mk, f'$(call inherit-product, {path})')
|
self.vendor = vendor
|
||||||
return ret
|
|
||||||
|
|
||||||
def write_one_dev_makefile(device, vendor):
|
def check_exist_mk(self, path, mk):
|
||||||
|
if self.config_mk_path is None and exists(path):
|
||||||
|
self.set_config_path(path)
|
||||||
|
|
||||||
|
def set_config_path(self, path: str):
|
||||||
|
self.config_mk_path = path
|
||||||
|
|
||||||
|
def write_one_dev_makefile(self, device):
|
||||||
device_path = f'{DEVICE_BASE}/{device}'
|
device_path = f'{DEVICE_BASE}/{device}'
|
||||||
|
vendor = self.vendor
|
||||||
log(f'Write entry => {device_path}')
|
log(f'Write entry => {device_path}')
|
||||||
with open(f'{device_path}/AndroidProducts.mk', 'w') as ap:
|
with open(f'{device_path}/AndroidProducts.mk', 'w') as ap:
|
||||||
writeln(ap, f'# Auto-Generated by {__file__}')
|
writeln(ap, f'# Auto-Generated by {__file__}')
|
||||||
|
|
@ -30,14 +37,15 @@ def write_one_dev_makefile(device, vendor):
|
||||||
writeln(mk, f'# Auto-Generated by {__file__}')
|
writeln(mk, f'# Auto-Generated by {__file__}')
|
||||||
writeln(mk, f'$(call inherit-product, {device_path}/full_{device}.mk)')
|
writeln(mk, f'$(call inherit-product, {device_path}/full_{device}.mk)')
|
||||||
existed = False
|
existed = False
|
||||||
existed |= check_exist_mk(f'vendor/{vendor}/config/common_full_phone.mk', mk)
|
if self.config_mk_path is None:
|
||||||
existed |= check_exist_mk(f'vendor/{vendor}/config/common.mk', mk)
|
self.check_exist_mk(f'vendor/{vendor}/config/common_full_phone.mk', mk)
|
||||||
existed |= check_exist_mk(f'vendor/{vendor}/config/rising.mk', mk)
|
self.check_exist_mk(f'vendor/{vendor}/config/common.mk', mk)
|
||||||
if not existed:
|
if self.config_mk_path is None:
|
||||||
raise RuntimeError(EX_RUNTIME_STR)
|
raise RuntimeError(EX_RUNTIME_STR)
|
||||||
writeln(mk, '')
|
writeln(mk, f'$(call inherit-product, {self.config_mk_path})')
|
||||||
|
writeln(mk)
|
||||||
writeln(mk, f'PRODUCT_NAME := {vendor}_{device}')
|
writeln(mk, f'PRODUCT_NAME := {vendor}_{device}')
|
||||||
writeln(mk, '')
|
writeln(mk)
|
||||||
if device in HD_DEVICES:
|
if device in HD_DEVICES:
|
||||||
writeln(mk, 'TARGET_BOOT_ANIMATION_RES := 720')
|
writeln(mk, 'TARGET_BOOT_ANIMATION_RES := 720')
|
||||||
else:
|
else:
|
||||||
|
|
@ -45,31 +53,53 @@ def write_one_dev_makefile(device, vendor):
|
||||||
writeln(mk, 'TARGET_USES_MINI_GAPPS := true')
|
writeln(mk, 'TARGET_USES_MINI_GAPPS := true')
|
||||||
log(f'Write entry <= {device_path}')
|
log(f'Write entry <= {device_path}')
|
||||||
|
|
||||||
def check_makefile(mk, vendor):
|
def write_makefiles(self):
|
||||||
devices = os.listdir(DEVICE_BASE)
|
devices = os.listdir(DEVICE_BASE)
|
||||||
|
|
||||||
log(f'Check MK => {mk}')
|
|
||||||
if exists(mk):
|
|
||||||
log(f'Check MK <= {mk} exist')
|
|
||||||
for i in devices:
|
for i in devices:
|
||||||
if not i[:1] == 'a':
|
if not i[:1] == 'a':
|
||||||
log(f'Skip entry: {i}')
|
log(f'Skip entry: {i}')
|
||||||
continue
|
continue
|
||||||
write_one_dev_makefile(i, vendor)
|
self.write_one_dev_makefile(i)
|
||||||
|
|
||||||
|
def check_makefile(self, mk):
|
||||||
|
log(f'Check MK => {mk}')
|
||||||
|
if exists(mk):
|
||||||
|
log(f'Check MK <= {mk} exist')
|
||||||
|
self.write_makefiles()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Hardcode paths for certain ROMs
|
||||||
|
class VendorFixer():
|
||||||
|
def __init__(self, makefile_path, vendor_folder):
|
||||||
|
self.mkpath = makefile_path
|
||||||
|
self.vfolder = vendor_folder
|
||||||
|
|
||||||
|
def check(self):
|
||||||
|
mkpath = f'vendor/{self.vfolder}/{self.mkpath}'
|
||||||
|
if exists(mkpath):
|
||||||
|
log(f'APPLY VF: Overriding to path: {mkpath}')
|
||||||
|
g_mk = GenerateMK(self.vfolder)
|
||||||
|
g_mk.set_config_path(mkpath)
|
||||||
|
g_mk.write_makefiles()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
RisingVF = VendorFixer('config/rising.mk', 'rising')
|
||||||
|
MikuVF = VendorFixer('build/product/miku_product.mk', 'miku')
|
||||||
|
TestVF = VendorFixer('config/my_ss.mk', 'ss')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
vendors = os.listdir('vendor')
|
vendors = os.listdir('vendor')
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
if 'rising' in vendors:
|
for vf in [RisingVF, MikuVF, TestVF]:
|
||||||
mk = 'vendor/rising/config/rising.mk'
|
if vf.check():
|
||||||
ok |= check_makefile(mk, 'rising')
|
return
|
||||||
else:
|
|
||||||
for vendor in vendors:
|
for vendor in vendors:
|
||||||
mk = f'vendor/{vendor}/config/common.mk'
|
mk = f'vendor/{vendor}/config/common.mk'
|
||||||
ok |= check_makefile(mk, vendor)
|
ok |= GenerateMK(vendor).check_makefile(mk)
|
||||||
if ok:
|
if ok:
|
||||||
break
|
break
|
||||||
if not ok:
|
if not ok:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue