diff --git a/CMakeLists.txt b/CMakeLists.txt index f2eba0c..a52f0de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,9 @@ include(Templates) bsp_reset() sysroot_reset() +sysroot_set_base( + PATH ${CMAKE_SOURCE_DIR}/base) + add_subdirectory(kernel) add_subdirectory(sys) add_subdirectory(lib) diff --git a/base/boot/grub/grub.cfg b/base/boot/grub/grub.cfg new file mode 100644 index 0000000..19e9ab3 --- /dev/null +++ b/base/boot/grub/grub.cfg @@ -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 +} diff --git a/cmake/Sysroot.cmake b/cmake/Sysroot.cmake index 80d9f65..01289e1 100644 --- a/cmake/Sysroot.cmake +++ b/cmake/Sysroot.cmake @@ -9,6 +9,34 @@ function(sysroot_reset) COMMAND_ERROR_IS_FATAL ANY) 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) set(options) set(one_value_args NAME HEADER_DIR LIB_DIR) @@ -93,7 +121,6 @@ function(sysroot_add_object_library) endif () get_property(tmp TARGET ${target_name} PROPERTY SUFFIX) - message(STATUS ${tmp}) set_property(GLOBAL PROPERTY sysroot_target_list ${sysroot_targets} ${sysroot_target_name}) endfunction(sysroot_add_object_library) diff --git a/util/lib/manifest.py b/util/lib/manifest.py index 6881070..34012ed 100644 --- a/util/lib/manifest.py +++ b/util/lib/manifest.py @@ -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 diff --git a/util/sysroot-tool.py b/util/sysroot-tool.py index 42354fe..a52a921 100644 --- a/util/sysroot-tool.py +++ b/util/sysroot-tool.py @@ -16,6 +16,24 @@ def reset(): return 0 +def set_base(): + if len(sys.argv) < 4: + print("USAGE: {} set-base ".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 ".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,