Forked from ArpegiusWhooves/modules.binaryrcc.binaryrcc.qbs
Created
October 25, 2016 12:48
-
-
Save DOOMer/9983f51ea8f8118fb457dca52c291513 to your computer and use it in GitHub Desktop.
QBS module that produce binnary resource files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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