Skip to main content

qbs - Quick (and dirty) build system

qbs is designed for people who perform the same tasks on small programs repeatedly and in a hurry. This can be helpful when you are learning a programming language and want to build (and rebuild) a series of short sample programs.

If you need qbs to do something more, chances are it's wiser just to use GNU Make. However, if you want a small feature (besides automated tests, which are a work in progress), submit an issue.

Table of Contents

Configuration

Format

qbs takes configuration files in the JSON file format. They have the following structure:

{
	"language1": {
		"command1": ["arg1", "argN"],
		"commandN": ["arg1", "argN"]
	},
	"languageN": {
		"command1": ["arg1", "argN"],
		"commandN": ["arg1", "argN"]
	}
}

Command arguments

Commands run by qbs will not be executed in a subshell. This means that you do not need to escape spaces, but you have to put each argument in a separate element in the array. You also cannot use shell-specific commands, such as [[.1

1. You can use [ though, because that's actually a binary program.

Filename replacement

In each command, you may use the strings {progname} and {progext}, which will be replaced by the path to the file which is being built (without the file extension) and the file extension of the file which is being built (with the dot), respectively.

Language aliases

qbs supports aliasing languages so that languages with weird filename conventions can all be built in the same way. The syntax is:

{
	"language": "alias"
}

i.e. instead of providing a map of commands, you just provide a string which holds the name of the language to actually use.

This way, if you want python files to be built even though the file extension is .py, you can do this:

{
	"py": "python"
}

Configuration file loading

qbs loads configuration files in the following orders:

Windows

C:\ProgramData\qbs\qbs.json
C:\Users\{username}\AppData\Roaming\qbs\qbs.json
.\qbs.json

Linux / OS X

/etc/qbs.json
/home/{username}/.qbs.json
/home/{username}/.config/qbs.json
./.qbs.json
./qbs.json

Configuration overriding

Each of the configuration files listed is loaded (after the default configuration file provided with this package) when qbs is run. Each configuration file overrides only the languages specified within it from the previous configuration files. This allows users to override settings for various languages on a per-system, per-user, and per-directory basis.

Command-line usage

Note: qbs does not support being used like a library. Importing qbs is not tested.

init

To use qbs, you first must initialize qbs with the file that you will be building. qbs has a built-in command to do this, init:

qbs init hello_world.cpp

init is also the only qbs command that supports arguments. Currently, the only arguments defined are:

-t <template file>
-l <language>

Arguments must fall between init and the filename, like so:

qbs init -l java -t java_template.java

The -t option causes qbs to copy the template file into the source file. It will also replace the same strings listed in Filename replacement within the template file. Here is an example template for an empty Java main class:

public class {progname} {
	public static void main(String[] args) {
		// put your code here
	}
}

The -l option simply selects the language you want to use. To avoid the extra typing of having to use this option, see Language aliases.

Other commands

Any other command will be executed as it is defined in the last-read configuration file.

Beware: because configuration files override one another on a per-language basis, this means that you can unset commands!

Command shortening

qbs allows you to only type a little bit of the command you want, and it will figure out which one you mean. For example, if init is the only command that starts with the letter 'i', then you can type qbs i instead of qbs init. However, if there is another command instantiate, you would have to type at lease ini for init and ins for instantiate.

Beware: If you create a command that contains the full text of another command at the beginning, you will not be able to execute the shorter command! For example, if you have a command initialize in addition to the built-in command init, you will not be able to execute init because qbs cannot tell if you meant for it to be short for initialize or for it to mean just init. You would also only be able to execute initialize by typing at least initi, for the same reason.

Command chaining

qbs allows you to execute multiple commands in one line. For example, if you have the functions build and run declared for the language cpp in addition to the built-in command init, the following would be a perfectly valid way to build and run the file hello.cpp with qbs:

qbs i hello.cpp b r

Now do you see why I called it quick and dirty?

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qbs-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qbs-1.0.0-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file qbs-1.0.0.tar.gz.

File metadata

  • Download URL: qbs-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for qbs-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eaaa0eb28ef1017f8194849851a64e5e0610336a31b03b2193b7597da182c7d9
MD5 2b5c60773921aa45eb823e5abba862ad
BLAKE2b-256 1d661a554a0f104ad1ef6f738c614a88b5b86bb2a2fe0ff2043c46f8060dcb8d

See more details on using hashes here.

File details

Details for the file qbs-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: qbs-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for qbs-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c34cc3faece0121936b58a7cbc644bea0fef56d5fb0c8ce64431ca7f68ef249
MD5 42187dbce78e3906f2fe1468c8a9e7b5
BLAKE2b-256 128d7c8d735da706277aa9151ee7b8d7a1c9d2d93ed8fbe642b4b5c9bd20fdb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page