From 8697a824beba7d52851caade345e5cf34cfcc654 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 8 Sep 2009 17:30:18 +0300 Subject: [PATCH] Managed to connect container SConstruct to main one --- SConstruct | 1 + conts/linux/SConscript | 100 ++++------------------------------------- 2 files changed, 9 insertions(+), 92 deletions(-) diff --git a/SConstruct b/SConstruct index 4bf9f19..ef45694 100644 --- a/SConstruct +++ b/SConstruct @@ -181,6 +181,7 @@ configuration data. 'scons -h' will then print the project help. Alias('containers', containers) baseEnvironment['targetHelpEntries']['containers'] = 'build all the containers.' + #containers = [] ########## Do the packing / create loadable ######################## diff --git a/conts/linux/SConscript b/conts/linux/SConscript index 71f7e9e..67b140d 100644 --- a/conts/linux/SConscript +++ b/conts/linux/SConscript @@ -4,103 +4,19 @@ # Copyright (C) 2009 B Labs # import os -import sys -import shutil from os.path import join -linux_kernel_path = join("/opt/codezero/build/conts/linux/arch/arm/boot/compressed/vmlinux") -rootfs_path = join("rootfs/rootfs.elf") +Import('environment') -container_assembler_body = \ -''' -.align 4 -.section .img.%d -.incbin "%s" -''' +cwd = os.getcwd() -container_lds_start = \ -'''/* - * Autogenerated linker script that embeds each container image. - * - * Copyright (C) 2009 B Labs - */ +os.chdir("/opt/codezero/conts/linux") -SECTIONS -{''' +os.system("scons") -container_lds_body = \ -''' - .img.%d : { *(.img.%d) }''' +image = [] +image.append(File("container.elf")) -container_lds_end = \ -''' -} -''' - -# TODO: This might be done much more elegantly and flexibly. -# -# But it makes sense to put the image finding logic to a function -# rather than hard-code it in an array at the beginning. -def collect_images(target, source, env): - cmd1 = "cp " + linux_kernel_path + " ./" - cmd2 = "cp " + rootfs_path + " ./" - os.system(cmd1) - os.system(cmd2) - os.system("echo " + cmd1) - os.system("echo " + cmd2) - - images.append("vmlinux") - images.append("rootfs.elf") - for i in images: - print i - -def generate_container_assembler(source, target, env): - f = open("container.S", "w+") - 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(source, target, env): - f = open("container.lds", "w+") - 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 build_rootfs(source, target, env): - os.chdir("./rootfs") - os.system("./build_rootfs.sh") - os.chdir("..") - -def build_linux(source, target, env): - os.system("./build_linux.sh") - -env = Environment(CC = 'arm-none-linux-gnueabi-gcc', - CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', \ - '-std=gnu99', '-Wall', '-Werror'], - LINKFLAGS = ['-nostdlib'], - PROGSUFFIX = '.elf', # The suffix to use for final executable - ENV = {'PATH' : os.environ['PATH']}, # Inherit shell path - ) -images = [] -linux_kernel = env.Command(linux_kernel_path, "linux-2.6.28.10", build_linux) -rootfs = env.Command(rootfs_path, "rootfs/rootfs.img", build_rootfs) -env.Command(["vmlinux", "rootfs.elf"], [linux_kernel_path, rootfs_path], collect_images) -container_S = env.Command("container.S", ["vmlinux", "rootfs.elf"], generate_container_assembler) -container_lds = env.Command("container.lds", ["vmlinux", "rootfs.elf"], generate_container_lds) - -env.Replace(LINKFLAGS = ['-nostdlib', '-Tcontainer.lds']) -env.Replace(PROGSUFFIX = '.elf') -objs = env.Object('container.S') -container = env.Program('container.elf', objs) -env.Depends(container, [linux_kernel, rootfs, container_S, container_lds]) +os.chdir(cwd) +Return('image')