OpenCores
URL https://opencores.org/ocsvn/sport/sport/trunk

Subversion Repositories sport

[/] [sport/] [trunk/] [syn/] [xilinx/] [vivado/] [sport_top/] [sport_top.runs/] [impl_1/] [ISEWrap.js] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 jeaander
//
2
//  Vivado(TM)
3
//  ISEWrap.js: Vivado Runs Script for WSH 5.1/5.6
4
//  Copyright 1986-1999, 2001-2013 Xilinx, Inc. All Rights Reserved. 
5
//
6
 
7
// GLOBAL VARIABLES
8
var ISEShell = new ActiveXObject( "WScript.Shell" );
9
var ISEFileSys = new ActiveXObject( "Scripting.FileSystemObject" );
10
var ISERunDir = "";
11
var ISELogFile = "runme.log";
12
var ISELogFileStr = null;
13
var ISELogEcho = true;
14
var ISEOldVersionWSH = false;
15
 
16
 
17
 
18
// BOOTSTRAP
19
ISEInit();
20
 
21
 
22
 
23
//
24
// ISE FUNCTIONS
25
//
26
function ISEInit() {
27
 
28
  // 1. RUN DIR setup
29
  var ISEScrFP = WScript.ScriptFullName;
30
  var ISEScrN = WScript.ScriptName;
31
  ISERunDir =
32
    ISEScrFP.substr( 0, ISEScrFP.length - ISEScrN.length - 1 );
33
 
34
  // 2. LOG file setup
35
  ISELogFileStr = ISEOpenFile( ISELogFile );
36
 
37
  // 3. LOG echo?
38
  var ISEScriptArgs = WScript.Arguments;
39
  for ( var loopi=0; loopi<ISEScriptArgs.length; loopi++ ) {
40
    if ( ISEScriptArgs(loopi) == "-quiet" ) {
41
      ISELogEcho = false;
42
      break;
43
    }
44
  }
45
 
46
  // 4. WSH version check
47
  var ISEOptimalVersionWSH = 5.6;
48
  var ISECurrentVersionWSH = WScript.Version;
49
  if ( ISECurrentVersionWSH < ISEOptimalVersionWSH ) {
50
 
51
    ISEStdErr( "" );
52
    ISEStdErr( "Warning: ExploreAhead works best with Microsoft WSH " +
53
               ISEOptimalVersionWSH + " or higher. Downloads" );
54
    ISEStdErr( "         for upgrading your Windows Scripting Host can be found here: " );
55
    ISEStdErr( "             http://msdn.microsoft.com/downloads/list/webdev.asp" );
56
    ISEStdErr( "" );
57
 
58
    ISEOldVersionWSH = true;
59
  }
60
 
61
}
62
 
63
function ISEStep( ISEProg, ISEArgs ) {
64
 
65
  // CHECK for a STOP FILE
66
  if ( ISEFileSys.FileExists(ISERunDir + "/.stop.rst") ) {
67
    ISEStdErr( "" );
68
    ISEStdErr( "*** Halting run - EA reset detected ***" );
69
    ISEStdErr( "" );
70
    WScript.Quit( 1 );
71
  }
72
 
73
  // WRITE STEP HEADER to LOG
74
  ISEStdOut( "" );
75
  ISEStdOut( "*** Running " + ISEProg );
76
  ISEStdOut( "    with args " + ISEArgs );
77
  ISEStdOut( "" );
78
 
79
  // LAUNCH!
80
  var ISEExitCode = ISEExec( ISEProg, ISEArgs );
81
  if ( ISEExitCode != 0 ) {
82
    WScript.Quit( ISEExitCode );
83
  }
84
 
85
}
86
 
