vxKernel/scripts/configure.py

96 lines
2.7 KiB
Python

"""
Vhex kernel configuration script
"""
import os
import sys
from scripts.core.board import board_command, board_select
from scripts.core.format import format_command, format_select
from scripts.core.config_file import config_file_generate
from scripts.core.cmake import cmake_configure
__all__ = [
'configure_entry'
]
__HELP__ = """ usage: vxdev 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
--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 configure_entry(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(84)
# configure default value
kernconf = {
'VXKERNEL_ENABLE_VERBOSE' : False,
'VXKERNEL_ENABLE_MODULES' : [],
'VXKERNEL_ENABLE_DRIVERS' : [],
'VXKERNEL_TARGET_FORMAT' : 'vdso',
}
# check subcommand
if argv[0] == 'board':
sys.exit(board_command(argv[1:]))
if argv[0] == 'format':
sys.exit(format_command(argv[1:]))
# check user arguments
for arg in argv:
if arg.find('--board=') == 0:
board_select(kernconf, arg[8:])
elif arg.find('--format=') == 0:
format_select(kernconf, arg[9:])
else:
print(f"argument '{arg}' not recognized", file=sys.stderr)
sys.exit(84)
# check vxSDK validity
try:
prefix_src = os.environ['VXSDK_CURRENT_SOURCE_DIR']
prefix_build = os.environ['VXSDK_PREFIX_BUILD']
if config_file_generate(kernconf, prefix_build) == 0:
sys.exit(cmake_configure(prefix_build, prefix_src))
except KeyError:
print(
"unable to generate the configuration file, you should use the "
"vxSDK",
file=sys.stderr
)
sys.exit(84)