kvm-guest-drivers-windows

Форк
0
242 строки · 9.0 Кб
1
/*
2
 * Copyright (c) 2010-2017 Red Hat, Inc.
3
 *
4
 * Author(s):
5
 *  Miki Mishael <mikim@daynix.com>
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met :
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and / or other materials provided with the distribution.
15
 * 3. Neither the names of the copyright holders nor the names of their contributors
16
 *    may be used to endorse or promote products derived from this software
17
 *    without specific prior written permission.
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
19
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
 * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
22
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
 * SUCH DAMAGE.
29
 */
30

31
/*----------------Define Section--------------------------*/
32

33
var ROOT_DIR = WScript.Arguments(0);
34
var PROJECT_XML_PATH = WScript.Arguments(1);
35
var PROJECT_DIR_PATH = WScript.Arguments(2);
36
var PROJECT_NAME = WScript.Arguments(3);
37

38
var logFileName = "SDV.log"; /* "SDV.log" */
39
var debugMode = true;
40
var ns = "xmlns:sdv = 'http://schemas.microsoft.com/developer/msbuild/2003'";
41
var exitProgram = ~~0; /* 0 == Success */
42

43
function logString(str) {
44
    if (logFileName != "") {
45
        var fso = new ActiveXObject("Scripting.FileSystemObject");
46
        var logFile = fso.OpenTextFile(logFileName, 8, true);
47
        logFile.WriteLine(str);
48
        logFile.Close();
49
    }
50
    if (debugMode) {
51
        WScript.Echo(str);
52
    }
53
}
54

55
function startLog() {
56
    var now = new Date();
57
    logString(now.toString());
58
}
59

60
function stopLog() {
61
    logString("\n---------------------------------------------------------------------------");
62
}
63

64
function parseXmlProject() {
65

66
    this.XmlDocument = new ActiveXObject("msxml2.DOMDocument.6.0");
67
    this.XmlDocument.async = false;
68
    this.XmlDocument.setProperty('ProhibitDTD', false);
69
    this.XmlDocument.resolveExternals = false;
70
    this.XmlDocument.validateOnParse = false;
71
    this.XmlDocument.load(PROJECT_XML_PATH);
72
    this.XmlDocument.setProperty("SelectionNamespaces", ns);
73
    this.node = { Configuration: [], Platform: [] };
74

75
    this.getProjectConfigs = function () {
76
        this.printParseError();
77
        this.node.Configuration = this.XmlDocument.selectNodes("//sdv:ProjectConfiguration//sdv:Configuration");
78
        this.node.Platform = this.XmlDocument.selectNodes("//sdv:ProjectConfiguration//sdv:Platform");
79
        return this.node;
80
    }
81

82
    this.printParseError = function () {
83
        if (this.XmlDocument.parseError.errorCode != 0) {
84
            var myErr = this.XmlDocument.parseError;
85
            throw "Xml parse error: " + myErr.reason;
86
        }
87
    }
88
}
89

