void PopulateDependentBuildModules(string config, string group, Project proj, ref string needRunCrossConfig, ref string pkgsNeedExploreCross, ref string indirectBuilddependents, string buildModules) { string buildDependenciesProperty = ""; string buildDependenciesPropertyPlatform = ""; string selectedModulesProperty = ""; string crossConfig = proj.Properties["config-cross"] + "-" + proj.Properties["config-name"]; foreach(string bm in NantToVSTools.TrimAndSplit(buildModules)) { if(bm != string.Empty) { ManagedModule managedModule = _managedmodulelist.Find(proj.Properties["package.name"] + "*" + config + "*" + bm + "*" + group); string groupname = group + "." + bm; string dependentlist = ""; buildDependenciesProperty = group + "." + bm + ".builddependencies"; if(proj.Properties.Contains(buildDependenciesProperty)) { dependentlist = proj.Properties[buildDependenciesProperty]; } else { buildDependenciesProperty = group + ".builddependencies"; if(proj.Properties.Contains(buildDependenciesProperty)) { groupname = group; dependentlist = proj.Properties[buildDependenciesProperty]; } } buildDependenciesPropertyPlatform = group + "." + bm + ".builddependencies." + proj.Properties["config-system"]; if(proj.Properties.Contains(buildDependenciesPropertyPlatform)) { dependentlist = CombineStrings(dependentlist, proj.Properties[buildDependenciesPropertyPlatform]); } else { buildDependenciesPropertyPlatform = group + ".builddependencies." + proj.Properties["config-system"]; if(proj.Properties.Contains(buildDependenciesPropertyPlatform)) { dependentlist = CombineStrings(dependentlist, proj.Properties[buildDependenciesPropertyPlatform]); } } // call per module vcproj prebuildtarget CallPerModuleVcprojPrebuildTarget(proj, groupname); foreach(string dependent in NantToVSTools.TrimAndSplit(dependentlist)) { if(dependent != string.Empty) { bool hasSelectedModules = false; bool singleModule = false; selectedModulesProperty = group + "." + bm + "." + dependent + ".runtime.buildmodules"; if(proj.Properties.Contains(selectedModulesProperty)) hasSelectedModules = true; else { selectedModulesProperty = group + "." + dependent + ".runtime.buildmodules"; if(proj.Properties.Contains(selectedModulesProperty)) { hasSelectedModules = true; singleModule = true; } } bool dependentProjAlreadyExist = false; Project dependentProj = null; if (_projects.Contains(dependent + "_" + config)) { dependentProjAlreadyExist = true; dependentProj = (Project)_projects[dependent + "_" + config]; } string newModules = ""; string modulesInSameConfig = ""; string modulesInDiffConfig = ""; if (!hasSelectedModules)// it means the current package depends on all modules of this dependent for this configuration { if (_properties.Contains(dependent + ".runtime.buildmodules." + config) && dependentProjAlreadyExist) { // figure out the new modules string existingModules = (string)_properties[dependent + ".runtime.buildmodules." + config]; if (existingModules != "") { _properties[dependent + ".runtime.buildmodules." + config] = ""; string allModules = GetUnProcessedBuildModules(dependentProj, "runtime", config); foreach (string sbm in NantToVSTools.TrimAndSplit(allModules)) { if (sbm != string.Empty) { if (!ListContainsString(existingModules, sbm)) { newModules = newModules + " " + sbm; } } } } } else _properties[dependent + ".runtime.buildmodules." + config] = ""; if (managedModule != null) { managedModule.AddDependentModules(dependent, config, "", "runtime"); } } else // it has selected modules { string sModules = (string)proj.Properties[selectedModulesProperty]; foreach (string sbm in NantToVSTools.TrimAndSplit(sModules)) { if (sbm != string.Empty) { if (sbm.StartsWith("cross-") && config.IndexOf("cross") == -1) modulesInDiffConfig = modulesInDiffConfig + " " + sbm; else { modulesInSameConfig = modulesInSameConfig + " " + sbm; } } } if (!_properties.Contains(dependent + ".runtime.buildmodules." + config)) { _properties[dependent + ".runtime.buildmodules." + config] = modulesInSameConfig; } else { string modules = (string)_properties[dependent + ".runtime.buildmodules." + config]; if (modules != "") { foreach (string sbm in NantToVSTools.TrimAndSplit(modulesInSameConfig)) { if (sbm != string.Empty) { if (!ListContainsString(modules, sbm)) { newModules = newModules + " " + sbm; } } } } if (!dependentProjAlreadyExist) _properties[dependent + ".runtime.buildmodules." + config] = CombineStrings(modules, newModules); } if (managedModule != null) { foreach (string m in NantToVSTools.TrimAndSplit(modulesInSameConfig)) { if (m == String.Empty) continue; // we add it to temporary store because we don't know if they are managed module yet at this point. managedModule.AddDependentModules(dependent, config, m, "runtime"); } } } // if dependent proj already exist if (dependentProjAlreadyExist && newModules != "") { if (dependentProj != null) { Hashtable nmHash = new Hashtable(); foreach (string nbm in NantToVSTools.TrimAndSplit(newModules)) { if (nbm == String.Empty) continue; if (IsModuleDefined(dependentProj, "runtime", nbm)) { // See if 'nbm' is a managed module or not. string basetype = ""; if (IsModuleManaged(dependentProj, "runtime", nbm, ref basetype)) { bool csharpModule = false; if (basetype == "CSharp") csharpModule = true; bool copylocal = false; if (dependentProj.Properties.Contains("runtime." + nbm + ".copylocal")) { if (dependentProj.Properties["runtime." + nbm + ".copylocal"] == "true" || dependentProj.Properties["runtime." + nbm + ".copylocal"] == "slim") copylocal = true; } ManagedModule mm = new ManagedModule(dependent, config, nbm, "runtime", csharpModule, false, copylocal); _managedmodulelist.Add(mm); } // Explore all intermodule depependencies using the existing proj // and find possible native->cross inter-module dependencies. // also add this new module to the corresponding constraint buildmodule property bool foundNativeToCrossModuleDependency = FindInterModuleDependencies(dependentProj, "runtime", nbm, nmHash); if (foundNativeToCrossModuleDependency) { pkgsNeedExploreCross = pkgsNeedExploreCross + " " + dependent; } } else throw new BuildException("\nError: module '" + nbm + "' is not defined in 'runtime' group for package '" + dependent + "' in '" + config + "' configuration!"); } string newCrossModules = ""; foreach (string nm in nmHash.Keys) { if (nm == string.Empty) continue; if (config.IndexOf("cross") != 1) newModules = CombineStrings(newModules, nm); else { if (nm.IndexOf("cross") != -1) newCrossModules = CombineStrings(newCrossModules, nm); else newModules = CombineStrings(newModules, nm); } } // need to populate dependent buildmodules for this new module because we missed them when dependent runs. string tempFlag = ""; // useless passthrough variable string extrabuilddependentlist = ""; PopulateDependentBuildModules(config, "runtime", dependentProj, ref tempFlag, ref pkgsNeedExploreCross, ref extrabuilddependentlist, newModules); indirectBuilddependents = CombineStrings(indirectBuilddependents, extrabuilddependentlist); string builddependentlist_deppackage = GetBuildDependentList(dependentProj, "runtime", newModules); indirectBuilddependents = CombineStrings(indirectBuilddependents, builddependentlist_deppackage); // examine all new explored build dependents' initialize.xml DoDependentTaskOnPackages(dependentProj, builddependentlist_deppackage); if (newCrossModules != "") { // we know the cross proj will exist by now. otherwise we won't see this cross module. Project crossdependentproj = (Project)_projects[dependent + "_" + crossConfig]; string bdlist = GetBuildDependentList(crossdependentproj, "runtime", newCrossModules); pkgsNeedExploreCross = CombineStrings(pkgsNeedExploreCross, bdlist); DoDependentTaskOnPackages(crossdependentproj, bdlist); PopulateDependentBuildModules(crossConfig, "runtime", crossdependentproj, ref tempFlag, ref pkgsNeedExploreCross, ref pkgsNeedExploreCross, newCrossModules); } } } // Found inter-package native to cross dependencies if (modulesInDiffConfig != "") { // tell slnmaker this dependent is depended by a native module, so if the dependent is a cross only package // and has zero-module in native config, slnmaker will still process it in native config if (singleModule) _properties[group + "." + dependent + ".nativedependable." + config] = "true"; else _properties[group + "." + bm + "." + dependent + ".nativedependable." + config] = "true"; pkgsNeedExploreCross = pkgsNeedExploreCross + " " + dependent; if (_properties.Contains(dependent + ".runtime.buildmodules." + crossConfig)) { string modules = (string)_properties[dependent + ".runtime.buildmodules." + crossConfig]; if (modules != "") { _properties[dependent + ".runtime.buildmodules." + crossConfig] = CombineStrings(modules, modulesInDiffConfig); } } else { _properties[dependent + ".runtime.buildmodules." + crossConfig] = modulesInDiffConfig; } } } } Hashtable newModulesHash = new Hashtable(); bool ntrc = FindInterModuleDependencies(proj, group, bm, newModulesHash); if(config.IndexOf("cross") != -1 && newModulesHash.Count != 0) { foreach(string ncm in newModulesHash.Keys) { if(ncm == string.Empty) continue; if(ListContainsString(buildModules, ncm)) continue; string ncmgroup = (string) newModulesHash[ncm]; if(ncmgroup != group) continue; string tempflag = ""; // useless passthrough parameter string bdlist = GetBuildDependentList(proj, ncmgroup, ncm); indirectBuilddependents = CombineStrings(indirectBuilddependents, bdlist); DoDependentTaskOnPackages(proj, bdlist); PopulateDependentBuildModules(config, ncmgroup, proj, ref tempflag, ref pkgsNeedExploreCross, ref indirectBuilddependents, ncm); } } else { foreach(string nm in newModulesHash.Keys) { if(nm == String.Empty) continue; string nmgroup = (string) newModulesHash[nm]; if(nmgroup != group) continue; string tempflag = ""; // useless passthrough parameter if(nm.StartsWith("cross")) { // we know the cross proj will exist by now. otherwise we won't see this cross module. Project crossproj = (Project) _projects[proj.Properties["package.name"] + "_" + crossConfig]; string bdlist = GetBuildDependentList(crossproj, nmgroup, nm); pkgsNeedExploreCross = CombineStrings(pkgsNeedExploreCross, bdlist); DoDependentTaskOnPackages(crossproj, bdlist); PopulateDependentBuildModules(crossConfig, nmgroup, crossproj, ref tempflag, ref pkgsNeedExploreCross, ref pkgsNeedExploreCross, nm); } else { if(ListContainsString(buildModules, nm)) continue; string bdlist = GetBuildDependentList(proj, nmgroup, nm); indirectBuilddependents = CombineStrings(indirectBuilddependents, bdlist); DoDependentTaskOnPackages(proj, bdlist); PopulateDependentBuildModules(config, nmgroup, proj, ref tempflag, ref pkgsNeedExploreCross, ref indirectBuilddependents, nm); } } } if (needRunCrossConfig != "true") { if (ntrc) needRunCrossConfig = "true"; } } } /// START: TO BE REMOVED // For backwards compatibility we still need to suppor this hack: // A Hack to model the group module dependencies other than 'runtime' moduledependencies. // Need to be removed once we have the other group moduledependencies support in eaconfig if (proj.NamedOptionSets.Contains("config.targetoverrides")) { if (proj.NamedOptionSets["config.targetoverrides"].Options.Contains("sln" + group + "-slnmaker")) { if (!proj.Properties.Contains("sln" + group + "-slnmaker.checked")) { string excludeFlag = proj.NamedOptionSets["config.targetoverrides"].Options["sln" + group + "-slnmaker"]; if (excludeFlag == "exclude" && proj.Properties.Contains("rwconfig-exclude-" + "sln" + group + "-slnmaker")) { if (proj.Targets.Find("sln" + group + "-slnmaker") != null) { string targetfile = proj.Targets.Find("sln" + group + "-slnmaker").Location.FileName; XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(targetfile); string xpath = "//target[@name = \"" + "sln" + group + "-slnmaker\"]/slnmaker"; XmlNode xmlNode = xmlDoc.DocumentElement.SelectSingleNode(xpath); GatherModuleDpdFromCustmizedSlnMaker(proj, config, group, xmlNode, ref needRunCrossConfig); proj.Properties.Add("sln" + group + "-slnmaker.checked", ""); } catch (Exception e) { string error = e.ToString(); } } } } } } /// END: TO BE REMOVED }
private bool FindInterModuleDependencies(Project proj, string group, string module, Hashtable newmodules) { string currentPackageName = proj.Properties["package.name"]; string config = proj.Properties["config"]; string bmConstrainProp = currentPackageName + "." + group + ".buildmodules." + config; ManagedModule managedModule = _managedmodulelist.Find(currentPackageName + "*" + config + "*" + module + "*" + group); if (_properties.Contains(bmConstrainProp)) { string existingbmConstrain = (string)_properties[bmConstrainProp]; if (existingbmConstrain != "") { _properties[bmConstrainProp] = CombineStrings(existingbmConstrain, module); } } else { if (Project.Properties["package.name"] == currentPackageName) _properties[bmConstrainProp] = ""; else _properties[bmConstrainProp] = module; } bool foundNative2CrossModuleDependency = false; string[] targetGroups = new String[] { "runtime", group }; if (group == "runtime") targetGroups = new String[] { "runtime" }; foreach (string dgroup in targetGroups) { string moduleDependenciesProperty = group + "." + module + "." + dgroup + ".moduledependencies"; string moduleDependenciesPropertyPlatform = group + "." + module + "." + dgroup + ".moduledependencies." + proj.Properties["config-system"]; string moduledependentlist = ""; if (!proj.Properties.Contains(moduleDependenciesProperty)) { // check for singleModule if (group != dgroup && proj.Properties.Contains(group + "." + dgroup + ".moduledependencies")) moduledependentlist = proj.Properties[group + "." + dgroup + ".moduledependencies"]; } else moduledependentlist = proj.Properties[moduleDependenciesProperty]; if(proj.Properties.Contains(moduleDependenciesPropertyPlatform)) { moduledependentlist = CombineStrings(moduledependentlist, proj.Properties[moduleDependenciesPropertyPlatform]); } else { moduleDependenciesPropertyPlatform = group + "." + dgroup + ".moduledependencies." + proj.Properties["config-system"]; if(proj.Properties.Contains(moduleDependenciesPropertyPlatform)) { moduledependentlist = CombineStrings(moduledependentlist, proj.Properties[moduleDependenciesPropertyPlatform]); } } if (moduledependentlist != "") { foreach (string mdependent in NantToVSTools.TrimAndSplit(moduledependentlist)) { if(mdependent == String.Empty) continue; // found cross -> native, error! if (config.IndexOf("cross") != -1 && mdependent.IndexOf("cross") == -1) throw new BuildException("\nError: cross module '" + module + "' can not depend on native module '" + mdependent + "' in package '" + currentPackageName + "'\n\n" + "If '" + mdependent + "' is a legitimate cross module, please prefix its name with 'cross-'!"); if (IsModuleDefined(proj, dgroup, mdependent)) // normal case, native->native cross->cross { newmodules[mdependent] = dgroup; if (_managedmodulelist.Find(currentPackageName + "*" + config + "*" + mdependent + "*" + dgroup) == null) { // See if 'nbm' is a managed module or not. string basetype = ""; if (IsModuleManaged(proj, dgroup, mdependent, ref basetype)) { bool csharpModule = false; if (basetype == "CSharp") csharpModule = true; bool copylocal = false; if (proj.Properties.Contains(dgroup + "." + mdependent + ".copylocal")) { if (proj.Properties[dgroup + "." + mdependent + ".copylocal"] == "true" || proj.Properties[dgroup + "." + mdependent + ".copylocal"] == "slim") copylocal = true; } ManagedModule mm = new ManagedModule(currentPackageName, config, mdependent, dgroup, csharpModule, false, copylocal); _managedmodulelist.Add(mm); if (managedModule != null) managedModule.AddDependentModules(currentPackageName, config, mdependent, dgroup); } } else { if (managedModule != null) managedModule.AddDependentModules(currentPackageName, config, mdependent, dgroup); } bool fn2cmd = FindInterModuleDependencies(proj, dgroup, mdependent, newmodules); if (!foundNative2CrossModuleDependency) foundNative2CrossModuleDependency = fn2cmd; } else if (config.IndexOf("cross") == -1 && mdependent.IndexOf("cross") != -1) // native -> cross { string crossConfig = proj.Properties["config-cross"] + "-" + proj.Properties["config-name"]; string bmConstrainProperty = currentPackageName + "." + dgroup + ".buildmodules." + crossConfig; bool moduleAlreadyExist = false; if (_properties.Contains(bmConstrainProperty)) { string existingbmConstrain = (string)_properties[bmConstrainProperty]; if (existingbmConstrain != "") { if(ListContainsString(existingbmConstrain, mdependent)) moduleAlreadyExist = true; else _properties[bmConstrainProperty] = existingbmConstrain + " " + mdependent; } else moduleAlreadyExist = true; } else { if (Project.Properties["package.name"] == currentPackageName) _properties[bmConstrainProperty] = ""; else _properties[bmConstrainProperty] = mdependent; } // if the cross project is already created, then we dont need to explore it anymore if (_projects.Contains(currentPackageName + "_" + crossConfig) && _projects[currentPackageName + "_" + crossConfig] != null) { Project crossProj = (Project)_projects[currentPackageName + "_" + crossConfig]; // Since cross config is already run, we can not rely on FindBuildDependencies to explore the dependents module info. // Instead we need to return this new cross module to the caller so that the caller can explore its dependents module info. if(! moduleAlreadyExist) newmodules[mdependent] = dgroup; FindInterModuleDependencies(crossProj, dgroup, mdependent, newmodules); } else // if the cross project is not created yet, we need to tell parents to auto explore it. foundNative2CrossModuleDependency = true; } else { throw new BuildException("\nError: module '" + mdependent + "' is not defined in '" + dgroup + "' group for package '" + currentPackageName + "' in '" + config + "' configuration!"); } } } } return foundNative2CrossModuleDependency; }
private string GetUnProcessedBuildModules(Project proj, string group, string config) { string buildModules = ""; bool singleModule = false; string packagename = proj.Properties["package.name"]; if (proj.Properties.Contains(group + ".buildmodules")) { buildModules = proj.Properties[group + ".buildmodules"]; if (group.Equals("runtime")) _properties[packagename + ".runtime.buildmodules.all." + config + ".vsproj"] = buildModules; } else if (proj.Properties.Contains(group + ".buildtype") || proj.Properties.Contains(group + ".builddependencies")) { buildModules = packagename; singleModule = true; } if(PackageList == "" || (! ListContainsString(PackageList, packagename))) { // Get the constraint build modules if the property exists if (_properties.Contains(packagename + "." + group + ".buildmodules." + config)) { string constraintBuildModules = (string)_properties[packagename + "." + group + ".buildmodules." + config]; if (constraintBuildModules != "") { buildModules = constraintBuildModules; } else { if(! singleModule) _properties[packagename + "." + group + ".buildmodules." + config] = buildModules; } } else _properties[packagename + "." + group + ".buildmodules." + config] = ""; } else _properties[packagename + "." + group + ".buildmodules." + config] = ""; // Find Managed Modules foreach (string bm in NantToVSTools.TrimAndSplit(buildModules)) { if (bm == String.Empty) continue; string basetype = ""; if (IsModuleManaged(proj, group, bm, ref basetype)) { bool csharpModule = false; if (basetype == "CSharp") csharpModule = true; bool copylocal = false; string copyLocalProperty = group + "." + bm + ".copylocal"; if (singleModule) copyLocalProperty = group + ".copylocal"; if (proj.Properties.Contains(copyLocalProperty)) { if (proj.Properties[copyLocalProperty] == "true" || proj.Properties[copyLocalProperty] == "slim") copylocal = true; } ManagedModule mm = new ManagedModule(packagename, config, bm, group, csharpModule, singleModule, copylocal); _managedmodulelist.Add(mm); } } return buildModules; }
internal PdbFile(ManagedModule module, bool isWow64) { _module = module; Symbols = ParseSymbols(isWow64).Result; }