sysroot: add a set of base system files
This commit is contained in:
@@ -16,6 +16,9 @@ include(Templates)
|
|||||||
bsp_reset()
|
bsp_reset()
|
||||||
sysroot_reset()
|
sysroot_reset()
|
||||||
|
|
||||||
|
sysroot_set_base(
|
||||||
|
PATH ${CMAKE_SOURCE_DIR}/base)
|
||||||
|
|
||||||
add_subdirectory(kernel)
|
add_subdirectory(kernel)
|
||||||
add_subdirectory(sys)
|
add_subdirectory(sys)
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
|
|||||||
11
base/boot/grub/grub.cfg
Normal file
11
base/boot/grub/grub.cfg
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
menuentry "Rosetta" {
|
||||||
|
multiboot /boot/mango_kernel
|
||||||
|
module /boot/rosetta-system.bsp
|
||||||
|
boot
|
||||||
|
}
|
||||||
|
|
||||||
|
menuentry "Rosetta (Serial Log)" {
|
||||||
|
multiboot /boot/mango_kernel kernel.early-console=ttyS0
|
||||||
|
module /boot/rosetta-system.bsp
|
||||||
|
boot
|
||||||
|
}
|
||||||
@@ -9,6 +9,34 @@ function(sysroot_reset)
|
|||||||
COMMAND_ERROR_IS_FATAL ANY)
|
COMMAND_ERROR_IS_FATAL ANY)
|
||||||
endfunction(sysroot_reset)
|
endfunction(sysroot_reset)
|
||||||
|
|
||||||
|
function(sysroot_set_base)
|
||||||
|
set(options)
|
||||||
|
set(one_value_args PATH)
|
||||||
|
set(multi_value_args)
|
||||||
|
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 arg
|
||||||
|
"${options}"
|
||||||
|
"${one_value_args}"
|
||||||
|
"${multi_value_args}")
|
||||||
|
|
||||||
|
set(sysroot_target_name _sysroot-base)
|
||||||
|
|
||||||
|
get_property(sysroot_targets GLOBAL PROPERTY sysroot_target_list)
|
||||||
|
list(LENGTH sysroot_targets nr_sysroot_targets)
|
||||||
|
if (${nr_sysroot_targets} GREATER 0)
|
||||||
|
math(EXPR serialiser_index "${nr_sysroot_targets}-1")
|
||||||
|
list(GET sysroot_targets ${serialiser_index} serialiser)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_custom_target(${sysroot_target_name}
|
||||||
|
COMMAND ${Python_EXECUTABLE} ${sysroot_tool}
|
||||||
|
set-base ${sysroot_manifest} ${arg_PATH}
|
||||||
|
COMMENT "Preparing sysroot base"
|
||||||
|
DEPENDS ${serialiser})
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
|
||||||
|
endfunction(sysroot_set_base)
|
||||||
|
|
||||||
function(sysroot_add_library)
|
function(sysroot_add_library)
|
||||||
set(options)
|
set(options)
|
||||||
set(one_value_args NAME HEADER_DIR LIB_DIR)
|
set(one_value_args NAME HEADER_DIR LIB_DIR)
|
||||||
@@ -93,7 +121,6 @@ function(sysroot_add_object_library)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
get_property(tmp TARGET ${target_name} PROPERTY SUFFIX)
|
get_property(tmp TARGET ${target_name} PROPERTY SUFFIX)
|
||||||
message(STATUS ${tmp})
|
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
|
set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name})
|
||||||
endfunction(sysroot_add_object_library)
|
endfunction(sysroot_add_object_library)
|
||||||
|
|||||||
@@ -58,19 +58,21 @@ class Component:
|
|||||||
class Manifest:
|
class Manifest:
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.base = None
|
||||||
self.components = {}
|
self.components = {}
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
with open(self.path, 'r') as f:
|
with open(self.path, 'r') as f:
|
||||||
self.data = json.load(f)
|
self.data = json.load(f)
|
||||||
|
|
||||||
if 'components' not in self.data:
|
if 'components' in self.data:
|
||||||
return 0
|
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():
|
if 'base' in self.data:
|
||||||
component = Component()
|
self.base = self.data['base']
|
||||||
component.deserialise(t)
|
|
||||||
self.components[n] = component
|
|
||||||
|
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
@@ -81,6 +83,9 @@ class Manifest:
|
|||||||
|
|
||||||
self.data['components'] = component_data
|
self.data['components'] = component_data
|
||||||
|
|
||||||
|
if self.base is not None:
|
||||||
|
self.data['base'] = self.base
|
||||||
|
|
||||||
with open(self.path, 'w') as f:
|
with open(self.path, 'w') as f:
|
||||||
json.dump(self.data, f, indent=4)
|
json.dump(self.data, f, indent=4)
|
||||||
|
|
||||||
@@ -97,5 +102,14 @@ class Manifest:
|
|||||||
self.components[name] = component
|
self.components[name] = component
|
||||||
return component
|
return component
|
||||||
|
|
||||||
|
|
||||||
|
def set_base(self, path):
|
||||||
|
self.base = path
|
||||||
|
|
||||||
|
|
||||||
|
def get_base(self):
|
||||||
|
return self.base
|
||||||
|
|
||||||
|
|
||||||
def get_all_components(self):
|
def get_all_components(self):
|
||||||
return self.components
|
return self.components
|
||||||
|
|||||||
@@ -16,6 +16,24 @@ def reset():
|
|||||||
return 0
|
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():
|
def add_headers():
|
||||||
if len(sys.argv) < 6:
|
if len(sys.argv) < 6:
|
||||||
print("USAGE: {} add-headers <manifest-path> <component-name> <dest-directory> <source-directory>".format(sys.argv[0]))
|
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 = Manifest(manifest_path)
|
||||||
manifest.load()
|
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 n, c in manifest.get_all_components().items():
|
||||||
for h in c.get_headers():
|
for h in c.get_headers():
|
||||||
header_src = h['src']
|
header_src = h['src']
|
||||||
@@ -122,6 +147,7 @@ if len(sys.argv) < 2:
|
|||||||
|
|
||||||
commands = {
|
commands = {
|
||||||
'reset': reset,
|
'reset': reset,
|
||||||
|
'set-base': set_base,
|
||||||
'add-headers': add_headers,
|
'add-headers': add_headers,
|
||||||
'add-binary': add_binary,
|
'add-binary': add_binary,
|
||||||
'build-sysroot': build_sysroot,
|
'build-sysroot': build_sysroot,
|
||||||
|
|||||||
Reference in New Issue
Block a user