コード例 #1
0
ファイル: SetBuildEnvironment.cs プロジェクト: AsgGitHub/VMS2
        static int Main(string[] args)
        {
            int errlvl = 0;

            try {
                // Process Command-line Arguments
                string buildCfgFile = null;
                string outputFile   = null;

                if (args.Length != 2)
                {
                    Console.WriteLine();
                    Console.Error.WriteLine("Missing or Invalid Parameter.");
                    Usage();
                    errlvl = 1;
                    return(errlvl);
                }

                buildCfgFile = args[0];
                outputFile   = args[1].Trim();

                Console.WriteLine();
                Console.WriteLine("buildCfgFile: " + buildCfgFile);
                Console.WriteLine("outputFile:   " + outputFile);
                Console.WriteLine();

                ProductBuildDataSet pbDataSet       = ProductBuildDataSet.ReadBuildConfigurationFile(buildCfgFile);
                SortedList          buildProperties = pbDataSet.GetBuildProperties();
                CollectionUtil.WritePropertyFile(buildProperties, outputFile);
            }
            catch (Exception e) {
                errlvl = 1;
                Console.Error.WriteLine("An error occurred in SetBuildEnvironment:");
                Console.Error.WriteLine(e.ToString());
                Usage();
            }

            return(errlvl);
        }
コード例 #2
0
ファイル: ProductBuilder.cs プロジェクト: AsgGitHub/VMS2
        static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                errorLevel = 3;
                Usage();
                return(errorLevel);
            }

            try {
                string    path = null;
                Hashtable commandLineProperties = new Hashtable();

                ProcessCommandLineArguments(args, ref path, commandLineProperties);

                LibraryManifest libraryInfo = new LibraryManifest(path);

                // default to Development profile
                string profileName            = "Development (Public)";
                string commandLineProfileName = (string)commandLineProperties["BuildProfileName"];
                profileName = (commandLineProfileName != null) ? commandLineProfileName : profileName;

                ProductBuildDataSet pbDataSet = ProductBuildDataSet.GetProductBuildDataSetWithoutComplist(
                    profileName,
                    libraryInfo.GetName(),
                    libraryInfo.GetVersion(),
                    libraryInfo.GetPlatform(),
                    libraryInfo.GetBranchOrTrunkName(),
                    libraryInfo.GetDirectory(),
                    path,
                    libraryInfo.GetDate());

                pbDataSet.ApplyCommandLineProperties(commandLineProperties);
                pbDataSet.LoadComplist();
                pbDataSet.FinalizeProperties();
                pbDataSet.WriteBuildConfigurationFile(pbDataSet.GetBuildConfigurationFilename());

                string           buildPath        = pbDataSet.GetBuildProperty("BuildPath");
                VmsProduct       currProduct      = new VmsProduct(libraryInfo.GetName(), libraryInfo.GetVersion(), libraryInfo.GetPlatform());
                VmsLibrary       currLibrary      = new VmsLibrary(currProduct, libraryInfo.GetBranchOrTrunkName());
                ControllerObject controllerObject = new ControllerObject();
                string           currentKey       = Util.GetServiceKey();
                bool             actionSucceeded  = false;
                string           errorMessage     = null;
                if (controllerObject.BuildLibrary(currLibrary, currentKey, buildPath, out errorMessage, false))
                {
                    NewMessage.ProcessMessages(currentKey, ref errorMessage, ref actionSucceeded, false, ref errorLevel);
                    if (actionSucceeded)
                    {
                        Console.WriteLine("    Successfully built " + currLibrary.ShortLibraryName);
                    }
                    else
                    {
                        Console.WriteLine("    Error building " + currLibrary.ShortLibraryName + ":" + errorMessage);
                    }
                }
                else
                {
                    Console.WriteLine("    Error building " + currLibrary.ShortLibraryName + ":" + errorMessage);
                }
            }
            catch (Exception e) {
                errorLevel = 3;
                Console.Error.WriteLine("An error occurred in ProductBuilder:");
                Console.Error.WriteLine(e.ToString());
                Usage();
            }
            return(errorLevel);
        }
