5.8. Local Build

5.8.1. Introduction

Local Build allows you to analyze your code changes before committing them to the repository. This can also speed up the “develop – analyze – fix issues” cycle.

This section provides an overview of how Local Build works, its integration into the plugins, and how to use Local Build without the plugins.

Although Local Build can be used without plugins, using the plugins is recommended as they handle most of the underlying complexity.

5.8.2. Overview of the Local Build

Local Build is a special mode of the axivion_ci tool, intended to use the same configuration as axivion_ci uses for server analysis.

At the start of a Local Build, axivion_ci fetches a reference version of the current issues from the dashboard. This version is compared against the issues found by the Local Build. The reference version and the issues found by the Local Build are written to the project database $HOME/.bauhaus/localbuild/projects/<project_name>.db. This file is created automatically, so no manual action is needed. After the Local Build completes, this database contains the Empty version, the reference version, and the Local Build results.

5.8.3. Preparing the Configuration

The configuration must be prepared appropriately to build native object files and the IR incrementally without interference. There is no “one-size-fits-all” solution for this.

Unlike the CI server build, which may only store analysis results in its working copy, Local Build analysis results must co-exist with native build results in the same working copy. There are two possible ways to resolve this:

  • Use different output folders for the native build and analysis (preferred).

  • Use different names for the output files (e.g., using an IR suffix).

In cross-compilation environments, a separate platform can be used for the analysis, which results in a separate output directory. A second working copy for the Local Build might be an option, but this requires synchronization between two independent copies of the code. irCC is not suitable because it cannot perform incremental builds independently; therefore, every Local Build run would require a clean build (both native and analysis). MSBuild can be used with an IR suffix without needing to clean the native build; however, incremental builds are not supported in this case.

The plugins automatically set axivion_ci to Local Build mode. For manually started Local Builds, Local Build mode is enabled using the environment variable:

AXIVION_LOCAL_BUILD=1

5.8.4. Configuring the TLS Certificate

Local Build must fetch a reference analysis from the Axivion Dashboard Server. If the Dashboard connection is encrypted (HTTPS), the client must verify the Dashboard’s certificate.

The certificate is verified against the operating system’s certificate store (the Windows certificate store, the system CA bundle on Linux, or the macOS Keychain). If the root certificate of the Dashboard’s certificate is trusted by the operating system, no further configuration is needed.

To trust other certificates, such as a self-signed Dashboard certificate, either install the root certificate into the operating system’s certificate store, see Places to Install the Root Certificate of the Dashboard Certificate (this does not work on macOS for the Dashboard’s automatically generated certificate), or set the environment variable REQUESTS_CA_BUNDLE to point to a certificate bundle file; the bundle is then used instead of the operating system’s certificate store. This file contains certificates in PEM format (ASCII armored Base64). To trust a server’s certificate, the corresponding root certificate must be placed in the file referenced by REQUESTS_CA_BUNDLE; an intermediate certificate alone or the server certificate (if not self-signed) is insufficient.

The Dashboard server’s root certificate can be retrieved using your browser.

In the simplest case, the file content looks similar to this example:

-----BEGIN CERTIFICATE-----
<base64 of root certificate>
-----END CERTIFICATE-----

A more complex example would be:

-----BEGIN CERTIFICATE-----
<base64 of root certificate A>
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
<base64 of root certificate B>
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
<base64 of immediate certificate B1>
-----END CERTIFICATE-----

5.8.5. Starting Local Build from within the IDE Plugins

Within the plugins, the Local Build can be started using the Local Build button in the toolbar above the issue list.

Local Build Button

Local Build Button

For Axivion Eclipse Plugin, Axivion Visual Studio Plugin, and Axivion CLion Plugin, a dialog box appears requesting the information required to run the Local Build: the path to the Axivion Suite installation folder and the command used to run the Local Build. The Axivion Visual Studio Code Plugin is configured via the settings.json as described in Configuration.

This command is typically the build script used on your CI server, e.g., start_analysis.bat or axivion_ci. Please ensure that the axivion_ci invocation can find the correct configuration by setting BAUHAUS_CONFIG.

The Build Type list allows you to switch between incremental and clean Local Builds. Selecting Clean Build sets the environment variable AXIVION_CLEAN_BUILD=1. Selecting Incremental Build sets the environment variable AXIVION_INCREMENTAL_BUILD=1. The default, empty entry sets neither variable.

The plugin sets axivion_ci to Local Build mode and provides the username and password required to fetch the reference version from the central Axivion Dashboard Server. The first time the plugin requests a password, it creates and internally stores an API token for that user. Subsequently, the plugin uses AXIVION_PASSWORD and AXIVION_PASSFILE together to securely pass this token to axivion_ci, which then uses it to communicate with the Dashboard. Therefore, these two variables must be kept in sync. If you overwrite AXIVION_PASSWORD in a wrapper script, you must also delete AXIVION_PASSFILE from the environment for it to work.

The plugin automatically updates the project’s Local Build status once the Local Build has finished.

When a Local Build is available, the View Local Build Results button becomes active. Use this button to toggle between analysis results from the Axivion Dashboard Server and the results of the Local Build.

View Local Build Results Button

View Local Build Results Button

Viewing the Local Build results provides three options:

  • All issues found by the Local Build (start version empty, end version Local Build).

  • All newly found issues in the Local Build (start version reference, end version Local Build).

  • All issues of the reference version (start version empty, end version reference).

