internal void Resolve()

in Sharpmake/Project.Configuration.cs [2867:3054]


            internal void Resolve(Resolver resolver)
            {
                if (_resolveState != Resolver.ResolveStates.NotResolved)
                    throw new Error("Can't resolve twice!");
                _resolveState = Resolver.ResolveStates.InProgress;

                if (PrecompHeader == null && PrecompSource != null)
                    throw new Error("Incoherent settings for {0} : PrecompHeader is null but PrecompSource is not", ToString());
                // TODO : Is it OK to comment this or is it a hack ?
                //if (PrecompHeader != null && PrecompSource == null)
                //    throw new Error("Incoherent settings for {0} : PrecompSource is null but PrecompHeader is not", ToString());

                SetPlatformDependentProperties();

                resolver.SetParameter("conf", this);
                resolver.SetParameter("target", Target);
                resolver.Resolve(this);

                Util.ResolvePath(Project.SharpmakeCsPath, ref ProjectPath);
                if (DebugBreaks.ShouldBreakOnProjectPath(DebugBreaks.Context.Resolving, Path.Combine(ProjectPath, ProjectFileName) + (Project is CSharpProject ? ".csproj" : ".vcxproj"), this))
                    System.Diagnostics.Debugger.Break();
                Util.ResolvePath(Project.SharpmakeCsPath, ref IntermediatePath);
                if (!string.IsNullOrEmpty(BaseIntermediateOutputPath))
                    Util.ResolvePath(Project.SharpmakeCsPath, ref BaseIntermediateOutputPath);
                Util.ResolvePath(Project.SharpmakeCsPath, ref LibraryPaths);
                Util.ResolvePathAndFixCase(Project.SharpmakeCsPath, ref TargetCopyFiles);
                Util.ResolvePath(Project.SharpmakeCsPath, ref TargetCopyFilesPath);
                Util.ResolvePathAndFixCase(Project.SharpmakeCsPath, Util.KeyValuePairResolveType.ResolveAll, ref EventPostBuildCopies);
                Util.ResolvePathAndFixCase(Project.SharpmakeCsPath, Util.KeyValuePairResolveType.ResolveKey, ref TargetCopyFilesToSubDirectory);
                Util.ResolvePath(Project.SharpmakeCsPath, ref TargetDependsFiles);
                Util.ResolvePath(Project.SharpmakeCsPath, ref TargetPath);
                Util.ResolvePath(Project.SharpmakeCsPath, ref TargetLibraryPath);
                Util.ResolvePath(Project.SharpmakeCsPath, ref AdditionalUsingDirectories);
                if (_blobPath != null)
                    Util.ResolvePath(Project.SharpmakeCsPath, ref _blobPath);

                // workaround for export projects: they do not generate pdb, so no need to resolve their paths
                if (Project.SharpmakeProjectType != ProjectTypeAttribute.Export)
                {
                    // Reset to the default if the script set it to an empty string.
                    if (!string.IsNullOrEmpty(LinkerPdbFilePath))
                        Util.ResolvePath(Project.SharpmakeCsPath, ref LinkerPdbFilePath);
                    if (!string.IsNullOrEmpty(CompilerPdbFilePath))
                        Util.ResolvePath(Project.SharpmakeCsPath, ref CompilerPdbFilePath);
                }
                if (PrecompHeaderOutputFolder != null)
                    Util.ResolvePath(Project.SharpmakeCsPath, ref PrecompHeaderOutputFolder);

                Util.ResolvePath(Project.SourceRootPath, ref SourceFilesBuildExclude);
                Util.ResolvePath(Project.SourceRootPath, ref IncludePaths);
                Util.ResolvePath(Project.SourceRootPath, ref IncludePrivatePaths);
                Util.ResolvePath(Project.SourceRootPath, ref IncludeSystemPaths);
                Util.ResolvePath(Project.SourceRootPath, ref PrecompSourceExclude);
                Util.ResolvePath(Project.SourceRootPath, ref PrecompSourceExcludeFolders);
                Util.ResolvePath(Project.SourceRootPath, ref ConsumeWinRTExtensions);
                Util.ResolvePath(Project.SourceRootPath, ref ExcludeWinRTExtensions);
                Util.ResolvePath(Project.SourceRootPath, ref ResourceIncludePaths);
                Util.ResolvePath(Project.SourceRootPath, ref ResourceIncludePrivatePaths);
                Util.ResolvePath(Project.SourceRootPath, ref SourceFilesExceptionsEnabled);
                Util.ResolvePath(Project.SourceRootPath, ref SourceFilesExceptionsEnabledWithExternC);
                Util.ResolvePath(Project.SourceRootPath, ref SourceFilesExceptionsEnabledWithSEH);
                Util.ResolvePath(Project.SourceRootPath, ref AdditionalManifestFiles);
                if (!string.IsNullOrEmpty(XmlDocumentationFile))
                    Util.ResolvePath(Project.SourceRootPath, ref XmlDocumentationFile);

                if (ModuleDefinitionFile != null)
                {
                    Util.ResolvePath(Project.SourceRootPath, ref ModuleDefinitionFile);
                }

                if (Project.IsFileNameToLower)
                {
                    ProjectFileName = ProjectFileName.ToLowerInvariant();
                    BffFileName = BffFileName.ToLowerInvariant();
                }

                if (Project.IsTargetFileNameToLower)
                {
                    TargetFilePlatformPrefix = TargetFilePlatformPrefix.ToLowerInvariant();
                    TargetFilePrefix = TargetFilePrefix.ToLowerInvariant();
                    TargetFileName = TargetFileName.ToLowerInvariant();
                    TargetFileSuffix = TargetFileSuffix.ToLowerInvariant();
                    TargetFileFullName = TargetFileFullName.ToLowerInvariant();
                    TargetFileFullNameWithExtension = TargetFileFullNameWithExtension.ToLowerInvariant();
                    TargetFileFullExtension = TargetFileFullExtension.ToLowerInvariant();
                }

                _resolvedTargetDependsFiles.AddRange(TargetDependsFiles);
                _resolvedTargetCopyFiles.AddRange(TargetCopyFiles);

                foreach (var keyValuePair in TargetCopyFilesToSubDirectory)
                {
                    _resolvedTargetCopyFilesToSubDirectory.Add(keyValuePair);
                }

                foreach (var tuple in new[] {
                    Tuple.Create(EventPreBuildExe,        _resolvedEventPreBuildExe),
                    Tuple.Create(EventPostBuildExe,       _resolvedEventPostBuildExe),
                    Tuple.Create(EventCustomPreBuildExe,  _resolvedEventCustomPreBuildExe),
                    Tuple.Create(EventCustomPostBuildExe, _resolvedEventCustomPostBuildExe),
                })
                {
                    UniqueList<BuildStepBase> eventsToResolve = tuple.Item1;
                    UniqueList<BuildStepBase> resolvedEvents = tuple.Item2;

                    foreach (BuildStepBase eventToResolve in eventsToResolve)
                        eventToResolve.Resolve(resolver);

                    resolvedEvents.AddRange(eventsToResolve);
                }

                foreach (var customFileBuildStep in CustomFileBuildSteps)
                {
                    customFileBuildStep.Resolve(resolver);
                    Util.ResolvePath(Project.SourceRootPath, ref customFileBuildStep.KeyInput);

                    if(!customFileBuildStep.UseExecutableFromSystemPath)
                    {
                        Util.ResolvePath(Project.SourceRootPath, ref customFileBuildStep.Executable);
                    }

                    Util.ResolvePath(Project.SourceRootPath, ref customFileBuildStep.Output);
                    Util.ResolvePath(Project.SourceRootPath, ref customFileBuildStep.AdditionalInputs);
                }

                if (CustomBuildSettings != null)
                {
                    CustomBuildSettings.Resolve(resolver);
                    Util.ResolvePath(Project.SourceRootPath, ref CustomBuildSettings.OutputFile);
                }

                foreach (var option in Options)
                {
                    var pathOption = option as Options.PathOption;
                    if (pathOption != null)
                    {
                        pathOption.Path = resolver.Resolve(pathOption.Path);
                        Util.ResolvePath(Project.SourceRootPath, ref pathOption.Path);
                    }
                }

                foreach (var filter in ForcedIncludesFilters)
                {
                    Util.ResolvePath(Project.SourceRootPath, ref filter.ExcludeFiles);
                    Util.ResolvePath(Project.SourceRootPath, ref filter.FilterFiles);
                }

                foreach (var eventDictionary in new[]{
                    EventPreBuildExecute,
                    EventCustomPrebuildExecute,
                    EventPostBuildExecute,
                    EventCustomPostBuildExecute
                })
                {
                    foreach (KeyValuePair<string, BuildStepBase> eventPair in eventDictionary)
                        eventPair.Value.Resolve(resolver);
                }

                if (PostBuildStampExe != null && PostBuildStampExes.Any())
                    throw new Error("Incoherent settings for {0} : both PostBuildStampExe and PostBuildStampExes have values, they are mutually exclusive.", ToString());

                foreach (var stampExe in PostBuildStampExes)
                    stampExe.Resolve(resolver);

                if (PostBuildStampExe != null)
                    PostBuildStampExe.Resolve(resolver);

                if (PostBuildStepTest != null)
                    PostBuildStepTest.Resolve(resolver);

                string dependencyExtension = Util.GetProjectFileExtension(this);
                ProjectFullFileNameWithExtension = ProjectFullFileName + dependencyExtension;

                if (string.IsNullOrEmpty(ProjectGuid) && Project.SharpmakeProjectType != ProjectTypeAttribute.Compile)
                    ProjectGuid = Util.BuildGuid(ProjectFullFileNameWithExtension, Project.GuidReferencePath);

                if (PrecompHeader != null)
                    PrecompHeader = Util.SimplifyPath(PrecompHeader);
                if (PrecompSource != null)
                    PrecompSource = Util.SimplifyPath(PrecompSource);

                ProjectReferencesByPath.Resolve(Project.SourceRootPath, resolver);

                resolver.RemoveParameter("conf");
                resolver.RemoveParameter("target");

                _resolveState = Resolver.ResolveStates.Resolved;
            }