1 /** 2 * Copyright: Copyright (c) 2011 Nick Sabalausky. All rights reserved. 3 * Authors: Nick Sabalausky 4 * Version: Initial created: July 31, 2011 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 6 */ 7 module dvm.commands.DmcInstall; 8 9 import std.stdio : writeln; 10 11 import tango.core.Exception; 12 import tango.io.Stdout; 13 import tango.io.device.File; 14 import tango.net.http.HttpGet; 15 import tango.sys.Common; 16 import tango.sys.Environment; 17 import tango.sys.Process; 18 import tango.sys.win32.Types; 19 import tango.text.Util; 20 import tango.util.compress.Zip : extractArchive; 21 22 import dvm.commands.Command; 23 import dvm.commands.DvmInstall; 24 import dvm.commands.Fetch; 25 import dvm.commands.Use; 26 import dvm.dvm.Wrapper; 27 import dvm.dvm._; 28 import Path = dvm.io.Path; 29 import dvm.util.Util; 30 31 // DMC is Windows-only, but this is allowed on Posix 32 // in case someone wants to try to use it through Wine. 33 34 class DmcInstall : Fetch 35 { 36 private 37 { 38 string archivePath; 39 string tmpCompilerPath; 40 Wrapper wrapper; 41 string installPath_; 42 } 43 44 override void execute () 45 { 46 install; 47 } 48 49 private: 50 51 void install () 52 { 53 archivePath = Path.join(options.path.archives, dmcArchiveName); 54 55 fetchDMC(options.path.archives); 56 writeln("Installing: dmc"); 57 58 unpack; 59 moveFiles; 60 61 version (Windows) 62 installWrapper; 63 } 64 65 void unpack () 66 { 67 tmpCompilerPath = Path.join(options.path.tmp, "dmc"); 68 verbose("Unpacking:"); 69 verbose(options.indentation, "source: ", archivePath); 70 verbose(options.indentation, "destination: ", tmpCompilerPath, '\n'); 71 extractArchive(archivePath, tmpCompilerPath); 72 } 73 74 void moveFiles () 75 { 76 verbose("Moving:"); 77 Path.move(Path.join(tmpCompilerPath, "dm"), installPath); 78 } 79 80 version (Windows) 81 void installWrapper () 82 { 83 wrapper.target = Path.join(installPath, options.path.bin, "dmc.exe"); 84 wrapper.path = Path.join(options.path.dvm, options.path.bin, "dmc.bat"); 85 86 verbose("Installing wrapper: " ~ wrapper.path); 87 wrapper.write; 88 } 89 90 string installPath () 91 { 92 if (installPath_.length > 0) 93 return installPath_; 94 95 return installPath_ = Path.join(options.path.compilers, "dmc"); 96 } 97 }