コード例 #3
0
ファイル: ImportComponents.cs プロジェクト: AsgGitHub/VMS2
        static int Main(string[] commandArgs)
        {
            int returnValue = 0;

            try {
                if (commandArgs.Length < 1)   //error, no arg. supplied
                {
                    string errMsg = "No argument supplied.\n";
                    errMsg += "\tUsage: " + Process.GetCurrentProcess().ProcessName + " <Build Import Manifest>\n";
                    errMsg += "\tFor example, " + Process.GetCurrentProcess().ProcessName + " BuildImports.xml";
                    throw new Exception(errMsg);
                }
                if (!File.Exists(commandArgs[0]))
                {
                    throw new Exception("File not found: " + commandArgs[0]);
                }
                //Get build attributes. Note: This module always expects q:\ to be mapped to the build path by
                //LibraryBuilder prior to invocation.
                LibraryManifest     currManifest        = new LibraryManifest(LBEnvironment.BuildMapDrive);
                string              buildDefinitionFile = ProductBuildDataSet.GetBuildConfigurationFilename(LBEnvironment.BuildMapDrive);
                ProductBuildDataSet pbDataSet           = ProductBuildDataSet.ReadBuildConfigurationFile(buildDefinitionFile);
                string              buildProfile        = pbDataSet.GetBuildProperty("BuildProfileName");

                //Parse the xml file.
                XmlDocument xmlManifestDoc = new XmlDocument();
                xmlManifestDoc.Load(commandArgs[0]);
                //file may or may not contain version info
                XmlNode versionNode = xmlManifestDoc.DocumentElement.Attributes.GetNamedItem("version");
                int     fileVersion = (versionNode == null)? 1 : int.Parse(versionNode.InnerText);
                //version 3 or higher is implemented in LB and uses zip file implementation
                if (fileVersion >= 3)
                {
                    FileSystemInterface.ValidateComponentImportStep(LBEnvironment.BuildMapDrive,
                                                                    currManifest.GetBranchOrTrunkName(),
                                                                    commandArgs[0], false, true, false);
                }
                else
                {
                    foreach (XmlNode importNode in xmlManifestDoc.DocumentElement.ChildNodes)
                    {
                        if (importNode.NodeType != XmlNodeType.Comment)
                        {
                            string prodName           = importNode.Attributes["sourceProduct"].InnerText;
                            string prodVer            = importNode.Attributes["sourceVersion"].InnerText;
                            string platCode           = importNode.Attributes["sourcePlatform"].InnerText;
                            string branchOrTrunkName  = importNode.Attributes["sourceBranchOrTrunkName"].InnerText;
                            string itemToCopy         = importNode.SelectSingleNode("source").Attributes["path"].InnerText;
                            string destPath           = importNode.SelectSingleNode("destination").Attributes["path"].InnerText;;
                            bool   copySubdirectories = false;
                            bool   cleanAtDestination = false;
                            if (fileVersion > 1)
                            {
                                copySubdirectories = bool.Parse(importNode.SelectSingleNode("source").Attributes["copySubDirectories"].InnerText.ToLower());
                                cleanAtDestination = bool.Parse(importNode.SelectSingleNode("source").Attributes["cleanDestination"].InnerText.ToLower());
                            }

                            //Trim spaces and path characters
                            itemToCopy = itemToCopy.Trim(new char[] { ' ', '\\', '/' });
                            destPath   = destPath.Trim(new char[] { ' ', '\\', '/' });

                            string productPath = LBEnvironment.NetworkProductRootDir + "\\" + prodName + "\\V" + prodVer.Replace(".", "_") + "." + platCode;
                            if (!Directory.Exists(productPath))
                            {
                                throw new Exception("Product directory not found: " + productPath);
                            }

                            //Compute and identify - directory, file or wildcard - what to copy. Compute the destination as well.
                            // Also indicate whether listed path exists.
                            string       sourceFullPath          = productPath + "\\" + branchOrTrunkName + "\\" + itemToCopy;;
                            string       destFullpath            = Path.Combine(LBEnvironment.BuildMapDrive, destPath);
                            string       alternateSourceFullPath = productPath + "\\" + "DEVELOP" + "\\" + itemToCopy;;
                            bool         usingAlternateCopyPath  = false;
                            CopyItemType copyItemType            = CopyItemType.UNIDENTIFIED;
                            if (itemToCopy.IndexOf("*") > 1)
                            {
                                copyItemType = CopyItemType.WILDCARD;
                                if (!Directory.Exists(Path.GetDirectoryName(sourceFullPath)))
                                {
                                    usingAlternateCopyPath  = true;
                                    alternateSourceFullPath = productPath + "\\" + "DEVELOP" + "\\" + itemToCopy;
                                }
                            }
                            else if (Directory.Exists(sourceFullPath))
                            {
                                copyItemType = CopyItemType.DIRECTORY;
                            }
                            else if (Directory.Exists(alternateSourceFullPath))
                            {
                                copyItemType           = CopyItemType.DIRECTORY;
                                usingAlternateCopyPath = true;
                            }
                            else if (File.Exists(sourceFullPath))
                            {
                                copyItemType = CopyItemType.FILE;
                            }
                            else if (File.Exists(alternateSourceFullPath))
                            {
                                copyItemType           = CopyItemType.FILE;
                                usingAlternateCopyPath = true;
                            }
                            else   //Listed path not valid
                            {
                                throw new Exception("Unable to find import source: " + sourceFullPath);
                            }
                            //Create the destination directory
                            Directory.CreateDirectory(destFullpath);

                            //For QA profiles or non-DEVELOP builds, a build must fail if a listed path cannot be found. Accept no substitutes:
                            //A listed path must not be from DEVELOP, PREPROD, PROD or CANDIDATE and it must exist
                            if (buildProfile.ToUpper().StartsWith("QA") || (currManifest.GetBranchOrTrunkName().ToUpper() != "DEVELOP"))
                            {
                                if ((branchOrTrunkName.ToUpper() == "DEVELOP") || (branchOrTrunkName.ToUpper() == "CANDIDATE") ||
                                    (branchOrTrunkName.ToUpper() == "PREPROD") || (branchOrTrunkName.ToUpper() == "PROD") ||
                                    (branchOrTrunkName.ToUpper() == "STABLE"))
                                {
                                    string errMsg = "Cannot build QA level library or profile without a branch library import source. ";
                                    errMsg += "Please check your entry in " + commandArgs[0] + " for ";
                                    errMsg += prodName + " " + prodVer + " " + platCode + " " + branchOrTrunkName;
                                    throw new Exception(errMsg);
                                }
                                if (usingAlternateCopyPath)
                                {
                                    throw new Exception("Unable to find import source: " + sourceFullPath);
                                }
                            }

                            string sourceItem = (usingAlternateCopyPath)? alternateSourceFullPath : sourceFullPath;
                            //If copying a directory add a wildcard
                            if (copyItemType == CopyItemType.DIRECTORY)
                            {
                                sourceItem = Path.Combine(sourceItem, "*.*");
                            }
                            //if clean copy was requested, delete source files' paths at destination
                            if (cleanAtDestination && Directory.Exists(destFullpath))
                            {
                                ImportComponents.DeleteFiles(Path.Combine(destFullpath, Path.GetFileName(sourceItem)), copySubdirectories);
                            }

                            returnValue = ImportComponents.XCopyDirToQDrive(sourceItem, destFullpath, copySubdirectories);
                            if (returnValue != 0)
                            {
                                throw new Exception("xcopy returned an error(" + returnValue.ToString() + ") while copying " + sourceItem + " to " + destFullpath);
                            }
                        }
                    }//foreach
                }
            }
            catch (Exception currExcept) {
                Console.WriteLine("Error occurred during build import: " + currExcept.Message);
                if (returnValue == 0)
                {
                    returnValue = 1;
                }
            }
            return(returnValue);
        }
コード例 #4
0
ファイル: ResolveComplist.cs プロジェクト: AsgGitHub/VMS2
        static int Main(string[] args)
        {
            int errlvl = 0;

            try {
                // Process Command-line Arguments
                bool   returnAll = false;
                string buildPath = null;
                string complistFilterFileName = null;
                string outputComplistFileName = null;
                string descExtension          = null;
                string targetExtension        = null;

                if (args.Length < 1)
                {
                    Console.WriteLine();
                    Console.Error.WriteLine("Missing or Invalid Parameter.");
                    Usage();
                    errlvl = 2;
                    return(errlvl);
                }

                buildPath = args[0];
                foreach (string arg in args)
                {
                    if (arg.StartsWith("/f:"))
                    {
                        complistFilterFileName = arg.Substring(3).Trim();
                    }
                    if (arg.StartsWith("/o:"))
                    {
                        outputComplistFileName = arg.Substring(3).Trim();
                    }
                    if (arg.StartsWith("/d:"))
                    {
                        descExtension = arg.Substring(3).Trim();
                    }
                    if (arg.StartsWith("/t:"))
                    {
                        targetExtension = arg.Substring(3).Trim();
                    }
                    if (arg == "/a")
                    {
                        returnAll = true;
                    }
                }
                if (complistFilterFileName == "")
                {
                    complistFilterFileName = null;
                }
                if (outputComplistFileName == "")
                {
                    outputComplistFileName = null;
                }
                if (descExtension == "")
                {
                    descExtension = null;
                }
                if (targetExtension == "")
                {
                    targetExtension = null;
                }

                Console.WriteLine();
                Console.WriteLine("buildPath:              " + buildPath);
                Console.WriteLine("complistFilterFileName: " + complistFilterFileName);
                Console.WriteLine("outputComplistFile:     " + outputComplistFileName);
                Console.WriteLine("descExtension:          " + descExtension);
                Console.WriteLine("targetExtension:        " + targetExtension);
                Console.WriteLine();

                string selectFilter = "";
                if (!returnAll)
                {
                    selectFilter += "Build = true and ";
                }
                if (descExtension != null)
                {
                    selectFilter += "DescriptorExtension = '" + descExtension + "' and ";
                }
                if (targetExtension != null)
                {
                    selectFilter += "Child.TargetExtension = '" + targetExtension + "'";
                }
                if (selectFilter.LastIndexOf("and ") == selectFilter.Length - 4)
                {
                    selectFilter = selectFilter.Substring(0, selectFilter.Length - 4);
                }

                // perform descriptor and target extension filtering
                ArrayList complist = ProductBuildDataSet.GetFilteredComplist(buildPath, selectFilter);

                // perform file filtering
                if (complistFilterFileName != null)
                {
                    StringCollection complistFilterFiles = CollectionUtil.ReadValueFile(complistFilterFileName);
                    foreach (string component in complist)
                    {
                        bool matched = false;
                        foreach (string complistFilterFile in complistFilterFiles)
                        {
                            if (component.ToUpper() == complistFilterFile.ToUpper())
                            {
                                matched = true;
                                break;
                            }
                        }
                        if (matched)
                        {
                            continue;
                        }
                        complist.Remove(component);
                    }
                }

                CollectionUtil.WriteValueFile(complist, outputComplistFileName);

                if (complist.Count < 1)
                {
                    Console.WriteLine("Complist is empty.");
                    errlvl = 1;
                }

                foreach (string component in complist)
                {
                    Console.WriteLine(component);
                }
            }
            catch (Exception e) {
                errlvl = 2;
                Console.Error.WriteLine("An error occurred in ResolveComplist:");
                Console.Error.WriteLine(e.ToString());
                Usage();
            }

            return(errlvl);
        }
