Restrictions on naming of baremetal containers removed and we have an

automation script for integrating containers in baremetal/
This commit is contained in:
Amit Mahajan
2009-11-30 19:22:27 +05:30
parent 6e3e11d37e
commit 3caa43d756
46 changed files with 83 additions and 67 deletions

View File

@@ -128,7 +128,15 @@ default CONT%(cn)d_VIRT4_END from (CONT%(cn)d_VIRT4_START + 0x10000000)
default CONT%(cn)d_VIRT5_START from 0xe0000000 default CONT%(cn)d_VIRT5_START from 0xe0000000
default CONT%(cn)d_VIRT5_END from 0xf0000000 default CONT%(cn)d_VIRT5_END from 0xf0000000
default CONT%(cn)d_OPT_NAME from (CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : ((CONT%(cn)d_TYPE_BAREMETAL==y) ? "baremetal%(cn)d" : "posix%(cn)d") derive baremetal%(cn)d from
(CONT%(cn)d_BAREMETAL_PROJ_EMPTY==y) ? "empty%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD==y) ? "hello_world%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO==y) ? "thread_demo%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_TEST==y) ? "test%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE==y) ? "uart_service%(cn)d" :
((CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE==y) ? "timer_service%(cn)d" : "baremetal_noname%(cn)d" )))))
default CONT%(cn)d_OPT_NAME from (CONT%(cn)d_TYPE_LINUX==y) ? "linux%(cn)d" : ((CONT%(cn)d_TYPE_BAREMETAL==y) ? baremetal%(cn)d : "posix%(cn)d")
when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_default_pager_params when CONT%(cn)d_TYPE_LINUX==y suppress cont%(cn)d_default_pager_params
unless CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_posix_pager_params unless CONT%(cn)d_TYPE_POSIX==y suppress cont%(cn)d_posix_pager_params
@@ -152,22 +160,22 @@ cont%(cn)d_linux_pager_params 'Container %(cn)d Linux Pager Parameters'
cont%(cn)d_default_pager_params 'Container %(cn)d Default Pager Parameters' cont%(cn)d_default_pager_params 'Container %(cn)d Default Pager Parameters'
cont%(cn)d_posix_pager_params 'Container %(cn)d POSIX Pager Parameters' cont%(cn)d_posix_pager_params 'Container %(cn)d POSIX Pager Parameters'
cont%(cn)d_baremetal_params 'Baremetal Project' cont%(cn)d_baremetal_params 'Baremetal Project'
CONT%(cn)d_BAREMETAL_PROJ0 'Empty Project' CONT%(cn)d_BAREMETAL_PROJ_EMPTY 'Empty Project'
CONT%(cn)d_BAREMETAL_PROJ1 'Hello World' CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD 'Hello World'
CONT%(cn)d_BAREMETAL_PROJ2 'Thread Library Demo' CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO 'Thread Library Demo'
CONT%(cn)d_BAREMETAL_PROJ3 'Test Project' CONT%(cn)d_BAREMETAL_PROJ_TEST 'Test Project'
CONT%(cn)d_BAREMETAL_PROJ4 'UART Service' CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE 'UART Service'
CONT%(cn)d_BAREMETAL_PROJ5 'Timer Service' CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE 'Timer Service'
choices cont%(cn)d_baremetal_params choices cont%(cn)d_baremetal_params
CONT%(cn)d_BAREMETAL_PROJ0 CONT%(cn)d_BAREMETAL_PROJ_EMPTY
CONT%(cn)d_BAREMETAL_PROJ1 CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD
CONT%(cn)d_BAREMETAL_PROJ2 CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO
CONT%(cn)d_BAREMETAL_PROJ3 CONT%(cn)d_BAREMETAL_PROJ_TEST
CONT%(cn)d_BAREMETAL_PROJ4 CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE
CONT%(cn)d_BAREMETAL_PROJ5 CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE
default CONT%(cn)d_BAREMETAL_PROJ0 default CONT%(cn)d_BAREMETAL_PROJ_EMPTY
menu cont%(cn)d_default_pager_params menu cont%(cn)d_default_pager_params
CONT%(cn)d_PAGER_LMA@ CONT%(cn)d_PAGER_LMA@

