Create a new Module:

Base of the module file:

To create a new module you will use a generic naming:

1 lutin_module-name.py

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:

1 #!/usr/bin/python
2 import lutin.module as module
3 import lutin.tools as tools
4 
5 # A simple list of type:
6 # - BINARY
7 # - BINARY_SHARED
8 # - BINARY_STAND_ALONE
9 # - LIBRARY
10 # - LIBRARY_DYNAMIC
11 # - LIBRARY_STATIC
12 # - PACKAGE
13 # - PREBUILD
14 # - DATA
15 def get_type():
16  return "LIBRARY"
17 
18 # simple description of the module that appear in the 'lutin -h'
19 # Note: this fucntion is optionnal.
20 def get_desc():
21  return "Ewol tool kit"
22 
23 # type of licence:
24 # "APACHE-2"
25 # "BSD-1" / "BSD-2" / "BSD-3" / "BSD-4"
26 # "GPL-1" / "GPL-2" / "GPL-3"
27 # "LGPL-1" / "LGPL-2" / "LGPL-3"
28 # PROPRIETARY
29 # ...
30 # Note: this fucntion is optionnal.
31 def get_licence():
32  return "APACHE-2"
33 
34 # type of compagny that provide the software:
35 # com : Commercial
36 # net : Network??
37 # org : Organisation
38 # gov : Governement
39 # mil : Military
40 # edu : Education
41 # pri : Private
42 # museum : ...
43 # ...
44 # Note: this fucntion is optionnal.
45 def get_compagny_type():
46  return "com"
47 
48 # Name of the compagny
49 # Note: this fucntion is optionnal.
50 def get_compagny_name():
51  return "hello-compagny"
52 
53 # People to contact if a problem appear in the build system / library
54 # Note: this fucntion is optionnal.
55 def get_maintainer():
56  return ["Mr NAME SurName <my-email@group.com>"]
57 
58 # Version of the library
59 # Note: this fucntion is optionnal.
60 def get_version():
61  return [0,9,"dev"]
62 
63 # create the module
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())
68  ...
69  return my_module

Thes it is simple to specify build for:

Create a new Module (LIBRARY):

What to change:

1 def get_type():
2  return "LIBRARY"

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:

1 def get_type():
2  return "BINARY"

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:

1 def get_type():
2  return "BINARY"
3 
4 def get_sub_type():
5  return "TEST"

or:

1 def get_type():
2  return "BINARY"
3 
4 def get_sub_type():
5  return "TOOL"

Create a new Module (DATA):

This pode permit to only copy data and no dependency with compilling system

What to change:

1 def get_type():
2  return "DATA"

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):
2  ...
3 
4  # add the file to compile:
5  my_module.add_src_file([
6  'module-name/file1.cpp',
7  'module-name/file2.cpp',
8  'module-name/file3.S'
9  ])
10 
11  ...

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):
2  ...
3 
4  my_module.add_header_file([
5  'module-name/file1.h',
6  'module-name/file2.h'
7  ])
8 
9  ...

You can add a path to your local include:

1 def create(target, module_name):
2  ...
3 
4  my_module.add_path(os.path.join(tools.get_current_path(__file__), "lib-name"))
5 
6  ...

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):
2  ...
3 
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')
10  # or other user lib:
11  my_module.add_module_depend('lib-name')
12 
13  ...

The system can have optinnal sub-library, then if you just want to add an optionnal dependency:

1 def create(target, module_name):
2  ...
3 
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"])
6 
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)
9 
10  ...

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):
2  ...
3  # external flags:
4  my_module.add_flag('link-lib', "pthread", export=True)
5  my_module.add_flag('c++', "-DHELLO_FLAG=\"kljlkj\"", export=True)
6  # internal flags:
7  my_module.add_flag('c', "-DMODE_RELEASE")
8 
9  ...

build mode (release/debug):

To add somes element dependent of the build mode:

1 def create(target, module_name):
2  ...
3 
4  if target.get_mode() == "release":
5  pass
6  else:
7  pass
8 
9  ...

build type target:

To add somes element dependent of the target type:

