mirror of
https://github.com/drasko/codezero.git
synced 2026-02-26 08:43:13 +01:00
Managed to connect container SConstruct to main one
This commit is contained in:
@@ -181,6 +181,7 @@ configuration data. 'scons -h' will then print the project help.
|
|||||||
|
|
||||||
Alias('containers', containers)
|
Alias('containers', containers)
|
||||||
baseEnvironment['targetHelpEntries']['containers'] = 'build all the containers.'
|
baseEnvironment['targetHelpEntries']['containers'] = 'build all the containers.'
|
||||||
|
#containers = []
|
||||||
|
|
||||||
########## Do the packing / create loadable ########################
|
########## Do the packing / create loadable ########################
|
||||||
|
|
||||||
|
|||||||
@@ -4,103 +4,19 @@
|
|||||||
# Copyright (C) 2009 B Labs
|
# Copyright (C) 2009 B Labs
|
||||||
#
|
#
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import shutil
|
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
linux_kernel_path = join("/opt/codezero/build/conts/linux/arch/arm/boot/compressed/vmlinux")
|
Import('environment')
|
||||||
rootfs_path = join("rootfs/rootfs.elf")
|
|
||||||
|
|
||||||
container_assembler_body = \
|
cwd = os.getcwd()
|
||||||
'''
|
|
||||||
.align 4
|
|
||||||
.section .img.%d
|
|
||||||
.incbin "%s"
|
|
||||||
'''
|
|
||||||
|
|
||||||
container_lds_start = \
|
os.chdir("/opt/codezero/conts/linux")
|
||||||
'''/*
|
|
||||||
* Autogenerated linker script that embeds each container image.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 B Labs
|
|
||||||
*/
|
|
||||||
|
|
||||||
SECTIONS
|
os.system("scons")
|
||||||
{'''
|
|
||||||
|
|
||||||
container_lds_body = \
|
image = []
|
||||||
'''
|
image.append(File("container.elf"))
|
||||||
.img.%d : { *(.img.%d) }'''
|
|
||||||
|
|
||||||
container_lds_end = \
|
os.chdir(cwd)
|
||||||
'''
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
|
|
||||||
# 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])
|
|
||||||
|
|
||||||
|
Return('image')
|
||||||
|
|||||||
Reference in New Issue
Block a user