mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Correct generation of include/l4/config.h
This commit is contained in:
57
configure.py
57
configure.py
@@ -11,29 +11,11 @@ CML2TOOLSDIR = join(TOOLSDIR, "cml2-tools")
|
||||
CML2RULES = join(BUILDDIR, "cml2_rules.out")
|
||||
CML2_CONFIG_PROPERTIES = join(BUILDDIR, "cml2_config.out")
|
||||
CML2_CONFIG_H = join(BUILDDIR, "cml2_config.h")
|
||||
CONFIG_H = join(BUILDDIR, "l4/config.h")
|
||||
CONFIG_H = join("include/l4/config.h")
|
||||
CONFIG_DATA_DIR = join(BUILDDIR, "configdata")
|
||||
CONFIG_DATA_FILENAME = "configuration"
|
||||
CONFIG_DATA = join(CONFIG_DATA_DIR, CONFIG_DATA_FILENAME)
|
||||
configuration = {}
|
||||
config_data = {}
|
||||
|
||||
def save_configuration(configuration):
|
||||
if not os.path.exists(CONFIG_DATA_DIR):
|
||||
os.mkdir(CONFIG_DATA_DIR)
|
||||
|
||||
config_shelve = shelve.open(CONFIG_DATA)
|
||||
config_shelve["cml2_config"] = configuration
|
||||
config_shelve.close()
|
||||
|
||||
'''
|
||||
def cml2_parse_config_symbol(name, value):
|
||||
sname, sval = line.split('=')
|
||||
if len(config_sym_pair) == 2: # This means it is a valid symbol
|
||||
cml2_parse_config_symbol(name, value)
|
||||
config, rest = name.split("_", 1)
|
||||
print symparts
|
||||
'''
|
||||
|
||||
class config_symbols:
|
||||
arch = None
|
||||
@@ -72,6 +54,10 @@ class config_symbols:
|
||||
parts = name.split("_", 3)
|
||||
self.platform = parts[2].lower()
|
||||
|
||||
# Extract number of containers
|
||||
def get_ncontainers(self, name, val):
|
||||
if name[:len("CONFIG_CONTAINERS")] == "CONFIG_CONTAINERS":
|
||||
self.ncontainers = val
|
||||
|
||||
symbols = config_symbols()
|
||||
|
||||
@@ -81,21 +67,17 @@ def cml2_header_to_symbols(cml2_header):
|
||||
pair = symbols.line_to_name_value(line)
|
||||
if pair is not None:
|
||||
name, value = pair
|
||||
symbols.get_all(name,value)
|
||||
symbols.get_arch(name,value)
|
||||
symbols.get_subarch(name,value)
|
||||
symbols.get_platform(name,value)
|
||||
print symbols.all
|
||||
print symbols.arch
|
||||
print symbols.subarch
|
||||
print symbols.platform
|
||||
symbols.get_all(name, value)
|
||||
symbols.get_arch(name, value)
|
||||
symbols.get_subarch(name, value)
|
||||
symbols.get_platform(name, value)
|
||||
symbols.get_ncontainers(name, value)
|
||||
|
||||
def cml2_update_config_h(configuration):
|
||||
config_h_path = BUILDDIR + '/l4/config.h'
|
||||
def cml2_update_config_h(symbols, config_h_path):
|
||||
with open(config_h_path, "a") as config_h:
|
||||
config_h.write("#define __ARCH__ " + configuration['ARCH'] + '\n')
|
||||
config_h.write("#define __PLATFORM__ " + configuration['PLATFORM'] + '\n')
|
||||
config_h.write("#define __SUBARCH__ " + configuration['SUBARCH'] + '\n')
|
||||
config_h.write("#define __ARCH__ " + symbols.arch + '\n')
|
||||
config_h.write("#define __PLATFORM__ " + symbols.platform + '\n')
|
||||
config_h.write("#define __SUBARCH__ " + symbols.subarch + '\n')
|
||||
|
||||
def cml2_configure(cml2_config_file):
|
||||
os.system(CML2TOOLSDIR + '/cmlcompile.py -o ' + CML2RULES + ' ' + cml2_config_file)
|
||||
@@ -105,14 +87,21 @@ def cml2_configure(cml2_config_file):
|
||||
os.mkdir("build/l4")
|
||||
shutil.copy(CML2_CONFIG_H, CONFIG_H)
|
||||
|
||||
def save_configuration(configuration):
|
||||
if not os.path.exists(CONFIG_DATA_DIR):
|
||||
os.mkdir(CONFIG_DATA_DIR)
|
||||
|
||||
config_shelve = shelve.open(CONFIG_DATA)
|
||||
config_shelve["config_symbols"] = symbols
|
||||
config_shelve.close()
|
||||
|
||||
def configure_kernel(cml_file):
|
||||
if not os.path.exists(BUILDDIR):
|
||||
os.mkdir(BUILDDIR)
|
||||
|
||||
cml2_configure(cml_file)
|
||||
cml2_header_to_symbols(CML2_CONFIG_H)
|
||||
#cml2_parse_config_data(configuration, config_data)
|
||||
#cml2_update_config_h(configuration)
|
||||
cml2_update_config_h(symbols, CONFIG_H)
|
||||
save_configuration(configuration)
|
||||
|
||||
return configuration
|
||||
|
||||
Reference in New Issue
Block a user