5 https://git.automotivelinux.org/src/cmake-apps-module/plain/docs/dev_guide/autobuild.md?h=master
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/devguides/master/cmake-apps-module-guides-devguides-book.yml -->
12 Applications based on the AGL framework should have a
13 full build and packaging solution that is independent of the
14 [Yocto Project](https://www.yoctoproject.org) workflow.
16 You can create a script named **autobuild** to control applications
18 AGL provides a BitBake class file (`aglwgt.bbclass`) that calls the
19 **autobuild** script for all operations.
20 The class file is located at the top level of the application repository.
22 You can write the **autobuild** script using any of the following languages:
28 The script executes directly after applying a `chmod()` command.
29 The caller, which can be the `aglwgt.bbclass`, a Jenkins job, or an actual person,
30 must make the **autobuild** executable before calling it.
31 To facilitate direct execution, you need to start the script with a
32 [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) sequence:
34 * '#!/usr/bin/make -f' for Makefile format
35 * '#!/usr/bin/bash' for Bash format
37 The calling convention is similar to the convention used in `make`.
38 To pass arguments, use environment variables.
40 **NOTE:** For Bash, an evaluation of the arguments
41 sets the environment variables correctly.
43 The following format shows the generic call:
46 autobuild/agl/autobuild <command> [ARG1="value1" [ARG2="value2" ... ]]
49 The **autobuild** script can be invoked from any directory
50 with all paths considered to be relative to the
52 For makefile scripts, this is the usual behavior.
53 For Bash scripts, a `cd $(dirname $0)` command must be run at
54 the beginning of the script.
56 At build time, the following calls must be made in the following order:
58 1. Initialize the build environment (e.g if the application uses
59 `cmake` the configure step runs CMake).
62 autobuild/agl/autobuild configure CONFIGURE_ARGS="..."
65 2. Build the application (i.e. compile, link binaries, assembles javascript,
69 autobuild/agl/autobuild build BUILD_ARGS="...."
72 3. Create the widget package(s) in the specified destination path
73 prepared by the caller.
76 autobuild/agl/autobuild package PACKAGE_ARGS="..." DEST=<path-for-resulting-wgt-files>
79 4. Create the test widget package(s) in the specified destination path
80 prepared by the caller.
83 autobuild/agl/autobuild package-test PACKAGE_ARGS="..." DEST=<path-for-resulting-wgt-files>
86 5. Clean the built files by removing the result of the **autobuild** build.
89 autobuild/agl/autobuild clean CLEAN_ARGS="..."
92 6. Clean everything by removing the result of the **autobuild** build
93 and the **autobuild** configure.
96 autobuild/agl/autobuild distclean DISTCLEAN_ARGS="..."
99 ## Integrating **autobuild** into the Yocto Project Workflow
101 If you want to integrate the **autobuild** script into the Yocto Project
102 workflow, you need to generate the script.
103 To generate the script, use the `autobuild` target.
105 The following commands create the **autobuild** script in the
106 `autobuild/agl` directory:
111 cmake .. && make autobuild
116 Following are the targets available from the **autobuild** script:
118 - **clean**: Removes all the object files and target results generated by Makefile.
119 - **clean-{release,debug,coverage,test}**: Removes all the object files and target results generated by Makefile for the specified build type.
120 - **clean-all**: Deletes the build directories for all build types.
121 - **distclean**: Deletes the build directories for all build types.
122 - **configure**: Generates the project Makefile from the `CMakeLists.txt` files for the release build type.
123 - **configure-{release,debug,coverage,test}**: Generates the project Makefile from the `CMakeLists.txt` files for the specified build type.
124 - **build**: Compiles all project targets for the release build type.
125 - **build-{release,debug,coverage,test}**: Compiles all project targets for the specified build type.
126 - **build-all**: Compiles all project targets for all specified build types.
127 - **package**: Builds the widget (**wgt**) package for the release build type.
128 - **package-{release,debug,coverage}**: Builds the widget (**wgt**) package for the specified build type.
129 - **package-test**: Builds the test **wgt** package.
130 - **package-all**: Builds the widget (**wgt**) packages for all build types.
131 - **install**: Installs the project into your filesystem.
133 Note that `aglwgt.bbclass` only will use the **package-{coverage,test}** targets (and thus the **build-{coverage,test}**, etc. targets) for service bindings by default, so **autobuild** scripts for applications may omit support for those.
135 Specifying the following variables lets you modify compilation behavior:
137 - **CLEAN_ARGS**: Variable used at **clean** time.
138 - **CONFIGURE_ARGS**: Variable used at **configure** time.
139 - **BUILD_ARGS**: Variable used at **build** time.
140 - **BUILD_DIR**: Build directory for release type build.
141 The default value is a "build" directory in the root of the project.
142 - **BUILD_DIR_DEBUG**: Build directory for debug type build.
143 The default value is a "build-debug" directory in the root of the project.
144 - **BUILD_DIR_TEST**: Build directory for test type build.
145 The default value is a "build-test" directory in the root of the project.
146 - **BUILD_DIR_COVERAGE**: Build directory for coverage type build.
147 The default value is a "build-coverage" directory in the root of the project.
148 - **DEST**: Directory in which to place the created ***wgt*** file(s).
149 The default directory is the build root directory.
151 Note that the values of **BUILD_DIR_{DEBUG,TEST,COVERAGE}** are defined based on the value of **BUILD_DIR**, so this needs to be kept in mind if over-riding it and building those other widget types.
153 When you provide a variable, use the CMake format (i.e.
154 BUILD_ARGS="-DC_FLAGS='-g -O2'").
155 Following is an example:
158 ./autobuild/agl/autobuild package DEST=/tmp