kvm-guest-drivers-windows
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
33var ROOT_DIR = WScript.Arguments(0);34var PROJECT_XML_PATH = WScript.Arguments(1);35var PROJECT_DIR_PATH = WScript.Arguments(2);36var PROJECT_NAME = WScript.Arguments(3);37
38var logFileName = "SDV.log"; /* "SDV.log" */39var debugMode = true;40var ns = "xmlns:sdv = 'http://schemas.microsoft.com/developer/msbuild/2003'";41var exitProgram = ~~0; /* 0 == Success */42
43function logString(str) {44if (logFileName != "") {45var fso = new ActiveXObject("Scripting.FileSystemObject");46var logFile = fso.OpenTextFile(logFileName, 8, true);47logFile.WriteLine(str);48logFile.Close();49}50if (debugMode) {51WScript.Echo(str);52}53}
54
55function startLog() {56var now = new Date();57logString(now.toString());58}
59
60function stopLog() {61logString("\n---------------------------------------------------------------------------");62}
63
64function parseXmlProject() {65
66this.XmlDocument = new ActiveXObject("msxml2.DOMDocument.6.0");67this.XmlDocument.async = false;68this.XmlDocument.setProperty('ProhibitDTD', false);69this.XmlDocument.resolveExternals = false;70this.XmlDocument.validateOnParse = false;71this.XmlDocument.load(PROJECT_XML_PATH);72this.XmlDocument.setProperty("SelectionNamespaces", ns);73this.node = { Configuration: [], Platform: [] };74
75this.getProjectConfigs = function () {76this.printParseError();77this.node.Configuration = this.XmlDocument.selectNodes("//sdv:ProjectConfiguration//sdv:Configuration");78this.node.Platform = this.XmlDocument.selectNodes("//sdv:ProjectConfiguration//sdv:Platform");79return this.node;80}81
82this.printParseError = function () {83if (this.XmlDocument.parseError.errorCode != 0) {84var myErr = this.XmlDocument.parseError;85throw "Xml parse error: " + myErr.reason;86}87}88}
89
90function runSdv(confList) {91
92this.WshShell = new ActiveXObject("WScript.Shell");93this.fso = new ActiveXObject("Scripting.FileSystemObject");94this.projectDirPath = PROJECT_DIR_PATH;95this.projectXmlPath = PROJECT_XML_PATH;96this.projectName = PROJECT_NAME;97this.target = 'sdv';98this.inputClean = '/clean';99this.inputCheck = '/check:*';100this.configuration = null;101this.platform = null;102this.cmd = null;103this.src = null;104this.dest = null;105this.res = null;106this.out = " >> ../SdvShellOutLog.log";107this.copyCmd = 'CMD /C xcopy /i/e/h/y ';108this.cmdCdToProjectDir = "cd " + '"' + this.projectDirPath + '"' +109" && title DO Not Close!-Running SDV on " + this.projectName + " && ";110
111this.buildCheckCmd = function () {112this.cmd = 'CMD /C ' + this.cmdCdToProjectDir + 'msbuild' + ' ' +113'"' + this.projectXmlPath + '"' + ' ' + '/t:' + this.target + ' ' +114'/p:inputs=' + '"' + this.inputCheck + '"' + ' ' + '/p:configuration=' +115'"' + this.configuration + '"' + ' ' + '/p:platform=' + '"' +116this.platform + '"' + this.out;117}118
119this.buildCleanCmd = function () {120this.cmd = 'CMD /C ' + this.cmdCdToProjectDir + 'msbuild' + ' ' +121'"' + this.projectXmlPath + '"' + ' ' + '/t:' + this.target + ' ' +122'/p:inputs=' + '"' + this.inputClean + '"' + ' ' + '/p:configuration=' +123'"' + this.configuration + '"' + ' ' + '/p:platform=' + '"' +124this.platform + '"' + this.out;125}126
127this.buildCopyCmd = function () {128this.src = this.projectDirPath + "\\sdv\\* ";129this.des = ROOT_DIR + "\SDV\\" + this.projectName + "\\" + '"' + this.configuration +130'"' + "\\" + this.platform;131this.cmd = this.copyCmd + this.src + this.des + this.out;132}133
134this.exeCheckCmd = function () {135this.buildCheckCmd();136logString("\nRunning " + '"' + this.inputCheck + '"' + ' ' + "SDV on: " + ' Project: "' +137this.projectName + '" Configuration: "' +138this.configuration + '" Platform: "' + this.platform + '" ...');139
140this.res = this.WshShell.run(this.cmd, 1, true);141logString("Res " + this.res);142if (this.res != 0)143throw "Error Running SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +144this.configuration + '" Platform: "' + this.platform + '"';145}146
147this.exeCleanCmd = function () {148this.buildCleanCmd();149logString("\n\nCleaning SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +150this.configuration + '" Platform: "' + this.platform + '" ...');151logString(this.cmd);152this.res = this.WshShell.run(this.cmd, 1, true);153logString("Res " + this.res);154if (this.res != 0)155throw "Error Cleaning SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +156this.configuration + '" Platform: "' + this.platform + '"';157}158
159
160this.exeCopySdvDir = function () {161this.buildCopyCmd();162logString("\nCopying SDV folder results from SRC: " + this.src + "to DES: " + this.des + ".");163this.res = this.WshShell.run(this.cmd, 1, true);164logString("Res " + this.res);165if (this.res != 0)166throw "Error Copying SDV folder results from SRC: " + this.src + "to DES: " + this.des + ".";167}168
169this.resetRunSdv = function () {170this.WshShell = new ActiveXObject("WScript.Shell");171this.fso = new ActiveXObject("Scripting.FileSystemObject");172this.configuration = null;173this.platform = null;174this.cmd = null;175this.src = null;176this.dest = null;177this.res = null;178}179
180this.iterateConfs = function () {181for (var idx = 0; idx < confList.Configuration.length; idx++) {182this.configuration = confList.Configuration[idx].text;183if (this.configuration.indexOf("Debug") != -1)184continue;185this.platform = confList.Platform[idx].text;186try {187stopLog();188startLog();189this.exeCleanCmd();190this.exeCheckCmd();191this.exeCopySdvDir();192stopLog();193}194catch (exception) {195logString("\t" + exception);196this.resetRunSdv();197exitProgram = ~~1;198stopLog();199continue;200}201}202}203
204this.test = function () {205this.exeCleanCmd();206this.exeCheckCmd();207this.exeCopySdvDir();208this.exeCleanCmd();209}210}
211
212function start() {213logString("ROOT_DIR:" + ROOT_DIR);214logString("PROJECT_XML_PATH:" + PROJECT_XML_PATH);215logString("PROJECT_DIR_PATH:" + PROJECT_DIR_PATH);216logString("PROJECT_NAME:" + PROJECT_NAME);217var res = new parseXmlProject();218var confList = res.getProjectConfigs();219if (confList.Configuration.length < 1)220throw " Could not find Configurations for this project.";221var sh = new runSdv(confList);222sh.iterateConfs();223}
224try {225startLog();226start();227stopLog();228WScript.quit(exitProgram);229}
230catch (exception) {231logString("ERROR: " + exception);232logString("**** ERROR Info ****");233logString("\tMessage : " + exception.message);234logString("\tName : " + exception.name);235logString("\tCode : " + (exception.number & 0xFFFF));236logString("\tFacility : " + (exception.number >> 16 & 0x1FFF));237logString("\tDescription: " + exception.description);238logString("********************");239stopLog();240WScript.StdErr.WriteLine("ERROR: " + exception);241WScript.quit(2);242}
243