> ## Documentation Index
> Fetch the complete documentation index at: https://docs.incredibuild.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Customize Build Executions Using Regular Expressions and Arguments in the ib_profile.xml File

Last updated on Nov 05, 2024

#### **Using Regular Expressions (regex)**

You can use regular expressions, `regex`, to define the build tools and processes you include in an ib\_profile.xml file. The regex applies to the process filename.

When `regex=true`, the process filename is checked as a regular expression instead of an exact match. This way, you can add to an ib\_profile.xml file tools and processes that has a dynamic name or whose name is not fully known.

**To use regex, enter the following:**

```
<process filename="<partial_name+regex>" regex="true" type="<distribution_type>" />
```

Here are two examples for the use of `regex` in an ib\_profile.xml file:

1. The "`$`" regular expression is used in the process filename definition:

   ```
   <process filename=".bash$" regex="true" type="intercepted" />
   ```

   In this case, every process whose name ends with "bash", that is `"<any_character>bash"`, will be handled as **intercepted**.

2. The "`^`" regular expression is used in the process filename definition:

   ```
   <process filename="^soong" regex="true" type="intercepted" />
   ```

   In this case, every process whose name starts with "soong", that is "soong\<any\_character>", will be handled as **intercepted**.

**Note**: For more information about regular expressions, see:[https://www.guru99.com/linux-regular-expressions.html](https://www.guru99.com/linux-regular-expressions.html)

#### **Using Arguments (args)**

The arguments, `args`, parameter enables you to filter the instances of the running process, and to automatically apply the defined distribution type only to instances that include or do not include certain arguments.

The `args` parameter is relevant for processes whose instances contain different arguments. In such a process, each running instance may need to be distributed in a different manner. For example, a process can run a compilation instance, which should be executed remotely, and a linker instance, which should be executed locally.

We can specify, for example, that all instances should be **local\_only**, except for instances that have the `-c` (compilation without linking) argument. This means that the distribution type of the compilation instances will not be **local\_only** but **allow\_remote**, while all other instances will be **local\_only**.

You can use the `args` parameter both in an exclusion and an inclusion approach. In both approaches, the args parameter specifies one or more arguments. If there is more than one argument in the `args` parameter, the arguments should be organized in a list, when each argument is separated by a colon.

**To use args, enter the following:**

```
<process filename="<process_name>"   type="<distribution_type>" exclude_args/include_args="<argument:argument:argument"/>
```

**Note**: Do not use partial names with regex as arguments. Enter into the ib\_profile.xml file the full argument for an exact match.

* **exclude\_args**:

If any of the arguments in the `exclude_args` list is met at the actual process execution, the specified distribution type will NOT be applied to the process instance.

For example:

```
<process filename="clang.real"         type="local_only" exclude_args="-c:-S:-E"/>
```

In this example, it is specified that the `clang.real` process should run as **local\_only**. However, if its instance contains one or more of the defined tokens (`-c`, `-S`, or `-E`), this distribution type will not be applied to it. This means that if the command that runs the `clang.real process` contains the `-c`, `-S` or `-E` tokens, the process will run as **allow\_remote** instead of **local\_only**.

* **include\_args**:

Only if any of the arguments in the `include_args` list is met at the actual process execution, the specified distribution type will be applied to the process.

If there is more than one entry regarding the same process, the entry with the `include_args` parameter will take effect.

For example:

```
<process filename="java"             type="allow_remote" /><process filename="java"             type="intercepted" include_args="org.gradle.launcher.GradleMain:org.gradle.wrapper.GradleWrapperMain" />
```

In this example, java processes will usually run as **allow\_remote**. However, if the actual command will contain `org.gradle.launcher.GradleMain` and/or `org.gradle.wrapper.GradleWrapperMain`, the java processes will be handled as **intercepted**.
