sysroot: add a set of base system files
This commit is contained in:
@@ -58,19 +58,21 @@ class Component:
|
||||
class Manifest:
|
||||
def __init__(self, path):
|
||||
self.path = path
|
||||
self.base = None
|
||||
self.components = {}
|
||||
|
||||
def load(self):
|
||||
with open(self.path, 'r') as f:
|
||||
self.data = json.load(f)
|
||||
|
||||
if 'components' not in self.data:
|
||||
return 0
|
||||
if 'components' in self.data:
|
||||
for n, t in self.data['components'].items():
|
||||
component = Component()
|
||||
component.deserialise(t)
|
||||
self.components[n] = component
|
||||
|
||||
for n, t in self.data['components'].items():
|
||||
component = Component()
|
||||
component.deserialise(t)
|
||||
self.components[n] = component
|
||||
if 'base' in self.data:
|
||||
self.base = self.data['base']
|
||||
|
||||
|
||||
def save(self):
|
||||
@@ -81,6 +83,9 @@ class Manifest:
|
||||
|
||||
self.data['components'] = component_data
|
||||
|
||||
if self.base is not None:
|
||||
self.data['base'] = self.base
|
||||
|
||||
with open(self.path, 'w') as f:
|
||||
json.dump(self.data, f, indent=4)
|
||||
|
||||
@@ -97,5 +102,14 @@ class Manifest:
|
||||
self.components[name] = component
|
||||
return component
|
||||
|
||||
|
||||
def set_base(self, path):
|
||||
self.base = path
|
||||
|
||||
|
||||
def get_base(self):
|
||||
return self.base
|
||||
|
||||
|
||||
def get_all_components(self):
|
||||
return self.components
|
||||
|
||||
@@ -16,6 +16,24 @@ def reset():
|
||||
return 0
|
||||
|
||||
|
||||
def set_base():
|
||||
if len(sys.argv) < 4:
|
||||
print("USAGE: {} set-base <manifest-path> <base-directory>".format(sys.argv[0]))
|
||||
return -1
|
||||
|
||||
manifest_path = sys.argv[2]
|
||||
base_path = sys.argv[3]
|
||||
|
||||
manifest = Manifest(manifest_path)
|
||||
manifest.load()
|
||||
|
||||
manifest.set_base(base_path)
|
||||
|
||||
manifest.save()
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def add_headers():
|
||||
if len(sys.argv) < 6:
|
||||
print("USAGE: {} add-headers <manifest-path> <component-name> <dest-directory> <source-directory>".format(sys.argv[0]))
|
||||
@@ -73,6 +91,13 @@ def build_sysroot():
|
||||
manifest = Manifest(manifest_path)
|
||||
manifest.load()
|
||||
|
||||
base_dir = manifest.get_base()
|
||||
if base_dir is not None:
|
||||
shutil.copytree(
|
||||
base_dir,
|
||||
sysroot_path,
|
||||
dirs_exist_ok=True)
|
||||
|
||||
for n, c in manifest.get_all_components().items():
|
||||
for h in c.get_headers():
|
||||
header_src = h['src']
|
||||
@@ -122,6 +147,7 @@ if len(sys.argv) < 2:
|
||||
|
||||
commands = {
|
||||
'reset': reset,
|
||||
'set-base': set_base,
|
||||
'add-headers': add_headers,
|
||||
'add-binary': add_binary,
|
||||
'build-sysroot': build_sysroot,
|
||||
|
||||
Reference in New Issue
Block a user