1ec33767ab
every system component now has its own self-contained build system, and a seed file describing the component and its build system and dependencies. a new tool, meadow, collects and uses these seed files to build the components into a full system. meadow also manages the target system root and a host prefix where toolchain tools are installed to. the build system has also been updated to use a new $ARCH-rosetta-gcc compiler, and the patches files necessary to build it have been added to toolchain/cross-compiler.
67 lines
1.6 KiB
Python
67 lines
1.6 KiB
Python
import os
|
|
import sys
|
|
import json
|
|
import tomli
|
|
|
|
|
|
class PresetParseError(Exception):
|
|
pass
|
|
|
|
|
|
class Preset:
|
|
def __collect_preset_files(self):
|
|
result = []
|
|
for root, dirs, files in os.walk(self.__path):
|
|
for f in files:
|
|
name = f
|
|
path = os.path.join(root, f)
|
|
|
|
result.append((name, path))
|
|
|
|
return result
|
|
|
|
|
|
def __apply_preset_file(self, data):
|
|
bootstrap = data.get('bootstrap', None)
|
|
contents = data.get('contents', None)
|
|
if bootstrap is not None:
|
|
self.__bootstrap = bootstrap
|
|
|
|
if contents is not None:
|
|
for dest, src in contents.items():
|
|
dest_list = self.__contents.get(dest, [])
|
|
|
|
for p in src:
|
|
dest_list.append(p)
|
|
|
|
self.__contents[dest] = dest_list
|
|
|
|
|
|
def __read_preset_files(self):
|
|
for n, p in self.__files:
|
|
data = None
|
|
try:
|
|
f = open(p, mode='rb')
|
|
data = tomli.load(f)
|
|
except Exception as e:
|
|
raise ParseError('Err: Failed to parse seed file {}: {}'.format(seed_path, e))
|
|
|
|
self.__apply_preset_file(data)
|
|
|
|
|
|
def __init__(self, path):
|
|
self.__bootstrap = {}
|
|
self.__contents = {}
|
|
self.__path = path
|
|
self.__files = self.__collect_preset_files()
|
|
self.__files = sorted(self.__files, key=lambda tup: tup[0])
|
|
self.__read_preset_files()
|
|
|
|
|
|
def contents(self):
|
|
return self.__contents
|
|
|
|
|
|
def bootstrap_program(self):
|
|
return self.__bootstrap.get('bootstrap_exec', None)
|