vxKernel/configure

80 lines
2.3 KiB
Python
Executable File

#! /usr/bin/env python3
"""
Vhex kernel configuration script
"""
import os
import sys
import scripts
__HELP__ = """ usage: configure [OTPIONS ...] [ACTIONS ...]
Configuration script for the Vhex unikernel.
Actions:
board: Board hadling
<board-name> select the board as compilation target
--list,list display board list information
--info,info display a particular board information
vdso: "Fake" kernel compilation like a vDSO
--info,info display all infromation that the vdso will exposes
--generate,gen generate the fake build source (debug)
Options:
-h,--help display this message
--verbose display more information during the compilation step
--board=<board> select the board to target
--format=<target>
select the format of the library generation. You can use two format:
<> static - generate a static library
<> vdso - generate a "fake" dynamic library (default)
"""
#---
# Public
#---
def main(argv):
""" main entry of the script """
# early check
if '-h' in argv or '--help' in argv:
print(__HELP__)
sys.exit(0)
# handle vxSDK configuration
if 'VXSDK_PKG_TARGET' in os.environ:
argv.append(f"--board={os.environ['VXSDK_PKG_TARGET']}")
# default behaviour
if not argv:
print(__HELP__)
sys.exit(0)
# configure default value
kernconf = {
'VXKERNEL_ENABLE_VERBOSE' : False,
'VXKERNEL_ENABLE_MODULES' : [],
'VXKERNEL_ENABLE_DRIVERS' : [],
'VXKERNEL_TARGET_FORMAT' : 'vdso',
}
# check user arguments
for i, arg in enumerate(argv):
if arg == '--verbose':
kernconf['VXKERNEL_ENABLE_VERBOSE'] = True
elif arg.find('--board=') == 0:
scripts.select('board', kernconf, arg[8:])
elif arg.find('--format=') == 0:
scripts.select('format', kernconf, arg[9:])
elif arg in ['board', 'format']:
scripts.subcommand(arg, argv[i+1:])
else:
print(f"argument '{arg}' not recognized", file=sys.stderr)
sys.exit(84)
# generate the configuration file
return scripts.generate_confile(kernconf)
main(sys.argv[1:])