47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
|
|
import sys
|
||
|
|
import os
|
||
|
|
import tomli
|
||
|
|
from colorama import init as colorama_init
|
||
|
|
from colorama import Fore, Style
|
||
|
|
from args import Args
|
||
|
|
from preset import Preset
|
||
|
|
from bsp import BSP
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
colorama_init()
|
||
|
|
|
||
|
|
args = Args(sys.argv)
|
||
|
|
|
||
|
|
preset_path = args.get_named('preset', 0, 1)
|
||
|
|
if preset_path is None:
|
||
|
|
print(f'{Fore.RED}Err:{Style.RESET_ALL} no preset specified')
|
||
|
|
return -1
|
||
|
|
|
||
|
|
out_path = args.get_named('out', 0, 1)
|
||
|
|
if out_path is None:
|
||
|
|
print(f'{Fore.RED}Err:{Style.RESET_ALL} no output path specified')
|
||
|
|
return -1
|
||
|
|
|
||
|
|
sysroot_path = args.get_named('sysroot', 0, 1)
|
||
|
|
if sysroot_path is None:
|
||
|
|
sysroot_path = '/'
|
||
|
|
|
||
|
|
preset = Preset(preset_path)
|
||
|
|
|
||
|
|
bsp = BSP(out_path, sysroot=sysroot_path)
|
||
|
|
for dst, src in preset.contents().items():
|
||
|
|
for src_filepath in src:
|
||
|
|
src_filename = os.path.basename(src_filepath)
|
||
|
|
dst_filepath = os.path.join(dst, src_filename)
|
||
|
|
bsp.add_file(src_filepath, dst_filepath)
|
||
|
|
|
||
|
|
bsp.set_bootstrap_program(preset.bootstrap_program())
|
||
|
|
bsp.close()
|
||
|
|
|
||
|
|
return 0
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
exit(main())
|