[QBS] Using qbs for in-source build
orgads at gmail.com
Tue Aug 4 22:14:54 CEST 2015
I have a code generator that transforms html (and html-related files like
css) to cpp.
The source files are located in some nested directory tree, and the
generator is in its top level (named pbuilder).
The code generator produces its artifacts in the source directory. I can't
control it (it's a closed binary executable).
I'd like to compare timestamps of the input and output file, and generate
iff the input is newer.
This is what I have so far:
import qbs 1.0
name: "Input Files"
filePath: FileInfo.path(input.filePath) + '/' +
FileInfo.baseName(input.filePath) + ".cpp"
var pbuilderPath = project.path + "/pbuilder";
var cmd = new Command(pbuilderPath, input.filePath);
cmd.description = 'pbuilding ' + input.fileName;
cmd.highlight = 'compiler';
When I execute it for the first time, it generates all the files.
Later, as long as I don't modify the qbs file or delete the build
graph, only source files that were modified are regenerated, which is
The problems I'm facing are:
- If I delete the output file it is not regenerated (unless I
delete the build graph, which regenerates all the files)
- If the source file is modified, but the target file has a newer
date (e.g. pbuilder was invoked from the shell), it is still
- On the first run, I'd like to avoid regenerating up-to-date
targets. I can live with that though.
- In my example, I simplified the generator's output. The generator
actually produces 2 files: input.c and input_v.cpp. After it finishes,
I need to rename input.c -> input.cpp (overwriting the existing one),
and delete input_v.cpp.
I'm currently using a rather ugly Makefile for this, which works quite
well, but is hard to maintain.
How can this be done correctly?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Qbs