[DEV] continue proper isolation of basic c and c++ libs

This commit is contained in:
Edouard DUPIN 2016-08-09 21:09:26 +02:00
parent 7e44373f79
commit d38ecf5432
14 changed files with 220 additions and 70 deletions

View File

@ -16,12 +16,12 @@ from . import debug
def append_to_list(list_out, elem):
if type(elem) == str:
if elem not in list_out:
list_out.append(elem)
list_out.append(copy.deepcopy(elem))
else:
# mulyiple imput in the list ...
for element in elem:
if element not in list_out:
list_out.append(element)
list_out.append(copy.deepcopy(element))
@ -61,6 +61,7 @@ class HeritageList:
self.regenerate_tree()
def regenerate_tree(self):
debug.verbose("Regenerate heritage list:")
self.flags = {}
# sources list:
self.src = { 'src':[],
@ -72,30 +73,37 @@ class HeritageList:
listHeritage = self.list_heritage
self.list_heritage = []
# first step : add all lib with no dependency:
debug.extreme_verbose(" add element with no dependency:")
for herit in listHeritage:
if len(herit.depends) == 0:
self.list_heritage.append(herit)
debug.extreme_verbose(" add: " + str(herit.name))
self.list_heritage.append(copy.deepcopy(herit))
listHeritage.remove(herit)
debug.extreme_verbose(" add element with dependency:")
while len(listHeritage) > 0:
currentHeritageSize = len(listHeritage)
debug.verbose("list heritage = " + str([[x.name, x.depends] for x in listHeritage]))
debug.verbose(" list heritage = " + str([[x.name, x.depends] for x in listHeritage]))
debug.extreme_verbose(" list heritage (rest):")
for tmppp_herit in listHeritage:
debug.extreme_verbose(" elem= " + str(tmppp_herit.name) + " : " + str(tmppp_herit.depends))
# Add element only when all dependence are resolved
for herit in listHeritage:
listDependsName = [y.name for y in self.list_heritage]
if all(x in listDependsName for x in herit.depends) == True:
debug.extreme_verbose(" add: " + str(herit.name))
listHeritage.remove(herit)
self.list_heritage.append(herit)
self.list_heritage.append(copy.deepcopy(herit))
if currentHeritageSize == len(listHeritage):
debug.warning("Not resolve dependency between the library ==> can be a cyclic dependency !!!")
for herit in listHeritage:
self.list_heritage.append(herit)
self.list_heritage.append(copy.deepcopy(herit))
listHeritage = []
debug.warning("new heritage list:")
for element in self.list_heritage:
debug.warning(" " + element.name + " " + str(element.depends))
debug.verbose("new heritage list:")
debug.extreme_verbose("new heritage list:")
for element in self.list_heritage:
debug.verbose(" " + element.name + " " + str(element.depends))
debug.extreme_verbose(" " + element.name + " " + str(element.depends))
for element in reversed(self.list_heritage):
for flags in element.flags:
# get value
@ -122,15 +130,26 @@ class HeritageList:
# keep only true, if false ==> bad case ...
if self.flags[flags] < value:
self.flags[flags] = value
append_to_list(self.src['src'], element.src['src'])
append_to_list(self.src['dynamic'], element.src['dynamic'])
append_to_list(self.src['static'], element.src['static'])
for element in self.list_heritage:
debug.extreme_verbose(" elem: " + str(element.name))
debug.extreme_verbose(" Path (base): " + str(self.path))
debug.extreme_verbose(" inside: " + str(element.path))
for ppp in element.path:
value = element.path[ppp]
value = copy.deepcopy(element.path[ppp])
if ppp not in self.path:
self.path[ppp] = value
else:
append_to_list(self.path[ppp], value)
append_to_list(self.src['src'], element.src['src'])
append_to_list(self.src['dynamic'], element.src['dynamic'])
append_to_list(self.src['static'], element.src['static'])
debug.extreme_verbose("Path : " + str(self.path))
for ppp in self.path:
tmp = self.path[ppp]
self.path[ppp] = []
for iii in reversed(tmp):
self.path[ppp].append(iii)
debug.extreme_verbose("Path : " + str(self.path))
def __repr__(self):
return "{HeritageList:" + str(self.list_heritage) + "}"
@ -157,8 +176,8 @@ class heritage:
self.name = module.name
self.depends = copy.deepcopy(module.depends)
# keep reference because the flags can change in time
self.flags = module.flags["export"]
self.path = module.path["export"]
self.flags = module.flags["export"] # have no deep copy here is a feature ...
self.path = copy.deepcopy(module.path["export"])
# if the user install some header ==> they will ba autoamaticaly exported ...
if target != None:
if len(module.header) > 0:
@ -210,7 +229,7 @@ class heritage:
for flags in other.flags:
value = other.flags[flags]
if flags not in self.flags:
self.flags[flags] = value
self.flags[flags] = copy.deepcopy(value)
else:
append_to_list(self.flags[flags], value)
self.add_import_path(other.path)

View File

@ -129,6 +129,7 @@ class Module:
"ANDROID_SIGN" : True
}
self.sub_heritage_list = None
self.generate_file = []
def __repr__(self):
return "{lutin.Module:" + str(self.name) + "}"
@ -488,12 +489,34 @@ class Module:
elif self.type == 'PACKAGE':
debug.print_element("Package", self.name, "-", package_version_string)
# list of all file to copy:
copy_list={}
# ---------------------------------------------------------------------------
# -- install header (generated header files) --
# ---------------------------------------------------------------------------
generate_path = target.get_build_path_temporary_generate(self.name)
include_path = target.get_build_path_include(self.name)
have_only_generate_file = False
if len(self.generate_file) > 0:
debug.debug("install GENERATED headers ...")
for elem_generate in self.generate_file:
ret_write = tools.file_write_data(os.path.join(generate_path, elem_generate["filename"]), elem_generate["data"], only_if_new=True)
if ret_write == True:
debug.print_element("generate", self.name, "##", elem_generate["filename"])
if elem_generate["install"] == True:
dst = os.path.join(include_path, elem_generate["filename"])
copy_list[dst] = {"src":os.path.join(generate_path, elem_generate["filename"]),
"cmd_file":None,
"need_copy":False}
else:
have_only_generate_file = True
if have_only_generate_file == True:
self.add_path(generate_path)
# ---------------------------------------------------------------------------
# -- install header (do it first for extern lib and gcov better interface) --
# ---------------------------------------------------------------------------
debug.debug("install headers ...")
copy_list={}
include_path = target.get_build_path_include(self.name)
for file in self.header:
src_path = os.path.join(self.origin_path, file["src"])
if "multi-dst" in file:
@ -516,9 +539,9 @@ class Module:
# add the pat to the usable dirrectory
self.add_path(include_path)
# ----------------------------------------------------
# -- Sources compilation --
# ----------------------------------------------------
# ---------------------------------------------------------------------------
# -- Sources compilation --
# ---------------------------------------------------------------------------
if self.type != 'PREBUILD':
# build local sources in a specific order:
for extention_local in self.extention_order_build:
@ -901,6 +924,8 @@ class Module:
if destination_path != None:
debug.verbose("Change destination PATH: '" + str(destination_path) + "'")
new_list = []
if type(list) == str:
list = [list]
for elem in list:
base = os.path.basename(elem)
if destination_path != None:
@ -949,6 +974,20 @@ class Module:
"recursive":recursive})
tools.list_append_to(self.header, new_list, True)
##
## @brief Many library need to generate dynamic file configuration, use this to generat your configuration and add it in the include path
## @param[in] data_file Data of the file that is generated
## @param[in] destination_path Path where to install data
## @param[in] install_element add the file in the include path and not only in the generate path
## @note this does not rewrite the file if it is not needed
##
def add_generated_header_file(self, data_file, destination_path, install_element=False):
self.generate_file.append({
"data":data_file,
"filename":destination_path,
"install":install_element
});
def add_export_path(self, list, type='c'):
tools.list_append_to_2(self.path["export"], type, list)

