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] my_module Module handle that migh be configured
66 # @return True The module is welled configure
67 # @return False The module is Not availlable (for this target or ...)
68 def configure(target, my_module):
69  ...
70  return True

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 configure(target, my_module):
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 configure(target, my_module):
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 configure(target, my_module):
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 configure(target, my_module):
2  ...
3 
4  # add dependency of the generic C library:
5  my_module.add_depend('c')
6  # add dependency of the generic C++ library:
7  my_module.add_depend('cxx')
8  # add dependency of the generic math library:
9  my_module.add_depend('m')
10  # or other user lib:
11  my_module.add_depend('lib-name')
12 
13  ...

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

1 def configure(target, my_module):
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_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_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 configure(target, my_module):
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 configure(target, my_module):
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 configure(target, my_module):
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 configure(target, my_module):
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 configure(target, my_module):
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  # return "authors.txt"
60 
61 # Version of the library
62 # Note: this fucntion is optionnal.
63 def get_version():
64  return [0,1,"dev"]
65  # return "version.txt"
66 
67 # create the module
68 # @param[in] target reference on the Target that is currently build
69 # @param[in] my_module Module handle that migh be configured
70 # @return True The module is welled configure
71 # @return False The module is Not availlable (for this target or ...)
72 def configure(target, my_module):
73 
74  # add the file to compile:
75  my_module.add_src_file([
76  'module-name/file1.cpp',
77  'module-name/file2.cpp',
78  'module-name/file3.S'
79  ])
80 
81  my_module.add_header_file([
82  'module-name/file1.h',
83  'module-name/file2.h'
84  ])
85 
86  my_module.add_path(os.path.join(tools.get_current_path(__file__), "lib-name"))
87 
88  # add dependency of the generic C library:
89  my_module.add_depend('c')
90  # add dependency of the generic C++ library:
91  my_module.add_depend('cxx')
92  # add dependency of the generic math library:
93  my_module.add_depend('m')
94  # or other user lib:
95  my_module.add_depend([
96  'lib-name1',
97  'lib-name2'
98  ])
99 
100  # Add an optionnal dependency (set flag in CPP build if the subLib exist) ==> flag is locally set
101  my_module.add_optionnal_depend('z', ["c++", "-DLIB_NAME_BUILD_ZLIB"])
102 
103  # Add an optionnal dependency (set flag in CPP build if the subLib exist) ==> flag is exported in external upper build
104  my_module.add_optionnal_depend('z', ["c++", "-DLIB_NAME_BUILD_ZLIB"], export=True)
105 
106  # external flags:
107  my_module.add_flag('link-lib', "pthread", export=True)
108  my_module.add_flag('c++', "-DHELLO_FLAG=\"kljlkj\"", export=True)
109  # internal flags:
110  my_module.add_flag('c', "-DMODE_RELEASE")
111 
112  if target.get_mode() == "release":
113  pass
114  else:
115  pass
116 
117  if "Windows" in target.get_type():
118  pass
119  elif "MacOs" in target.get_type():
120  pass
121  elif "IOs" in target.get_type():
122  pass
123  elif "Linux" in target.get_type():
124  pass
125  elif "Android" in target.get_type():
126  pass
127 
128  # copy file in the share/binanyName/ path (no sub path)
129  my_module.copy_path('data/icon.svg')
130 
131  my_module.copy_path('data/*', 'destinationPath')
132 
133  # Return True if the module is compatible with the target or ...
134  return True

Index: