1 /** 2 * Copyright: Copyright (c) 2011 Jacob Carlborg. All rights reserved. 3 * Authors: Jacob Carlborg 4 * Version: Initial created: Jan 16, 2011 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 6 */ 7 module dvm.dvm.Wrapper; 8 9 import mambo.core._; 10 import dvm.dvm.ShellScript; 11 import dvm.io.Path; 12 13 struct Wrapper 14 { 15 string path; 16 string target; 17 18 private ShellScript sh; 19 20 static Wrapper opCall (string path = "", string target = "") 21 { 22 Wrapper wrapper; 23 24 wrapper.path = path; 25 wrapper.target = target; 26 27 return wrapper; 28 } 29 30 void write () 31 { 32 createContent; 33 sh.path = path; 34 sh.write; 35 } 36 37 private void createContent () 38 { 39 native(path.toMutable); 40 native(target.toMutable); 41 42 sh = new ShellScript(path); 43 auto dmd = "dmd"; 44 auto dmdPath = Sh.quote(target); 45 46 sh.shebang; 47 sh.echoOff; 48 sh.nl; 49 50 sh.ifFileIsNotEmpty(dmdPath, { 51 sh.exec(dmdPath, Sh.allArgs); 52 }, { 53 sh.printError(format(`Missing target: "{}"`, target), true); 54 }); 55 } 56 }