| 196 | === Adding applications using unified build tools ri:add_app(1|2) === |
| 197 | |
| 198 | The main goal of this approach to make the application loading method simpler to the end user. |
| 199 | |
| 200 | The loading of files are simplified to the ri:add_app(1|2) interface that is extensible and can support various build tools. |
| 201 | |
| 202 | Control flow details |
| 203 | {{{#!erlang |
| 204 | ri:add_app(1|2) ==> reflib_ui_router:request/2 ==> reflib_ui:add_app/3 ==> |
| 205 | ==> refcore_apploader:add_app/3 ==> refcore_confparser:parser/2 ==> refcore_$(parser):parse/2 |
| 206 | + |
| 207 | refcore_apploader:add_files $(parser) : [rebar, emakefile, erlang_mk, makefile] |
| 208 | }}} |
| 209 | |
| 210 | The confparser tries to recognize the parser primarily by the name of the file if the passed path is a regular file (rebar, Emakefile, erlang.mk, Makefile). |
| 211 | When the passed path is a directory the following priority takes place in detecting the appropriate parser : rebar, rebar.config, Emakefile, erlang.mk, Makefile. |
| 212 | See the configuration of various parsers below: |
| 213 | |
| 214 | see [#point1 Rebar Parser] |
| 215 | |
| 216 | see [#point2 Emakefile Parser] |
| 217 | |
| 218 | see [#point3 erlang_mk Parser] |
| 219 | |
| 220 | see [#point4 Makefile Parse] |
| 221 | |
| 222 | [=#point1] |
| 223 | ==== Rebar Parser ==== |
| 224 | |
| 225 | The application directory layout must follow the Rebar and OTP conventions (src, priv, include, ebin), for further details please refer to https://github.com/rebar/rebar/wiki. |
| 226 | The rebar parser reads recursively the directories and the rebar.config files. |
| 227 | The subdirectories inhert the the rebar.config options from the parent directories the rebar.config options from the actual directory may overrides them. |
| 228 | |
| 229 | |
| 230 | Interface options refcore_rebar_parser:parse/2 |
| 231 | * BaseDirectoryOrRebarPath - Application base dir or the path including the rebar.config file |
| 232 | * UserOptions - user properties [{rebar_load_tests, true}] |
| 233 | |
| 234 | The parser extracts the following options from rebar.config file: |
| 235 | * lib_dirs - additional library directories to add to the code path |
| 236 | * erl_first_files - rrlang files to compile before the rest |
| 237 | * erl_opts - erlang compiler options |
| 238 | * sub_dirs - subdirectories |
| 239 | * deps_dir - location of dependencies. |
| 240 | * deps - dependencies |
| 241 | When the user property rebar_load_tests is set to true the tests related options are also loaded: |
| 242 | * ct_dir - test SUITEs location |
| 243 | * ct_extra_params - option to pass extra parameters when launching Common Test (-dir, -include, -spec ) |
| 244 | * eunit_first_files - same as erl_first_files, but used only when running 'eunit' |
| 245 | * eunit_compile_opts - additional compile options for eunit. erl_opts is also used (-dir, -include, -spec ), |
| 246 | * qc_first_files - same as erl_first_files, but used only when running 'qc' |
| 247 | * qc_compile_opts - additional compile options for qc. erl_opts is also used (-dir, -include, -spec ) |
| 248 | |
| 249 | Further details and a more complete example of the rebar.config file is available at: https://github.com/rebar/rebar/blob/master/rebar.config.sample |
| 250 | [=#point2 ] |
| 251 | ==== Emakefile Parser ==== |
| 252 | The Emakefile Parser consults the given Emakefile and extracts the files and other information (appbase,def). |
| 253 | |
| 254 | Example Emakefile: |
| 255 | {{{#!erlang |
| 256 | {'src/hello', |
| 257 | |
| 258 | [debug_info, |
| 259 | {i,"include"}, |
| 260 | {outdir, "ebin"} |
| 261 | ] |
| 262 | |
| 263 | }. |
| 264 | |
| 265 | {'src/*', |
| 266 | [debug_info] |
| 267 | }. |
| 268 | }}} |
| 269 | |
| 270 | Further reading: http://www.erlang.org/doc/man/make.html. |
| 271 | |
| 272 | refcore_emakefile_parser:parse/2 |
| 273 | * DirectoryOrEmakefilePath - Path to the Emakefile or to the application directory |
| 274 | * _ - second argument is ignored during the Emakefile parsing. |
| 275 | [=#point3 ] |
| 276 | ==== erlang_mk Parser ==== |
| 277 | |
| 278 | Further reading: https://github.com/ninenines/erlang.mk |
| 279 | [=#point4 ] |
| 280 | ==== Makefile Parser ==== |
| 281 | Further reading: http://www.gnu.org/software/make/manual/make.html |