Skip to content

Instantly share code, notes, and snippets.

@ArpegiusWhooves
Created December 3, 2015 01:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ArpegiusWhooves/9b9d95eb238b995e45fa to your computer and use it in GitHub Desktop.
Save ArpegiusWhooves/9b9d95eb238b995e45fa to your computer and use it in GitHub Desktop.
QBS module that produce binnary resource files.
import qbs
import qbs.FileInfo
import qbs.Xml
Module {
property bool compress: false
FileTagger {
patterns: "*.qrc"
fileTags: ["qrc"]
}
Rule {
inputs: ["qrc"] // needed to trigger this rule
Artifact {
filePath: {
return FileInfo.baseName(input.fileName)+".rcc";
}
fileTags: ["rcc"]
}
prepare: {
var rccToolPath = product.moduleProperty("Qt.core", "binPath");
if(!rccToolPath) throw "Unknown resource compiler path:\"" + rccTool + "\"!";
var args = ["-binary", input.filePath,
"-o",output.filePath ];
if(!product.moduleProperty("binaryrcc","compress"))
args.unshift("-no-compress");
var cmd = new Command(rccToolPath+"/rcc", args);
cmd.description = "generating binnary rcc from "+input.fileName;
return cmd;
}
}
Scanner {
inputs: ["qrc"]
scan: {
var xml = new XmlDomDocument();
xml.load(input.fileName);
var fileTag = xml.firstChild("RCC").firstChild("qresource");
fileTag= fileTag.firstChild("file");
var dependencies = [];
while(fileTag&&fileTag.isElement()) {
dependencies.push(fileTag.text());
fileTag= fileTag.nextSibling("file");
}
print(input.fileName+" depends on:\n "+dependencies.join("\n "));
return dependencies;
}
}
Depends { name: "Qt.core" }
}
Product {
name:"resources"
type:"rcc"
files: "*.qrc"
Group {
fileTagsFilter: product.type
qbs.install: true
}
qbsSearchPaths: "."
Depends { name: "binaryrcc" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment