Qbs Manual

Qbs 1.13.1

# BinaryProbe QML Type

Locates executable files outside the project. More...

Import Statement: | import
Inherits: | PathProbe

- List of all members, including inherited members

## Detailed Description

Finds executable files that have the specified file names.

BinaryProbe searches for executable files within directories specified by the PATH environment variable.

Note: On Unix, also searches in the `/usr/bin` and `/usr/local/bin` directories by default. Override PathProbe.platformSearchPaths to change this behavior.

Note: On Windows, only files that have .com, .exe, .bat, .cmd extensions are considered executables. Override PathProbe.nameSuffixes to change this behavior.

For example, BinaryProbe can be used to search for a protobuf compiler executable as follows:

      import qbs.File
      import qbs.Probes

      Module {
          // search for a protoc executable
          Probes.BinaryProbe {
              id: protocProbe
              names: "protoc"
          }
          property string executableFilePath: protocProbe.filePath

          validate: {
              if (!File.exists(executableFilePath))
                  throw "The executable '" + executableFilePath + "' does not exist.";
          }

          // use the found executable
          Rule {
              // rule input/outputs here...

              // run executable
              prepare: {
                  var args = // initialize arguments...
                  var cmd = new Command(executableFilePath, args);
                  cmd.highlight = "codegen";
                  cmd.description = "generating protobuf files for " + input.fileName;
                  return [cmd];
              }
          }
      }