Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
AAAAh. let's try to fix the fix of a fix. Correctly if possible
[simgrid.git] / SimGridConfig.js
1 // SimGrid configuration file for Windows.\r
2 // Register all environement variables needed for the compilation of SimGrid library\r
3 // and all the tesh suite, examples and test suites.\r
4 \r
5 \r
6 // FIXME declare the include directory in the environment of the compilation.\r
7 \r
8 // Test if the string s is in the array a.\r
9 function ArrayContains(a, s)\r
10 {\r
11         var i = 0;\r
12         \r
13         for(i = 0; i < a.length; i++)\r
14                 if(a[i] == s)\r
15                         return true;\r
16                          \r
17         return false;           \r
18 }\r
19 \r
20 // SimGrid configuration file for Windows.\r
21 // Register all environement variables needed for the compilation of SimGrid library\r
22 // and all the tesh suite, examples and test suites.\r
23 \r
24 var Shell;\r
25 var UserEnv;\r
26 var FileSystem;\r
27 \r
28 \r
29 var DebugLibraryPath;           // The path of the SimGrid debug library\r
30 var ReleaseLibraryPath;         // The path of the SimGrid release library\r
31 \r
32 var Lib;                                        // The value of the environment variable LIB\r
33 var Include;                            // The value of the environment variable INCLUDE\r
34 var Libs;                                       // SimGrid library name (the value of the environment variable LIBS).\r
35 \r
36 \r
37 var VCInstallDir;                       // Visual C install directory\r
38 var SGBuildDir;                         // This build directory\r
39 var JNIIncludeDir;                      // The path of the jni.h header\r
40 \r
41 var Args = WScript.Arguments;\r
42 \r
43 // check the arguments to be sure it's right\r
44 if (Args.Count() < 3)\r
45 {\r
46    WScript.Echo("SimGrid Configuration.");\r
47    WScript.Echo("Configure the environment of the compilation of SimGrid library");\r
48    WScript.Echo("\n\tUsage: CScript SimGridConfig.js <SGBuildDir> <VCInsallDir> <JNIIncludeDir>");\r
49    WScript.Quit(1);\r
50 }\r
51 \r
52 SGBuildDir = Args.Item(0);\r
53 VCInstallDir = Args.Item(1);\r
54 JNIIncludeDir = Args.Item(2); \r
55 \r
56 var FileSystem = new ActiveXObject("Scripting.FileSystemObject");\r
57 \r
58 // Build the 2 paths of SimGrid library paths (debug and release)\r
59 ReleaseLibraryPath = SGBuildDir + "build\\vc7\\simgrid\\Release";\r
60 DebugLibraryPath = SGBuildDir + "build\\vc7\\simgrid\\Debug";\r
61 \r
62 // Check the directories specified as parameters of the script.\r
63 \r
64 if(!FileSystem.FolderExists(SGBuildDir))\r
65 {\r
66         WScript.Echo("Not a directory `(" + SGBuildDir + ")'"); \r
67         WScript.Quit(2);\r
68 }\r
69 else if(!FileSystem.FolderExists(VCInstallDir))\r
70 {\r
71         WScript.Echo("Not a directory `(" + VCInstallDir + ")'");       \r
72         WScript.Quit(3);\r
73 }\r
74 else if(!FileSystem.FolderExists(JNIIncludeDir))\r
75 {\r
76         WScript.Echo("Not a directory `(" + JNIIncludeDir + ")'");      \r
77         WScript.Quit(5);\r
78 }\r
79 \r
80 Shell = WScript.CreateObject("Wscript.Shell");\r
81 UserEnv = Shell.Environment("USER");\r
82 \r
83 WScript.Echo("Configuration of SimGrig Library Compilation in progress...");\r
84 WScript.Echo("Build directory : " + SGBuildDir);        \r
85 WScript.Echo("Visual C install directory : " + VCInstallDir);\r
86 WScript.Echo("Java Native Interface include directory : " + JNIIncludeDir);\r
87 \r
88 \r
89 // Build the content of the environment variable LIB.\r
90 Lib = UserEnv("LIB");\r
91 \r
92 if(typeof(UserEnv("LIB")) != "undefined" && Lib.length > 0)\r
93 {\r
94         var a = Lib.split(";");\r
95         \r
96         if(!ArrayContains(a,DebugLibraryPath))\r
97                 Lib = Lib + DebugLibraryPath + ";";;\r
98                 \r
99          if(!ArrayContains(a,ReleaseLibraryPath))\r
100                 Lib = Lib +  ReleaseLibraryPath + ";";\r
101                 \r
102         if(!ArrayContains(a, VCInstallDir + "lib"))\r
103                 Lib = Lib +  VCInstallDir + "lib" + ";";\r
104                 \r
105         if(!ArrayContains(a, VCInstallDir + "PlatformSDK\\Lib"))\r
106                 Lib = Lib +  VCInstallDir + "PlatformSDK\\Lib" + ";";   \r
107 }\r
108 else\r
109 {\r
110         // SimGrid librairy paths\r
111          Lib = DebugLibraryPath + ";";\r
112          Lib = Lib + ReleaseLibraryPath + ";";\r
113          // Visual C library paths.\r
114          Lib = Lib + VCInstallDir + "lib" + ";";\r
115          Lib = Lib + VCInstallDir + "PlatformSDK\\Lib" + ";";\r
116                 \r
117 }\r
118 \r
119 // Build the content of the environment variable INCLUDE.\r
120 Include = UserEnv("INCLUDE");\r
121 \r
122 if(typeof(UserEnv("INCLUDE")) != "undefined" && Include.length > 0)\r
123 {\r
124         \r
125         var a = Include.split(";");\r
126         \r
127         // Add the Visual C include directories\r
128         if(!ArrayContains(a, VCInstallDir + "include"))\r
129                 Include = Include + VCInstallDir + "include" + ";";\r
130                 \r
131         if(!ArrayContains(a,VCInstallDir + "PlatformSDK\\include"))\r
132                 Include = Include +  VCInstallDir + "PlatformSDK\\include" + ";";\r
133         \r
134         \r
135         // Add the SimGrid include directories\r
136         if(!ArrayContains(a,SGBuildDir + "src"))\r
137                 Include = Include + SGBuildDir + "src" + ";";\r
138                 \r
139         if(!ArrayContains(a,SGBuildDir + "include"))\r
140                 Include = Include + SGBuildDir + "include" + ";";\r
141                 \r
142         if(!ArrayContains(a,SGBuildDir + "src\\include"))\r
143                 Include = Include + SGBuildDir + "src\\include" + ";";\r
144                 \r
145         // Add the JNI include directories.\r
146         if(!ArrayContains(a,JNIIncludeDir))\r
147                 Include = Include +  JNIIncludeDir + ";";\r
148                 \r
149         if(!ArrayContains(a,JNIIncludeDir + "awin32"))\r
150                 Include = Include + JNIIncludeDir + "win32" + ";";\r
151         \r
152 }\r
153 else\r
154 {\r
155         // Visual C include directories\r
156         Include = VCInstallDir + "include" + ";";\r
157         Include = Include + VCInstallDir + "PlatformSDK\\include" + ";";\r
158         // SimGrid include directories.\r
159         Include = Include + SGBuildDir + "src" + ";";\r
160         Include = Include + SGBuildDir + "include" + ";" ;\r
161         Include = Include + SGBuildDir + "src\\include" + ";";\r
162         // JNI include directories.\r
163         Include = Include + JNIIncludeDir + ";";\r
164         Include = Include + JNIIncludeDir + "win32" + ";";\r
165          \r
166 }\r
167 \r
168 // Build the content of the environment variable LIBS.\r
169 Libs = UserEnv("LIBS");\r
170 \r
171 if(typeof(UserEnv("LIBS")) != "undefined" && Libs.length > 0)\r
172 {\r
173         var a = Libs.split(";");\r
174         \r
175         if(!ArrayContains(a, "simgrid.lib"))\r
176                 Libs = Libs + "simgrid.lib" + ";";\r
177 }\r
178 else\r
179 {\r
180         Libs = "simgrid.lib" + ";";\r
181 }\r
182 \r
183 // Update the environment variables.\r
184 UserEnv("LIB") = Lib;\r
185 UserEnv("INCLUDE") = Include;\r
186 UserEnv("LIBS") = Libs;\r
187 \r
188 \r
189 \r
190 WScript.Echo("Configuration successeded");\r