View File

@@ -12,7 +12,6 @@ class Container:
self.name = None self.name = None
self.type = None self.type = None
self.id = id self.id = id
self.baremetal_id = 0
self.pager_lma = 0 self.pager_lma = 0
self.pager_vma = 0 self.pager_vma = 0
self.pager_size = 0 self.pager_size = 0
@@ -170,12 +169,11 @@ class configuration:
if regionid + 1 > self.containers[id].phys_regions: if regionid + 1 > self.containers[id].phys_regions:
self.containers[id].phys_regions = regionid + 1 self.containers[id].phys_regions = regionid + 1
elif param[:len("OPT_NAME")] == "OPT_NAME": elif param[:len("OPT_NAME")] == "OPT_NAME":
dirname = val[1:-1].lower() name = val[1:-1].lower()
self.containers[id].dirname = dirname self.containers[id].name = name
self.containers[id].name = dirname elif param[:len("BAREMETAL_PROJ_")] == "BAREMETAL_PROJ_":
elif param[:len("BAREMETAL_PROJ")] == "BAREMETAL_PROJ": param1 = param.split("_", 2)
param1 = param.split("_", 1) self.containers[id].dirname = param1[2].lower()
self.containers[id].baremetal_id = param1[1][-1:]
elif param[:len("CAP_")] == "CAP_": elif param[:len("CAP_")] == "CAP_":
prefix, param_rest = param.split('_', 1) prefix, param_rest = param.split('_', 1)
prepare_capability(self.containers[id], param_rest, val) prepare_capability(self.containers[id], param_rest, val)

View File

