mirror of
https://github.com/drasko/codezero.git
synced 2026-03-02 18:43:16 +01:00
Improved on option parsing help + added it to configure.py as well.
This commit is contained in:
41
build.py
41
build.py
@@ -13,47 +13,10 @@ from config.projpaths import *
|
|||||||
from config.configuration import *
|
from config.configuration import *
|
||||||
from scripts.conts import containers
|
from scripts.conts import containers
|
||||||
from configure import *
|
from configure import *
|
||||||
from optparse import OptionParser
|
from config.parse_options import *
|
||||||
from scripts.cml.generate_container_cml 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():
|
def main():
|
||||||
autogen_true = 0
|
build_parse_options()
|
||||||
usage = "usage: %prog [options] arg"
|
|
||||||
parser = OptionParser(usage)
|
|
||||||
|
|
||||||
parser.add_option("-a", "--arch", type = "string", dest = "arch",
|
|
||||||
help = "Use configuration file for architecture")
|
|
||||||
parser.add_option("-c", "--num-containers", type = "int", dest = "ncont",
|
|
||||||
help = "Maximum number of containers available in configuration")
|
|
||||||
parser.add_option("-f", "--use-file", dest = "cml_file",
|
|
||||||
help = "Supply user-defined cml file"
|
|
||||||
"(Use only if you want to override default)")
|
|
||||||
parser.add_option("-w", "--wipeout-old-config", action = "store_true",
|
|
||||||
default = False, dest = "wipeout",
|
|
||||||
help = "Wipe out existing configuration file settings")
|
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
autogen_true = len(sys.argv) > 1 or not os.path.exists(CML2_CML_FILE)
|
|
||||||
|
|
||||||
if autogen_true and not options.arch:
|
|
||||||
print "No arch supplied (-a), using `arm' as default."
|
|
||||||
options.arch = "arm"
|
|
||||||
if autogen_true and not options.ncont:
|
|
||||||
options.ncont = 4
|
|
||||||
print "Max container count not supplied (-c), using %d as default." % options.ncont
|
|
||||||
|
|
||||||
# Regenerate cml file if options are supplied or the file doesn't exist.
|
|
||||||
if autogen_true:
|
|
||||||
generate_container_cml(options.arch, options.ncont)
|
|
||||||
if options.wipeout == 1 and os.path.exists(CML2_OLDCONFIG_FILE):
|
|
||||||
print "Deleting %s" % CML2_OLDCONFIG_FILE
|
|
||||||
os.remove(CML2_OLDCONFIG_FILE)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configure
|
# Configure
|
||||||
|
|||||||
50
config/parse_options.py
Normal file
50
config/parse_options.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#! /usr/bin/env python2.6
|
||||||
|
# -*- mode: python; coding: utf-8; -*-
|
||||||
|
#
|
||||||
|
from optparse import OptionParser
|
||||||
|
import os, sys
|
||||||
|
|
||||||
|
PROJRELROOT = '../'
|
||||||
|
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELROOT)))
|
||||||
|
|
||||||
|
from scripts.cml.generate_container_cml import *
|
||||||
|
|
||||||
|
# Parse options + autogenerate cml rule file if necessary.
|
||||||
|
def build_parse_options():
|
||||||
|
autogen_true = 0
|
||||||
|
usage = "usage: %prog [options] arg"
|
||||||
|
parser = OptionParser(usage)
|
||||||
|
|
||||||
|
parser.add_option("-a", "--arch", type = "string", dest = "arch",
|
||||||
|
help = "Use configuration file for architecture")
|
||||||
|
parser.add_option("-c", "--num-containers", type = "int", dest = "ncont",
|
||||||
|
help = "Maximum number of containers that will be "
|
||||||
|
"made available in configuration")
|
||||||
|
parser.add_option("-f", "--use-file", dest = "cml_file",
|
||||||
|
help = "Supply user-defined cml file "
|
||||||
|
"(Use only if you want to override default)")
|
||||||
|
parser.add_option("-r", "--reset-old-config", action = "store_true",
|
||||||
|
default = False, dest = "reset_old_config",
|
||||||
|
help = "Reset configuration file settings "
|
||||||
|
"(If you had configured before and changing the "
|
||||||
|
"rule file, this will reset existing values to default)")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
autogen_true = len(sys.argv) > 1 or not os.path.exists(CML2_CML_FILE)
|
||||||
|
|
||||||
|
if autogen_true and not options.arch:
|
||||||
|
print "No arch supplied (-a), using `arm' as default."
|
||||||
|
options.arch = "arm"
|
||||||
|
if autogen_true and not options.ncont:
|
||||||
|
options.ncont = 4
|
||||||
|
print "Max container count not supplied (-c), using %d as default." % options.ncont
|
||||||
|
|
||||||
|
# Regenerate cml file if options are supplied or the file doesn't exist.
|
||||||
|
if autogen_true:
|
||||||
|
generate_container_cml(options.arch, options.ncont)
|
||||||
|
if options.reset_old_config == 1 and os.path.exists(CML2_OLDCONFIG_FILE):
|
||||||
|
print "Deleting %s" % CML2_OLDCONFIG_FILE
|
||||||
|
os.remove(CML2_OLDCONFIG_FILE)
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ from config.projpaths import *
|
|||||||
from config.configuration import *
|
from config.configuration import *
|
||||||
from scripts.bare.bare_generator import *
|
from scripts.bare.bare_generator import *
|
||||||
from scripts.conts.generate_kernel_cinfo import *
|
from scripts.conts.generate_kernel_cinfo import *
|
||||||
|
from config.parse_options import *
|
||||||
|
|
||||||
def cml2_header_to_symbols(cml2_header, config):
|
def cml2_header_to_symbols(cml2_header, config):
|
||||||
with file(cml2_header) as header_file:
|
with file(cml2_header) as header_file:
|
||||||
@@ -64,7 +65,6 @@ def configure_kernel(cml_file):
|
|||||||
generate_kernel_cinfo(config.containers, KERNEL_CINFO_PATH)
|
generate_kernel_cinfo(config.containers, KERNEL_CINFO_PATH)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if not os.path.exists(join(CML2_CONFIG_SRCDIR, 'out.cml')):
|
build_parse_options()
|
||||||
generate_container_cml(4)
|
|
||||||
configure_kernel(join(CML2_CONFIG_SRCDIR, "out.cml"))
|
configure_kernel(join(CML2_CONFIG_SRCDIR, "out.cml"))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user