Exemplo n.º 1
0
        protected override void ExecuteTask()
        {
            if(! IsPackageCompatibleWithSlnGenerator())
            {
                throw new BuildException("ERROR: This package does not support automated SLN generation. Please call 'generate-sln' or set the property 'rwconfig.enableslngeneration' to true !");
            }

            ValidatePackageConfigs();

            System.DateTime dt1 = System.DateTime.Now;

            string packageConfigs = ReOrderPackageConfigs();
            string packageBuildDir = Project.Properties["package.builddir"];
            string packageName = Project.Properties["package.name"];
            originalPackageConfigs = Project.Properties["package.configs"];
            InitializeGlobalVariables();

            if(Project.Properties.Contains("generate-single-config"))
            {
                packageConfigs = Project.Properties["config"];
                Project.Properties.UpdateReadOnly("package.configs", packageConfigs);
            }

            foreach(string config in NantToVSTools.TrimAndSplit(packageConfigs))
            {
                if(config == string.Empty)
                    continue;

                if(PackageList != "")
                {
                    foreach(string pkgname in NantToVSTools.TrimAndSplit(PackageList))
                    {
                        AddPackageProperties(pkgname);
                        FindBuildDependencies(pkgname, config, packageConfigs, Group, true, false, null);
                    }
                }
                else
                {
                    FindBuildDependencies(packageName, config, packageConfigs, Group, true, false, null);
                }

                // instantiate one fileset for each package (input to slnmerger)
                if(generateCompleteSlnsForAllPackages || PackageList != "")
                {
                    foreach(object package in _packages.Keys)
                    {
                        EAPackage eap = (EAPackage) _packages[package];
                        if (!_filesets.Contains(eap.pkgName))
                        {
                            XmlElement filesetElement = _xmlDoc.CreateElement("fileset");
                            filesetElement.SetAttribute("name", "sln_fileset_" + eap.pkgName);
                            _filesets[eap.pkgName] = filesetElement;
                        }
                    }
                }
                else
                {
                    if (!_filesets.Contains(packageName))
                    {
                        XmlElement filesetElement = _xmlDoc.CreateElement("fileset");
                        filesetElement.SetAttribute("name", "sln_fileset_" + packageName);
                        _filesets[packageName] = filesetElement;
                    }
                }

                // first execuate all packages using old rwconfigs
                foreach(object package in _packages.Keys)
                {
                    EAPackage eap = (EAPackage) _packages[package];
                    if(eap.slnTarget != null)
                    {
                        Project proj = (Project) _projects[eap.pkgName + "_" + config];
                        if(proj == null)
                            continue;
                        proj.Properties["package.nantToVSTools.slnmaker.default.output"] = proj.Properties["package.builddir"] + Path.DirectorySeparatorChar
                            + proj.Properties["config"] + Path.DirectorySeparatorChar
                            + eap.pkgName + ".sln";
                        if(ProjectTargetFind(proj, eap.slnTarget) != null)
                        {
                            ProjectTargetFind(proj, eap.slnTarget).Copy().Execute();
                            AddSlnToFileSets(eap.pkgName, "runtime", proj.Properties["package.builddir"] + Path.DirectorySeparatorChar
                                + proj.Properties["config"] + Path.DirectorySeparatorChar
                                + eap.pkgName + ".sln");
                        }
                        else
                        {
                            throw new BuildException(eap.pkgName + ": target " + eap.slnTarget + " is missing!");
                        }
                        _projects[eap.pkgName + "_" + config] = null;
                        proj.Dispose();
                        proj = null;
                        // This is to tell slnmaker to treat rwconfig1.x packages differently because
                        // the generated vcproj files break the one-config-at-a-time SLN generation semantics
                        _properties[eap.pkgName + ".is-using-rwconfig1x." + config] = "";
                    }
                }

                PopulateProjectReferences(config);

                /// START: TO BE REMOVED for backwards compatibility with customized slngroup-slnmaker.
                PopulateNativeToCrossBuildModuleConstrains(config);
                PopulateModuleDependencies();
                /// END: TO BE REMOVED

                // Generate vsproj and solution files for all slnmerger workflow packages
                Hashtable temppackages = (Hashtable) _packages.Clone();
                foreach(object package in temppackages.Keys)
                {
                    Vcproj((EAPackage) temppackages[package], config);
                }
                temppackages.Clear();

                // In case I'm building EASharp using recursive nant call I need only create csproject, but not solutions
                if (!Project.Properties.Contains("easharp.runtime.build.buildcsc"))
                {
                    foreach (object package in _packages.Keys)
                    {
                        SlnMaker((EAPackage)_packages[package], config);
                    }
                }
            }
            // In case I'm building EASharp using recursive nant call I'm done
            if (Project.Properties.Contains("easharp.runtime.build.buildcsc"))
                return;

            if (!Project.Properties.Contains("generate-single-config"))
            {
                MergeVcprojs();
                MergeCsprojs();
            }

            if(PackageList != "")
            {
                XmlElement megaslnfileset = _xmlDoc.CreateElement("fileset");
                megaslnfileset.SetAttribute("name", "megasolution");
                foreach(string pkgname in NantToVSTools.TrimAndSplit(PackageList))
                {
                    if(((XmlElement)_filesets[pkgname]).ChildNodes.Count != 0)
                    {
                        string output = MergeSolutions(pkgname, Project.Properties["package." + pkgname + ".builddir"], true);
                        XmlElement includes = _xmlDoc.CreateElement("includes");
                        includes.SetAttribute("name", output);
                        megaslnfileset.AppendChild(includes);
                    }
                }
                if(generateCompleteSlnsForAllPackages)
                {
                    foreach(object package in _packages.Keys)
                    {
                        EAPackage eap = (EAPackage) _packages[package];
                        if(! ListContainsString(PackageList, eap.pkgName))
                        {
                            string output = MergeSolutions(eap.pkgName, Project.Properties["package." + eap.pkgName + ".builddir"], false);
                            XmlElement includes = _xmlDoc.CreateElement("includes");
                            includes.SetAttribute("name", output);
                            megaslnfileset.AppendChild(includes);
                        }
                    }
                }
                SlnMerger slnMergerMegaSln = new SlnMerger(Project);
                FileSet fs = new FileSet();
                fs.Project = Project;
                fs.Initialize(megaslnfileset);
                slnMergerMegaSln.Inputs = fs;
                slnMergerMegaSln.Output = Project.Properties["package.builddir"] + Path.DirectorySeparatorChar + packageName + ".sln";
                if(! Directory.Exists(Project.Properties["package.builddir"]))
                    Directory.CreateDirectory(Project.Properties["package.builddir"]);
                slnMergerMegaSln.ExecuteSlnMergerTask();
            }
            else
            {
                // Merge all generated solution files to the final solution file.
                if (_filesets.Contains(packageName) && ((XmlElement)_filesets[packageName]).ChildNodes.Count != 0)
                {
                    MergeSolutions(packageName, packageBuildDir, true);
                }

                if(generateCompleteSlnsForAllPackages)
                {
                    foreach(object package in _packages.Keys)
                    {
                        EAPackage eap = (EAPackage) _packages[package];
                        if(eap.pkgName != packageName)
                        {
                            MergeSolutions(eap.pkgName, Project.Properties["package." + eap.pkgName + ".builddir"], false);
                        }
                    }
                }
            }

            // restore the package.configs
            Project.Properties.UpdateReadOnly("package.configs", originalPackageConfigs);

            System.DateTime dt2 = System.DateTime.Now;
            System.TimeSpan dt3 = dt2.Subtract(dt1);
            Console.WriteLine("start time:" + dt1.ToString());
            Console.WriteLine("end time:" + dt2.ToString());
            Console.WriteLine("time elapsed: " + dt3.TotalMilliseconds + " milliseconds");
        }
