Main Content

padv.builtin.query.FindBuildfile Class

Namespace: padv.builtin.query
Superclasses: padv.Query, padv.builtin.query.FindArtifacts

Query for finding build file for MATLAB build tool

Description

This class requires CI/CD Automation for Simulink Check.

The padv.builtin.query.FindBuildfile class provides a query that can return a build file in the current project. A build file is a function file named buildfile.m that defines a build plan for the MATLAB® build tool. With the MATLAB build tool, you can create a build plan that identifies code issues, runs tests, and performs other operations. For more information, see Build Automation. By default, the query finds the buildfile.m file in the project root folder. But you can automatically select a specific build file by using the optional name-value arguments.

If you define a build file for your project, you can use the built-in task padv.builtin.task.RunBuildTool to invoke the build tool. The RunBuildTool task uses the FindBuildfile query to find the build file in your project and use that file as a task input.

The padv.builtin.query.FindBuildfile class is a handle class.

Creation

Description

query = padv.builtin.query.FindBuildfile() creates a query for finding the MATLAB Build Tool build file in your project.

example

query = padv.builtin.query.FindBuildfile(Name=Value) sets certain properties using one or more name-value arguments. For example, FindBuildfile(IncludePathRegex="BuildFileFolderName*") creates a query that only includes build files where the file path includes the specified string BuildFileFolderName.

The padv.builtin.query.FindBuildfile class also has other properties, but you cannot set those properties during query creation.

example

Input Arguments

expand all

Unique identifier for query, specified as a string or a character vector.

Example: "FindMyBuildFile"

Data Types: char | string

Type of artifact, specified as one or more artifact types. To specify multiple artifact types, use an array. For a list of valid digital thread artifact types, see Valid Artifact Types.

Since the MATLAB build tool expects the build file to be a function file (.m) in the project root folder, the padv.builtin.query.FindBuildfile query specifies ArtifactType as "m_file".

Example: "m_file"

Find build file with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.

Example: {"Classification","Design"}

Data Types: cell

Exclude build file with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.

Example: {"Classification","Design"}

Data Types: cell

Find artifacts where the path contains specific text, specified as a string. Consider using IncludePathRegex instead.

Since the MATLAB build tool expects the build file to be a function file (.m) in the project root folder, the padv.builtin.query.FindBuildfile query specifies IncludePath as "buildfile.m".

Data Types: string

Exclude artifacts where the path contains specific text, specified as a string or a character vector. Consider using ExcludePathRegex instead.

Data Types: string

Find build file where the path matches a regular expression pattern, specified as a string or character vector. IncludePathRegex expects UNIX®-style path separators.

If you want to use a literal path, use IncludePath instead. You can specify either IncludePath or IncludePathRegex but not both.

Data Types: char | string

Exclude build file where the path matches a regular expression pattern, specified as a string or a character vector. ExcludePathRegex expects UNIX-style path separators.

If you want to use a literal path, use ExcludePath instead. You can specify either ExcludePath or ExcludePathRegex but not both.

Data Types: char | string

Include only a build file that has been added to the project, specified as a numeric or logical 1 (true) or 0 (false).

For more information about how to add or remove files from a project, see Manage Project Files.

Note

If you specify InProject as true, you cannot use the query as an input query.

Example: true

Attributes:

Dependent

true

Data Types: logical

Properties

expand all

Unique identifier for query, specified as a string or a character vector.

Example: "FindMyBuildFile"

Data Types: char | string

Type of artifact, specified as one or more artifact types. To specify multiple artifact types, use an array. For a list of valid digital thread artifact types, see Valid Artifact Types.

Since the MATLAB build tool expects the build file to be a function file (.m) in the project root folder, the padv.builtin.query.FindBuildfile query specifies ArtifactType as "m_file".

Example: "m_file"

Find build file with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.

Example: {"Classification","Design"}

Data Types: cell

Exclude build file with specific project label, specified as a cell array where the first entry is the project label category and the second entry is the project label name.

Example: {"Classification","Design"}

Data Types: cell

Find artifacts where the path contains specific text, specified as a string. Consider using IncludePathRegex instead.

Since the MATLAB build tool expects the build file to be a function file (.m) in the project root folder, the padv.builtin.query.FindBuildfile query specifies IncludePath as "buildfile.m".

Data Types: string

Exclude artifacts where the path contains specific text, specified as a string or a character vector. Consider using ExcludePathRegex instead.

Data Types: string

Find build file where the path matches a regular expression pattern, specified as a string or character vector. IncludePathRegex expects UNIX-style path separators.