View File

@ -145,6 +145,7 @@ class Target:
self.path_data="share"
self.path_doc="doc"
self.path_include="include"
self.path_temporary_generate="generate"
self.path_object="obj"
@ -362,6 +363,9 @@ class Target:
def get_build_path_include(self, binary_name):
return os.path.join(self.get_build_path(binary_name), self.path_include)
def get_build_path_temporary_generate(self, binary_name):
return os.path.join(self.get_build_path(binary_name), self.path_temporary_generate)
def get_build_file_bin(self, binary_name):
return os.path.join(self.get_build_path_bin(binary_name), binary_name + self.suffix_binary)

View File

@ -36,5 +36,8 @@ class System(system.System):
],
destination_path="dssi",
recursive=True)
self.add_module_depend([
'c'
])

View File

@ -27,6 +27,9 @@ class System(system.System):
],
destination_path="arpa",
recursive=True)
self.add_module_depend([
'c'
])

View File

@ -22,55 +22,113 @@ class System(system.System):
# no check needed ==> just add this:
#self.add_export_flag("c", "-D__STDCPP_GNU__")
#self.add_export_flag("c++", "-nodefaultlibs")
# grep "This file is part of the GNU C Library" /usr/include/*
self.add_header_file([
"/usr/include/unistd*",
"/usr/include/assert.h*",
"/usr/include/ctype.h*",
"/usr/include/errno.h*",
"/usr/include/execinfo.h*",
"/usr/include/fenv.h*",
"/usr/include/float.h*",
"/usr/include/inttypes.h*",
"/usr/include/iso646.h*",
"/usr/include/limits.h*",
"/usr/include/locale.h*",
"/usr/include/setjmp.h*",
"/usr/include/signal.h*",
"/usr/include/string.h*",
"/usr/include/strings.h*",
"/usr/include/std*",
"/usr/include/tgmath.h*",
"/usr/include/time.h*",
"/usr/include/uchar.h*",
"/usr/include/wchar.h*",
"/usr/include/wctype.h*",
"/usr/include/features.h*",
"/usr/include/xlocale.h*",
"/usr/include/endian.h*",
"/usr/include/alloca.h*",
"/usr/include/libio.h*",
"/usr/include/_G_config.h*",
"/usr/include/fcntl.h*",
"/usr/include/utime.h*",
"/usr/include/dlfcn.h*",
"/usr/include/libintl.h*",
"/usr/include/getopt.h*",
"/usr/include/dirent.h*",
"/usr/include/setjmp.h*",
"/usr/include/netdb.h*",
"/usr/include/syslog.h*",
"/usr/include/memory.h*",
"/usr/include/poll.h*",
"/usr/include/termios.h*",
"/usr/include/regex.h*",
"/usr/include/semaphore.h*",
"/usr/include/libgen.h*",
"/usr/include/ifaddrs.h*",
"/usr/include/stropts.h*",
"/usr/include/pwd.h*",
'/usr/include/aio.h',
'/usr/include/aliases.h',
'/usr/include/alloca.h',
'/usr/include/ansidecl.h',
'/usr/include/argp.h',
'/usr/include/argz.h',
'/usr/include/ar.h',
'/usr/include/assert.h',
'/usr/include/byteswap.h',
'/usr/include/complex.h',
'/usr/include/cpio.h',
'/usr/include/ctype.h',
'/usr/include/dirent.h',
'/usr/include/dlfcn.h',
'/usr/include/elf.h',
'/usr/include/endian.h',
'/usr/include/envz.h',
'/usr/include/err.h',
'/usr/include/errno.h',
'/usr/include/error.h',
'/usr/include/execinfo.h',
'/usr/include/fcntl.h',
'/usr/include/features.h',
'/usr/include/fenv.h',
'/usr/include/fmtmsg.h',
'/usr/include/fnmatch.h',
'/usr/include/fpu_control.h',
'/usr/include/fts.h',
'/usr/include/ftw.h',
'/usr/include/gconv.h',
'/usr/include/getopt.h',
'/usr/include/glob.h',
'/usr/include/gnu-versions.h',
'/usr/include/grp.h',
'/usr/include/gshadow.h',
'/usr/include/iconv.h',
'/usr/include/ieee754.h',
'/usr/include/ifaddrs.h',
'/usr/include/inttypes.h',
'/usr/include/langinfo.h',
'/usr/include/libgen.h',
'/usr/include/libintl.h',
'/usr/include/libio.h',
'/usr/include/limits.h',
'/usr/include/link.h',
'/usr/include/locale.h',
'/usr/include/malloc.h',
'/usr/include/mcheck.h',
'/usr/include/memory.h',
'/usr/include/mntent.h',
'/usr/include/monetary.h',
'/usr/include/mqueue.h',
'/usr/include/netdb.h',
'/usr/include/nl_types.h',
'/usr/include/nss.h',
'/usr/include/obstack.h',
'/usr/include/printf.h',
'/usr/include/pthread.h',
'/usr/include/pty.h',
'/usr/include/pwd.h',
'/usr/include/re_comp.h',
'/usr/include/regex.h',
'/usr/include/regexp.h',
'/usr/include/sched.h',
'/usr/include/search.h',
'/usr/include/semaphore.h',
'/usr/include/setjmp.h',
'/usr/include/sgtty.h',
'/usr/include/shadow.h',
'/usr/include/signal.h',
'/usr/include/spawn.h',
'/usr/include/stdc-predef.h',
'/usr/include/stdint.h',
'/usr/include/stdio_ext.h',
'/usr/include/stdio.h',
'/usr/include/stdlib.h',
'/usr/include/string.h',
'/usr/include/strings.h',
'/usr/include/stropts.h',
'/usr/include/tar.h',
'/usr/include/termios.h',
'/usr/include/tgmath.h',
'/usr/include/thread_db.h',
'/usr/include/time.h',
'/usr/include/uchar.h',
'/usr/include/ucontext.h',
'/usr/include/ulimit.h',
'/usr/include/unistd.h',
'/usr/include/utime.h',
'/usr/include/utmp.h',
'/usr/include/utmpx.h',
'/usr/include/values.h',
'/usr/include/wchar.h',
'/usr/include/wctype.h',
'/usr/include/wordexp.h',
'/usr/include/xlocale.h',
],
recursive=False)
destination_path="")
self.add_header_file([
'/usr/include/poll.h',
'/usr/include/unistdio.h',
'/usr/include/syslog.h',
'/usr/include/_G_config.h',
],
destination_path="")
self.add_header_file([
"/usr/include/sys/*",
],
@ -113,4 +171,3 @@ class System(system.System):
recursive=True)
self.add_export_flag("link", "-B/usr/lib")

