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):
|
||||
print(x)
|
||||
|
||||
def writeln(f, txt):
|
||||
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
|
||||
class GenerateMK():
|
||||
def __init__(self, vendor):
|
||||
self.config_mk_path = None
|
||||
self.vendor = vendor
|
||||
|
||||
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}'
|
||||
vendor = self.vendor
|
||||
log(f'Write entry => {device_path}')
|
||||
with open(f'{device_path}/AndroidProducts.mk', 'w') as ap:
|
||||
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'$(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:
|
||||
if self.config_mk_path is None:
|
||||
self.check_exist_mk(f'vendor/{vendor}/config/common_full_phone.mk', mk)
|
||||
self.check_exist_mk(f'vendor/{vendor}/config/common.mk', mk)
|
||||
if self.config_mk_path is None:
|
||||
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, '')
|
||||
writeln(mk)
|
||||
if device in HD_DEVICES:
|
||||
writeln(mk, 'TARGET_BOOT_ANIMATION_RES := 720')
|
||||
else:
|
||||
|
|
@ -45,31 +53,53 @@ def write_one_dev_makefile(device, vendor):
|
|||
writeln(mk, 'TARGET_USES_MINI_GAPPS := true')
|
||||
log(f'Write entry <= {device_path}')
|
||||
|
||||
def check_makefile(mk, vendor):
|
||||
def write_makefiles(self):
|
||||
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)
|
||||
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 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():
|
||||
vendors = os.listdir('vendor')
|
||||
ok = False
|
||||
|
||||
if 'rising' in vendors:
|
||||
mk = 'vendor/rising/config/rising.mk'
|
||||
ok |= check_makefile(mk, 'rising')
|
||||
else:
|
||||
for vf in [RisingVF, MikuVF, TestVF]:
|
||||
if vf.check():
|
||||
return
|
||||
|
||||
for vendor in vendors:
|
||||
mk = f'vendor/{vendor}/config/common.mk'
|
||||
ok |= check_makefile(mk, vendor)
|
||||
ok |= GenerateMK(vendor).check_makefile(mk)
|
||||
if ok:
|
||||
break
|
||||
if not ok:
|
||||
|
|
|
|||
Loading…
Reference in a new issue