Files
yttrium-virtio-gpu/Tools/RunSdv.js
T
Miki Mishael 006208d44e BZ#954183 Tools: Added SDVTOOL script.
for running sdv on project.

       SDVTOOL - Static Driver Verifier Script.

       Script @SDVTOOL.bat@.

       The script consists from 3 scripts.

       1. SDVTOOL.bat.
       located in root directory.

       2. RunSdv.bat.
       located in root directory.

       3. RunSdv.js.
       located in Tools directory.

       Syntax:
       Usage SDVTOOL.bat

       [NO Parameters] will start to run on all projects on all
       configurations.

       [ANY Parameter] will pup up User interactive mode menu.

       The script parses ".vcxproj" project xml files and retrieves the
       Configuration and Platform.
           For each Configuration and Platform (Only Release) it will go
       Through this flow:

       1. Clean.
       2. Check.
       3. Copy SDV Directory created by sdv in the projects root
       directory.

       When error occurs in one of the above steps it will immediately
       continue to the next Configuration and Platform.

       Example Clean:
       msbuild
       "C:\Users\mikim\projects\daynix-kvm-guest-drivers.eng\vioserial\sys\vioser.vcxproj"
       /t:sdv /p:inputs="/clean" /p:configuration="Win8 Release"
       /p:platform="Win32"

       Example check:
       msbuild
       "C:\Users\mikim\projects\daynix-kvm-guest-drivers.eng\vioserial\sys\vioser.vcxproj"
       /t:sdv /p:inputs="/check:*" /p:configuration="Win8 Release"
       /p:platform="Win32"

       Copy:
       Copy will create tree like directory from the run:

       SDV-->
             Project A-->
                         Configuration -->
                                          Platform.
             Project B-->
                         Configuration -->
                                          Platform.
       The script has creates 2 logs:

       1. SDV.log.

       located in the root projects directory, It's the output of the
       RunSdv.bat and RunSdv.js scripts.

       2. SdvShellOutLog.log.

       located in the root projects directory, It's the output of child
       shells, created during the run of above steps.

Signed-off-by: Miki Mishael <[email protected]>
2013-12-17 16:47:26 +11:00

227 lines
7.8 KiB
JavaScript