View File

@ -21,7 +21,9 @@ class System(system.System):
self.valid = True
# no check needed ==> just add this:
self.add_module_depend([
'c'
'c',
'm',
'pthread'
])
self.add_export_flag("c++", "-D__STDCPP_GNU__")
#self.add_export_flag("c++-remove", "-nostdlib")

View File

@ -26,7 +26,8 @@ class System(system.System):
# todo : create a searcher of the presence of the library:
self.add_export_flag("link-lib", "jack")
self.add_module_depend([
'uuid'
'uuid',
'c'
])
self.add_header_file([
"/usr/include/jack/*",

View File

@ -22,6 +22,9 @@ class System(system.System):
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag("link-lib", "m")
self.add_module_depend([
'c'
])
self.add_header_file([
"/usr/include/math.h"
],

View File

@ -30,5 +30,8 @@ class System(system.System):
"/usr/include/pthread.h"
],
clip_path="/usr/include/")
self.add_module_depend([
'c'
])

View File

@ -38,6 +38,9 @@ class System(system.System):
return
self.set_version([int(version),int(version2)])
self.valid = True
self.add_module_depend([
'c'
])
# todo : create a searcher of the presence of the library:
self.add_export_flag("link-lib", [
"pulsecommon-" + version + ".0",

View File

@ -20,6 +20,9 @@ class System(system.System):
self.help="rpc : generic RPC library (developed by oracle)"
# No check ==> on the basic std libs:
self.valid = True
self.add_module_depend([
'c'
])
# todo : create a searcher of the presence of the library:
self.add_export_flag("link-lib", "rpcsvc")
self.add_header_file([

View File

@ -23,6 +23,9 @@ class System(system.System):
# we did not find the library reqiested (just return) (automaticly set at false)
return;
self.valid = True
self.add_module_depend([
'c'
])
# todo : create a searcher of the presence of the library:
self.add_export_flag("link-lib", "uuid")
self.add_header_file([

View File

@ -25,5 +25,12 @@ class System(system.System):
self.valid = True
# todo : create a searcher of the presence of the library:
self.add_export_flag("link-lib", "z")
self.add_module_depend([
'c'
])
self.add_header_file([
"/usr/include/zlib.h"
],
destination_path="")