Commit d5bb8670 authored by Bruno Gomes's avatar Bruno Gomes

Configurator: v4.2 released

- Configuring enviroment now enquires user for which POS to add
- Configurator now accepts a pre-configured configurator file config as argument using -f or --cfg

refs #201957
parent 4c6f2346
......@@ -19,7 +19,6 @@ import subprocess
__OS_CONFIG_FILE__ = os.path.join(air.ROOT_DIRECTORY, '.air_config')
AIR_POS = os.path.join(air.CONFIGURATOR_DIRECTORY, 'air', 'pos')
AIR_TARGETS = os.path.join(air.CONFIGURATOR_DIRECTORY, 'air', 'targets')
AIR_LIBRARIES = os.path.join(air.CONFIGURATOR_DIRECTORY, 'air', 'libraries')
......@@ -88,35 +87,8 @@ def get_available_libraries():
return libs
def get_available_pos():
pos = {}
# Prompt to install RTOS
opts = ['No', 'Yes']
promptx = 'Install All RTOS ?'
all_rtos = terminalutils.promptActions(promptx, opts)
pos_names = [x for x in os.listdir(AIR_POS)
if os.path.isdir(os.path.join(AIR_POS, x)) and x != 'shared']
for pos_name in pos_names:
try:
i = 0
if all_rtos == 0:
promptx = 'Install ' + pos_name + '?'
i = terminalutils.promptActions(promptx, opts)
if i == 1 or all_rtos == 1:
pos_path = os.path.join(AIR_POS, pos_name, 'config.py')
module = imp.load_source(pos_name, pos_path)
module.path = pos_path
pos[module.name.lower()] = module
except IOError:
logging.warning ('Missing AIR POS : %s, name: %s', pos_path, pos_name)
pass
return pos
supported_architectures = {}
available_libraries = {}
available_pos = {}
##
# @brief Class to hold the AIR OS current configuration
......@@ -127,7 +99,7 @@ class Configuration(object):
# @param self object pointer
# @param arch target architecture
# @param bsp target board support package
def __init__(self, arch, bsp, fpu_enabled, cache_init):
def __init__(self, arch, bsp, fpu_enabled, cache_init, pos_select):
self.arch = arch.lower()
self.bsp = bsp.lower()
......@@ -138,16 +110,17 @@ class Configuration(object):
# get supported pos
self.supported_pos = {}
for pos in available_pos:
pos = available_pos[pos]
if not hasattr(pos, 'supported_libraries'):
pos.supported_libraries = []
if self.arch in pos.source_files and \
self.arch in pos.private_header_files and self.arch in pos.public_header_files:
self.supported_pos[pos.name.lower()] = pos
if pos.alias is not None:
for alias in pos.alias:
self.supported_pos[alias.lower()] = pos
for pos in pos_select:
pos_path = os.path.join(air.POS_DIRECTORY, pos, 'config.py')
module = imp.load_source(pos, pos_path)
if not hasattr(module, 'supported_libraries'):
module.supported_libraries = []
if self.arch in module.source_files and \
self.arch in module.private_header_files and self.arch in module.public_header_files:
self.supported_pos[pos] = module
if module.alias is not None:
for alias in module.alias:
self.supported_pos[alias.lower()] = module
# get supported libraries
self.supported_libraries = {}
......@@ -157,16 +130,16 @@ class Configuration(object):
if lib.requires_pos is not None:
for pos_name in lib.requires_pos:
try:
pos = self.supported_pos[pos_name]
pos.supported_libraries.append(lib.name)
module = self.supported_pos[pos_name]
module.supported_libraries.append(lib.name)
supported = True
except Exception:
logging.warning ('the library: %s is not installed because %s is missing', lib.name, pos_name)
pass
else:
for pos_name in self.supported_pos:
pos = self.supported_pos[pos_name]
self.supported_pos[pos_name].supported_libraries.append(lib.name)
module = self.supported_pos[pos_name]
module.supported_libraries.append(lib.name)
supported = True
if supported:
......@@ -174,9 +147,9 @@ class Configuration(object):
# clear duplicates in partition library list
for pos_name in self.supported_pos:
pos = self.supported_pos[pos_name]
if pos.alias is None or pos_name not in pos.alias:
pos.supported_libraries = list(set(pos.supported_libraries))
module = self.supported_pos[pos_name]
if module.alias is None or pos_name not in module.alias:
module.supported_libraries = list(set(module.supported_libraries))
##
# @brief Check if a POS is supported
......@@ -561,10 +534,14 @@ class Configuration(object):
# @param os_configuration OS configuration object pointer
# @param logger logger to report errors
def save_configuration(os_configuration, logger):
#save only the pos names
savepos = []
for pos in os_configuration.supported_pos:
savepos.append(os_configuration.supported_pos[pos].name.lower())
try:
fd = open(__OS_CONFIG_FILE__, 'w+')
pickle.dump((os_configuration.arch, os_configuration.bsp, os_configuration.fpu_enabled, os_configuration.cache_init), fd)
pickle.dump((os_configuration.arch, os_configuration.bsp, os_configuration.fpu_enabled, os_configuration.cache_init, savepos), fd)
fd.close()
except Exception, why:
......@@ -574,17 +551,17 @@ def save_configuration(os_configuration, logger):
# @brief Loads the OS configuration from the build directory
# @param logger logger to report errors
# @return OS configuration object pointer
def load_configuration(logger):
def load_configuration(logger, config=__OS_CONFIG_FILE__):
# sanity check
if not os.path.isfile(__OS_CONFIG_FILE__):
logger.error("Error POS config file is missing ", __OS_CONFIG_FILE__)
if not os.path.isfile(config):
logger.error("Error POS config file is missing ", config)
return None
# try to load the configuration
try:
fd = open(__OS_CONFIG_FILE__, 'r')
arch, bsp, fpu_enabled, cache_init = pickle.load(fd)
os_configuration = Configuration(arch, bsp, fpu_enabled, cache_init)
fd = open(config, 'r')
arch, bsp, fpu_enabled, cache_init, pos_select = pickle.load(fd)
os_configuration = Configuration(arch, bsp, fpu_enabled, cache_init, pos_select)
fd.close()
return os_configuration
except:
......
......@@ -17,7 +17,7 @@ name = "posixrtems5"
description = "POSIXRTEMS-5"
# @brief OS alias
alias = ['rtems5']
alias = ['posixrtems5']
# @brief Supported git checkout id
git_id = "6bb9b3df7b5ea97e151d39654092c060d2175045"
......
......@@ -24,6 +24,9 @@ PGM=$(EXEC)
# IO Manager = io
MANAGERS=sem rtmon msg timer io
MODULES := $(sort $(dir $(wildcard ./*/*.c)))
BUILD_DIR := $(addprefix o-optimize/,$(MODULES))
# C source code and headers filenames used in the example
CSRCS=$(shell find ./ -type f -name '*.c')
CHDRS=$(shell find ./ -type f -name '*.h')
......@@ -47,7 +50,7 @@ $(AIR_LIBS)/${libname.lower()}/${libname.lower()}.a${'\\' if i < len(partition.l
# The RTEMS_MAKEFILE_PATH is defined by the user for the specific CPU and BSP
RTEMS_MAKEFILE_PATH=$(AIR_POS)/${os.path.join('rtems5', 'rtems5-install', 'sparc-rtems5', 'leon3')}
# These includes should not be modified by the user.
# These includes should not be modified by the user.
include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
include $(RTEMS_CUSTOM)
include $(PROJECT_ROOT)/make/leaf.cfg
......@@ -65,7 +68,10 @@ LDFLAGS += -Wl,--gc-sections -Wl,--wrap=printf -Wl,--wrap=puts -Wl,--wrap=putcha
OBJS = $(COBJS) $(ASOBJS)
all: $(ARCH) $(PGM)
all: $(ARCH) $(BUILD_DIR) $(PGM)
$(PGM): $(OBJS) $(CHDRS)
${'\t'}$(make-exe)
$(BUILD_DIR):
${'\t'}@mkdir -p $@
#!/usr/bin/python
# =============================================================================
# Copyright (C) GMVIS Skysoft S.A., 2014
# Copyright (C) GMVIS Skysoft S.A., 2014-2019
# =============================================================================
# This file is part of the AIR Operating System configuration sub-system.
# The license and distribution terms for this file may be found in the file
......@@ -22,8 +22,7 @@ from utils.logger import Logger
from localization.common import *
from argparse import ArgumentParser, RawTextHelpFormatter
__version__ = '4.1'
__copyright__ = 'Copyright (C) GMVIS Skysoft S.A., 2018'
__version__ = '4.2'
__author__ = 'dtms, llgg, gmvs, lumm, pfnf'
__app__ = os.path.basename(__file__)
......@@ -48,7 +47,6 @@ if __name__ == "__main__":
# get available architectures
air_configuration.supported_architectures = air_configuration.get_available_targets()
air_configuration.available_libraries = air_configuration.get_available_libraries()
air_configuration.available_pos = air_configuration.get_available_pos()
# check if we are configuring AIR or a partition
if air.WORKING_DIRECTORY == air.ROOT_DIRECTORY:
......
AIR_CONFIG_WELCOME = [ ' AIR Configurator v{0}', ' Copyright (C) GMVIS Skysoft S.A., 2018' ]
AIR_CONFIG_WELCOME = [ ' AIR Configurator v{0}', ' Copyright (C) GMVIS Skysoft S.A., 2019' ]
IOP_CONFIG_WELCOME = [ ' IOP Configurator v{0}', ' Copyright (C) GMVIS Skysoft S.A., 2017' ]
AIR_DESCRIPTION = 'Tool to configure an AIR application'
......@@ -70,4 +70,4 @@ AIR_ERROR_NO_FILES = 'No AIR configuration file found in the current directo
AIR_ERROR_MANY_FILES = 'Multiple AIR configuration files found in the current directory'
IOP_ERROR_NO_FILES = 'No IOP configuration file found in the current directory'
IOP_ERROR_MANY_FILES = 'Multiple IOP configuration files found in the current directory'
\ No newline at end of file
IOP_ERROR_MANY_FILES = 'Multiple IOP configuration files found in the current directory'
......@@ -20,8 +20,8 @@ def InputArgs(arg_parser, logger):
arg_parser.add_argument('-i', '--info', dest='info', action='store_const', const=True,
default=False, help='Installation information')
arg_parser.add_argument('-t', '--target', dest='target', default=None,
help='Deployment target')
arg_parser.add_argument('-f', '--cfg', dest='config', default=None,
help='Insert .air_config file')
arg_parser.add_argument('-d', '--dev', dest='dev', action='store_const',
const=True, default=False, help='Development symbols')
return arg_parser.parse_args()
......@@ -53,16 +53,15 @@ def Run(args, logger):
fileutils.setHardcodedFiles()
# parse input args or prompt the user for configuration
if args.target is None:
arch, bsp, fpu_enabled, cache_init = prompt_configuration(logger)
if args.config is None:
arch, bsp, fpu_enabled, cache_init, pos = prompt_configuration(logger)
# create the OS configuration object
os_configuration = air_configuration.Configuration(arch, bsp, fpu_enabled, cache_init, pos)
else:
arch, bsp, fpu_enabled, cache_init = input_configuration(args.target, logger)
# create the OS configuration object
os_configuration = air_configuration.Configuration(arch, bsp, fpu_enabled, cache_init)
os_configuration = input_configuration(logger, args.config)
logger.event(0, 'Configuring AIR OS:')
logger.information(1, 'Target: {0} - {1}\n'.format(arch.upper(), bsp))
logger.information(1, 'Target: {0} - {1}\n'.format(os_configuration.arch.upper(), os_configuration.bsp))
# template lookup directories
template_includes = \
......@@ -191,39 +190,36 @@ def prompt_configuration(logger):
else:
cache_init = 0
return arch, bsp, fpu_enabled, cache_init
def input_configuration(target, logger):
try:
# get the current target
args = target.split('-', 1)
arch = args[0]; bsp = args[1]; fpu_flag = args[2];
# check if target is supported
if arch not in air_configuration.supported_architectures.keys() or \
bsp not in air_configuration.supported_architectures[arch].keys():
logger.error("Unsupported target: '{0}'", target)
arch = bsp = None
except:
logger.logger.exception("Exception, See details below")
# error
logger.error("Unsupported target: '{0}'", target)
arch = bsp = None
# present list of supported targets if an error occurred
if arch is None or bsp is None:
# check if arch is supported
logger.event(0, "Supported targets:")
for arch in air_configuration.supported_architectures.keys():
for bsp in air_configuration.supported_architectures[arch].keys():
logger.information(1, '{0}-{1}', arch, bsp)
pos = []
# Prompt to install RTOS
opts = ['No', 'Yes']
promptx = 'Install All RTOS ?'
all_rtos = terminalutils.promptActions(promptx, opts)
pos_names = [x for x in os.listdir(air.POS_DIRECTORY)
if os.path.isdir(os.path.join(air.POS_DIRECTORY, x)) and x != 'shared']
for pos_name in pos_names:
try:
i = 0
if all_rtos == 0:
promptx = 'Install ' + pos_name + '?'
i = terminalutils.promptActions(promptx, opts)
if i == 1 or all_rtos == 1:
pos.append(pos_name)
except IOError:
logging.warning ('Missing AIR POS : %s, name: %s', pos_path, pos_name)
pass
return arch, bsp, fpu_enabled, cache_init, pos
def input_configuration(logger, config):
__CONFIG_FILE__ = os.path.join(air.ROOT_DIRECTORY, config)
if not os.path.isfile(__CONFIG_FILE__):
logger.error("Error config file is missing ", __CONFIG_FILE__)
sys.exit(-1)
return arch, bsp, fpu_flag
os_configuration = air_configuration.load_configuration(logger, __CONFIG_FILE__)
return os_configuration
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment