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_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
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_posix_pager_params 'Container %(cn)d POSIX Pager Parameters'
cont%(cn)d_baremetal_params 'Baremetal Project'
CONT%(cn)d_BAREMETAL_PROJ0 'Empty Project'
CONT%(cn)d_BAREMETAL_PROJ1 'Hello World'
CONT%(cn)d_BAREMETAL_PROJ2 'Thread Library Demo'
CONT%(cn)d_BAREMETAL_PROJ3 'Test Project'
CONT%(cn)d_BAREMETAL_PROJ4 'UART Service'
CONT%(cn)d_BAREMETAL_PROJ5 'Timer Service'
cont%(cn)d_baremetal_params 'Baremetal Project'
CONT%(cn)d_BAREMETAL_PROJ_EMPTY 'Empty Project'
CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD 'Hello World'
CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO 'Thread Library Demo'
CONT%(cn)d_BAREMETAL_PROJ_TEST 'Test Project'
CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE 'UART Service'
CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE 'Timer Service'
choices cont%(cn)d_baremetal_params
CONT%(cn)d_BAREMETAL_PROJ0
CONT%(cn)d_BAREMETAL_PROJ1
CONT%(cn)d_BAREMETAL_PROJ2
CONT%(cn)d_BAREMETAL_PROJ3
CONT%(cn)d_BAREMETAL_PROJ4
CONT%(cn)d_BAREMETAL_PROJ5
default CONT%(cn)d_BAREMETAL_PROJ0
CONT%(cn)d_BAREMETAL_PROJ_EMPTY
CONT%(cn)d_BAREMETAL_PROJ_HELLO_WORLD
CONT%(cn)d_BAREMETAL_PROJ_THREADS_DEMO
CONT%(cn)d_BAREMETAL_PROJ_TEST
CONT%(cn)d_BAREMETAL_PROJ_UART_SERVICE
CONT%(cn)d_BAREMETAL_PROJ_TIMER_SERVICE
default CONT%(cn)d_BAREMETAL_PROJ_EMPTY
menu cont%(cn)d_default_pager_params
CONT%(cn)d_PAGER_LMA@

View File

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

View File

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

View File

@@ -49,8 +49,7 @@ class BaremetalContGenerator:
def create_baremetal_srctree(self, config, cont):
# First, create the base project directory and sources
str = 'baremetal' + cont.baremetal_id
shutil.copytree(join(self.BAREMETAL_PROJ_SRC_DIR, str), self.CONT_SRC_DIR)
shutil.copytree(join(self.BAREMETAL_PROJ_SRC_DIR, cont.dirname), self.CONT_SRC_DIR)
def copy_baremetal_build_desc(self, config, cont):
id_header = '[Container ID]\n'
@@ -114,7 +113,7 @@ class BaremetalContGenerator:
for cont in config.containers:
if cont.type == "baremetal":
# 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_desc_out = join(self.CONT_SRC_DIR, self.build_desc_name)
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_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)
else:
# Don't create new sources but update configuration