1 module dsemver.buildinterface; 2 3 import std.file; 4 import std.stdio; 5 import std.process; 6 import std.format; 7 import std..string; 8 9 import dsemver.options; 10 11 private enum dsemverDir = ".dsemver"; 12 13 private string getDflags() { 14 auto r = executeShell("dub describe --data=dflags"); 15 return r.output.strip(); 16 } 17 18 private string jsonFile(string dfiles, string ver) { 19 executeShell("dub clean"); 20 const fn = format("%s/dsemver_%s.json", dsemverDir, ver); 21 const s = "DFLAGS=\"%s -X -Xf=%s\" dub build" 22 .format(dfiles, fn); 23 writeln(s); 24 executeShell(s); 25 return fn; 26 } 27 28 string buildInterface(string ver) { 29 string oldCwd = getcwd(); 30 scope(exit) { 31 chdir(oldCwd); 32 } 33 chdir(getOptions().projectPath); 34 35 if(!exists(dsemverDir)) { 36 mkdir(dsemverDir); 37 } 38 39 const dflags = getDflags(); 40 return getOptions().projectPath ~ "/" ~ jsonFile(dflags, ver); 41 }