90
function runSdv(confList) {
91

92
    this.WshShell = new ActiveXObject("WScript.Shell");
93
    this.fso = new ActiveXObject("Scripting.FileSystemObject");
94
    this.projectDirPath = PROJECT_DIR_PATH;
95
    this.projectXmlPath = PROJECT_XML_PATH;
96
    this.projectName = PROJECT_NAME;
97
    this.target = 'sdv';
98
    this.inputClean = '/clean';
99
    this.inputCheck = '/check:*';
100
    this.configuration = null;
101
    this.platform = null;
102
    this.cmd = null;
103
    this.src = null;
104
    this.dest = null;
105
    this.res = null;
106
    this.out = " >> ../SdvShellOutLog.log";
107
    this.copyCmd = 'CMD /C xcopy /i/e/h/y ';
108
    this.cmdCdToProjectDir = "cd " + '"' + this.projectDirPath + '"' +
109
                             " && title DO Not Close!-Running SDV on " + this.projectName + " && ";
110

111
    this.buildCheckCmd = function () {
112
        this.cmd = 'CMD /C ' + this.cmdCdToProjectDir + 'msbuild' + ' ' +
113
    '"' + this.projectXmlPath + '"' + ' ' + '/t:' + this.target + ' ' +
114
    '/p:inputs=' + '"' + this.inputCheck + '"' + ' ' + '/p:configuration=' +
115
    '"' + this.configuration + '"' + ' ' + '/p:platform=' + '"' +
116
    this.platform + '"' + this.out;
117
    }
118

119
    this.buildCleanCmd = function () {
120
        this.cmd = 'CMD /C ' + this.cmdCdToProjectDir + 'msbuild' + ' ' +
121
    '"' + this.projectXmlPath + '"' + ' ' + '/t:' + this.target + ' ' +
122
    '/p:inputs=' + '"' + this.inputClean + '"' + ' ' + '/p:configuration=' +
123
    '"' + this.configuration + '"' + ' ' + '/p:platform=' + '"' +
124
    this.platform + '"' + this.out;
125
    }
126

127
    this.buildCopyCmd = function () {
128
        this.src = this.projectDirPath + "\\sdv\\* ";
129
        this.des = ROOT_DIR + "\SDV\\" + this.projectName + "\\" + '"' + this.configuration +
130
        '"' + "\\" + this.platform;
131
        this.cmd = this.copyCmd + this.src + this.des + this.out;
132
    }
133

134
    this.exeCheckCmd = function () {
135
        this.buildCheckCmd();
136
        logString("\nRunning " + '"' + this.inputCheck + '"' + ' ' + "SDV on: " + ' Project: "' +
137
        this.projectName + '" Configuration: "' +
138
        this.configuration + '" Platform: "' + this.platform + '" ...');
139

140
        this.res = this.WshShell.run(this.cmd, 1, true);
141
        logString("Res " + this.res);
142
        if (this.res != 0)
143
            throw "Error Running SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +
144
            this.configuration + '" Platform: "' + this.platform + '"';
145
    }
146

147
    this.exeCleanCmd = function () {
148
        this.buildCleanCmd();
149
        logString("\n\nCleaning SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +
150
        this.configuration + '" Platform: "' + this.platform + '" ...');
151
        logString(this.cmd);
152
        this.res = this.WshShell.run(this.cmd, 1, true);
153
        logString("Res " + this.res);
154
        if (this.res != 0)
155
            throw "Error Cleaning SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +
156
            this.configuration + '" Platform: "' + this.platform + '"';
157
    }
158

159

160
    this.exeCopySdvDir = function () {
161
        this.buildCopyCmd();
162
        logString("\nCopying SDV folder results from SRC: " + this.src + "to DES: " + this.des + ".");
163
        this.res = this.WshShell.run(this.cmd, 1, true);
164
        logString("Res " + this.res);
165
        if (this.res != 0)
166
            throw "Error Copying SDV folder results from SRC: " + this.src + "to DES: " + this.des + ".";
167
    }
168

169
    this.resetRunSdv = function () {
170
        this.WshShell = new ActiveXObject("WScript.Shell");
171
        this.fso = new ActiveXObject("Scripting.FileSystemObject");
172
        this.configuration = null;
173
        this.platform = null;
174
        this.cmd = null;
175
        this.src = null;
176
        this.dest = null;
177
        this.res = null;
178
    }
179

180
    this.iterateConfs = function () {
181
        for (var idx = 0; idx < confList.Configuration.length; idx++) {
182
            this.configuration = confList.Configuration[idx].text;
183
            if (this.configuration.indexOf("Debug") != -1)
184
            continue;
185
            this.platform = confList.Platform[idx].text;
186
            try {
187
                stopLog();
188
                startLog();
189
                this.exeCleanCmd();
190
                this.exeCheckCmd();
191
                this.exeCopySdvDir();
192
                stopLog();
193
            }
194
            catch (exception) {
195
                logString("\t" + exception);
196
                this.resetRunSdv();
197
                exitProgram = ~~1;
198
                stopLog();
199
                continue;
200
            }
201
        }
202
    }
203

204
    this.test = function () {
205
        this.exeCleanCmd();
206
        this.exeCheckCmd();
207
        this.exeCopySdvDir();
208
        this.exeCleanCmd();
209
    }
210
}
211

212
function start() {
213
    logString("ROOT_DIR:" + ROOT_DIR);
214
    logString("PROJECT_XML_PATH:" + PROJECT_XML_PATH);
215
    logString("PROJECT_DIR_PATH:" + PROJECT_DIR_PATH);
216
    logString("PROJECT_NAME:" + PROJECT_NAME);
217
    var res = new parseXmlProject();
218
    var confList = res.getProjectConfigs();
219
    if (confList.Configuration.length < 1)
220
        throw " Could not find Configurations for this project.";
221
    var sh = new runSdv(confList);
222
    sh.iterateConfs();
223
}
224
try {
225
    startLog();
226
    start();
227
    stopLog();
228
    WScript.quit(exitProgram);
229
}
230
catch (exception) {
231
    logString("ERROR: " + exception);
232
    logString("**** ERROR Info ****");
233
    logString("\tMessage    : " + exception.message);
234
    logString("\tName       : " + exception.name);
235
    logString("\tCode       : " + (exception.number & 0xFFFF));
236
    logString("\tFacility   : " + (exception.number >> 16 & 0x1FFF));
237
    logString("\tDescription: " + exception.description);
238
    logString("********************");
239
    stopLog();
240
    WScript.StdErr.WriteLine("ERROR: " + exception);
241
    WScript.quit(2);
242
}
243

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.