With the following steps, you will prepare the local workspace to build and run the Hello World Application with Pesto/Bazel.

Optional: Make a Copy

If you don't want to inflict changes to the original Hello World Application example, make a copy of the application first.

  1. Create an empty directory as a workspace for building and running a copy of your application.
  2. Copy the amsr-vector-app-example-hello-world  directory of the original application (located in the Examples directory of your delivery) to your newly created directory.
  3. Rename the application copy in the newly created directory.
notice

If you decide to make a copy and want to use that for the following steps, please adapt the given paths from all instructions (building, adapting, installing and running your application) to match the location of your copy.

Step 1: Create a Registry

The components of MICROSAR Adaptive are structured as Bazel modules. To make your project aware of all modules, you need to create a registry.

  1. Navigate to the directory of your application in your terminal.
  2. notice

    This can either be the original Hello World Application directory or the copy you made in Optional: Make a Copy.

  3. Set the environmental variable APP_DIR to the application directory which you want to work with in this tutorial:
  4. export APP_DIR="$(pwd)"

  5. Set the environmental variable AMSR_SRC_DIR to the root directory of your delivery:
  6. export AMSR_SRC_DIR="$(pwd)/../.."

  7. Create a registry by running the Bazel integration tool located in your delivery:
  8. "${AMSR_SRC_DIR}/Bazel/addon/bazel_integration/bazel_integration.py" create-registry \
      --output bazel_registry \
      --source-type local_path \
      --module-base-path "${AMSR_SRC_DIR}" \
      --relative-module-base-path \
      --add-to-bazelrc .bazelrc \
      --workspace .

notice

Depending on your setup, you can adapt the arguments of the Bazel integration tool to create a registry as shown in the command above. General information about commands/arguments can be found by running the tool with --help.

  1. --output:
    If you want to change the directory of the Bazel registry to be created, set this argument accordingly (e.g. ../../bazel_registry).
  2. --source-type:
    If you plan to host the BSW Package on a Git repository or HTTP server instead, adapt this argument value accordingly.
  3. --module-base-path:
    If this argument is specified, module paths will be considered as relative to the specified value.
  4. --relative-module-base-path:
    If this argument is specified, the --module-base-path will be considered as relative to the registry.
  5. If neither --module-base-path nor --relative-module-base-path are specified (default), all local paths in the registry will be considered absolute.
  6. --add-to-bazelrc:
    If this parameter is specified, it will activate the registry in the specified .bazelrc file (using a relative path to directory specified by --workspace).
  7. --workspace:
    If you want to specify a different Bazel workspace, you can set the path to its root with this argument.

Step 2: Generate .bazelrc File

To provide configuration options of MICROSAR Adaptive, a .bazelrc file must be generated.

  1. Create the .bazelrc file:
  2. "${AMSR_SRC_DIR}/Bazel/addon/bazel_integration/bazel_integration.py" create-bazelrc \
      --output .bazelrc_amsr \
      --add-to-bazelrc .bazelrc \
      --workspace .

notice

General information about commands/arguments can be found by running the tool with --help.

  1. --output:
    If you want to change the directory of the .bazelrc file to be created, set this argument accordingly (e.g. ../../.bazelrc).
  2. --add-to-bazelrc:
    This argument will import the generated file in the specified .bazelrc file (using a relative path to the specified value of --workspace).
  3. --workspace:
    If you want to specify a different Bazel workspace, you can set the path to its root with this argument.

 

Next step in the tutorial: Build Application Files