Base of the module file:
To create a new module you will use a generic naming:
Replace your module-name
with the delivery you want. The name can contain [a-zA-Z0-9-_] values.
In the module name you must define some values:
2 import lutin.module as module
3 import lutin.tools as tools
5 # A simple list of type:
18 # simple description of the module that appear in the 'lutin -h'
19 # Note: this fucntion is optionnal.
21 return "Ewol tool kit"
25 # "BSD-1" / "BSD-2" / "BSD-3" / "BSD-4"
26 # "GPL-1" / "GPL-2" / "GPL-3"
27 # "LGPL-1" / "LGPL-2" / "LGPL-3"
30 # Note: this fucntion is optionnal.
34 # type of compagny that provide the software:
44 # Note: this fucntion is optionnal.
45 def get_compagny_type():
48 # Name of the compagny
49 # Note: this fucntion is optionnal.
50 def get_compagny_name():
51 return "hello-compagny"
53 # People to contact if a problem appear in the build system / library
54 # Note: this fucntion is optionnal.
56 return ["Mr NAME SurName <my-email@group.com>"]
58 # Version of the library
59 # Note: this fucntion is optionnal.
64 # @param[in] target reference on the Target that is currently build
65 # @param[in] module_name Name of the module that is extract from the file name (to be generic)
66 def create(target, module_name):
67 my_module = module.Module(__file__, module_name, get_type())
Thes it is simple to specify build for:
Create a new Module (LIBRARY):
What to change:
By default the library is compile in shared and static. The binary select the mode it prefer...
You can force the library to be compile as a dll/so: LIBRARY_DYNAMIC
or a basic include lib: .a LIBRARY_STATIC
Create a new Module (BINARY):
Generic Binary:
What to change:
The Binay is compile by default target mode (note that the IOs target generate a single .so with all the library inside)
You can force the Binary to be use dynamic library when possible: BINARY_SHARED
or create a single binary with no .so depenency: BINARY_STAND_ALONE
Create a new Module (TEST-BINARY / TOOL-BINARY):
Two binary are really usefull in developpement, the tools and the test-unit, This is the reason why we specify for this 2 cases.
Add the subElement description:
or:
Create a new Module (DATA):
This pode permit to only copy data and no dependency with compilling system
What to change:
Module internal specifications:
Add file to compile:
This is simple: (you just need to specify all the file to compile)
1 def create(target, module_name):
4 # add the file to compile:
5 my_module.add_src_file([
6 'module-name/file1.cpp',
7 'module-name/file2.cpp',
Include directory & install header:
A big point to understand is that your library will be used by an other module, then it need to use headers.
The developper must isolate the external include and internal include, then lutin "install" the header and add the "install" header path to build the local library. This permit to check error inclusion directly in developpement and separate the #include "XXX.h"
and the #include <lib-xxx/XXX.h>
Add file to external include:
1 def create(target, module_name):
4 my_module.add_header_file([
You can add a path to your local include:
1 def create(target, module_name):
4 my_module.add_path(os.path.join(tools.get_current_path(__file__), "lib-name"))
Add Sub-dependency:
All library need to add at minimum of a simple library (C lib) and other if needed. To do it jus call:
1 def create(target, module_name):
4 # add dependency of the generic C library:
5 my_module.add_module_depend('c')
6 # add dependency of the generic C++ library:
7 my_module.add_module_depend('cxx')
8 # add dependency of the generic math library:
9 my_module.add_module_depend('m')
11 my_module.add_module_depend('lib-name')
The system can have optinnal sub-library, then if you just want to add an optionnal dependency:
1 def create(target, module_name):
4 # Add an optionnal dependency (set flag in CPP build if the subLib exist) ==> flag is locally set
5 my_module.add_optionnal_module_depend('z', ["c++", "-DLIB_NAME_BUILD_ZLIB"])
7 # Add an optionnal dependency (set flag in CPP build if the subLib exist) ==> flag is exported in external upper build
8 my_module.add_optionnal_module_depend('z', ["c++", "-DLIB_NAME_BUILD_ZLIB"], export=True)
Compilation adn link flags/libs:
It is possible to define local and external flags (external are set internal too):
1 def create(target, module_name):
4 my_module.add_flag('link-lib', "pthread", export=True)
5 my_module.add_flag('c++', "-DHELLO_FLAG=\"kljlkj\"", export=True)
7 my_module.add_flag('c', "-DMODE_RELEASE")
build mode (release/debug):
To add somes element dependent of the build mode:
1 def create(target, module_name):
4 if target.get_mode() == "release":
build type target:
To add somes element dependent of the target type:
1 def create(target, module_name):
4 if "Windows" in target.get_type():
6 elif "MacOs" in target.get_type():
8 elif "IOs" in target.get_type():
10 elif "Linux" in target.get_type():
12 elif "Android" in target.get_type():
The target get_type return a list of type that represent the hiararchy dependency, a simple example:
A "Debian" herited of a "Linux" then it will return ["Linux", "Debian"]
Add some data in the install path (share path):
You can install a simple file:
1 def create(target, module_name):
4 # copy file in the share/binanyName/ path (no sub path)
5 my_module.copy_path('data/icon.svg')
Copy multiple files (change path)
1 def create(target, module_name):
4 my_module.copy_path('data/*', 'destinationPath')
display some debug to help writing code:
1 import lutin.debug as debug
5 debug.error("comment that stop the build")
6 debug.warning("comment that print a simple warning")
7 debug.info("comment that print a simple information")
8 debug.debug("comment that print a simple debug")
9 debug.verbose("comment that print a simple verbose")
A Full template:
Create the file:
With:
2 import lutin.module as module
3 import lutin.tools as tools
4 import lutin.debug as debug
7 # A simple list of type:
10 # - BINARY_STAND_ALONE
20 # simple description of the module that appear in the 'lutin -h'
21 # Note: this fucntion is optionnal.
23 return "Descriptiuon of the PROGRAMM"
27 # "BSD-1" / "BSD-2" / "BSD-3" / "BSD-4"
28 # "GPL-1" / "GPL-2" / "GPL-3"
29 # "LGPL-1" / "LGPL-2" / "LGPL-3"
32 # Note: this fucntion is optionnal.
36 # type of compagny that provide the software:
46 # Note: this fucntion is optionnal.
47 def get_compagny_type():
50 # Name of the compagny
51 # Note: this fucntion is optionnal.
52 def get_compagny_name():
53 return "hello-compagny"
55 # People to contact if a problem appear in the build system / library
56 # Note: this fucntion is optionnal.
58 return ["Mr NAME SurName <my-email@group.com>"]
60 # Version of the library
61 # Note: this fucntion is optionnal.
66 # @param[in] target reference on the Target that is currently build
67 # @param[in] module_name Name of the module that is extract from the file name (to be generic)
68 def create(target, module_name):
69 my_module = module.Module(__file__, module_name, get_type())
71 # add the file to compile:
72 my_module.add_src_file([
73 'module-name/file1.cpp',
74 'module-name/file2.cpp',
78 my_module.add_header_file([
79 'module-name/file1.h',
83 my_module.add_path(os.path.join(tools.get_current_path(__file__), "lib-name"))
85 # add dependency of the generic C library:
86 my_module.add_module_depend('c')
87 # add dependency of the generic C++ library:
88 my_module.add_module_depend('cxx')
89 # add dependency of the generic math library:
90 my_module.add_module_depend('m')
92 my_module.add_module_depend([
97 # Add an optionnal dependency (set flag in CPP build if the subLib exist) ==> flag is locally set
98 my_module.add_optionnal_module_depend('z', ["c++", "-DLIB_NAME_BUILD_ZLIB"])
100 # Add an optionnal dependency (set flag in CPP build if the subLib exist) ==> flag is exported in external upper build
101 my_module.add_optionnal_module_depend('z', ["c++", "-DLIB_NAME_BUILD_ZLIB"], export=True)
104 my_module.add_flag('link-lib', "pthread", export=True)
105 my_module.add_flag('c++', "-DHELLO_FLAG=\"kljlkj\"", export=True)
107 my_module.add_flags('c', "-DMODE_RELEASE")
109 if target.get_mode() == "release":
114 if "Windows" in target.get_type():
116 elif "MacOs" in target.get_type():
118 elif "IOs" in target.get_type():
120 elif "Linux" in target.get_type():
122 elif "Android" in target.get_type():
125 # copy file in the share/binanyName/ path (no sub path)
126 my_module.copy_path('data/icon.svg')
128 my_module.copy_path('data/*', 'destinationPath')
Index: