Changes since April

Clean up of build directories.
Simplifications to capability model.
This commit is contained in:
Bahadir Balban
2010-06-01 15:08:13 +03:00
parent aef14b55ec
commit 6fa4884a5a
450 changed files with 10449 additions and 7383 deletions

View File

@@ -11,44 +11,41 @@ from tools.pyelf.elfsize import *
from tools.pyelf.elf_section_info import *
PROJRELROOT = '../../'
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
sys.path.append(os.path.abspath("../"))
from config.projpaths import *
from config.configuration import *
from scripts.config.projpaths import *
from scripts.config.configuration import *
from scripts.linux.build_linux import *
from scripts.linux.build_rootfs import *
from scripts.linux.build_atags import *
from pack import *
from packall import *
from scripts.baremetal.baremetal_generator import *
def fill_pager_section_markers(cont, pager_binary):
cont.pager_rw_section_start, cont.pager_rw_section_end, \
cont.pager_rx_section_start, cont.pager_rx_section_end = \
elf_loadable_section_info(join(PROJROOT, pager_binary))
cont.pager_rw_pheader_start, cont.pager_rw_pheader_end, \
cont.pager_rx_pheader_start, cont.pager_rx_pheader_end = \
elf_loadable_section_info(join(PROJROOT, pager_binary))
def build_linux_container(config, projpaths, container):
linux_builder = LinuxBuilder(projpaths, container)
linux_builder.build_linux(config)
def build_linux_container(config, projpaths, container, opts):
linux_builder = LinuxBuilder(projpaths, container, opts)
linux_builder.build_linux(config, opts)
rootfs_builder = RootfsBuilder(projpaths, container)
rootfs_builder.build_rootfs(config)
atags_builder = AtagsBuilder(projpaths, container)
atags_builder.build_atags(config)
os.chdir(LINUX_ROOTFSDIR)
os.system('scons cid=' + str(container.id))
os.chdir(LINUX_ATAGSDIR)
os.system('scons cid=' + str(container.id))
# Calculate and store size of pager
pager_binary = \
join(BUILDDIR, "cont" + str(container.id) +
"/linux/linux-2.6.33/linux.elf")
"/linux/kernel-2.6.34/linux.elf")
config.containers[container.id].pager_size = \
conv_hex(elf_binary_size(pager_binary))
fill_pager_section_markers(config.containers[container.id], pager_binary)
linux_container_packer = \
LinuxContainerPacker(container, linux_builder, \
rootfs_builder, atags_builder)
linux_container_packer = LinuxContainerPacker(container, linux_builder)
return linux_container_packer.pack_container(config)
def glob_by_walk(arg, dirname, names):
@@ -67,12 +64,12 @@ def source_to_builddir(srcdir, id):
# This is very similar to examples container builder:
# In fact this notion may become a standard convention for
# calling specific bare containers
def build_posix_container(config, projpaths, container):
def build_posix_container(config, projpaths, container, opts):
images = []
cwd = os.getcwd()
os.chdir(POSIXDIR)
print '\nBuilding Posix Container %d...' % container.id
scons_cmd = 'scons ' + 'cont=' + str(container.id)
scons_cmd = 'scons ' + 'cont=' + str(container.id) + ' -j ' + opts.jobs
#print "Issuing scons command: %s" % scons_cmd
os.system(scons_cmd)
builddir = source_to_builddir(POSIXDIR, container.id)
@@ -93,16 +90,27 @@ def build_posix_container(config, projpaths, container):
# 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(config, projpaths, container):
def build_default_container(config, projpaths, container, opts):
images = []
cwd = os.getcwd()
projdir = join(join(PROJROOT, 'conts'), container.name)
builddir = join(join(BUILDDIR, 'cont') + str(container.id), container.name)
if container.duplicate == 0:
projdir = join(join(PROJROOT, 'conts/baremetal'), container.dirname)
else:
projdir = join(join(PROJROOT, 'conts'), container.name)
BaremetalContGenerator().baremetal_container_generate(config)
if not os.path.exists(builddir):
os.mkdir(builddir)
os.chdir(projdir)
os.system("scons")
os.path.walk(projdir, glob_by_walk, ['*.elf', images])
os.system("scons -j " + opts.jobs + " cid=" + str(container.id))
os.path.walk(builddir, glob_by_walk, ['*.elf', images])
# Calculate and store size of pager
pager_binary = join(PROJROOT, "conts/" + container.name + "/main.elf")
pager_binary = join(builddir, "main.elf")
config.containers[container.id].pager_size = \
conv_hex(elf_binary_size(pager_binary))
@@ -111,17 +119,16 @@ def build_default_container(config, projpaths, container):
container_packer = DefaultContainerPacker(container, images)
return container_packer.pack_container(config)
def build_all_containers():
def build_all_containers(opts):
config = configuration_retrieve()
cont_images = []
for container in config.containers:
if container.type == 'linux':
pass
cont_images.append(build_linux_container(config, projpaths, container))
cont_images.append(build_linux_container(config, projpaths, container, opts))
elif container.type == 'baremetal':
cont_images.append(build_default_container(config, projpaths, container))
cont_images.append(build_default_container(config, projpaths, container, opts))
elif container.type == 'posix':
cont_images.append(build_posix_container(config, projpaths, container))
cont_images.append(build_posix_container(config, projpaths, container, opts))
else:
print "Error: Don't know how to build " + \
"container of type: %s" % (container.type)
@@ -131,6 +138,56 @@ def build_all_containers():
return all_cont_packer.pack_all(config)
# Clean containers
def clean_all_containers():
config = configuration_retrieve()
for container in config.containers:
if container.type == 'linux':
linux_builder = LinuxBuilder(projpaths, container, None)
linux_builder.clean(config)
os.chdir(LINUX_ROOTFSDIR)
os.system('scons -c cid=' + str(container.id))
os.chdir(LINUX_ATAGSDIR)
os.system('scons -c cid=' + str(container.id))
LinuxContainerPacker(container, linux_builder).clean()
elif container.type == 'baremetal':
builddir = join(join(BUILDDIR, 'cont') + str(container.id), container.name)
if container.duplicate == 0:
projdir = join(join(PROJROOT, 'conts/baremetal'), container.dirname)
else:
projdir = join(join(PROJROOT, 'conts'), container.name)
os.chdir(projdir)
os.system("scons -c cid=" + str(container.id))
BaremetalContGenerator().baremetal_del_dynamic_files(container)
DefaultContainerPacker(container, None).clean()
elif container.type == 'posix':
os.chdir(POSIXDIR)
scons_cmd = 'scons -c ' + 'cont=' + str(container.id)
os.system(scons_cmd)
DefaultContainerPacker(container, None).clean()
else:
print "Error: Don't know how to build " + \
"container of type: %s" % (container.type)
exit(1)
# Clean packed containers elf
all_cont_packer = AllContainerPacker(None, None)
all_cont_packer.clean()
return None
def find_container_from_cid(cid):
config = configuration_retrieve()
for container in config.containers:
if cid == container.id:
return container
return None
if __name__ == "__main__":
build_all_containers()

