+// SimGrid configuration file for Windows.\r
+// Register all environement variables needed for the compilation of SimGrid library\r
+// and all the tesh suite, examples and test suites.\r
+\r
+\r
+// FIXME declare the include directory in the environment of the compilation.\r
+\r
+// Test if the string s is in the array a.\r
+function ArrayContains(a, s)\r
+{\r
+ var i = 0;\r
+ \r
+ for(i = 0; i < a.length; i++)\r
+ if(a[i] == s)\r
+ return true;\r
+ \r
+ return false; \r
+}\r
+\r
+// SimGrid configuration file for Windows.\r
+// Register all environement variables needed for the compilation of SimGrid library\r
+// and all the tesh suite, examples and test suites.\r
+\r
+var Shell;\r
+var UserEnv;\r
+var FileSystem;\r
+\r
+\r
+var DebugLibraryPath; // The path of the SimGrid debug library\r
+var ReleaseLibraryPath; // The path of the SimGrid release library\r
+\r
+var Lib; // The value of the environment variable LIB\r
+var Include; // The value of the environment variable INCLUDE\r
+var Libs; // SimGrid library name (the value of the environment variable LIBS).\r
+\r
+\r
+var VCInstallDir; // Visual C install directory\r
+var SGBuildDir; // This build directory\r
+var JNIIncludeDir; // The path of the jni.h header\r
+\r
+var Args = WScript.Arguments;\r
+\r
+// check the arguments to be sure it's right\r
+if (Args.Count() < 3)\r
+{\r
+ WScript.Echo("SimGrid Configuration.");\r
+ WScript.Echo("Configure the environment of the compilation of SimGrid library");\r
+ WScript.Echo("\n\tUsage: CScript SimGridConfig.js <SGBuildDir> <VCInsallDir> <JNIIncludeDir>");\r
+ WScript.Quit(1);\r
+}\r
+\r
+SGBuildDir = Args.Item(0);\r
+VCInstallDir = Args.Item(1);\r
+JNIIncludeDir = Args.Item(2); \r
+\r
+var FileSystem = new ActiveXObject("Scripting.FileSystemObject");\r
+\r
+// Build the 2 paths of SimGrid library paths (debug and release)\r
+ReleaseLibraryPath = SGBuildDir + "\\build\\vc7\\simgrid\\Release";\r
+DebugLibraryPath = SGBuildDir + "\\build\\vc7\\simgrid\\Debug";\r
+\r
+// Check the directories specified as parameters of the script.\r
+\r
+if(!FileSystem.FolderExists(SGBuildDir))\r
+{\r
+ WScript.Echo("Not a directory `(" + SGBuildDir + ")'"); \r
+ WScript.Quit(2);\r
+}\r
+else if(!FileSystem.FolderExists(VCInstallDir))\r
+{\r
+ WScript.Echo("Not a directory `(" + VCInstallDir + ")'"); \r
+ WScript.Quit(3);\r
+}\r
+else if(!FileSystem.FolderExists(JNIIncludeDir))\r
+{\r
+ WScript.Echo("Not a directory `(" + JNIIncludeDir + ")'"); \r
+ WScript.Quit(5);\r
+}\r
+\r
+Shell = WScript.CreateObject("Wscript.Shell");\r
+UserEnv = Shell.Environment("USER");\r
+\r
+WScript.Echo("Configuration of SimGrig Library Compilation in progress...");\r
+WScript.Echo("Build directory : " + SGBuildDir); \r
+WScript.Echo("Visual C install directory : " + VCInstallDir);\r
+WScript.Echo("Java Native Interface include directory : " + JNIIncludeDir);\r
+\r
+\r
+// Build the content of the environment variable LIB.\r
+Lib = UserEnv("LIB");\r
+\r
+if(typeof(UserEnv("LIB")) != "undefined" && Lib.length > 0)\r
+{\r
+ var a = Lib.split(";");\r
+ \r
+ if(!ArrayContains(a,DebugLibraryPath))\r
+ Lib = Lib + DebugLibraryPath + ";";;\r
+ \r
+ if(!ArrayContains(a,ReleaseLibraryPath))\r
+ Lib = Lib + ReleaseLibraryPath + ";";\r
+ \r
+ if(!ArrayContains(a, VCInstallDir + "lib"))\r
+ Lib = Lib + VCInstallDir + "lib" + ";";\r
+ \r
+ if(!ArrayContains(a, VCInstallDir + "PlatformSDK\\Lib"))\r
+ Lib = Lib + VCInstallDir + "PlatformSDK\\Lib" + ";"; \r
+}\r
+else\r
+{\r
+ // SimGrid librairy paths\r
+ Lib = DebugLibraryPath + ";";\r
+ Lib = Lib + ReleaseLibraryPath + ";";\r
+ // Visual C library paths.\r
+ Lib = Lib + VCInstallDir + "lib" + ";";\r
+ Lib = Lib + VCInstallDir + "PlatformSDK\\Lib" + ";";\r
+ \r
+}\r
+\r
+// Build the content of the environment variable INCLUDE.\r
+Include = UserEnv("INCLUDE");\r
+\r
+if(typeof(UserEnv("INCLUDE")) != "undefined" && Include.length > 0)\r
+{\r
+ \r
+ var a = Include.split(";");\r
+ \r
+ // Add the Visual C include directories\r
+ if(!ArrayContains(a, VCInstallDir + "include"))\r
+ Include = Include + VCInstallDir + "include" + ";";\r
+ \r
+ if(!ArrayContains(a,VCInstallDir + "PlatformSDK\\include"))\r
+ Include = Include + VCInstallDir + "PlatformSDK\\include" + ";";\r
+ \r
+ \r
+ // Add the SimGrid include directories\r
+ if(!ArrayContains(a,SGBuildDir + "src"))\r
+ Include = Include + SGBuildDir + "src" + ";";\r
+ \r
+ if(!ArrayContains(a,SGBuildDir + "include"))\r
+ Include = Include + SGBuildDir + "include" + ";";\r
+ \r
+ if(!ArrayContains(a,SGBuildDir + "src\\include"))\r
+ Include = Include + SGBuildDir + "src\\include" + ";";\r
+ \r
+ // Add the JNI include directories.\r
+ if(!ArrayContains(a,JNIIncludeDir))\r
+ Include = Include + JNIIncludeDir + ";";\r
+ \r
+ if(!ArrayContains(a,JNIIncludeDir + "awin32"))\r
+ Include = Include + JNIIncludeDir + "win32" + ";";\r
+ \r
+}\r
+else\r
+{\r
+ // Visual C include directories\r
+ Include = VCInstallDir + "include" + ";";\r
+ Include = Include + VCInstallDir + "PlatformSDK\\include" + ";";\r
+ // SimGrid include directories.\r
+ Include = Include + SGBuildDir + "src" + ";";\r
+ Include = Include + SGBuildDir + "include" + ";" ;\r
+ Include = Include + SGBuildDir + "src\\include" + ";";\r
+ // JNI include directories.\r
+ Include = Include + JNIIncludeDir + ";";\r
+ Include = Include + JNIIncludeDir + "win32" + ";";\r
+ \r
+}\r
+\r
+// Build the content of the environment variable LIBS.\r
+Libs = UserEnv("LIBS");\r
+\r
+if(typeof(UserEnv("LIBS")) != "undefined" && Libs.length > 0)\r
+{\r
+ var a = Libs.split(";");\r
+ \r
+ if(!ArrayContains(a, "simgrid.lib"))\r
+ Libs = Libs + "simgrid.lib" + ";";\r
+}\r
+else\r
+{\r
+ Libs = "simgrid.lib" + ";";\r
+}\r
+\r
+// Update the environment variables.\r
+UserEnv("LIB") = Lib;\r
+UserEnv("INCLUDE") = Include;\r
+UserEnv("LIBS") = Libs;\r
+\r
+\r
+\r
+WScript.Echo("Configuration successeded");\r