1 module dflexe; 2 ///come from the old 'dflexe.d' 3 import std.path; 4 import std.stream; 5 import dfl.application; 6 import std.conv; 7 private import dfl.internal.winapi, dfl.internal.utf;//dfl.all, 8 9 alias dfl.internal.winapi.ShellExecuteA ShellExecuteA; 10 alias dfl.environment.Environment Environment; 11 12 13 private extern(Windows) 14 { 15 DWORD GetLogicalDriveStringsA(DWORD nBufferLength,LPSTR lpBuffer); 16 UINT GetDriveTypeA(LPCTSTR lpRootPathName); 17 DWORD GetShortPathNameA(LPCSTR lpszLongPath, LPSTR lpszShortPath, DWORD cchBuffer); 18 19 20 enum: UINT 21 { 22 DRIVE_FIXED = 3, 23 } 24 alias DWORD function(LPCWSTR lpszLongPath, LPWSTR lpszShortPath, DWORD cchBuffer) GetShortPathNameWProc; 25 } 26 27 28 enum Flags: DWORD 29 { 30 NONE = 0, 31 32 INSTALLED = 1, // Everything is setup. 33 } 34 35 36 string importdir,startpath, basepath; 37 string dmdpath, dmdpath_windows = "\0"; 38 void main(string[] args) 39 { 40 startpath = getshortpath(Application.startupPath); 41 if(args.length <2) return; 42 buildExe(args[1]); 43 } 44 45 void buildExe(string args) 46 { 47 //findimportdir(); 48 49 //string dflsrcdir = std.path.buildPath(importdir, "dfl"); 50 string batfilepath = std.path.buildPath(startpath, "exe.bat"); 51 52 scope batf = new BufferedFile(batfilepath, FileMode.OutNew); 53 string buildstr ="dmd -de -debug -w -property -X -I$(DMDInstallDir)windows\\import dfl_debug.lib ole32.lib oleAut32.lib gdi32.lib Comctl32.lib Comdlg32.lib advapi32.lib uuid.lib ws2_32.lib -L/SUBSYSTEM:WINDOWS "~args~"\r\n"; 54 batf.writeString(buildstr); 55 batf.writeString("\r\n"); 56 //batf.writeString("\r\n pause"); 57 batf.close(); 58 59 std.process.system(batfilepath); 60 61 std.file.remove(batfilepath); 62 } 63 64 65 string getshortpath(string fn) 66 { 67 if(dfl.internal.utf.useUnicode) 68 { 69 version(STATIC_UNICODE) 70 { 71 alias GetShortPathNameW proc; 72 } 73 else 74 { 75 const string NAME = "GetShortPathNameW"; 76 static GetShortPathNameWProc proc = null; 77 78 if(!proc) 79 { 80 proc = cast(GetShortPathNameWProc)GetProcAddress(GetModuleHandleA("kernel32.dll"), NAME.ptr); 81 if(!proc) 82 throw new Exception("GetShortPathNameW not found"); 83 } 84 } 85 86 DWORD len; 87 wchar[MAX_PATH] s; 88 len = proc(dfl.internal.utf.toUnicodez(fn), s.ptr, s.length); 89 return to!string(s[0..len]); 90 } 91 else 92 { 93 DWORD len; 94 char[MAX_PATH] s; 95 len = GetShortPathNameA(dfl.internal.utf.toAnsiz(fn), s.ptr, s.length); 96 return to!string(s[0..len]); 97 } 98 } 99