If you want to use a literal path, use IncludePath instead. You can specify either IncludePath or IncludePathRegex but not both.

Data Types: char | string

Exclude build file where the path matches a regular expression pattern, specified as a string or a character vector. ExcludePathRegex expects UNIX-style path separators.

If you want to use a literal path, use ExcludePath instead. You can specify either ExcludePath or ExcludePathRegex but not both.

Data Types: char | string

Filter out sub-file artifacts from query results, specified as a numeric or logical 1 (true) or 0 (false).

A sub-file is a part of a larger file. For example, the function defined inside a MATLAB program file is a sub-file of that MATLAB file.

Example: false

Data Types: logical

Include only a build file that has been added to the project, specified as a numeric or logical 1 (true) or 0 (false).

For more information about how to add or remove files from a project, see Manage Project Files.

Note

If you specify InProject as true, you cannot use the query as an input query.

Example: true

Attributes:

Dependent
true

Data Types: logical

Query title, specified as a string or a character vector.

Example: "Find my buildfile"

Data Types: string

Default artifact type returned by the query, specified as one or more artifact types. To specify multiple values, use an array. For a list of valid digital thread artifact types, see Valid Artifact Types.

Example: "padv_output_file"

Initial query that runs before iteration query, specified as either a padv.Query object or the Name of a padv.Query object. When you specify an iteration query for a task, the parent query is the initial query that the build system runs before running the specified iteration query.

By default, the FindBuildfile query does not use this property because you cannot use FindBuildfile as an iteration query.

Unique identifier for query, specified as a string or a character vector.

Example: "FindMyBuildfile"

Data Types: char | string

Show file extensions in the Alias property of the returned build file, specified as a numeric or logical 1 (true) or 0 (false). The Alias property controls the display name for the artifact in the Tasks column in Process Advisor.

By default, queries strip file extensions from the Alias property of each task iteration artifact. To show file extensions for all artifacts in the Tasks column, select the project setting Show file extensions. To keep file extensions in the results for a specific query, specify the query property ShowFileExtension as true.

Example: true

Data Types: logical

Setting for automatically sorting artifacts by address, specified as a numeric or logical 1 (true) or 0 (false). When a query returns artifacts, the artifacts should be in a consistent order. By default, the build system sorts artifacts by the artifact address.

Alternatively, you can sort artifacts in a different order by overriding the internal sortArtifacts method in a subclass that defines a custom sort behavior. For an example, see Sort Artifacts in Specific Order.

The build system automatically calls the sortArtifacts method when using the process model. The sortArtifacts method expects two input arguments: a padv.Query object and a list of padv.Artifact objects returned by the run method. The sortArtifacts method should return a list of sorted padv.Artifact objects.

Example: SortArtifacts = false

Data Types: logical

Handle to the function that a function-based query runs, specified as a function_handle.

If you define your query functionality inside a function and you or the build system call run on the query, the query runs the function specified by the function_handle.

The built-in queries are defined inside classes and do not use the FunctionHandle.

Example: FunctionHandle = @FunctionForQuery

Data Types: function_handle

Methods

expand all

Examples

collapse all

You can use the FindBuildfile query in your task definition to find the build file for the MATLAB build tool. For example, the built-in task padv.builtin.task.RunBuildTool uses the FindBuildfile query to find the build file in your project and use that file as a task input.

Open the source code for the built-in task padv.builtin.task.RunBuildTool.

open padv.builtin.task.RunBuildTool

The task specifies "padv.builtin.query.FindBuildfile" as one of the input queries for the task by using the task property InputQueries.

Although you typically use a query inside your process model, you can run an instance of the FindBuildfile query outside of your process model to confirm which artifact the query returns.

Open a project. For this example, you can open the Process Advisor example project.

processAdvisorExampleStart

By default, the Process Advisor example project does not contain a build file. Inside the project root folder, add a file named buildfile.m to the project.

For information on how to define a build plan for the MATLAB build tool, see Build Automation.

Create an instance of the query.

q = padv.builtin.query.FindBuildfile();

Run the query and inspect the artifact that the query returns.

run(q)
ans = 

  Artifact with properties:

               Type: "m_file"
             Parent: [0×0 padv.Artifact]
    ArtifactAddress: [1×1 padv.util.ArtifactAddress]
              Alias: "buildfile.m"

Capabilities and Limitations

This table identifies functionality that is supported by the query.

FunctionalitySupported?

Input query for task

Only when the query property InProject is false.

Iteration query for task

No.