f9d9e9033f85c81eede221899e942126a92a41e8
[apps/agl-service-data-persistence.git] / ll-database-binding / conf.d / app-templates / docs / dev_guide / 3_advanced_usage.md
1 # Build a widget
2
3 ## config.xml.in file
4
5 To build a widget you need a _config.xml_ file describing what is your apps and
6 how Application Framework would launch it. This repo provide a simple default
7 file _config.xml.in_ that should work for simple application without
8 interactions with others bindings.
9
10 It is recommanded that you use the sample one which is more complete. You can
11 find it at the same location under the name _config.xml.in.sample_ (stunning
12 isn't it). Just copy the sample file to your _conf.d/wgt_ directory and name it
13 _config.xml.in_, then edit it to fit your needs.
14
15 > ***CAUTION*** : The default file is only meant to be use for a
16 > simple widget app, more complicated ones which needed to export
17 > their api, or ship several app in one widget need to use the provided
18 > _config.xml.in.sample_ which had all new Application Framework
19 > features explained and examples.
20
21 ## Using cmake template macros
22
23 To leverage all cmake templates features, you have to specify ***properties***
24 on your targets. Some macros will not works without specifying which is the
25 target type.
26
27 As the type is not always specified for some custom targets, like an ***HTML5***
28 application, macros make the difference using ***LABELS*** property.
29
30 Choose between:
31
32 - **BINDING**: Shared library that be loaded by the AGL Application Framework
33 - **BINDINGV2**: Shared library that be loaded by the AGL Application Framework.
34  This has to be accompagnied with a JSON file named like the *${OUTPUT_NAME}-apidef* of
35  the target that describe the API with OpenAPI syntax (e.g: *mybinding-apidef*).
36  Or you can choose the name by setting the *CACHE* cmake variable *OPENAPI_DEF*
37  (***CAUTION***: setting a CACHE variable is needed, or set a normal variable
38  with the *PARENT_SCOPE* option to make it visible for the parent scope
39  where the target is defined) JSON file will be used to generate header file
40  using `afb-genskel` tool.
41 - **HTDOCS**: Root directory of a web app. This target has to build its
42  directory and puts its files in the ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
43 - **DATA**: Resources used by your application. This target has to build its
44  directory and puts its files in the ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
45 - **EXECUTABLE**: Entry point of your application executed by the AGL
46  Application Framework
47
48 > **TIP** you should use the prefix _afb-_ with your **BINDING* targets which
49 > stand for **Application Framework Binding**.
50
51 Example:
52
53 ```cmake
54 SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
55                 LABELS "HTDOCS"
56                 OUTPUT_NAME dist.prod
57         )
58 ```
59
60 > **NOTE**: You doesn't need to specify an **INSTALL** command for these
61 > targets. This is already handle by template and will be installed in the
62 > following path : **${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}**
63
64 ## Macro reference
65
66 ### PROJECT_TARGET_ADD
67
68 Typical usage would be to add the target to your project using macro
69 `PROJECT_TARGET_ADD` with the name of your target as parameter.
70
71 Example:
72
73 ```cmake
74 PROJECT_TARGET_ADD(low-can-demo)
75 ```
76
77 > ***NOTE***: This will make available the variable `${TARGET_NAME}`
78 > set with the specificied name. This variable will change at the next call
79 > to this macros.
80
81 ### project_subdirs_add
82
83 This macro will search in all subfolder any `CMakeLists.txt` file. If found then
84 it will be added to your project. This could be use in an hybrid application by
85 example where the binding lay in a sub directory.
86
87 Usage :
88
89 ```cmake
90 project_subdirs_add()
91 ```
92
93 You also can specify a globbing pattern as argument to filter which folders
94 will be looked for.
95
96 To filter all directories that begin with a number followed by a dash the
97 anything:
98
99 ```cmake
100 project_subdirs_add("[0-9]-*")
101 ```