@@ -7,9 +7,14 @@
# This script should be called from project root directory # This script should be called from project root directory
# #
import os, sys, shutil, re import os, sys, shutil, re
PROJRELROOT = '../../'
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
from optparse import OptionParser from optparse import OptionParser
from os.path import join from os.path import join
from shutil import copytree from shutil import copytree
from config.projpaths import *
def parse_cmdline_options(): def parse_cmdline_options():
usage = "usage: %prog [options] arg" usage = "usage: %prog [options] arg"
@@ -19,11 +24,11 @@ def parse_cmdline_options():
dest = "addproject", help = "Add new project to baremetal projects") dest = "addproject", help = "Add new project to baremetal projects")
parser.add_option("-d", "--del", action = "store_true", default = False, parser.add_option("-d", "--del", action = "store_true", default = False,
dest = "delproject", help = "Delete existing project from baremetal projects") dest = "delproject", help = "Delete existing project from baremetal projects")
parser.add_option("--desc", type = "string", dest = "projdesc", parser.add_option("-i", "--desc", type = "string", dest = "projdesc",
help = "Description to be used for newly added project") help = "Description of new project to be added")
parser.add_option("--id", type = "int", dest = "srcid", parser.add_option("-s", "--src", type = "string", dest = "srcpath",
help = "If used with -a, Baremetal container id, to be used as source for source project\ help = "With -a, Source directory for new project to be added \
If used with -d, Baremetal container id to be deleted") With -d, Source directory of baremetal project to be deleted")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
@@ -35,21 +40,21 @@ def parse_cmdline_options():
if options.addproject: if options.addproject:
add_del = 1 add_del = 1
if not options.projdesc or not options.srcid: if not options.projdesc or not options.srcpath:
parser.error("--desc or --id missing, use -h argument for help") parser.error("--desc or --src missing, use -h argument for help")
exit() exit()
if options.delproject: if options.delproject:
add_del = 0 add_del = 0
if options.projdesc or not options.srcid: if options.projdesc or not options.srcpath:
parser.error("--desc provided or --id missing with -d, use -h argument for help") parser.error("--desc provided or --src missing with -d, use -h argument for help")
exit() exit()
return options.projdesc, options.srcid, add_del return options.projdesc, options.srcpath, add_del
def container_cml_templ_del_symbl(srcid): def container_cml_templ_del_symbl(projname):
cont_templ = "config/cml/container_ruleset.template" cont_templ = "config/cml/container_ruleset.template"
sym = "CONT%(cn)d_BAREMETAL_PROJ" + str(srcid) sym = "CONT%(cn)d_BAREMETAL_PROJ_" + projname.upper()
buffer = "" buffer = ""
with open(cont_templ, 'r') as fin: with open(cont_templ, 'r') as fin:
@@ -67,7 +72,7 @@ def container_cml_templ_del_symbl(srcid):
buffer += line buffer += line
if exist == False: if exist == False:
print "Project named baremetal" + str(srcid) + " does not exist" print "Baremetal project named " + projname + " does not exist"
exit() exit()
# Write new cont_templ # Write new cont_templ
@@ -75,18 +80,17 @@ def container_cml_templ_del_symbl(srcid):
fout.write(buffer) fout.write(buffer)
def container_cml_templ_add_symbl(projdesc): def container_cml_templ_add_symbl(projdesc, projname):
cont_templ = "config/cml/container_ruleset.template" cont_templ = "config/cml/container_ruleset.template"
pattern = re.compile("(CONT\%\(cn\)d_BAREMETAL_PROJ)([0-9]*)") pattern = re.compile("(CONT\%\(cn\)d_BAREMETAL_PROJ_)(.*)")
new_sym = "CONT%(cn)d_BAREMETAL_PROJ" baremetal_name_templ = "CONT%(cn)d_BAREMETAL_PROJ_"
new_sym = baremetal_name_templ + projname.upper()
# ID for new project
projid = -1
buffer = "" buffer = ""
with open(cont_templ, 'r') as fin: with open(cont_templ, 'r') as fin:
baremetal_sym_found = False baremetal_sym_found = False
last_baremetal_proj = ""
# Prepare buffer for new cont_templ with new project symbols added # Prepare buffer for new cont_templ with new project symbols added
for line in fin: for line in fin:
@@ -95,20 +99,20 @@ def container_cml_templ_add_symbl(projdesc):
# Find out where baremetal symbols start in cont_templ # Find out where baremetal symbols start in cont_templ
if len(parts) > 1 and re.match(pattern, parts[0]): if len(parts) > 1 and re.match(pattern, parts[0]):
baremetal_sym_found = True baremetal_sym_found = True
# Last project id in use for baremetal conts
projid = \ # Find the name of last baremetal project already present in list
int(parts[0][len("CONT%(cn)d_BAREMETAL_PROJ"):]) last_baremetal_proj = parts[0][len(baremetal_name_templ):]
# We are done with baremetal symbols, add new symbol to buffer # We are done with baremetal symbols, add new symbol to buffer
elif baremetal_sym_found == True: elif baremetal_sym_found == True:
baremetal_sym_found = False baremetal_sym_found = False
sym_def = new_sym + str(int(projid) + 1) + \ sym_def = new_sym + "\t\'" + projdesc + "\'\n"
"\t\'" + projdesc + "\'\n"
buffer += sym_def buffer += sym_def
# Search for baremetal menu and add new project symbol # Search for baremetal menu and add new project symbol
elif len(parts) == 1 and parts[0] == new_sym + str(projid): elif len(parts) == 1 and \
sym_reference = "\t" + new_sym + str(projid + 1) + "\n" parts[0] == baremetal_name_templ + last_baremetal_proj:
sym_reference = "\t" + new_sym + "\n"
line += sym_reference line += sym_reference
buffer += line buffer += line
@@ -117,38 +121,45 @@ def container_cml_templ_add_symbl(projdesc):
with open(cont_templ, 'w+') as fout: with open(cont_templ, 'w+') as fout:
fout.write(buffer) fout.write(buffer)
return projid + 1 def add_project(projdesc, srcdir, projname):
container_cml_templ_add_symbl(projdesc, projname)
def add_project(projdesc, srcid):
dest_id = container_cml_templ_add_symbl(projdesc)
baremetal_dir = "conts/baremetal" baremetal_dir = "conts/baremetal"
src_dir = join(baremetal_dir, "baremetal" + str(srcid)) dest_dir = join(baremetal_dir, projname)
dest_dir = join(baremetal_dir, "baremetal" + str(dest_id))
print "Copying source files from " + src_dir + " to " + dest_dir print "Copying source files from " + srcdir + " to " + dest_dir
shutil.copytree(src_dir, dest_dir) shutil.copytree(srcdir, dest_dir)
print "Done, New project baremetal" +str(dest_id) + \ print "Done, New baremetal project " + projname + \
" is ready to be used." " is ready to be used."
def del_project(srcid): def del_project(srcdir, projname):
container_cml_templ_del_symbl(srcid) container_cml_templ_del_symbl(projname)
baremetal_dir = "conts/baremetal" baremetal_dir = "conts/baremetal"
src_dir = join(baremetal_dir, "baremetal" + str(srcid)) src_dir = join(baremetal_dir, projname)
print "Deleting source files from " + src_dir print "Deleting source files from " + src_dir
shutil.rmtree(src_dir, "ignore_errors") shutil.rmtree(src_dir, "ignore_errors")
print "Done.." print "Done.."
def main(): def main():
projdesc, srcid, add_del = parse_cmdline_options() projdesc, srcdir, add_del = parse_cmdline_options()
# Get the base directory
projpath, projname = os.path.split(srcdir)
# Python's basename() doesnot work fine if path ends with /,
# so we need to manually correct this
if projname == "":
projpath, projname = os.path.split(projpath)
if add_del == 1: if add_del == 1:
add_project(projdesc, srcid) add_project(projdesc, srcdir, projname)
else: else:
del_project(srcid) del_project(srcdir, projname)
# Delete the config.cml file, so that user can see new projects
os.system("rm -f " + CML2_CONFIG_FILE)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@@ -49,8 +49,7 @@ class BaremetalContGenerator:
def create_baremetal_srctree(self, config, cont): def create_baremetal_srctree(self, config, cont):
# First, create the base project directory and sources # First, create the base project directory and sources
str = 'baremetal' + cont.baremetal_id shutil.copytree(join(self.BAREMETAL_PROJ_SRC_DIR, cont.dirname), self.CONT_SRC_DIR)
shutil.copytree(join(self.BAREMETAL_PROJ_SRC_DIR, str), self.CONT_SRC_DIR)
def copy_baremetal_build_desc(self, config, cont): def copy_baremetal_build_desc(self, config, cont):
id_header = '[Container ID]\n' id_header = '[Container ID]\n'
@@ -114,7 +113,7 @@ class BaremetalContGenerator:
for cont in config.containers: for cont in config.containers:
if cont.type == "baremetal": if cont.type == "baremetal":
# Determine container directory name. # Determine container directory name.
self.CONT_SRC_DIR = join(self.BAREMETAL_SRC_BASEDIR, cont.dirname.lower()) self.CONT_SRC_DIR = join(self.BAREMETAL_SRC_BASEDIR, cont.name.lower())
self.build_readme_out = join(self.CONT_SRC_DIR, self.build_readme_name) self.build_readme_out = join(self.CONT_SRC_DIR, self.build_readme_name)
self.build_desc_out = join(self.CONT_SRC_DIR, self.build_desc_name) self.build_desc_out = join(self.CONT_SRC_DIR, self.build_desc_name)
self.linker_lds_out = join(join(self.CONT_SRC_DIR, 'include'), \ self.linker_lds_out = join(join(self.CONT_SRC_DIR, 'include'), \
@@ -122,7 +121,7 @@ class BaremetalContGenerator:
self.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), \ self.container_h_out = join(join(self.CONT_SRC_DIR, 'include'), \
self.container_h_name) self.container_h_name)
if not os.path.exists(join(self.BAREMETAL_SRC_BASEDIR, cont.dirname)): if not os.path.exists(join(self.BAREMETAL_SRC_BASEDIR, cont.name)):
self.create_baremetal_sources(config, cont) self.create_baremetal_sources(config, cont)
else: else:
# Don't create new sources but update configuration # Don't create new sources but update configuration