Prevent dub from blindly rebuilding every time
This commit is contained in:
parent
df035368e2
commit
43e010d9e8
2
dub.json
2
dub.json
|
@ -24,6 +24,6 @@
|
|||
"bin"
|
||||
],
|
||||
"preGenerateCommands" : [
|
||||
"rdmd --eval=\"auto dir=environment.get(\\\"DUB_PACKAGE_DIR\\\"); dir.buildPath(\\\"bin\\\").mkdirRecurse; auto gitVer = (\\\"git -C \\\"~dir~\\\" describe --tags\\\").executeShell; (gitVer.status == 0 ? gitVer.output.strip : \\\"v\\\" ~ dir.dirName.baseName.findSplitAfter(environment.get(\\\"DUB_ROOT_PACKAGE\\\")~\\\"-\\\")[1]).ifThrown(\\\"0.0.0\\\").chain(newline).to!string.toFile(dir.buildPath(\\\"bin\\\", \\\"dubhash.txt\\\"));\""
|
||||
"rdmd dubhash.d"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import std.algorithm;
|
||||
import std.ascii;
|
||||
import std.conv;
|
||||
import std.exception;
|
||||
import std.file;
|
||||
import std.path;
|
||||
import std.process;
|
||||
import std.range;
|
||||
import std.string;
|
||||
|
||||
void main()
|
||||
{
|
||||
auto dir = environment.get("DUB_PACKAGE_DIR");
|
||||
auto hashFile = dir.buildPath("bin", "dubhash.txt");
|
||||
auto gitVer = executeShell("git -C " ~ dir ~ " describe --tags");
|
||||
auto ver = (gitVer.status == 0 ? gitVer.output.strip
|
||||
: "v" ~ dir.dirName.baseName.findSplitAfter(
|
||||
environment.get("DUB_ROOT_PACKAGE") ~ "-")[1]).ifThrown("0.0.0")
|
||||
.chain(newline).to!string.strip;
|
||||
dir.buildPath("bin").mkdirRecurse;
|
||||
if (!hashFile.exists || ver != hashFile.readText.strip)
|
||||
hashFile.write(ver);
|
||||
}
|
Loading…
Reference in New Issue