Skip to content

Portable projects & Named Roots in CI

A .und records where its source files live. If those absolute paths differ between the machine that created the project and the CI agent (or another developer), the project won't resolve its files. Two mechanisms make a project portable:

  • Relative paths — record file paths relative to the project, for source that always sits at a fixed layout beneath it.
  • Named Roots — map a symbolic name (e.g. SRC) to a directory that can differ per machine, so files beneath that directory stay resolvable wherever the tree is checked out.

This matters for CI because the build agent almost never checks the source out to the same absolute path as your workstation.

What a Named Root is

A Named Root is a mapping of a name → a directory path. A file can use a Named Root if it resides beneath that directory. Each machine (or CI agent) can point the same root name at its own location.

Identifier rules (enforced by Understand):

  • ALL CAPS
  • two or more characters
  • begins with an alphabetic character
  • contains only alphabetic, numeric, $, or _ characters

A Named Root cannot be nested beneath another Named Root. Example: SRC=/work/src is valid for files inside /work/src/foobar.

From the command line

# Add a Named Root
und add -root SRC=/work/src myProject.und

# List roots, and find files that still need attention
und list roots myProject.und
und list -unmapped -unportable roots myProject.und
  • und list -unmapped roots — files whose Named Root is undefined on this machine.
  • und list -unportable roots — files not portable (not mapped to a root and not relative).
  • und add -root accepts a relative path as a root's value. It is taken from the directory und runs in, or from the project's folder when only that one exists, and the absolute directory is what gets recorded.
  • und add -root refuses a root with no value (SRC=), a value written as another root's name plus a path (the value must be a plain directory), or a value that overlaps an existing root — and the error says which rule the root broke.
  • Full syntax: und roots and und list.
  • Named Roots can also be created and edited in the GUI: Project → Configure Project → Portability (a top-level page in the Configure Project dialog), using the page's add/edit toolbar actions.

How a file's path is recorded

und add and und settings store each path in its portable form automatically: relative to the project folder when the file lies beneath it, as ROOT/... when it lies beneath a Named Root, and absolute otherwise. Keep the source beneath the project, or map it with a Named Root, and the recorded paths stay portable.

Enforce portability

To stop non-portable (unmapped, absolute) files from creeping in, turn on the enforce-portability setting:

und settings -enforceportability on myProject.und

Sharing analysis data is different

und create -local stores machine-specific project data, including the parsed analysis data, in the project's local folder instead of the user's AppData folder. You can also use it to share an analyzed project with someone who can't build it on their machine. They can browse it without analyzing, but to view source they need the files at the same place relative to the project, and analyzing without the source drops the missing files from the data.

Goal Use Requirement
Resolve source when paths differ per machine/agent Named Roots (or relative paths) Each machine maps the root to its own path
Share an analyzed project with someone who can't build it und create -local Source at the same place relative to the project to view it

For a shared CI project you generally want Named Roots for portability, and you re-run und analyze on the agent rather than depending on -local. Don't commit the local folder to version control.

In a pipeline

  1. Create the project where the source sits beneath it, or add Named Roots for the source trees that live elsewhere.
  2. Commit the .und (or a script that rebuilds it) to version control.
  3. On the agent, set each Named Root to the checkout path (GUI/und add -root), then und analyze -changed and run the rest of your pipeline.