root/trunk/install.d

Revision 300, 3.8 kB (checked in by aldacron, 3 months ago)

[DerelictFT]
* incorporated Cyborg16's updates for FreeType? 2.3.5 (Ticket #19)
[DerelictGL]
* added mclysenk's changes to load OpenGL extensions on Mac
[All]
* updated copyright header in all source modules (long overdue, that)

Line 
1 /*
2     IMPORTANT: This script currently does not copy any library files anywhere.
3     It only copies the source tree to the directory specified on the command line.
4     All modules will be flattened into a <install_path>/derelict directory.
5     
6     Untested on linux!
7 */
8 /*
9  * Copyright (c) 2004-2008 Derelict Developers
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions are
14  * met:
15  *
16  * * Redistributions of source code must retain the above copyright
17  *   notice, this list of conditions and the following disclaimer.
18  *
19  * * Redistributions in binary form must reproduce the above copyright
20  *   notice, this list of conditions and the following disclaimer in the
21  *   documentation and/or other materials provided with the distribution.
22  *
23  * * Neither the names 'Derelict' nor the names of its contributors
24  *   may be used to endorse or promote products derived from this software
25  *   without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
31  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  */
39
40 version(Tango)
41 {
42     static assert(0, "This script does not support Tango");
43 }
44
45 import std.stdio;
46 import std.path;
47 import std.file;
48 import std.string;
49 import std.c.process;
50
51 version(Windows)
52 {
53     private static const char[] mkdir   = "mkdir ";
54     private static const char[] copyCmd = "@copy /Y ";
55 }
56 else version(linux)
57 {
58     private static const char[] mkdir   = "mkdir ";
59     private static const char[] copyCmd = "cp ";
60 }
61 else
62 {
63     static assert(0, "Unsupported Operating System.");
64 }
65
66 void main(char[][] args)
67 {
68     if(args.length < 2)
69     {
70         writefln("Usage: dmd -run install.d <install_path>");
71         return;
72     }
73    
74     char[] installPath = args[1];
75     if(!exists(installPath))
76     {
77         throw new Error("Path [" ~ installPath ~ " does not exist.");
78     }
79    
80     auto iderelict = std.path.join(installPath, "derelict");
81     if(!exists(iderelict))
82     {
83         execute(mkdir ~ iderelict);
84     }
85    
86     if(args.length > 2)
87     {
88         for(int i=2; i<args.length; ++i)
89         {
90             auto derelict = std.path.join(args[i], "derelict");
91             if(exists(derelict))
92             {
93                 process(derelict, iderelict, "");
94             }
95         }
96     }
97     else
98     {
99         char[][] dirList = listdir(".");
100         foreach(d; dirList)
101         {
102             if(d[0] == '.' || !isdir(d)) continue;
103             auto derelict = std.path.join(d, "derelict");
104             if(exists(derelict))
105             {
106                 process(derelict, iderelict, "");
107             }
108         }
109     }
110 }
111
112 void process(char[] path, char[] root, char[] dir)
113 {
114     //writefln("Processing %s, %s, %s", path, root, dir);
115     char[] ipath = std.path.join(root, dir);
116     if(!exists(ipath))
117     {
118         //writefln("Create dir %s", ipath);
119         execute(mkdir ~ ipath);
120     }
121    
122     char[][] dirList = listdir(path);
123     foreach(d; dirList)
124     {
125         if(d[0] == '.') continue;
126         auto fullpath = std.path.join(path, d);
127         if(isdir(fullpath))
128         {
129             process(fullpath, ipath, d);
130         }
131         else
132         {
133             auto dst = std.path.join(ipath, d);
134             execute(copyCmd ~ fullpath ~ " " ~ dst);
135             //writefln("Copy %s to %s", fullpath, dst);         
136         }
137     }
138 }
139
140 void execute(char[] cmd)
141 {
142     system(toStringz(cmd));
143 }
Note: See TracBrowser for help on using the browser.