From 6aac5332aea5ffe557fa8d2192c00884b2f672b4 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Thu, 17 Sep 2009 12:49:49 +0300 Subject: [PATCH] final.axf building from top-level build.py including containers --- build.py | 46 +++++++++++++++++++++++++++ config/configuration.py | 19 ++++++++++- configure.py | 1 + scripts/conts/containers.py | 8 +++-- scripts/conts/packall.py | 7 ++-- scripts/loader/generate_loader_asm.py | 4 --- 6 files changed, 72 insertions(+), 13 deletions(-) create mode 100755 build.py diff --git a/build.py b/build.py new file mode 100755 index 0000000..4b7aeda --- /dev/null +++ b/build.py @@ -0,0 +1,46 @@ +#! /usr/bin/env python2.6 +# -*- mode: python; coding: utf-8; -*- +# +# Top-level build script for Codezero +# +# Configures the Codezero environment, builds the kernel and userspace +# libraries, builds and packs all containers and builds the final loader +# image that contains all images. +# +import os, sys, shelve, shutil +from os.path import join +from config.projpaths import * +from config.configuration import * +from scripts.conts import containers +from configure import * + +# NOTE: +# The scripts obtain all the configuration data (a set of class +# instances) from the configuration shelve, so we don't pass +# any arguments here. + +def main(): + # + # Configure + # + configure_kernel(join(CML2_CONFIG_SRCDIR, 'arm.cml')) + + # + # Build the kernel and libl4 + # + os.chdir(PROJROOT) + os.system("scons") + + # + # Build containers + # + containers.build_all_containers() + + # + # Build libs and loader + # + os.chdir(PROJROOT) + os.system("scons -f SConstruct.loader") + +if __name__ == "__main__": + main() diff --git a/config/configuration.py b/config/configuration.py index 2aa2f2e..6ef1f08 100644 --- a/config/configuration.py +++ b/config/configuration.py @@ -1,6 +1,6 @@ #! /usr/bin/env python2.6 # -*- mode: python; coding: utf-8; -*- -import os, sys, shelve, shutil, re +import os, sys, shelve, shutil, re, string from projpaths import * class Container: @@ -108,6 +108,23 @@ class configuration: # Make sure elements in order for indexed accessing self.containers.sort() + + def containers_print(self, containers): + for c in containers: + print '\nContainer %d' % c.id + print 'Container type: %s' % string.ljust(c.type, 10) + print 'Container lma: %s' % string.ljust('%s - %s' % (c.lma_start, c.lma_end), 10) + print 'Container vma: %s' % string.ljust('%s - %s' % (c.vma_start, c.vma_end), 10) + + def config_print(self): + print 'Configuration\n' + print '-------------\n' + print 'Arch: %s' % string.ljust('%s, %s' % (self.arch, self.subarch), 16) + print 'Platform: %s' % string.ljust(self.platform, 16) + print 'Symbols:\n %s' % self.all + print 'Containers: %s' % self.ncontainers + self.containers_print(self.containers) + def configuration_save(config): if not os.path.exists(CONFIG_SHELVE_DIR): os.mkdir(CONFIG_SHELVE_DIR) diff --git a/configure.py b/configure.py index 5a1c66c..7b0bba4 100755 --- a/configure.py +++ b/configure.py @@ -44,6 +44,7 @@ def configure_kernel(cml_file): cml2_header_to_symbols(CML2_CONFIG_H, config) cml2_update_config_h(CONFIG_H, config) configuration_save(config) + #config.config_print() if __name__ == "__main__": configure_kernel(join(CML2_CONFIG_SRCDIR, "arm.cml")) diff --git a/scripts/conts/containers.py b/scripts/conts/containers.py index ee47d4e..2cea271 100755 --- a/scripts/conts/containers.py +++ b/scripts/conts/containers.py @@ -36,17 +36,19 @@ def build_container(container): "container of type: %s" % (container.type) Exit(1) -def main(): +def build_all_containers(): container_images = [] config = configuration_retrieve() + + # config.config_print() for container in config.containers: container_images.append(build_container(container)) all_cont_packer = AllContainerPacker(container_images, config.containers) - all_cont_packer.pack_all() + return all_cont_packer.pack_all() if __name__ == "__main__": - main() + build_all_containers() diff --git a/scripts/conts/packall.py b/scripts/conts/packall.py index e2fe36a..8271d3b 100755 --- a/scripts/conts/packall.py +++ b/scripts/conts/packall.py @@ -62,7 +62,6 @@ class AllContainerPacker: file_body = "" img_i = 0 for img in self.cont_images_in: - print img file_body += containers_assembler_body % (img_i, img) img_i += 1 @@ -86,10 +85,8 @@ class AllContainerPacker: self.containers_lds_out, self.containers_S_out)) -# oldwd = os.getcwd() -# os.chdir(PROJROOT) -# os.system("scons -f SConstruct.loader") -# os.chdir(oldwd) + # Return the final image to calling script + return self.containers_elf_out def clean(self): if os.path.exists(self.containers_elf_out): diff --git a/scripts/loader/generate_loader_asm.py b/scripts/loader/generate_loader_asm.py index 8bcc18c..3f57bbe 100755 --- a/scripts/loader/generate_loader_asm.py +++ b/scripts/loader/generate_loader_asm.py @@ -44,9 +44,6 @@ assembler_symbol_definition = \ ''' def generate_ksym_to_loader(target_path, source_path): - print "Source: ", source_path - print "Target: ", target_path - symbols = ['break_virtual'] with open(target_path, 'w') as asm_file: asm_file.write(ksym_header % (target_path, source_path, sys.argv[0])) @@ -76,7 +73,6 @@ def generate_image_S(target_path, images): fbody = '' with open(target_path, 'w+') as images_S: for img in images: -# print img[:-len(kern_fname)] print os.path.basename(img.path) if os.path.basename(img.path) == kern_fname: fbody += decl_sect_asm % ('.kernel', img)