aboutsummaryrefslogtreecommitdiffstats
path: root/docs/1_Getting_Started/2_Building_AGL_Image/5_Customizing_Your_Build.md
blob: 1c30ddd04bba0b2b6afc28f245ff45f4100e9c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
---
title: Customizing Your Build
---

Because the build process is based on BitBake and the Yocto Project,
build customizations are driven through configuration files used during
the build.

Lots of configuration files exist that define a build.
However, the primary one that acts as a global configuration mechanism is the
`local.conf` file, which is found in the Build Directory in a folder named "conf".

Before you start your build process, you should open up the `local.conf` file
and look through it to be sure the general configurations are correct.
The file is well commented so you should be able to understand what the
various variables accomplish.

To view and customize the `local.conf` file, use any text editor:

```sh
$ vim $AGL_TOP/<release-branch-name>/<build-dir>/conf/local.conf
```

As mentioned in the "[Initializing Your Build Environment](./3_Initializing_Your_Build_Environment.md)" section,
the `local.conf` file gets augmented with AGL configuration fragments based on
how you execute the `aglsetup.sh` script.
You can see those fragments at the end the configuration file.

Even though your build should work fine after running the `aglsetup.sh` script,
you might consider editing your `local.conf` file to use one or more of the
following configurations.

## Capturing Build History

You can enable build history to help maintain the quality of your build output.
You can use it to highlight unexpected and possibly unwanted changes in the build output.
Basically, with build history enabled, you get a record of information about the contents
of each package and image.
That information is committed to a local Git repository where you can examine it.

To enable build history, make sure the following two lines are in your
`local.conf` file:

```sh
INHERIT += "buildhistory"
BUILDHISTORY_COMMIT = "1"
```

See the
"[Maintaining Build Output Quality](https://www.yoctoproject.org/docs/3.1.4/ref-manual/ref-manual.html#maintaining-build-output-quality)"
section in the Yocto Project Reference Manual for a complete discussion on
build history.

## Deleting Temporary Workspace

During a build, the build system uses a lot of disk space to store temporary files.
You can ease the burden on your system and speed up the build by configuring the build
to remove temporary workspace.

You need to inherit the `rm_work` class by using this statement in the `local.conf` file:

```sh
INHERIT += "rm_work"
```

You can read about the class in the
"[rm_work.bbclass](https://www.yoctoproject.org/docs/3.1.4/ref-manual/ref-manual.html#ref-classes-rm-work)"
section of the Yocto Project Reference Manual for more information.

##  Pointing at Shared State Cache Locations

The build system creates everything from scratch unless BitBake can determine that parts do not need to be rebuilt. Fundamentally, building from scratch is attractive as it means all parts are built fresh and there is no possibility of stale data causing problems.
When developers hit problems, they typically default back to building from scratch so they know the state
of things from the start.

The build process uses Shared State Cache (sstate) to speed up subsequent builds.
This cache retains artifacts that can be re-used once it is determined that they
would not be different as compared to a re-built module.

For the AGL build, you can specify the location for sstate files by including the
following in the `local.conf` file:

```sh
SSTATE_DIR = "${AGL_TOP}/sstate-cache"
```

Also, in the `local.conf` file, you can specify additional directories in which the build
system can look for shared state information.
Use the following form in your file to list out the directories you want the build
process to look at for sstate information:

```sh
SSTATE_MIRRORS ?= "\
    file://.* http://someserver.tld/share/sstate/PATH;downloadfilename=PATH \n \
    file://.* file:///some/local/dir/sstate/PATH"
```

If you want to know more about the Yocto Project sstate mechanism, see the
"[Shared State Cache](https://www.yoctoproject.org/docs/3.1.4/ref-manual/ref-manual.html#shared-state-cache)"
section in the Yocto Project Reference Manual.

## Preserving the Download Directory

During the initial build, the system downloads many different source code tarballs
from various upstream projects.
Downloading these files can take a while, particularly if your network
connection is slow.
The process downloads files into a
"[download directory](https://www.yoctoproject.org/docs/3.1.4/ref-manual/ref-manual.html#var-DL_DIR)".
The `DL_DIR` variable defines the download directory.
For subsequent builds, you can preserve this directory to speed up the download
part of a build.

The default download directory is in a folder named "downloads".
For the AGL build you can set the download directory by adding the following to your
`local.conf` file:

```sh
DL_DIR = "${AGL_TOP}/downloads"
```

## Using a Shared State (sstate) Mirror

The underlying Yocto Project build system uses Shared State Mirrors to cache
artifacts from previous builds.
You can significantly speed up builds and guard against fetcher failures by
using mirrors.
To use mirrors, add this line to your `local.conf` file in the Build directory:

```sh
SSTATE_MIRRORS_append = " file://.* https://download.automotivelinux.org/sstate-mirror/master/${DEFAULTTUNE}/PATH \n "
```

You can learn more about shared state and how it is used in the
"[Shared State Cache](https://yoctoproject.org/docs/3.1.4/ref-manual/ref-manual.html#shared-state-cache)"
section of the Yocto Project Reference Manual.

## Common Settings using Symbolic Link with site.conf

```sh
$ echo "# reuse download directories" >> $AGL_TOP/site.conf
$ echo "DL_DIR = \"$HOME/downloads/\"" >> $AGL_TOP/site.conf
$ echo "SSTATE_DIR = \"$AGL_TOP/sstate-cache/\"" >> $AGL_TOP/site.conf
$ cd $AGL_TOP/master/qemux86-64/
$ ln -sf $AGL_TOP/site.conf conf/

In General;
$ cd $AGL_TOP/<release-branch-name>/<build-dir>/
$ ln -sf $AGL_TOP/site.conf conf/
```