[DEV] set relative path in add path

This commit is contained in:
Edouard DUPIN 2016-10-04 22:42:54 +02:00
parent b6a5f7e539
commit 4c883f177c
4 changed files with 100 additions and 47 deletions

View File

@ -603,7 +603,7 @@ class Module:
if elem_generate["install"] == True: if elem_generate["install"] == True:
have_only_generate_file = True have_only_generate_file = True
if have_only_generate_file == True: if have_only_generate_file == True:
self.add_path(generate_path) self._add_path(generate_path)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# -- install header (do it first for extern lib and gcov better interface) -- # -- install header (do it first for extern lib and gcov better interface) --
@ -629,7 +629,7 @@ class Module:
# remove unneded files (NOT folder ...) # remove unneded files (NOT folder ...)
tools.clean_directory(include_path, copy_list) tools.clean_directory(include_path, copy_list)
# add the pat to the usable dirrectory # add the pat to the usable dirrectory
self.add_path(include_path) self._add_path(include_path)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# -- Sources compilation -- # -- Sources compilation --
@ -660,7 +660,7 @@ class Module:
if res_file["action"] == "add": if res_file["action"] == "add":
list_sub_file_needed_to_build.append(res_file["file"]) list_sub_file_needed_to_build.append(res_file["file"])
elif res_file["action"] == "path": elif res_file["action"] == "path":
self.add_path(res_file["path"], type='c') self._add_path(res_file["path"], type='c')
else: else:
debug.error("an not do action for : " + str(res_file)) debug.error("an not do action for : " + str(res_file))
except ValueError: except ValueError:
@ -689,7 +689,7 @@ class Module:
if res_file["action"] == "add": if res_file["action"] == "add":
list_sub_file_needed_to_build.append(res_file["file"]) list_sub_file_needed_to_build.append(res_file["file"])
elif res_file["action"] == "path": elif res_file["action"] == "path":
self.add_path(res_file["path"], type='c') self._add_path(res_file["path"], type='c')
else: else:
debug.error("an not do action for : " + str(res_file)) debug.error("an not do action for : " + str(res_file))
except ValueError: except ValueError:
@ -928,26 +928,26 @@ class Module:
## ##
## @brief Add a tools in dependency ## @brief Add a tools in dependency
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] list ([string,...] or string) Name(s) of the tools ## @param[in] in_list ([string,...] or string) Name(s) of the tools
## @return None ## @return None
## ##
def add_tools(self, list): def add_tools(self, in_list):
tools.list_append_to(self._tools, list, True) tools.list_append_to(self._tools, in_list, True)
## ##
## @brief Add a dependency on this module ## @brief Add a dependency on this module
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] list ([string,...] or string) Name(s) of the modules dependency ## @param[in] in_list ([string,...] or string) Name(s) of the modules dependency
## @return None ## @return None
## ##
def add_depend(self, list): def add_depend(self, in_list):
tools.list_append_to(self._depends, list, True) tools.list_append_to(self._depends, in_list, True)
## @brief deprecated ... ## @brief deprecated ...
## @return None ## @return None
def add_module_depend(self, list): def add_module_depend(self, in_list):
debug.warning("[" + self._name + "] add_module_depend is deprecated ==> use add_depend(...)") debug.warning("[" + self._name + "] add_module_depend is deprecated ==> use add_depend(...)")
self.add_depend(list) self.add_depend(in_list)
## ##
## @brief Add an optionnal dependency on this module ## @brief Add an optionnal dependency on this module
@ -971,17 +971,66 @@ class Module:
## ##
## @brief Add a path to include when build ## @brief Add a path to include when build
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] list ([string,...] or string) List of path to include ## @param[in] in_list ([string,...] or string) List of path to include (default: local path) only relative path...
## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ... ## @param[in] in_type (string) inclusion group name 'c', 'c++', 'java' ...
## @param[in] export (bool) export the include path. ## @param[in] export (bool) export the include path.
## @return None ## @return None
## ##
def add_path(self, list, type='c', export=False): def add_path(self, in_list=".", in_type='c', export=False):
if export == True: if type(in_list) == list:
tools.list_append_to_2(self._path["export"], type, list) add_list = []
for elem in in_list:
if len(elem) > 1 \
and elem[0] == '/':
# unix case
debug.warning(" add_path(" + in_list + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in / directory (only relative path) (compatibility until 2.x)")
add_list.append(elem)
elif len(elem) > 2 \
and elem[1] == ':':
# windows case :
debug.warning(" add_path(" + in_list + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in '" + elem[0] + ":' directory (only relative path) (compatibility until 2.x)")
add_list.append(elem)
if elem == ".":
add_list.append(tools.get_current_path(self._origin_file))
else:
add_list.append(os.path.join(tools.get_current_path(self._origin_file), elem))
else: else:
tools.list_append_to_2(self._path["local"], type, list) if len(in_list) > 1 \
and in_list[0] == '/':
# unix case
debug.warning(" add_path(" + in_list + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in / directory (only relative path) (compatibility until 2.x)")
add_list = in_list
elif len(in_list) > 2 \
and in_list[1] == ':':
# windows case :
debug.warning(" add_path(" + in_list + ")")
debug.warning("[" + self._name + "] Not permited to add a path that start in '" + in_list[0] + ":' directory (only relative path) (compatibility until 2.x)")
add_list = in_list
elif in_list == ".":
add_list = tools.get_current_path(self._origin_file)
else:
add_list = os.path.join(tools.get_current_path(self._origin_file), in_list)
debug.verbose("Convert path : " + str(in_list) + " in " + str(add_list))
self._add_path(add_list, in_type, export)
##
## @brief (INTERNAL API) Add a path to include when build
## @param[in] self (handle) Class handle
## @param[in] in_list ([string,...] or string) List of path to include (default: local path)
## @param[in] in_type (string) inclusion group name 'c', 'c++', 'java' ...
## @param[in] export (bool) export the include path.
## @return None
##
def _add_path(self, in_list=".", in_type='c', export=False):
if export == True:
tools.list_append_to_2(self._path["export"], in_type, in_list)
else:
tools.list_append_to_2(self._path["local"], in_type, in_list)
##
## @brief deprecated ... ## @brief deprecated ...
## @return None ## @return None
def add_export_path(self, list, type='c'): def add_export_path(self, list, type='c'):
@ -992,27 +1041,27 @@ class Module:
## @brief Add compilation flags ## @brief Add compilation flags
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ... ## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ...
## @param[in] list ([string,...] or string) List of path to include ## @param[in] in_list ([string,...] or string) List of path to include
## @param[in] export (bool) export the flat that has been requested to add if module is present. ## @param[in] export (bool) export the flat that has been requested to add if module is present.
## @return None ## @return None
## ##
def add_flag(self, type, list, export=False): def add_flag(self, type, in_list, export=False):
if export == True: if export == True:
tools.list_append_to_2(self._flags["export"], type, list) tools.list_append_to_2(self._flags["export"], type, in_list)
else: else:
tools.list_append_to_2(self._flags["local"], type, list) tools.list_append_to_2(self._flags["local"], type, in_list)
## @brief deprecated ... ## @brief deprecated ...
## @return None ## @return None
def add_export_flag(self, type, list): def add_export_flag(self, type, in_list):
debug.warning("[" + self._name + "] add_export_flag is deprecated ==> use add_flag(xxx, yyy, export=True)") debug.warning("[" + self._name + "] add_export_flag is deprecated ==> use add_flag(xxx, yyy, export=True)")
self.add_flag(type, list, export=True) self.add_flag(type, in_list, export=True)
## @brief deprecated ... ## @brief deprecated ...
## @return None ## @return None
def compile_flags(self, type, list): def compile_flags(self, type, in_list):
debug.warning("[" + self._name + "] compile_flags is deprecated ==> use add_flag(xxx, yyy)") debug.warning("[" + self._name + "] compile_flags is deprecated ==> use add_flag(xxx, yyy)")
self.add_flag(type, list) self.add_flag(type, in_list)
## ##
## @brief Set the compilation version of the ## @brief Set the compilation version of the
@ -1060,15 +1109,15 @@ class Module:
## ##
## @brief Add source file to compile ## @brief Add source file to compile
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] list ([string,...] or string) File(s) to compile ## @param[in] in_list ([string,...] or string) File(s) to compile
## @return None ## @return None
## ##
def add_src_file(self, list): def add_src_file(self, in_list):
tools.list_append_to(self._src, list, True) tools.list_append_to(self._src, in_list, True)
## ##
## @brief An an header file in the install directory ## @brief An an header file in the install directory
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] list ([string,...] or string) List of element that is needed to install ## @param[in] in_list ([string,...] or string) List of element that is needed to install
## @param[in] destination_path (string) Path to install the files (remove all the path of the file) ## @param[in] destination_path (string) Path to install the files (remove all the path of the file)
## @param[in] clip_path (string) Remove a part of the path set in the list and install data in generic include path ## @param[in] clip_path (string) Remove a part of the path set in the list and install data in generic include path
## @param[in] recursive (bool) when use regexp in file list ==> we can add recursive property ## @param[in] recursive (bool) when use regexp in file list ==> we can add recursive property
@ -1111,13 +1160,13 @@ class Module:
## ##
## @return None ## @return None
## ##
def add_header_file(self, list, destination_path=None, clip_path=None, recursive=False): def add_header_file(self, in_list, destination_path=None, clip_path=None, recursive=False):
if destination_path != None: if destination_path != None:
debug.verbose("Change destination PATH: '" + str(destination_path) + "'") debug.verbose("Change destination PATH: '" + str(destination_path) + "'")
new_list = [] new_list = []
if type(list) == str: if type(in_list) == str:
list = [list] in_list = [in_list]
for elem in list: for elem in in_list:
base = os.path.basename(elem) base = os.path.basename(elem)
if destination_path != None: if destination_path != None:
if clip_path != None: if clip_path != None:
@ -1536,12 +1585,12 @@ def list_all_module():
## ##
def list_all_module_with_desc(): def list_all_module_with_desc():
global __module_list global __module_list
tmpList = [] tmp_list = []
for mod in __module_list: for mod in __module_list:
sys.path.append(os.path.dirname(mod[1])) sys.path.append(os.path.dirname(mod[1]))
the_module = __import__(env.get_build_system_base_name() + __start_module_name + mod[0]) the_module = __import__(env.get_build_system_base_name() + __start_module_name + mod[0])
tmpList.append(get_module_option(os.path.dirname(mod[1]), the_module, mod[0])) tmp_list.append(get_module_option(os.path.dirname(mod[1]), the_module, mod[0]))
return tmpList return tmp_list
## ##

View File

@ -155,11 +155,15 @@ class System:
debug.verbose("add element :" + str(elem) + " elems=" + str(self._export_flags[elem])) debug.verbose("add element :" + str(elem) + " elems=" + str(self._export_flags[elem]))
module.add_flag(elem, self._export_flags[elem], export=True) module.add_flag(elem, self._export_flags[elem], export=True)
# add module dependency # add module dependency
module.add_depend(self._export_depends) if self._export_depends != []:
module.add_depend(self._export_depends)
# add exporting sources # add exporting sources
module.add_src_file(self._export_src) if self._export_src != []:
module.add_src_file(self._export_src)
# add export path # add export path
module.add_path(self._export_path, export=True) if self._export_path != []:
# no control on API
module._add_path(self._export_path, export=True)
# Export all actions ... # Export all actions ...
for elem in self._action_on_state: for elem in self._action_on_state:
level, name, action = self._action_on_state[elem] level, name, action = self._action_on_state[elem]

View File

@ -218,11 +218,11 @@ class Target:
## @brief Add global target flags ## @brief Add global target flags
## @param[in] self (handle) Class handle ## @param[in] self (handle) Class handle
## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ... ## @param[in] type (string) inclusion group name 'c', 'c++', 'java' ...
## @param[in] list ([string,...] or string) List of path to include ## @param[in] in_list ([string,...] or string) List of path to include
## @return None ## @return None
## ##
def add_flag(self, type, list): def add_flag(self, in_type, in_list):
tools.list_append_to_2(self.global_flags, type, list) tools.list_append_to_2(self.global_flags, in_type, in_list)
## ##
## @brief Update basic tree path positions on the build tree ## @brief Update basic tree path positions on the build tree

View File

@ -339,16 +339,16 @@ def list_append_to(out_list, in_list, order=False):
else: else:
debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list))) debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list)))
def list_append_to_2(listout, module, list, order=False): def list_append_to_2(listout, module, in_list, order=False):
# sepcial cse of bool # sepcial cse of bool
if type(list) == bool: if type(in_list) == bool:
listout[module] = list listout[module] = in_list
return return
# add list in the Map # add list in the Map
if module not in listout: if module not in listout:
listout[module] = [] listout[module] = []
# add elements... # add elements...
list_append_to(listout[module], list, order) list_append_to(listout[module], in_list, order)
## ##