1 def create(target, module_name):
2  ...
3 
4  if "Windows" in target.get_type():
5  pass
6  elif "MacOs" in target.get_type():
7  pass
8  elif "IOs" in target.get_type():
9  pass
10  elif "Linux" in target.get_type():
11  pass
12  elif "Android" in target.get_type():
13  pass
14  ...

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):
2  ...
3 
4  # copy file in the share/binanyName/ path (no sub path)
5  my_module.copy_path('data/icon.svg')
6 
7  ...

Copy multiple files (change path)

1 def create(target, module_name):
2  ...
3 
4  my_module.copy_path('data/*', 'destinationPath')
5 
6  ...

display some debug to help writing code:

1 import lutin.debug as debug
2 
3 def function(...):
4 
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:

1 lutin_module-name.py

With:

1 #!/usr/bin/python
2 import lutin.module as module
3 import lutin.tools as tools
4 import lutin.debug as debug
5 import os
6 
7 # A simple list of type:
8 # - BINARY
9 # - BINARY_SHARED
10 # - BINARY_STAND_ALONE
11 # - LIBRARY
12 # - LIBRARY_DYNAMIC
13 # - LIBRARY_STATIC
14 # - PACKAGE
15 # - PREBUILD
16 # - DATA
17 def get_type():
18  return "LIBRARY"
19 
20 # simple description of the module that appear in the 'lutin -h'
21 # Note: this fucntion is optionnal.
22 def get_desc():
23  return "Descriptiuon of the PROGRAMM"
24 
25 # type of licence:
26 # "APACHE-2"
27 # "BSD-1" / "BSD-2" / "BSD-3" / "BSD-4"
28 # "GPL-1" / "GPL-2" / "GPL-3"
29 # "LGPL-1" / "LGPL-2" / "LGPL-3"
30 # PROPRIETARY
31 # ...
32 # Note: this fucntion is optionnal.
33 def get_licence():
34  return "PROPRIETARY"
35 
36 # type of compagny that provide the software:
37 # com : Commercial
38 # net : Network??
39 # org : Organisation
40 # gov : Governement
41 # mil : Military
42 # edu : Education
43 # pri : Private
44 # museum : ...
45 # ...
46 # Note: this fucntion is optionnal.
47 def get_compagny_type():
48  return "com"
49 
50 # Name of the compagny
51 # Note: this fucntion is optionnal.
52 def get_compagny_name():
53  return "hello-compagny"
54 
55 # People to contact if a problem appear in the build system / library
56 # Note: this fucntion is optionnal.
57 def get_maintainer():
58  return ["Mr NAME SurName <my-email@group.com>"]
59 
60 # Version of the library
61 # Note: this fucntion is optionnal.
62 def get_version():
63  return [0,1,"dev"]
64 
65 # create the module
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())
70 
71  # add the file to compile:
72  my_module.add_src_file([
73  'module-name/file1.cpp',
74  'module-name/file2.cpp',
75  'module-name/file3.S'
76  ])
77 
78  my_module.add_header_file([
79  'module-name/file1.h',
80  'module-name/file2.h'
81  ])
82 
83  my_module.add_path(os.path.join(tools.get_current_path(__file__), "lib-name"))
84 
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')
91  # or other user lib:
92  my_module.add_module_depend([
93  'lib-name1',
94  'lib-name2'
95  ])
96 
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"])
99 
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)
102 
103  # external flags:
104  my_module.add_flag('link-lib', "pthread", export=True)
105  my_module.add_flag('c++', "-DHELLO_FLAG=\"kljlkj\"", export=True)
106  # internal flags:
107  my_module.add_flags('c', "-DMODE_RELEASE")
108 
109  if target.get_mode() == "release":
110  pass
111  else:
112  pass
113 
114  if "Windows" in target.get_type():
115  pass
116  elif "MacOs" in target.get_type():
117  pass
118  elif "IOs" in target.get_type():
119  pass
120  elif "Linux" in target.get_type():
121  pass
122  elif "Android" in target.get_type():
123  pass
124 
125  # copy file in the share/binanyName/ path (no sub path)
126  my_module.copy_path('data/icon.svg')
127 
128  my_module.copy_path('data/*', 'destinationPath')
129 
130  return my_module

Index: