mirror of
https://github.com/drasko/codezero.git
synced 2026-03-06 20:43:14 +01:00
Packing of bare container done.
This commit is contained in:
11
build.py
11
build.py
@@ -26,20 +26,29 @@ def main():
|
|||||||
configure_kernel(join(CML2_CONFIG_SRCDIR, 'arm.cml'))
|
configure_kernel(join(CML2_CONFIG_SRCDIR, 'arm.cml'))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build the kernel and libl4
|
# Build the kernel
|
||||||
#
|
#
|
||||||
|
print "\nBuilding the kernel..."
|
||||||
os.chdir(PROJROOT)
|
os.chdir(PROJROOT)
|
||||||
os.system("scons")
|
os.system("scons")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build userspace libraries
|
||||||
|
#
|
||||||
|
print "\nBuilding userspace libraries..."
|
||||||
|
os.system('scons -f SConstruct.userlibs')
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build containers
|
# Build containers
|
||||||
#
|
#
|
||||||
|
print "\nBuilding containers..."
|
||||||
containers.build_all_containers()
|
containers.build_all_containers()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build libs and loader
|
# Build libs and loader
|
||||||
#
|
#
|
||||||
os.chdir(PROJROOT)
|
os.chdir(PROJROOT)
|
||||||
|
print "\nBuilding the loader and packing..."
|
||||||
os.system("scons -f SConstruct.loader")
|
os.system("scons -f SConstruct.loader")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -51,5 +51,4 @@ src = Glob('*.[cS]')
|
|||||||
src += Glob('src/*.[cS]')
|
src += Glob('src/*.[cS]')
|
||||||
|
|
||||||
objs = env.Object(src)
|
objs = env.Object(src)
|
||||||
|
prog = env.Program('main.elf', objs)
|
||||||
env.Program('main.elf', objs)
|
|
||||||
|
|||||||
8
scripts/bare/bare_generator.py
Normal file → Executable file
8
scripts/bare/bare_generator.py
Normal file → Executable file
@@ -28,10 +28,10 @@ class BareContGenerator:
|
|||||||
self.main_configurator_name = 'configure.py'
|
self.main_configurator_name = 'configure.py'
|
||||||
self.mailing_list_url = 'http://lists.l4dev.org/mailman/listinfo/codezero-devel'
|
self.mailing_list_url = 'http://lists.l4dev.org/mailman/listinfo/codezero-devel'
|
||||||
|
|
||||||
self.build_script_in = join(SCRIPTROOT, 'SConstruct.in')
|
self.build_script_in = join(SCRIPTROOT, 'files/SConstruct.in')
|
||||||
self.build_readme_in = join(SCRIPTROOT, 'build.readme.in')
|
self.build_readme_in = join(SCRIPTROOT, 'files/build.readme.in')
|
||||||
self.build_desc_in = join(SCRIPTROOT, 'container.desc.in')
|
self.build_desc_in = join(SCRIPTROOT, 'files/container.desc.in')
|
||||||
self.linker_lds_in = join(SCRIPTROOT, 'linker.lds.in')
|
self.linker_lds_in = join(SCRIPTROOT, 'files/linker.lds.in')
|
||||||
|
|
||||||
self.build_script_name = 'SConstruct'
|
self.build_script_name = 'SConstruct'
|
||||||
self.build_readme_name = 'build.readme'
|
self.build_readme_name = 'build.readme'
|
||||||
|
|||||||
@@ -20,32 +20,53 @@ from scripts.linux.build_rootfs import *
|
|||||||
from pack import *
|
from pack import *
|
||||||
from packall import *
|
from packall import *
|
||||||
|
|
||||||
def build_container(container):
|
def build_linux_container(projpaths, container):
|
||||||
if container.type == "linux":
|
linux_builder = LinuxBuilder(projpaths, container)
|
||||||
linux_builder = LinuxBuilder(projpaths, container)
|
linux_builder.build_linux()
|
||||||
linux_builder.build_linux()
|
rootfs_builder = RootfsBuilder(projpaths, container)
|
||||||
rootfs_builder = RootfsBuilder(projpaths, container)
|
rootfs_builder.build_rootfs()
|
||||||
rootfs_builder.build_rootfs()
|
linux_container_packer = LinuxContainerPacker(container, \
|
||||||
linux_container_packer = LinuxContainerPacker(container, \
|
linux_builder, \
|
||||||
linux_builder, \
|
rootfs_builder)
|
||||||
rootfs_builder)
|
return linux_container_packer.pack_container()
|
||||||
return linux_container_packer.pack_container()
|
|
||||||
|
|
||||||
|
def glob_by_walk(arg, dirname, names):
|
||||||
|
ext, imglist = arg
|
||||||
|
files = glob.glob(join(dirname, ext))
|
||||||
|
imglist.extend(files)
|
||||||
|
|
||||||
|
|
||||||
|
# This simply calls SCons on a given container, and collects
|
||||||
|
# all images with .elf extension, instead of using whole classes
|
||||||
|
# for building and packing.
|
||||||
|
def build_default_container(projpaths, container):
|
||||||
|
images = []
|
||||||
|
cwd = os.getcwd()
|
||||||
|
projdir = join(join(PROJROOT, 'conts'), container.name)
|
||||||
|
os.chdir(projdir)
|
||||||
|
os.system("scons")
|
||||||
|
os.path.walk(projdir, glob_by_walk, ['*.elf', images])
|
||||||
|
container_packer = DefaultContainerPacker(container, images)
|
||||||
|
return container_packer.pack_container()
|
||||||
|
|
||||||
else:
|
|
||||||
print "Error: Don't know how to build " + \
|
|
||||||
"container of type: %s" % (container.type)
|
|
||||||
Exit(1)
|
|
||||||
|
|
||||||
def build_all_containers():
|
def build_all_containers():
|
||||||
container_images = []
|
|
||||||
|
|
||||||
config = configuration_retrieve()
|
config = configuration_retrieve()
|
||||||
|
|
||||||
# config.config_print()
|
cont_images = []
|
||||||
for container in config.containers:
|
for container in config.containers:
|
||||||
container_images.append(build_container(container))
|
if container.type == 'linux':
|
||||||
|
pass
|
||||||
|
#cont_images.append(build_linux_container(projpaths, container))
|
||||||
|
elif container.type == 'bare':
|
||||||
|
cont_images.append(build_default_container(projpaths, container))
|
||||||
|
else:
|
||||||
|
print "Error: Don't know how to build " + \
|
||||||
|
"container of type: %s" % (container.type)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
all_cont_packer = AllContainerPacker(container_images, config.containers)
|
all_cont_packer = AllContainerPacker(cont_images, config.containers)
|
||||||
|
|
||||||
return all_cont_packer.pack_all()
|
return all_cont_packer.pack_all()
|
||||||
|
|
||||||
|
|||||||
@@ -111,3 +111,63 @@ class LinuxContainerPacker:
|
|||||||
if os.path.exists(self.container_S_out):
|
if os.path.exists(self.container_S_out):
|
||||||
shutil.rmtree(self.container_S_out)
|
shutil.rmtree(self.container_S_out)
|
||||||
|
|
||||||
|
|
||||||
|
class DefaultContainerPacker:
|
||||||
|
def __init__(self, container, images_in):
|
||||||
|
|
||||||
|
# Here, we simply attempt to get PROJROOT/conts as
|
||||||
|
# PROJROOT/build/cont[0-9]
|
||||||
|
self.CONTAINER_BUILDDIR_BASE = \
|
||||||
|
source_to_builddir(join(PROJROOT,'conts'), container.id)
|
||||||
|
|
||||||
|
if not os.path.exists(self.CONTAINER_BUILDDIR_BASE):
|
||||||
|
os.mkdir(self.CONTAINER_BUILDDIR_BASE)
|
||||||
|
|
||||||
|
self.container_lds_out = join(self.CONTAINER_BUILDDIR_BASE, \
|
||||||
|
'container.lds')
|
||||||
|
self.container_S_out = join(self.CONTAINER_BUILDDIR_BASE, 'container.S')
|
||||||
|
self.container_elf_out = join(self.CONTAINER_BUILDDIR_BASE, \
|
||||||
|
'container' + str(container.id) + '.elf')
|
||||||
|
self.images_in = images_in
|
||||||
|
|
||||||
|
def generate_container_assembler(self, source):
|
||||||
|
with open(self.container_S_out, 'w+') as f:
|
||||||
|
file_body = ""
|
||||||
|
img_i = 0
|
||||||
|
for img in source:
|
||||||
|
file_body += container_assembler_body % (img_i, img)
|
||||||
|
img_i += 1
|
||||||
|
|
||||||
|
f.write(file_body)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def generate_container_lds(self, source):
|
||||||
|
with open(self.container_lds_out, 'w+') as f:
|
||||||
|
img_i = 0
|
||||||
|
file_body = container_lds_start
|
||||||
|
for img in source:
|
||||||
|
file_body += container_lds_body % (img_i, img_i)
|
||||||
|
img_i += 1
|
||||||
|
file_body += container_lds_end
|
||||||
|
f.write(file_body)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def pack_container(self):
|
||||||
|
self.generate_container_lds(self.images_in)
|
||||||
|
self.generate_container_assembler(self.images_in)
|
||||||
|
os.system("arm-none-linux-gnueabi-gcc " + "-nostdlib -o %s -T%s %s" \
|
||||||
|
% (self.container_elf_out, \
|
||||||
|
self.container_lds_out,
|
||||||
|
self.container_S_out))
|
||||||
|
# Final file is returned so that the final packer needn't
|
||||||
|
# get the packer object for this information
|
||||||
|
return self.container_elf_out
|
||||||
|
|
||||||
|
def clean(self):
|
||||||
|
if os.path.exists(self.container_elf_out):
|
||||||
|
shutil.rmtree(self.container_elf_out)
|
||||||
|
if os.path.exists(self.container_lds_out):
|
||||||
|
shutil.rmtree(self.container_lds_out)
|
||||||
|
if os.path.exists(self.container_S_out):
|
||||||
|
shutil.rmtree(self.container_S_out)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user