/**********************************************************************
* Copyright (c) 2010 Red Hat, Inc.
*
* File: RunSdv.js
*
* Author(s):
* Miki Mishael <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
**********************************************************************/
/*----------------Define Section--------------------------*/
var ROOT_DIR = WScript.Arguments(0);
var PROJECT_XML_PATH = WScript.Arguments(1);
var PROJECT_DIR_PATH = WScript.Arguments(2);
var PROJECT_NAME = WScript.Arguments(3);
var logFileName = "SDV.log"; /* "SDV.log" */
var debugMode = true;
var ns = "xmlns:sdv = 'http://schemas.microsoft.com/developer/msbuild/2003'";
var exitProgram = ~~0; /* 0 == Success */
function logString(str) {
if (logFileName != "") {
var fso = new ActiveXObject("Scripting.FileSystemObject");
var logFile = fso.OpenTextFile(logFileName, 8, true);
logFile.WriteLine(str);
logFile.Close();
}
if (debugMode) {
WScript.Echo(str);
}
}
function startLog() {
var now = new Date();
logString(now.toString());
}
function stopLog() {
logString("\n---------------------------------------------------------------------------");
}
function parseXmlProject() {
this.XmlDocument = new ActiveXObject("msxml2.DOMDocument.6.0");
this.XmlDocument.async = false;
this.XmlDocument.setProperty('ProhibitDTD', false);
this.XmlDocument.resolveExternals = false;
this.XmlDocument.validateOnParse = false;
this.XmlDocument.load(PROJECT_XML_PATH);
this.XmlDocument.setProperty("SelectionNamespaces", ns);
this.node = { Configuration: [], Platform: [] };
this.getProjectConfigs = function () {
this.printParseError();
this.node.Configuration = this.XmlDocument.selectNodes("//sdv:ProjectConfiguration//sdv:Configuration");
this.node.Platform = this.XmlDocument.selectNodes("//sdv:ProjectConfiguration//sdv:Platform");
return this.node;
}
this.printParseError = function () {
if (this.XmlDocument.parseError.errorCode != 0) {
var myErr = this.XmlDocument.parseError;
throw "Xml parse error: " + myErr.reason;
}
}
}
function runSdv(confList) {
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.projectDirPath = PROJECT_DIR_PATH;
this.projectXmlPath = PROJECT_XML_PATH;
this.projectName = PROJECT_NAME;
this.target = 'sdv';
this.inputClean = '/clean';
this.inputCheck = '/check:*';
this.configuration = null;
this.platform = null;
this.cmd = null;
this.src = null;
this.dest = null;
this.res = null;
this.out = " >> ../SdvShellOutLog.log";
this.copyCmd = 'CMD /C xcopy /i/e/h/y ';
this.cmdCdToProjectDir = "cd " + '"' + this.projectDirPath + '"' +
" && title DO Not Close!-Running SDV on " + this.projectName + " && ";
this.buildCheckCmd = function () {
this.cmd = 'CMD /C ' + this.cmdCdToProjectDir + 'msbuild' + ' ' +
'"' + this.projectXmlPath + '"' + ' ' + '/t:' + this.target + ' ' +
'/p:inputs=' + '"' + this.inputCheck + '"' + ' ' + '/p:configuration=' +
'"' + this.configuration + '"' + ' ' + '/p:platform=' + '"' +
this.platform + '"' + this.out;
}
this.buildCleanCmd = function () {
this.cmd = 'CMD /C ' + this.cmdCdToProjectDir + 'msbuild' + ' ' +
'"' + this.projectXmlPath + '"' + ' ' + '/t:' + this.target + ' ' +
'/p:inputs=' + '"' + this.inputClean + '"' + ' ' + '/p:configuration=' +
'"' + this.configuration + '"' + ' ' + '/p:platform=' + '"' +
this.platform + '"' + this.out;
}
this.buildCopyCmd = function () {
this.src = this.projectDirPath + "\\sdv\\* ";
this.des = ROOT_DIR + "\SDV\\" + this.projectName + "\\" + '"' + this.configuration +
'"' + "\\" + this.platform;
this.cmd = this.copyCmd + this.src + this.des + this.out;
}
this.exeCheckCmd = function () {
this.buildCheckCmd();
logString("\nRunnig " + '"' + this.inputCheck + '"' + ' ' + "SDV on: " + ' Project: "' +
this.projectName + '" Configuration: "' +
this.configuration + '" Platform: "' + this.platform + '" ...');
this.res = this.WshShell.run(this.cmd, 1, true);
logString("Res " + this.res);
if (this.res != 0)
throw "Error Runnig SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +
this.configuration + '" Platform: "' + this.platform + '"';
}
this.exeCleanCmd = function () {
this.buildCleanCmd();
logString("\n\nCleaning SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +
this.configuration + '" Platform: "' + this.platform + '" ...');
logString(this.cmd);
this.res = this.WshShell.run(this.cmd, 1, true);
logString("Res " + this.res);
if (this.res != 0)
throw "Error Cleaning SDV logs" + ' Project: "' + this.projectName + '" Configuration: "' +
this.configuration + '" Platform: "' + this.platform + '"';
}
this.exeCopySdvDir = function () {
this.buildCopyCmd();
logString("\nCopying SDV folder results from SRC: " + this.src + "to DES: " + this.des + ".");
this.res = this.WshShell.run(this.cmd, 1, true);
logString("Res " + this.res);
if (this.res != 0)
throw "Error Copying SDV folder results from SRC: " + this.src + "to DES: " + this.des + ".";
}
this.resetRunSdv = function () {
this.WshShell = new ActiveXObject("WScript.Shell");
this.fso = new ActiveXObject("Scripting.FileSystemObject");
this.configuration = null;
this.platform = null;
this.cmd = null;
this.src = null;
this.dest = null;
this.res = null;
}
this.iterateConfs = function () {
for (var idx = 0; idx < confList.Configuration.length; idx++) {
this.configuration = confList.Configuration[idx].text;
if (this.configuration.indexOf("Debug") != -1)
continue;
this.platform = confList.Platform[idx].text;
try {
stopLog();
startLog();
this.exeCleanCmd();
this.exeCheckCmd();
this.exeCopySdvDir();
stopLog();
}
catch (exception) {
logString("\t" + exception);
this.resetRunSdv();
exitProgram = ~~1;
stopLog();
continue;
}
}
}
this.test = function () {
this.exeCleanCmd();
this.exeCheckCmd();
this.exeCopySdvDir();
this.exeCleanCmd();
}
}
function start() {
logString("ROOT_DIR:" + ROOT_DIR);
logString("PROJECT_XML_PATH:" + PROJECT_XML_PATH);
logString("PROJECT_DIR_PATH:" + PROJECT_DIR_PATH);
logString("PROJECT_NAME:" + PROJECT_NAME);
var res = new parseXmlProject();
var confList = res.getProjectConfigs();
if (confList.Configuration.length < 1)
throw " Could not find Configurations for this project.";
var sh = new runSdv(confList);
sh.iterateConfs();
}
try {
startLog();
start();
stopLog();
WScript.quit(exitProgram);
}
catch (exception) {
logString("ERROR: " + exception);
logString("**** ERROR Info ****");
logString("\tMessage : " + exception.message);
logString("\tName : " + exception.name);
logString("\tCode : " + (exception.number & 0xFFFF));
logString("\tFacility : " + (exception.number >> 16 & 0x1FFF));
logString("\tDesription: " + exception.description);
logString("********************");
stopLog();
WScript.StdErr.WriteLine("ERROR: " + exception);
WScript.quit(2);
}