1 /* 2 Copyright (c) 2014 Timur Gafarov 3 4 Boost Software License - Version 1.0 - August 17th, 2003 5 6 Permission is hereby granted, free of charge, to any person or organization 7 obtaining a copy of the software and accompanying documentation covered by 8 this license (the "Software") to use, reproduce, display, distribute, 9 execute, and transmit the Software, and to prepare derivative works of the 10 Software, and to permit third-parties to whom the Software is furnished to 11 do so, all subject to the following: 12 13 The copyright notices in the Software and this entire statement, including 14 the above license grant, this restriction and the following disclaimer, 15 must be included in all copies of the Software, in whole or in part, and 16 all derivative works of the Software, unless such copies or derivative 17 works are solely in the form of machine-executable object code generated by 18 a source language processor. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 23 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 24 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 25 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 DEALINGS IN THE SOFTWARE. 27 */ 28 29 module project; 30 31 import std.file; 32 import std.datetime; 33 import std.array; 34 35 import std.stdio; 36 37 import cmdopt; 38 import conf; 39 import dmodule; 40 import exdep; 41 42 class Project 43 { 44 CmdOptions ops; 45 Config config; 46 47 int[string] versionIds; 48 int[string] debugIds; 49 string ext; 50 51 DModule[string] modules; 52 string mainModuleFilename; 53 54 Exdep[string] exdeps; 55 56 this(CmdOptions cmdops, Config conf) 57 { 58 ext = conf.get("source.ext"); 59 ops = cmdops; 60 config = conf; 61 62 version(Posix) versionIds["Posix"] = 1; 63 version(linux) versionIds["linux"] = 1; 64 version(Windows) versionIds["Windows"] = 1; 65 version(Win32) versionIds["Win32"] = 1; 66 version(Win64) versionIds["Win64"] = 1; 67 version(OSX) versionIds["OSX"] = 1; 68 version(X86) versionIds["X86"] = 1; 69 version(X86_64) versionIds["X86_64"] = 1; 70 versionIds["D_Version2"] = 1; 71 72 genExdeps(); 73 } 74 75 DModule addModule(string filename) 76 { 77 auto m = new DModule(filename, ext); 78 m.versionIds = versionIds.dup; 79 m.debugIds = debugIds.dup; 80 modules[filename] = m; 81 return m; 82 } 83 84 string[] getExternalDeps(string depsConfFilename, out Config conf) 85 { 86 string[] res; 87 88 Config depsConf = new Config(); 89 90 if (exists(depsConfFilename)) 91 readConfiguration(depsConf, depsConfFilename); 92 93 string deps = depsConf.get("project.dependencies"); 94 95 if (deps.length) 96 res = split(deps); 97 98 conf = depsConf; 99 100 return res; 101 } 102 103 Config genExdeps(string depsConfFilename = "deps.conf") 104 { 105 Config conf; 106 string[] deps = getExternalDeps(depsConfFilename, conf); 107 108 foreach(desc; deps) 109 { 110 Exdep e = new Exdep(desc, ops.https, ops); 111 if (!(e.id in exdeps)) 112 { 113 exdeps[e.id] = e; 114 auto c = genExdeps(e.location ~ "/" ~ "deps.conf"); 115 e.subdir = c.get("project.source.dir"); 116 } 117 } 118 119 return conf; 120 } 121 } 122