1 /* 2 *Copyright (C) 2018 Laurent Tréguier 3 * 4 *This file is part of DLS. 5 * 6 *DLS is free software: you can redistribute it and/or modify 7 *it under the terms of the GNU General Public License as published by 8 *the Free Software Foundation, either version 3 of the License, or 9 *(at your option) any later version. 10 * 11 *DLS is distributed in the hope that it will be useful, 12 *but WITHOUT ANY WARRANTY; without even the implied warranty of 13 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 *GNU General Public License for more details. 15 * 16 *You should have received a copy of the GNU General Public License 17 *along with DLS. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 module dls.util.setup; 22 23 void initialSetup() 24 { 25 version (Windows) 26 { 27 import std.algorithm : splitter; 28 import std.file : exists; 29 import std.path : buildNormalizedPath, dirName; 30 import std.process : environment; 31 32 version (X86_64) 33 { 34 enum binDir = "bin64"; 35 } 36 else 37 { 38 enum binDir = "bin"; 39 } 40 41 auto pathParts = splitter(environment["PATH"], ';'); 42 43 foreach (path; pathParts) 44 { 45 if (exists(buildNormalizedPath(path, "dmd.exe"))) 46 { 47 environment["PATH"] = buildNormalizedPath(dirName(path), binDir) 48 ~ ';' ~ environment["PATH"]; 49 return; 50 } 51 } 52 53 foreach (path; pathParts) 54 { 55 if (exists(buildNormalizedPath(path, "ldc2.exe"))) 56 { 57 environment["PATH"] = path ~ ';' ~ environment["PATH"]; 58 } 59 } 60 } 61 }