Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added a new network model option, LegrandVelho, based on recent evaluation studies.
[simgrid.git] / TeshConfig.js
1 // Tesh configuration file for Windows.
2 // Register all environement variables needed by Tesh
3 // during its compilation and during the running of Tesh files.
4
5
6 // Test if the string s is in the array a.
7 function ArrayContains(a, s)
8 {
9         var i = 0;
10         
11         for(i = 0; i < a.length; i++)
12                 if(a[i] == s)
13                         return true;
14                          
15         return false;           
16 }
17
18 // SimGrid configuration file for Windows.
19 // Register all environement variables needed for the compilation of SimGrid library
20 // and all the tesh suite, examples and test suites.
21
22 var Shell;
23 var UserEnv;
24 var FileSystem;
25
26 var SGBuildDir;                         // This build directory
27 var TeshDir;
28 var TeshExampleDir;
29 var TeshSuiteDir;
30 var TestSuiteDir;
31 var ExampleDir;
32 var SrcDir;
33
34 var Path;
35 var Include;
36
37 var Args = WScript.Arguments;
38
39 // check the arguments to be sure it's right
40 if (Args.Count() < 1)
41 {
42    WScript.Echo("Tesh Configuration.");
43    WScript.Echo("Configure the environment of Tesh (mini test shell)");
44    WScript.Echo("\n\tUsage: CScript TeshConfig.js <SGBuildDir> <TeshVersion>");
45    WScript.Quit(1);
46 }
47
48 SGBuildDir = Args.Item(0);
49 TeshVersion = Args.Item(1);
50
51 var FileSystem = new ActiveXObject("Scripting.FileSystemObject");
52
53 // Check the directories specified as parameters of the script.
54
55 if(!FileSystem.FolderExists(SGBuildDir))
56 {
57         WScript.Echo("Not a directory `(" + SGBuildDir + ")'"); 
58         WScript.Quit(2);
59 }
60
61
62
63 // Build the directories
64
65 TeshDir = SGBuildDir + "tools\\tesh" + TeshVersion;
66 TeshExampleDir = TeshDir + "\\examples";
67 TeshSuiteDir = SGBuildDir + "teshsuite";
68 TestSuiteDir = SGBuildDir + "testsuite";
69 ExampleDir =  SGBuildDir + "examples";
70 SrcDir = ExampleDir + "\\msg";
71
72
73 Shell = WScript.CreateObject("Wscript.Shell");
74 UserEnv = Shell.Environment("USER");
75
76 WScript.Echo("Configuration of Tesh Library Compilation in progress...");
77 WScript.Echo("Build directory : " + SGBuildDir);
78
79
80 // Include Tesh in the Path
81 Path = UserEnv("PATH");
82
83 if(typeof(UserEnv("PATH")) != "undefined" && Path.length > 0)
84 {
85         var a = Path.split(";");
86         
87         // Add the Visual C include directories
88         if(!ArrayContains(a, TeshDir))
89                 Path = Path + TeshDir + ";";
90 }
91 else
92 {
93         Path = TeshDir + ";";
94 }
95
96 Include = UserEnv("INCLUDE");
97
98 if(typeof(UserEnv("INCLUDE")) != "undefined" && Include.length > 0)
99 {
100         var a = Include.split(";");
101         
102         // Add the Visual C include directories
103         if(!ArrayContains(a, TeshDir + "\\include"))
104                 Include = Include + TeshDir + "\\include" + ";";
105                 
106         if(!ArrayContains(a, TeshDir + "\\w32\\include"))
107                 Include = Include + TeshDir + "\\w32\\include" + ";";
108 }
109 else
110 {
111         Include = TeshDir + "\\include";
112         Include = Include + ";" + TeshDir + "\\w32\\include" + ";";
113 }
114
115 // Build environement of Tesh.
116 UserEnv("TESH") = "tesh";
117 UserEnv("TESH_DIR") = TeshDir;
118 UserEnv("TESHEXAMPLE_DIR") = TeshExampleDir;
119 UserEnv("TESHSUITE_DIR") = TeshSuiteDir;
120 UserEnv("TESTSUITE_DIR") = TestSuiteDir;
121 UserEnv("EXAMPLE_DIR") = ExampleDir;
122 UserEnv("SRCDIR") = SrcDir;
123 UserEnv("INCLUDE") = Include;
124
125
126 UserEnv("PATH") = Path;
127
128
129 WScript.Echo("Configuration successeded");