Exemplo n.º 2
0
 string MergeSolutions(string packagename, string packagebuilddir, bool toplevel)
 {
     try
     {
         SlnMerger slnMergerTask = new SlnMerger(Project);
         FileSet fs = new FileSet();
         fs.Project = Project;
         fs.Initialize((XmlElement)_filesets[packagename]);
         slnMergerTask.Inputs = fs;
         if(Project.Properties.Contains("generate-single-config"))
         {
             slnMergerTask.Output = packagebuilddir + Path.DirectorySeparatorChar + Project.Properties["config"] + Path.DirectorySeparatorChar + packagename + ".sln";
         }
         else if(Group == "all" || Group == "allall" || Group == "runtime")
         {
             slnMergerTask.Output = packagebuilddir + Path.DirectorySeparatorChar + packagename + ".sln";
         }
         else
         {
             if(toplevel)
             {
                 slnMergerTask.Output = packagebuilddir + Path.DirectorySeparatorChar + packagename + "-" + Group + ".sln";
             }
             else
             {
                 slnMergerTask.Output = packagebuilddir + Path.DirectorySeparatorChar + packagename + ".sln";
             }
         }
         slnMergerTask.ExecuteSlnMergerTask();
         return slnMergerTask.Output;
     }
     catch(BuildException be)
     {
         throw new BuildException(be.ToString());
     }
 }