View File

@@ -9,12 +9,11 @@ import os, sys, shelve, glob
from os.path import join
PROJRELROOT = '../../'
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
sys.path.append(os.path.abspath('../'))
from config.projpaths import *
from config.configuration import *
from scripts.config.projpaths import *
from scripts.config.configuration import *
container_assembler_body = \
'''
@@ -53,7 +52,7 @@ def source_to_builddir(srcdir, id):
return join(BUILDDIR, cont_builddir)
class LinuxContainerPacker:
def __init__(self, container, linux_builder, rootfs_builder, atags_builder):
def __init__(self, container, linux_builder):
# Here, we simply attempt to get PROJROOT/conts as
# PROJROOT/build/cont[0-9]
@@ -65,9 +64,10 @@ class LinuxContainerPacker:
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.kernel_image_in = linux_builder.kernel_image
self.rootfs_elf_in = rootfs_builder.rootfs_elf_out
self.atags_elf_in = atags_builder.atags_elf_out
self.rootfs_elf_in = join(self.CONTAINER_BUILDDIR_BASE, 'linux/rootfs/rootfs.elf')
self.atags_elf_in = join(self.CONTAINER_BUILDDIR_BASE, 'linux/atags/atags.elf')
def generate_container_assembler(self, source):
with open(self.container_S_out, 'w+') as f:
@@ -104,12 +104,9 @@ class LinuxContainerPacker:
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)
os.system('rm -rf ' + self.container_elf_out)
os.system('rm -rf ' + self.container_lds_out)
os.system('rm -rf ' + self.container_S_out)
class DefaultContainerPacker:
@@ -118,7 +115,7 @@ class DefaultContainerPacker:
# 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)
join(source_to_builddir(join(PROJROOT,'conts'), container.id), 'packer')
if not os.path.exists(self.CONTAINER_BUILDDIR_BASE):
os.mkdir(self.CONTAINER_BUILDDIR_BASE)
@@ -163,10 +160,7 @@ class DefaultContainerPacker:
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)
os.system('rm -f ' + self.container_elf_out)
os.system('rm -f ' + self.container_lds_out)
os.system('rm -f ' + self.container_S_out)

View File

@@ -9,12 +9,11 @@ import os, sys, shelve
from os.path import join
PROJRELROOT = '../../'
SCRIPTROOT = os.path.abspath(os.path.dirname("."))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
from config.projpaths import *
from config.configuration import *
from scripts.config.projpaths import *
from scripts.config.configuration import *
containers_assembler_body = \
'''
@@ -46,7 +45,10 @@ containers_lds_end = \
class AllContainerPacker:
def __init__(self, image_list, container_list):
self.cont_images_in = image_list
self.cont_images_in.sort()
if self.cont_images_in:
self.cont_images_in.sort()
self.containers = container_list
self.CONTAINERS_BUILDDIR = join(PROJROOT, 'build/conts')
@@ -87,12 +89,9 @@ class AllContainerPacker:
return self.containers_elf_out
def clean(self):
if os.path.exists(self.containers_elf_out):
shutil.rmtree(self.containers_elf_out)
if os.path.exists(self.containers_lds_out):
shutil.rmtree(self.containers_lds_out)
if os.path.exists(self.containers_S_out):
shutil.rmtree(self.containers_S_out)
os.system('rm -f ' + self.containers_elf_out)
os.system('rm -f ' + self.containers_lds_out)
os.system('rm -f ' + self.containers_S_out)
if __name__ == "__main__":
all_cont_packer = AllContainerPacker([], [])