87
function ISEExec( ISEProg, ISEArgs ) {
88
 
89
  var ISEStep = ISEProg;
90
  if (ISEProg == "realTimeFpga" || ISEProg == "planAhead" || ISEProg == "vivado") {
91
    ISEProg += ".bat";
92
  }
93
 
94
  var ISECmdLine = ISEProg + " " + ISEArgs;
95
  var ISEExitCode = 1;
96
 
97
  if ( ISEOldVersionWSH ) { // WSH 5.1
98
 
99
    // BEGIN file creation
100
    ISETouchFile( ISEStep, "begin" );
101
 
102
    // LAUNCH!
103
    ISELogFileStr.close();
104
    ISECmdLine =
105
      "%comspec% /c " + ISECmdLine + " >> " + ISELogFile + " 2>&1";
106
    ISEExitCode = ISEShell.Run( ISECmdLine, 0, true );
107
    ISELogFileStr = ISEOpenFile( ISELogFile );
108
 
109
  } else {  // WSH 5.6
110
 
111
    // LAUNCH!
112
    ISEShell.CurrentDirectory = ISERunDir;
113
 
114
    // Redirect STDERR to STDOUT
115
    ISECmdLine = "%comspec% /c " + ISECmdLine + " 2>&1";
116
    var ISEProcess = ISEShell.Exec( ISECmdLine );
117
 
118
    // BEGIN file creation
119
    var ISENetwork = WScript.CreateObject( "WScript.Network" );
120
    var ISEHost = ISENetwork.ComputerName;
121
    var ISEUser = ISENetwork.UserName;
122
    var ISEPid = ISEProcess.ProcessID;
123
    var ISEBeginFile = ISEOpenFile( "." + ISEStep + ".begin.rst" );
124
    ISEBeginFile.WriteLine( "<?xml version=\"1.0\"?>" );
125
    ISEBeginFile.WriteLine( "<ProcessHandle Version=\"1\" Minor=\"0\">" );
126
    ISEBeginFile.WriteLine( "    <Process Command=\"" + ISEProg +
127
                            "\" Owner=\"" + ISEUser +
128
                            "\" Host=\"" + ISEHost +
129
                            "\" Pid=\"" + ISEPid +
130
                            "\">" );
131
    ISEBeginFile.WriteLine( "    </Process>" );
132
    ISEBeginFile.WriteLine( "</ProcessHandle>" );
133
    ISEBeginFile.Close();
134
 
135
    var ISEOutStr = ISEProcess.StdOut;
136
    var ISEErrStr = ISEProcess.StdErr;
137
 
138
    // WAIT for ISEStep to finish
139
    while ( ISEProcess.Status == 0 ) {
140
 
141
      // dump stdout then stderr - feels a little arbitrary
142
      while ( !ISEOutStr.AtEndOfStream ) {
143
        ISEStdOut( ISEOutStr.ReadLine() );
144
      }
145
 
146
      WScript.Sleep( 100 );
147
    }
148
 
149
    ISEExitCode = ISEProcess.ExitCode;
150
  }
151
 
152
  // END/ERROR file creation
153
  if ( ISEExitCode != 0 ) {
154
    ISETouchFile( ISEStep, "error" );
155
 
156
  } else {
157
    ISETouchFile( ISEStep, "end" );
158
  }
159
 
160
  return ISEExitCode;
161
}
162
 
163
 
164
//
165
// UTILITIES
166
//
167
function ISEStdOut( ISELine ) {
168
 
169
  ISELogFileStr.WriteLine( ISELine );
170
 
171
  if ( ISELogEcho ) {
172
    WScript.StdOut.WriteLine( ISELine );
173
  }
174
}
175
 
176
function ISEStdErr( ISELine ) {
177
 
178
  ISELogFileStr.WriteLine( ISELine );
179
 
180
  if ( ISELogEcho ) {
181
    WScript.StdErr.WriteLine( ISELine );
182
  }
183
}
184
 
185
function ISETouchFile( ISERoot, ISEStatus ) {
186
 
187
  var ISETFile =
188
    ISEOpenFile( "." + ISERoot + "." + ISEStatus + ".rst" );
189
  ISETFile.close();
190
}
191
 
192
function ISEOpenFile( ISEFilename ) {
193
 
194
  var ISEFullPath = ISERunDir + "/" + ISEFilename;
195
  return ISEFileSys.OpenTextFile( ISEFullPath, 8, true );
196
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.