We now have a correctly compiling (but untested) posix container build.

This commit is contained in:
Bahadir Balban
2009-09-30 18:37:51 +03:00
parent 73225a0119
commit 748d6734c3
8 changed files with 75 additions and 25 deletions

View File

@@ -13,6 +13,7 @@ sys.path.append(PROJRELROOT)
from config.projpaths import *
from config.configuration import *
from config.lib import *
config = configuration_retrieve()
arch = config.arch
@@ -45,7 +46,7 @@ LIBPOSIX_LIBPATH = join(BUILDDIR, LIBPOSIX_RELDIR)
env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
CCFLAGS = ['-g', '-nostdlib', '-ffreestanding', \
'-std=gnu99', '-Wall', '-Werror'],
LINKFLAGS = ['-nostdlib'], \
LINKFLAGS = ['-nostdlib'],
ASFLAGS = ['-D__ASSEMBLY__'],
PROGSUFFIX = '.elf',
ENV = {'PATH' : os.environ['PATH']},
@@ -65,19 +66,19 @@ libposix = SConscript('libposix/SConscript', \
mm0_env = env.Clone()
mm0_env.Append(CPPPATH = LIBPOSIX_INCLUDE_SERVER)
mm0 = SConscript('mm0/SConscript', \
exports = { 'config' : config, 'env' : mm0_env, 'contid' : contid}, duplicate = 0, \
exports = { 'config' : config, 'env' : mm0_env, 'contid' : contid }, duplicate = 0, \
variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/mm0'))
fs0_env = env.Clone()
fs0_env.Append(CPPPATH = LIBPOSIX_INCLUDE_SERVER)
fs0 = SConscript('fs0/SConscript', \
exports = { 'config' : config, 'env' : fs0_env, 'contid' : contid}, duplicate = 0, \
exports = { 'config' : config, 'env' : fs0_env, 'contid' : contid, 'previmage' : mm0 }, duplicate = 0, \
variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/fs0'))
test0_env = env.Clone()
test0_env.Replace(CPPPATH = ['include', KERNEL_INCLUDE, LIBL4_INCLUDE, LIBMEM_INCLUDE])
test0 = SConscript('test0/SConscript', \
exports = { 'config' : config, 'environment' : test0_env, 'contid' : contid}, duplicate = 0, \
exports = { 'config' : config, 'environment' : test0_env, 'contid' : contid, 'previmage' : fs0 }, duplicate = 0, \
variant_dir = join(BUILDDIR, 'cont' + str(contid) + '/posix' + '/test0'))
images = [mm0, fs0, test0]

View File

@@ -1,17 +1,29 @@
Import('config', 'env', 'contid')
Import('config', 'env', 'previmage', 'contid')
import os, sys
arch = config.arch
sys.path.append('../../../../')
from config.lib import *
from tools.pyelf.lmanext import *
src = [Glob('*.c') + Glob('src/*.c') + Glob('src/arch/arm/*.c') + Glob('src/memfs/*.c') + Glob('src/lib/*.c')]
def generate_lma_lds(target, source, env):
with open(source[1].path, 'r') as lds_in:
with open(target[0].path, 'w+') as lds_out:
linker_script = lds_in.read()
lds_out.write(linker_script % next_available_lma(source[0].path))
lma_lds = Command('include/linker.lds', [previmage, 'include/linker.lds.in'], generate_lma_lds)
e = env.Clone()
e.Append(LIBS = 'posix')
e.Append(LINKFLAGS = ['-T' + "fs0/include/linker.lds", '-u_start'])
e.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
objs = e.Object(src)
fs0 = e.Program('fs0.elf', objs)
Depends(fs0, lma_lds)
Return('fs0')

View File

@@ -4,17 +4,9 @@
* Copyright (C) 2007 Bahadir Balban
*/
/*
* The only catch with this linker script is that everything
* is linked starting at virtual_base, and loaded starting
* at physical_base. virtual_base is the predefined region
* of virtual memory for userland applications. physical_base
* is determined at build-time, it is one of the subsequent pages
* that come after the kernel image's load area.
*/
/* USER_AREA_START, see memlayout.h */
virtual_base = 0x10000000;
physical_base = 0x8000;
physical_base = %s;
__stack = (0x20000000 - 0x1000 - 8); /* First page before env/args page */
/* INCLUDE "include/physical_base.lds" */

View File

@@ -5,6 +5,11 @@ import os, sys
arch = config.arch
sys.path.append('../../../../')
from config.lib import *
container = next((c for c in config.containers if int(c.id) == int(contid)), None)
def create_symlinks(arch):
arch_path = "include/arch"
arch_path2 ="src/arch"
@@ -15,12 +20,22 @@ def create_symlinks(arch):
os.system("rm %s" % (arch_path2))
os.system("ln -s %s %s" % ("arch-" + arch, arch_path2))
def generate_lma_lds(target, source, env):
with open(source[0].path, 'r') as lds_in:
with open(target[0].path, 'w+') as lds_out:
linker_script = lds_in.read()
lds_out.write(linker_script % conv_hex(container.pager_lma))
lma_lds = Command('include/linker.lds', 'include/linker.lds.in', generate_lma_lds)
src = [Glob('*.c') + Glob('src/*.c') + Glob('src/lib/*.c') + Glob('src/lib/elf/*.c') + Glob('src/arch/*.c')]
e = env.Clone()
e.Append(LINKFLAGS = ['-T' + "mm0/include/linker.lds", '-u_start'])
e.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
objs = e.Object(src)
mm0 = e.Program('mm0.elf', objs)
Depends(mm0, lma_lds)
Return('mm0')

View File

@@ -14,7 +14,7 @@
*/
/* INITTASK_AREA_START, see memlayout.h */
virtual_base = 0xE0000000;
physical_base = 0x8000;
physical_base = %s;
/* INCLUDE "include/physical_base.lds" */

View File

@@ -1,20 +1,33 @@
Import('config', 'environment', 'contid')
Import('config', 'environment', 'previmage', 'contid')
import os, sys
arch = config.arch
sys.path.append('../../../../')
from config.lib import *
from tools.pyelf.lmanext import *
src = [Glob('*.[cS]') + Glob('src/*.c') + Glob('src/arch/arm/*.c')]
def generate_lma_lds(target, source, env):
with open(source[1].path, 'r') as lds_in:
with open(target[0].path, 'w+') as lds_out:
linker_script = lds_in.read()
lds_out.write(linker_script % next_available_lma(source[0].path))
lma_lds = Command('include/linker.lds', [previmage, 'include/linker.lds.in'], generate_lma_lds)
env = environment.Clone()
test_env = environment.Clone()
env.Append(LIBS = ['posix', 'c-userspace'])
env.Append(LINKFLAGS = ['-T' + "test0/include/linker.lds", '-u_start'])
env.Append(LINKFLAGS = ['-T' + lma_lds[0].path, '-u_start'])
env.Append(CPPFLAGS = ' -D__USERSPACE__')
objs = env.Object(src)
test0 = env.Program('test0.elf', objs)
Depends(test0, lma_lds)
test_env.Append(LIBS = ['posix', 'c-userspace'])
test_env.Append(LINKFLAGS = ['-T' + "test0/include/test_exec_linker.lds", '-u_start'])

View File

@@ -14,7 +14,7 @@
*/
/* USER_AREA_START, see memlayout.h */
virtual_base = 0x10000000;
physical_base = 0x8000;
physical_base = %s;
__stack = (0x20000000 - 0x1000 - 8); /* First page before the env/args */
/* INCLUDE "include/physical_base.lds" */

View File

@@ -30,15 +30,32 @@ def build_linux_container(projpaths, container):
rootfs_builder)
return linux_container_packer.pack_container()
def build_posix_container(projpaths, container):
posix_builder = PosixBuilder(projpaths, container)
posix_builder.build_posix()
def glob_by_walk(arg, dirname, names):
ext, imglist = arg
files = glob.glob(join(dirname, ext))
imglist.extend(files)
def source_to_builddir(srcdir, id):
cont_builddir = \
os.path.relpath(srcdir, \
PROJROOT).replace("conts", \
"cont" + str(id))
return join(BUILDDIR, cont_builddir)
# We simply use SCons to figure all this out from container.id
# This is very similar to default container builder:
# In fact this notion may become a standard convention for
# calling specific bare containers
def build_posix_container(projpaths, container):
images = []
print '\nBuilding the Posix Container...'
scons_cmd = 'scons -f ' + join(POSIXDIR, 'SConstruct') + ' cont=' str(container.id)
print "Issuing scons command: %s" % scons_cmd
os.system(scons_cmd)
builddir = source_to_builddir(POSIXDIR, container.id)
os.path.walk(builddir, glob_by_walk, ['*.elf', images])
container_packer = DefaultContainerPacker(container, images)
return container_packer.pack_container()
# This simply calls SCons on a given container, and collects
# all images with .elf extension, instead of using whole classes