コード例 #5
0
        static int Main(string[] args)
        {
            int errlvl = 0;

            try {
                // Process Command-line Arguments
                string buildPath        = null;
                string buildUserProfile = null;
                string maxFileAge       = null;
                string exclusionFile    = null;
                string buildCfgFile     = null;

                if (args.Length < 1)
                {
                    Console.WriteLine();
                    Console.Error.WriteLine("Missing or Invalid Parameter.");
                    Usage();
                    errlvl = 2;
                    return(errlvl);
                }

                buildPath = args[0];
                foreach (string arg in args)
                {
                    if (arg.ToLower().StartsWith("/p:"))
                    {
                        buildUserProfile = arg.Substring(3).Trim();
                    }
                    if (arg.ToLower().StartsWith("/a:"))
                    {
                        maxFileAge = arg.Substring(3).Trim();
                    }
                    if (arg.ToLower().StartsWith("/e:"))
                    {
                        exclusionFile = arg.Substring(3).Trim();
                    }
                    if (arg.ToLower().StartsWith("/f:"))
                    {
                        buildCfgFile = arg.Substring(3).Trim();
                    }
                }

                Console.WriteLine();
                Console.WriteLine("buildPath:        " + buildPath);
                Console.WriteLine("buildUserProfile: " + buildUserProfile);
                Console.WriteLine("maxFileAge:       " + maxFileAge);
                Console.WriteLine("exclusionFile:    " + exclusionFile);
                Console.WriteLine("buildCfgFile:     " + buildCfgFile);
                Console.WriteLine();

                //build dataset
                ProductBuildDataSet pbDataSet = null;
                if (buildCfgFile != null)
                {
                    pbDataSet = ProductBuildDataSet.ReadBuildConfigurationFile(buildCfgFile);
                }
                else
                {
                    LibraryManifest li = new LibraryManifest(buildPath);
                    if (buildUserProfile == null)
                    {
                        buildUserProfile = "Development";
                    }
                    pbDataSet = ProductBuildDataSet.GetProductBuildDataSetWithoutComplist(buildUserProfile,
                                                                                          li.GetName(),
                                                                                          li.GetVersion(),
                                                                                          li.GetPlatform(),
                                                                                          li.GetBranchOrTrunkName(),
                                                                                          li.GetDirectory(),
                                                                                          buildPath,
                                                                                          li.GetDate());
                    pbDataSet.LoadComplist();
                    pbDataSet.FinalizeProperties();
                }

                if (maxFileAge == null)
                {
                    maxFileAge = pbDataSet.GetBuildProperty("MaximumTargetAge");
                }
                //hack for backwards compatibility
                int colonIndex  = maxFileAge.IndexOf(':');
                int periodIndex = maxFileAge.IndexOf('.');
                if (periodIndex == -1 || colonIndex < periodIndex)
                {
                    maxFileAge = maxFileAge.Substring(0, colonIndex) + "." + maxFileAge.Substring(colonIndex + 1);
                }

                ArrayList checkedTargets   = pbDataSet.GetTargets(true);
                ArrayList uncheckedTargets = pbDataSet.GetTargets(false);

                if (exclusionFile != null)
                {
                    StringCollection excludedFiles = CollectionUtil.ReadValueFile(exclusionFile);
                    foreach (string excludedFile in excludedFiles)
                    {
                        foreach (string checkedTarget in checkedTargets)
                        {
                            if (excludedFile.ToLower() == checkedTarget.ToLower())
                            {
                                checkedTargets.Remove(checkedTarget);
                                uncheckedTargets.Add(checkedTarget);
                            }
                        }
                    }
                    uncheckedTargets.Sort();
                }

                //check the build
                Console.WriteLine();
                Console.WriteLine("Checking product , {0}, {1}, {2}, {3}",
                                  new object[] { pbDataSet.GetBuildProperty("ProductName"),
                                                 pbDataSet.GetBuildProperty("ProductVersion"),
                                                 pbDataSet.GetBuildProperty("ProductPlatform"),
                                                 pbDataSet.GetBuildProperty("BranchOrTrunkName"),
                                                 buildPath });
                Console.WriteLine("  in {0}", buildPath);
                Console.WriteLine();

                int  totalTargets     = checkedTargets.Count + uncheckedTargets.Count;
                int  foundTargets     = 0;
                int  duplicateTargets = 0;
                int  excludedTargets  = uncheckedTargets.Count;
                int  missingTargets   = 0;
                int  overAgeTargets   = 0;
                bool buildSucceeded   = true;

                string binPath = Path.Combine(buildPath, "bin");

                DateTime currentTime = DateTime.Now;
                DateTime checkTime   = currentTime - TimeSpan.Parse(maxFileAge);
                for (int targetIndex = 0; targetIndex < checkedTargets.Count; targetIndex++)
                {
                    string target = (string)checkedTargets[targetIndex];
                    if (targetIndex > 0 && target.ToLower() == ((string)checkedTargets[targetIndex - 1]).ToLower())
                    {
                        duplicateTargets++;
                        continue;
                    }
                    string targetFilename = Path.Combine(binPath, target);
                    if (!File.Exists(targetFilename))
                    {
                        buildSucceeded = false;
                        missingTargets++;
                        Console.WriteLine("{0,-32} Missing", target);
                        continue;
                    }
                    foundTargets++;
                    DateTime creationTime = File.GetLastWriteTime(targetFilename);
                    if (creationTime < checkTime)
                    {
                        buildSucceeded = false;
                        overAgeTargets++;
                        TimeSpan overAgeTime   = currentTime - creationTime;
                        string   overAgeString = "";
                        if (overAgeTime.Days > 0)
                        {
                            overAgeString += String.Format("{0,4}d", overAgeTime.Days);
                        }
                        if (overAgeTime.Hours > 0)
                        {
                            overAgeString += String.Format("{0:D2}h", overAgeTime.Hours);
                        }
                        overAgeString += String.Format("{0:D2}m", overAgeTime.Minutes);
                        Console.WriteLine("{0,-32} OverAge:{1}", target, overAgeString);
                    }
                }

                //results summary
                Console.WriteLine();
                Console.WriteLine("CheckBuild Statistics:");
                Console.WriteLine("Product           : {0}", pbDataSet.GetBuildProperty("ProductName"));
                Console.WriteLine("Version           : {0}", pbDataSet.GetBuildProperty("ProductVersion"));
                Console.WriteLine("Platform          : {0}", pbDataSet.GetBuildProperty("ProductPlatform"));
                Console.WriteLine("BranchOrTrunkName : {0}", pbDataSet.GetBuildProperty("BranchOrTrunkName"));
                Console.WriteLine("Target Dir        : {0}", buildPath);
                Console.WriteLine("Max File Age      : {0} (DD.HH:MM:SS)", maxFileAge);
                Console.WriteLine("Targets           : {0}", totalTargets);
                Console.WriteLine("Found             : {0}", foundTargets);
                Console.WriteLine("Duplicates        : {0}", duplicateTargets);
                Console.WriteLine("Excluded          : {0}", excludedTargets);
                Console.WriteLine("Missing           : {0}", missingTargets);
                Console.WriteLine("OverAge           : {0}", overAgeTargets);
                string successString = (buildSucceeded) ? "Successful Build." : "Build Failed!!!";
                Console.WriteLine("Results           : {0}", successString);

                errlvl = (buildSucceeded) ? 0 : 1;
            }
            catch (Exception e) {
                errlvl = 2;
                Console.Error.WriteLine("An error occurred in CheckBuild:");
                Console.Error.WriteLine(e.ToString());
                Usage();
            }

            return(errlvl);
        }