diff --git a/lutin/module.py b/lutin/module.py index 2603e0c..3fe6cc5 100644 --- a/lutin/module.py +++ b/lutin/module.py @@ -500,7 +500,7 @@ class Module: dst_path = os.path.join(include_path, file["multi-dst"]) tools.copy_anything(src_path, dst_path, - recursive=False, + recursive=file["recursive"], force_identical=True, in_list=copy_list) else: @@ -854,23 +854,99 @@ class Module: def add_src_file(self, list): tools.list_append_to(self.src, list, True) - - def add_header_file(self, list, destination_path=None): + ## + ## @brief An an header file in the install directory + ## @param[in] list List of element that is needed to install (can be a list or a simple string) + ## @param[in,optional] destination_path Path to install the files (remove all the path of the file) + ## @param[in,optional] clip_path Remove a part of the path set in the list and install data in generic include path + ## @param[in,optional] recursive when use regexp in file list ==> we can add recursive property + ## + ## @code + ## my_module.add_header_file([ + ## 'include/ewol/widget.h', + ## 'include/ewol/context/context.h', + ## ]) + ## @endcode + ## Here the user need to acces to the file wrote: #include + ## + ## We can simplify it: + ## @code + ## my_module.add_header_file([ + ## 'include/ewol/widget.h', + ## 'include/ewol/context/context.h', + ## ], + ## destination_path='ewol') + ## @endcode + ## Here the user need to acces to the file wrote: #include ==> the internal path has been removed + ## + ## An other way is: + ## @code + ## my_module.add_header_file([ + ## 'include/ewol/widget.h', + ## 'include/ewol/context/context.h', + ## ], + ## clip_path='include') + ## @endcode + ## Here the user need to acces to the file wrote: #include ==> it just remove the include data + ## + ## With a copy all methode: + ## @code + ## my_module.add_header_file( + ## 'include/*.h', + ## recursive=True) + ## @endcode + ## Here the user need to acces to the file wrote: #include ==> it just remove the include data + ## + def add_header_file(self, list, destination_path=None, clip_path=None, recursive=False): if destination_path != None: debug.verbose("Change destination PATH: '" + str(destination_path) + "'") new_list = [] for elem in list: + base = os.path.basename(elem) if destination_path != None: - base = os.path.basename(elem) - if '*' in base or '[' in base or '(' in base: + if clip_path != None: + debug.error("can not use 'destination_path' and 'clip_path' at the same time ..."); + if '*' in base \ + or '[' in base \ + or '(' in base: new_list.append({"src":elem, - "multi-dst":destination_path}) + "multi-dst":destination_path, + "recursive":recursive}) else: new_list.append({"src":elem, - "dst":os.path.join(destination_path, base)}) + "dst":os.path.join(destination_path, base), + "recursive":recursive}) else: - new_list.append({"src":elem, - "dst":elem}) + if clip_path == None: + if '*' in base \ + or '[' in base \ + or '(' in base: + new_list.append({"src":elem, + "multi-dst":"", + "recursive":recursive}) + else: + new_list.append({"src":elem, + "dst":elem, + "recursive":recursive}) + else: + if len(clip_path)>len(elem): + debug.error("can not clip a path with not the same name: '" + clip_path + "' != '" + elem + "' (size too small)") + if clip_path != elem[:len(clip_path)]: + debug.error("can not clip a path with not the same name: '" + clip_path + "' != '" + elem[:len(clip_path)] + "'") + out_elem = elem[len(clip_path):] + while len(out_elem) > 0 \ + and out_elem[0] == "/": + out_elem = out_elem[1:] + if '*' in base \ + or '[' in base \ + or '(' in base: + new_list.append({"src":elem, + "multi-dst":"", + "recursive":recursive}) + else: + new_list.append({"src":elem, + "dst":out_elem, + "recursive":recursive}) tools.list_append_to(self.header, new_list, True) def add_export_path(self, list, type='c'): diff --git a/lutin/system.py b/lutin/system.py index 5e23fda..841effc 100644 --- a/lutin/system.py +++ b/lutin/system.py @@ -28,6 +28,7 @@ class System: self.export_src=[] self.export_path=[] self.action_on_state={} + self.headers=[] def add_export_sources(self, list): tools.list_append_to(self.export_src, list) @@ -47,7 +48,13 @@ class System: self.action_on_state[name_of_state] = [[level, name, action]] else: self.action_on_state[name_of_state].append([level, name, action]) - + def add_header_file(self, list, destination_path=None, clip_path=None, recursive=False): + self.headers.append({ + "list":list, + "dst":destination_path, + "clip":clip_path, + "recursive":recursive + }) def __repr__(self): return "{lutin.System}" @@ -69,7 +76,12 @@ def create_module_from_system(target, dict): for elem in dict["system"].action_on_state: level, name, action = dict["system"].action_on_state[elem] target.add_action(elem, level, name, action) - + for elem in dict["system"].headers: + myModule.add_header_file( + elem["list"], + destination_path=elem["dst"], + clip_path=elem["clip"], + recursive=elem["recursive"]) return myModule diff --git a/lutin/target.py b/lutin/target.py index 53fce8e..912656b 100644 --- a/lutin/target.py +++ b/lutin/target.py @@ -98,6 +98,7 @@ class Target: '-D__TARGET_ADDR__' + self.select_bus + 'BITS', '-D_REENTRANT' ]) + self.add_flag("c", "-nodefaultlibs") self.add_flag("c++", "-nostdlib") self.add_flag("ar", 'rcs') diff --git a/lutin/z_system/lutinSystem_Linux_X11.py b/lutin/z_system/lutinSystem_Linux_X11.py new file mode 100644 index 0000000..baf4835 --- /dev/null +++ b/lutin/z_system/lutinSystem_Linux_X11.py @@ -0,0 +1,33 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +## +## @author Edouard DUPIN +## +## @copyright 2012, Edouard DUPIN, all right reserved +## +## @license APACHE v2.0 (see license file) +## + +from lutin import debug +from lutin import system +from lutin import tools +import os + +class System(system.System): + def __init__(self, target): + system.System.__init__(self) + # create some HELP: + self.help = "X11: Basic interface of Linux Graphic interface" + self.valid = True + # no check needed ==> just add this: + self.add_module_depend(['c']) + + self.add_header_file([ + "/usr/include/X11/*" + ], + destination_path="X11", + recursive=True) + + self.add_export_flag('link-lib', 'X11') + + diff --git a/lutin/z_system/lutinSystem_Linux_c.py b/lutin/z_system/lutinSystem_Linux_c.py new file mode 100644 index 0000000..4319a51 --- /dev/null +++ b/lutin/z_system/lutinSystem_Linux_c.py @@ -0,0 +1,95 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +## +## @author Edouard DUPIN +## +## @copyright 2012, Edouard DUPIN, all right reserved +## +## @license APACHE v2.0 (see license file) +## + +from lutin import debug +from lutin import system +from lutin import tools +import os + +class System(system.System): + def __init__(self, target): + system.System.__init__(self) + # create some HELP: + self.help = "C: Generic C library" + self.valid = True + # no check needed ==> just add this: + #self.add_export_flag("c", "-D__STDCPP_GNU__") + #self.add_export_flag("c++", "-nodefaultlibs") + + 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/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*", + ], + recursive=False) + self.add_header_file([ + "/usr/include/sys/*", + ], + destination_path="sys", + recursive=False) + self.add_header_file([ + "/usr/include/bits/*", + ], + destination_path="bits", + recursive=False) + self.add_header_file([ + "/usr/include/gnu/*", + ], + destination_path="gnu", + recursive=False) + self.add_header_file([ + "/usr/include/linux/*", + ], + destination_path="linux", + recursive=False) + self.add_header_file([ + "/usr/include/asm/*", + ], + destination_path="asm", + recursive=False) + self.add_header_file([ + "/usr/include/asm-generic/*", + ], + destination_path="asm-generic", + recursive=False) + self.add_export_flag("link-bin", "/usr/lib/crti.o") + self.add_export_flag("link-bin", "/usr/lib/crt1.o") + + diff --git a/lutin/z_system/lutinSystem_Linux_cxx.py b/lutin/z_system/lutinSystem_Linux_cxx.py index 0906fc1..78c58d2 100644 --- a/lutin/z_system/lutinSystem_Linux_cxx.py +++ b/lutin/z_system/lutinSystem_Linux_cxx.py @@ -20,8 +20,14 @@ class System(system.System): self.help = "CXX: Generic C++ library" self.valid = True # no check needed ==> just add this: + self.add_module_depend(['c']) self.add_export_flag("c++", "-D__STDCPP_GNU__") - self.add_export_flag("c++-remove", "-nostdlib") - self.add_export_flag("need-libstdc++", True) + #self.add_export_flag("c++-remove", "-nostdlib") + #self.add_export_flag("need-libstdc++", True) + + self.add_header_file([ + "/usr/include/c++/6.1.1/*" + ], + recursive=True) diff --git a/lutin/z_system/lutinSystem_Linux_m.py b/lutin/z_system/lutinSystem_Linux_m.py index a7c9383..74acad7 100644 --- a/lutin/z_system/lutinSystem_Linux_m.py +++ b/lutin/z_system/lutinSystem_Linux_m.py @@ -22,5 +22,11 @@ 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_header_file([ + "/usr/include/math.h" + ], + clip_path="/usr/include", + recursive=False) + diff --git a/lutin/z_system/lutinSystem_Linux_opengl.py b/lutin/z_system/lutinSystem_Linux_opengl.py new file mode 100644 index 0000000..cf481e9 --- /dev/null +++ b/lutin/z_system/lutinSystem_Linux_opengl.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +## +## @author Edouard DUPIN +## +## @copyright 2012, Edouard DUPIN, all right reserved +## +## @license APACHE v2.0 (see license file) +## + +from lutin import debug +from lutin import system +from lutin import tools +import os + +class System(system.System): + def __init__(self, target): + system.System.__init__(self) + # create some HELP: + self.help = "OpenGL: Generic graphic library" + self.valid = True + # no check needed ==> just add this: + self.add_module_depend([ + 'c', + 'X11' + ]) + + self.add_header_file([ + "/usr/include/GL/*" + ], + destination_path="GL", + recursive=True) + + self.add_export_flag('link-lib', 'GL') + """ + if target.name=="Linux": + + elif target.name=="Android": + my_module.add_export_flag('link-lib', "GLESv2") + elif target.name=="Windows": + my_module.add_module_depend([ + "glew" + ]) + elif target.name=="MacOs": + my_module.add_export_flag('link', [ + "-framework OpenGL"]) + elif target.name=="IOs": + my_module.add_export_flag('link', [ + "-framework OpenGLES" + ]) + """ + + diff --git a/lutin/z_system/lutinSystem_Linux_pthread.py b/lutin/z_system/lutinSystem_Linux_pthread.py new file mode 100644 index 0000000..767bfd0 --- /dev/null +++ b/lutin/z_system/lutinSystem_Linux_pthread.py @@ -0,0 +1,34 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +## +## @author Edouard DUPIN +## +## @copyright 2012, Edouard DUPIN, all right reserved +## +## @license APACHE v2.0 (see license file) +## + +from lutin import debug +from lutin import system +from lutin import tools +import os + +class System(system.System): + def __init__(self, target): + system.System.__init__(self) + # create some HELP: + self.help="pthread : Generic multithreading system\n Can be install with the package:\n - pthread-dev" + # check if the library exist: + if not os.path.isfile("/usr/include/pthread.h"): + # we did not find the library reqiested (just return) (automaticly set at false) + return; + self.valid = True + # todo : create a searcher of the presence of the library: + self.add_export_flag("link-lib", "pthread") + self.add_header_file([ + "/usr/include/sched.h", + "/usr/include/pthread.h" + ], + clip_path="/usr/include/") + + diff --git a/lutin/z_target/lutinTarget_Linux.py b/lutin/z_target/lutinTarget_Linux.py index dd62d5b..91b7214 100644 --- a/lutin/z_target/lutinTarget_Linux.py +++ b/lutin/z_target/lutinTarget_Linux.py @@ -41,6 +41,9 @@ class Target(target.Target): self.pkg_path_bin = "bin" self.pkg_path_lib = "lib" self.pkg_path_license = "license" + + self.sysroot = "--sysroot=/aDirectoryThatDoesNotExist/" + """ .local/application