[Qbs] Specify custom applications and application arguments in qbs project

Jochen Ulrich jochen.ulrich at clausmark.com
Mon Sep 21 15:06:15 CEST 2020


Hi Yury!

> I want to specify in the qbs project that there are several predefined command line arguments which will be visible as separate runnables in QtCreator.

The "several predefined command line arguments" parts should be possible by writing a Product with a corresponding Rule.

Something like this (UNTESTED!):

	Product {
		name: "my-command"
		type: [ "command" ]
		builtByDefault: false

		Rule {
			multiplex: true
			alwaysRun: true
			inputs: []

			Artifact {
				filePath: "dummy"
				fileTags: [ "command" ]
			}

			prepare: {
				let cmd = new Command();
				cmd.description = "Running my-command";
				cmd.program = "path/to/my-command";
				cmd.arguments = [ "--arg1", "--arg2" ];
				return cmd;
			}
		}
	}

Then, *building* the product "my-command" will run the command.
Maybe you need to tune the Rule's properties to have it work as expected (as written above: this is untested).
See also https://doc.qt.io/qbs/qml-qbslanguageitems-rule.html and https://doc.qt.io/qbs/commands.html for more info.

However, this won't show up as a runnable in QtCreator because the execution of the command is happening as a build step and there is no artifact to be executed after building.
But "my-command" would show up in QtCreator's project view and there it could be triggered by right-click -> Build.
Maybe that's good enough for you?

Best
Jochen



More information about the Qbs mailing list