To view the results of a Local Build, the plugin starts a local dashboard that prints its credentials to stdout. The plugin reads these credentials to communicate with the local dashboard.

Note

The IDE plugins set these environment variables for the Local Build subprocess:

  • AXIVION_USER_AGENT=<plugin-identifier>/<version> where <plugin-identifier> is

    • AxivionClionPlugin or

    • AxivionEclipsePlugin or

    • AxivionVisualStudioPlugin or

    • AxivionVsCodePlugin

  • AXIVION_LOCAL_BUILD=1

  • AXIVION_PROJECT_NAME: the name of the project to build in the (global) Dashboard

  • AXIVION_BASE_DIR: the path to the Axivion Suite installation directory if known

Caution

Changing Axivion Dashboard Server-related environment variables should not be necessary when the Local Build is started from an Axivion IDE plugin. The plugin sets the required variables to allow the Axivion CI to connect to the Dashboard.

Caution

During the local build, the current value of the environment variable BAUHAUS_PYTHON is stored. If a BAUHAUS_PYTHON variable is stored, the plugin sets it for the local Dashboard when it starts the local Dashboard.

After an in-place upgrade to a Axivion Suite version that requires a different Python version, the stored value may prevent the local Dashboard from starting. Use local_build_config [--project PROJECT] [--version VERSION] python set "path/to/python.exe" to adjust the local build configuration.

This is only necessary for existing local builds. Alternatively, the local build can be fixed by re-running it with the new Axivion Suite version.

5.8.5.1. Inspecting and Changing the Local Build Configuration

The IDE plugins store the metadata for each Local Build in a configuration database. The local_build_config tool reads and modifies this database:

local_build_config [--dbl DBL] [--project PROJECT] [--version VERSION] [--json] <command>

The following options apply to all commands:

--dbl DBL

Path to the configuration database. The default is localbuild/config.dbl in the .bauhaus directory in your home directory.

--project PROJECT

Restricts the command to the Local Build of the specified Dashboard project. The name is case-sensitive.

--version VERSION

Restricts the command to projects analyzed with a matching Axivion Suite version. The version is a prefix match on version components: 7.9 matches 7.9.0 and 7.9.2, but not 7.90.

--json

Prints the output of the query command in JSON format.

The following commands are available:

query

Prints the project name, the Axivion Suite version and installation directory, the local Dashboard start and stop command lines, and the stored environment variables for each Local Build.

python get

Prints the stored value of BAUHAUS_PYTHON for each Local Build.

python set NEW_BAUHAUS_PYTHON

Sets the stored value of BAUHAUS_PYTHON. An empty string "" deletes the stored value.

take

Updates the stored Axivion Suite installation directory and the local Dashboard command lines to the Axivion Suite installation that runs local_build_config. Local Builds created with a newer Axivion Suite version are skipped.

5.8.6. Local Build without Plugins

Depending on whether a running dashboard is available for your project or not (either because it is not yet set up or because you do not have a network connection to the dashboard), you can execute an Online Local Build without Plugins or an Offline Local Build without Plugins.

5.8.6.1. Online Local Build without Plugins

This mode of operation requires a running central dashboard. It connects to the dashboard using an authentication method, downloads a reference version, and then performs a delta analysis in the local workspace.

To start the Online Local Build manually (without plugins), set the following environment variables:

AXIVION_LOCAL_BUILD=1
AXIVION_DASHBOARD_URL=http://your-dashboard-url.example/axivion
AXIVION_USERNAME=dashboard_username
AXIVION_PASSWORD=dashboard_password_or_token

The AXIVION_USERNAME and AXIVION_PASSWORD variables are optional. If AXIVION_USERNAME is omitted, the operating system account username is used. If AXIVION_PASSWORD is omitted, the password or token (which can be created on the User Preferences Page) is requested interactively.

After setting the environment variables, start your build script as you would on your CI server, or run, for example, start_analysis.bat or axivion_ci.

To view the Local Build results, you can either use the server instance of the dashboard and install the project database mentioned above, or start/stop a local dashboard as shown below:

#On Linux
dashserver start --local
  --install_file=$HOME/.bauhaus/localbuild/projects/<project>.db

#On Windows
dashserver start --local
  --install_file=%USERPROFILE%\.bauhaus\localbuild\projects\<project>.db

#Stopping the local dashboard
dashserver stop --local

#Prints further options and description
dashserver start --help
The --local switch has the following effect:
It uses the predefined local dashboard configuration, which is intended for use by a single user on a single machine. There is only one local dashboard per user and its configuration is stored in a central location in the temporary directory; therefore, you do not need to specify the --confdir option. Its configuration is automatically deleted when it is stopped, so although it is possible, you should not spend effort configuring it.

Caution

Since IDE plugins are unaware of manually started Local Build processes, they are unable to update their state automatically after the Local Build finishes.

5.8.6.2. Offline Local Build without Plugins

This mode of operation is completely local and does not require a running dashboard. Consequently, the results are not presented as a delta against a reference version, but instead contain the full set of findings from the workspace.

To start the Offline Local Build manually (without plugins), set the environment variable AXIVION_LOCAL_BUILD to 1. The environment variable AXIVION_DASHBOARD_URL must not be defined, because that would trigger an Online Local Build with a dashboard connection. Accordingly, the environment variables AXIVION_USERNAME and AXIVION_PASSWORD do not need to be set.

Starting the analysis and viewing the results is performed in the same way as an Online Local Build without Plugins.