Files
codezero/configure.py
Bahadir Balban 59f30a175a More progress on build scripts
Created a config directory for configuration files.
Moved all absolute path variables to a projpaths.py file
All scripts can now universally learn absolute paths via projpaths.py
Moved the config_symbols class to the configuration.py file.
Moved libs to loader since they are only referred by the loader
2009-09-12 13:42:30 +03:00

60 lines
2.1 KiB
Python
Executable File

#! /usr/bin/env python2.6
# -*- mode: python; coding: utf-8; -*-
import os, sys, shelve, shutil
from os.path import join
from config.projpaths import *
from config.configuration import *
symbols = config_symbols()
def cml2_header_to_symbols(cml2_header):
with file(cml2_header) as header_file:
for line in header_file:
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)
symbols.get_ncontainers(name, value)
def cml2_update_config_h(symbols, config_h_path):
with open(config_h_path, "a") as config_h:
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)
os.system(CML2TOOLSDIR + '/cmlconfigure.py -c -o ' + CML2_CONFIG_PROPERTIES + ' ' + CML2RULES)
os.system(TOOLSDIR + '/cml2header.py -o ' + CML2_CONFIG_H + ' -i ' + CML2_CONFIG_PROPERTIES)
if not os.path.exists("build/l4"):
os.mkdir("build/l4")
shutil.copy(CML2_CONFIG_H, CONFIG_H)
def save_configuration():
if not os.path.exists(CONFIG_SHELVE_DIR):
os.mkdir(CONFIG_SHELVE_DIR)
config_shelve = shelve.open(CONFIG_SHELVE)
config_shelve["config_symbols"] = symbols
config_shelve["arch"] = symbols.arch
config_shelve["subarch"] = symbols.subarch
config_shelve["platform"] = symbols.platform
config_shelve["all_symbols"] = symbols.all
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_update_config_h(symbols, CONFIG_H)
save_configuration()
if __name__ == "__main__":
configure_kernel(join(CML2_CONFIG_SRCDIR, "arm.cml"))