Exemple #1
0
        internal VcFileConfiguration(string relativePath, string parentName, XmlElement elem, VcProjectConfiguration parentConfig, DirectoryInfo outputDir) : base(elem, parentConfig.Project, outputDir)
        {
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }
            if (parentName == null)
            {
                throw new ArgumentNullException("parentName");
            }
            if (parentConfig == null)
            {
                throw new ArgumentNullException("parentConfig");
            }

            _relativePath = relativePath;
            _parentName   = parentName;

            string excludeFromBuild = elem.GetAttribute("ExcludedFromBuild");

            if (excludeFromBuild.Length != 0)
            {
                _excludeFromBuild = string.Compare(excludeFromBuild.Trim(), "true", true, CultureInfo.InvariantCulture) == 0;
            }

            _parentConfig = parentConfig;
        }
Exemple #2
0
        internal VcFileConfiguration(string relativePath, string parentName, VcProjectConfiguration parentConfig, DirectoryInfo outputDir) : base(parentConfig.Name, parentConfig.Project, outputDir) {
            if (relativePath == null) {
                throw new ArgumentNullException("relativePath");
            }
            if (parentName == null) {
                throw new ArgumentNullException("parentName");
            }
            if (parentConfig == null) {
                throw new ArgumentNullException("parentConfig");
            }

            _relativePath = relativePath;
            _parentName = parentName;
            _parentConfig = parentConfig;
        }
Exemple #3
0
        internal VcFileConfiguration(string relativePath, string parentName, VcProjectConfiguration parentConfig, DirectoryInfo outputDir) : base(parentConfig.Name, parentConfig.Project, outputDir)
        {
            if (relativePath == null)
            {
                throw new ArgumentNullException("relativePath");
            }
            if (parentName == null)
            {
                throw new ArgumentNullException("parentName");
            }
            if (parentConfig == null)
            {
                throw new ArgumentNullException("parentConfig");
            }

            _relativePath = relativePath;
            _parentName   = parentName;
            _parentConfig = parentConfig;
        }
Exemple #4
0
        internal VcFileConfiguration(string relativePath, string parentName, XmlElement elem, VcProjectConfiguration parentConfig, DirectoryInfo outputDir) : base(elem, parentConfig.Project, outputDir) {
            if (relativePath == null) {
                throw new ArgumentNullException("relativePath");
            }
            if (parentName == null) {
                throw new ArgumentNullException("parentName");
            }
            if (parentConfig == null) {
                throw new ArgumentNullException("parentConfig");
            }

            _relativePath = relativePath;
            _parentName = parentName;

            string excludeFromBuild = elem.GetAttribute("ExcludedFromBuild");
            if (excludeFromBuild.Length != 0) {
                _excludeFromBuild = string.Compare(excludeFromBuild.Trim(), "true", true, CultureInfo.InvariantCulture) == 0;
            }

            _parentConfig = parentConfig;
        }
Exemple #5
0
        public VcProject(SolutionBase solution, string projectPath, XmlElement xmlDefinition, 
                SolutionTask solutionTask, 
                TempFileCollection tfc, 
                GacCache gacCache, 
                ReferencesResolver refResolver, 
                DirectoryInfo outputDir)
            : base(xmlDefinition, solutionTask, tfc, gacCache, refResolver, outputDir)
        {
            if (projectPath == null) {
                throw new ArgumentNullException("projectPath");
            }

            _references = new ArrayList();
            _clArgMap = VcArgumentMap.CreateCLArgumentMap();
            _linkerArgMap = VcArgumentMap.CreateLinkerArgumentMap();
            _midlArgMap = VcArgumentMap.CreateMidlArgumentMap();
            _projectPath = FileUtils.GetFullPath(projectPath);

            _name = xmlDefinition.GetAttribute("Name");
            _guid = xmlDefinition.GetAttribute("ProjectGUID");

            XmlNodeList configurationNodes = xmlDefinition.SelectNodes("//Configurations/Configuration");
            foreach (XmlElement configElem in configurationNodes) {
                VcProjectConfiguration config = new VcProjectConfiguration(configElem, this, OutputDir);
                ProjectConfigurations[new Configuration (config.Name, config.PlatformName)] = config;
            }

            XmlNodeList references = xmlDefinition.SelectNodes("//References/child::*");
            foreach (XmlElement referenceElem in references) {
                ReferenceBase reference = CreateReference(solution, referenceElem);
                _references.Add(reference);
            }

            XmlNodeList fileNodes = xmlDefinition.SelectNodes("//File");
            _projectFiles = new ArrayList(fileNodes.Count);
            foreach (XmlElement fileElem in fileNodes) {
                string parentName = Name;

                // determine name of parent
                if (fileElem.ParentNode != null && fileElem.ParentNode.Name == "Filter") {
                    XmlNode filterName = fileElem.ParentNode.Attributes.GetNamedItem("Name");
                    if (filterName != null) {
                        parentName = filterName.Value;
                    }
                }

                string relPath = fileElem.GetAttribute("RelativePath");

                Hashtable htFileConfigurations = null;

                XmlNodeList fileConfigList = fileElem.GetElementsByTagName("FileConfiguration");
                if (fileConfigList.Count > 0) {
                    htFileConfigurations = CollectionsUtil.CreateCaseInsensitiveHashtable(fileConfigList.Count);
                    foreach (XmlElement fileConfigElem in fileConfigList) {
                        Configuration fileConfig = Configuration.Parse (
                            fileConfigElem.GetAttribute("Name"));
                        VcProjectConfiguration projectConfig = (VcProjectConfiguration) ProjectConfigurations[fileConfig];
                        htFileConfigurations[projectConfig.Name] = new VcFileConfiguration(
                            relPath, parentName, fileConfigElem, projectConfig, outputDir);
                    }
                }

                // TODO: refactor this together with the Build methods

                // we'll always create a file configuration for IDL and res
                // files as macro's in the configuration properties for these
                // files will always need to be expanded on the file level
                string ext = Path.GetExtension(relPath).ToLower(CultureInfo.InvariantCulture);
                switch (ext) {
                    case ".idl":
                    case ".odl":
                    case ".rc":
                        // ensure there's a file configuration for each project
                        // configuration
                        foreach (VcProjectConfiguration projectConfig in ProjectConfigurations.Values) {
                            // if file configuration for project config existed
                            // in project file, then skip this project config
                            if (htFileConfigurations != null && htFileConfigurations.ContainsKey(projectConfig.Name)) {
                                continue;
                            }

                            // lazy initialize hashtable
                            if (htFileConfigurations == null) {
                                htFileConfigurations = CollectionsUtil.CreateCaseInsensitiveHashtable();
                            }

                            // create the file configuration
                            htFileConfigurations[projectConfig.Name] = new
                                VcFileConfiguration(relPath, parentName, projectConfig, outputDir);
                        }
                        break;
                }

                if (htFileConfigurations != null) {
                    _projectFiles.Add(htFileConfigurations);
                } else {
                    _projectFiles.Add(relPath);
                }
            }
        }
Exemple #6
0
        private void RunLibrarian(VcProjectConfiguration projectConfig)
        {
            // check if there's anything to do
            if (projectConfig.ObjFiles.Count == 0) {
                Log(Level.Debug, "No files to compile.");
                return;
            }

            // create instance of Lib task
            LibTask libTask = new LibTask();

            // inherit project from solution task
            libTask.Project = SolutionTask.Project;

            // inherit namespace manager from solution task
            libTask.NamespaceManager = SolutionTask.NamespaceManager;

            // parent is solution task
            libTask.Parent = SolutionTask;

            // inherit verbose setting from solution task
            libTask.Verbose = SolutionTask.Verbose;

            // make sure framework specific information is set
            libTask.InitializeTaskConfiguration();

            // set parent of child elements
            libTask.Sources.Parent = libTask;

            // inherit project from solution task for child elements
            libTask.Sources.Project = libTask.Project;

            // inherit namespace manager from parent
            libTask.Sources.NamespaceManager = libTask.NamespaceManager;

            libTask.OutputFile = new FileInfo(projectConfig.OutputPath);

            // Additional Library Directory
            string addLibDirs = projectConfig.GetToolSetting(VcConfigurationBase.LibTool, "AdditionalLibraryDirectories");
            if (!String.IsNullOrEmpty(addLibDirs)) {
                foreach (string addLibDir in addLibDirs.Split(',', ';')) {
                    if (addLibDir.Length == 0) {
                        continue;
                    }
                    libTask.LibDirs.DirectoryNames.Add(addLibDir);
                }
            }

            // Additional Dependencies
            string addDeps = projectConfig.GetToolSetting(VcConfigurationBase.LibTool, "AdditionalDependencies");
            if (!String.IsNullOrEmpty(addDeps)) {
                int insertedDeps = 0;
                foreach (string addDep in addDeps.Split(' ')) {
                    if (Path.GetExtension(addDep) == ".obj") {
                        projectConfig.ObjFiles.Insert(insertedDeps++, addDep);
                    } else {
                        libTask.Sources.FileNames.Add(addDep);
                    }
                }
            }

            foreach (string objFile in projectConfig.ObjFiles) {
                libTask.Sources.FileNames.Add(objFile);
            }

            // Module Definition File Name
            string moduleDefinitionFile = projectConfig.GetToolSetting(VcConfigurationBase.LibTool, "ModuleDefinitionFile");
            if (!String.IsNullOrEmpty(moduleDefinitionFile)) {
                libTask.ModuleDefinitionFile = new FileInfo(FileUtils.CombinePaths(
                    ProjectDirectory.FullName, moduleDefinitionFile));
            }

            // Ignore All Default Libraries
            string ignoreAllDefaultLibraries = projectConfig.GetToolSetting(VcConfigurationBase.LibTool, "IgnoreAllDefaultLibraries");
            if (string.Compare(ignoreAllDefaultLibraries, "TRUE", true, CultureInfo.InvariantCulture) == 0) {
                libTask.Options = "/NODEFAULTLIB";
            }

            // Ignore Specific Libraries
            string ignoreDefaultLibraries = projectConfig.GetToolSetting(VcConfigurationBase.LibTool, "IgnoreDefaultLibraryNames");
            if (!String.IsNullOrEmpty(ignoreDefaultLibraries)) {
                foreach (string ignoreLibrary in ignoreDefaultLibraries.Split(';')) {
                    libTask.IgnoreLibraries.Add(new Library(ignoreLibrary));
                }
            }

            // Export Named Functions
            // TODO

            // Forced Symbol References
            string symbolReferences = projectConfig.GetToolSetting(VcConfigurationBase.LibTool,
                "ForceSymbolReferences");
            if (!String.IsNullOrEmpty(symbolReferences)) {
                foreach (string symbol in symbolReferences.Split(';')) {
                    libTask.Symbols.Add(new Symbol(symbol));
                }
            }

            // execute the task
            ExecuteInProjectDirectory(libTask);
        }
Exemple #7
0
        private bool RunCustomBuildStep(Configuration solutionConfiguration, VcProjectConfiguration projectConfig)
        {
            // check if a custom build step is configured
            string commandLine = projectConfig.GetToolSetting(VcConfigurationBase.CustomBuildTool,
                "CommandLine");
            if (String.IsNullOrEmpty(commandLine)) {
                return true;
            }

            DateTime oldestOutputFile = DateTime.MinValue;

            string outputs = projectConfig.GetToolSetting(VcConfigurationBase.CustomBuildTool,
                "Outputs");
            if (!String.IsNullOrEmpty(outputs)) {
                foreach (string output in outputs.Split(';')) {
                    if (output.Length == 0) {
                        continue;
                    }

                    string outputFile = Path.Combine (ProjectDirectory.FullName,
                        output);
                    if (File.Exists(outputFile)) {
                        DateTime lastWriteTime = File.GetLastWriteTime(outputFile);
                        if (lastWriteTime < oldestOutputFile || oldestOutputFile == DateTime.MinValue) {
                            oldestOutputFile = lastWriteTime;
                        }
                    }
                }
            }

            bool runCustomBuildStep = false;

            // when at least one of the output files of the custom build step
            // does not exist or is older than the project output file, then
            // the custom build step must be executed
            string projectOutputFile = GetOutputPath(solutionConfiguration);
            if (projectOutputFile != null && File.Exists (projectOutputFile)) {
                DateTime lastWriteTime = File.GetLastWriteTime(projectOutputFile);
                if (lastWriteTime > oldestOutputFile) {
                    runCustomBuildStep = true;
                }
            }

            // if one of the additional dependencies was updated after the oldest
            // output file of the custom build step, then the custom build step
            // must also be executed
            if (!runCustomBuildStep) {
                string additionalDependencies = projectConfig.GetToolSetting(
                    VcConfigurationBase.CustomBuildTool, "AdditionalDependencies");
                if (!String.IsNullOrEmpty(additionalDependencies)) {
                    foreach (string dependency in additionalDependencies.Split(';')) {
                        if (dependency.Length == 0) {
                            continue;
                        }

                        string dependencyFile = Path.Combine (ProjectDirectory.FullName,
                            dependency);
                        if (File.Exists (dependencyFile)) {
                            DateTime lastWriteTime  = File.GetLastWriteTime(dependencyFile);
                            if (lastWriteTime > oldestOutputFile) {
                                runCustomBuildStep = true;
                                break;
                            }
                        }
                    }
                }
            }

            if (!runCustomBuildStep) {
                return true;
            }

            string description = projectConfig.GetToolSetting(VcConfigurationBase.CustomBuildTool,
                "Description", "Performing Custom Build Step");
            Log(Level.Info, description);
            return ExecuteBuildEvent("Custom-Build", commandLine, projectConfig);
        }
Exemple #8
0
        private bool PreLink(VcProjectConfiguration projectConfig)
        {
            // check if the build event should be executed
            string excludedFromBuild = projectConfig.GetToolSetting(VcConfigurationBase.PreLinkEventTool,
                "ExcludedFromBuild");
            if (excludedFromBuild != null) {
                if (string.Compare(excludedFromBuild.Trim(), "true", true, CultureInfo.InvariantCulture) == 0) {
                    return true;
                }
            }

            string commandLine = projectConfig.GetToolSetting(VcConfigurationBase.PreLinkEventTool,
                "CommandLine");
            if (!String.IsNullOrEmpty(commandLine)) {
                Log(Level.Info, "Performing Pre-Link Event...");
                return ExecuteBuildEvent("Pre-Link", commandLine, projectConfig);
            }

            return true;
        }
Exemple #9
0
        /// <summary>
        /// Merges the specified tool setting of <paramref name="projectConfig" /> 
        /// with <paramref name="fileConfig" />.
        /// </summary>
        /// <remarks>
        /// The merge is suppressed when the flag $(noinherit) is defined in
        /// <paramref name="fileConfig" />.
        /// </remarks>
        private string MergeToolSetting(VcProjectConfiguration projectConfig, VcConfigurationBase fileConfig, string tool, string setting)
        {
            const string noinherit = "$(noinherit)";

            // get tool setting from either the file configuration or project
            // configuration (if setting is not defined on file configuration)
            string settingValue = fileConfig.GetToolSetting(tool, setting);
            if (settingValue != null) {
                if (settingValue.ToLower(CultureInfo.InvariantCulture).IndexOf(noinherit) == -1) {
                    // only add project-level setting to value if noherit if
                    // "fileConfig" is not actually the project config
                    if (!object.ReferenceEquals(projectConfig, fileConfig)) {
                        string baseSettingValue = projectConfig.GetToolSetting(tool, setting);
                        if (!String.IsNullOrEmpty(baseSettingValue)) {
                            settingValue += ";" + baseSettingValue;
                        }
                    }
                } else {
                    settingValue = settingValue.Remove(settingValue.ToLower(CultureInfo.InvariantCulture).IndexOf(noinherit), noinherit.Length);
                }
            } else {
                // if settingValue is null, then its not defined in neither the
                // file nor the project configuration
                return null;
            }

            // individual values are separated by ';'
            string[] values = settingValue.Split(';');

            // holds filtered setting value
            settingValue = string.Empty;

            // filter duplicate setting values
            Hashtable filteredValues = CollectionsUtil.CreateCaseInsensitiveHashtable(values.Length);
            foreach (string value in values) {
                if (!filteredValues.ContainsKey(value)) {
                    filteredValues.Add(value, null);

                    if (settingValue.Length != 0) {
                        settingValue += ';';
                    }
                    settingValue += value;
                }
            }

            return settingValue;
        }
Exemple #10
0
        /// <summary>
        /// Build resource files for the given configuration.
        /// </summary>
        /// <param name="fileNames">The resource files to build.</param>
        /// <param name="projectConfig">The project configuration.</param>
        /// <param name="fileConfig">The build configuration.</param>
        /// <remarks>
        /// TODO: refactor this as we should always get only one element in the
        /// <paramref name="fileNames" /> list. Each res file should be built
        /// with its own file configuration.
        /// </remarks>
        private void BuildResourceFiles(ArrayList fileNames, VcProjectConfiguration projectConfig, VcConfigurationBase fileConfig)
        {
            // create instance of RC task
            RcTask rcTask = new RcTask();

            // inherit project from solution task
            rcTask.Project = SolutionTask.Project;

            // Set the base directory
            rcTask.BaseDirectory = ProjectDirectory;

            // inherit namespace manager from solution task
            rcTask.NamespaceManager = SolutionTask.NamespaceManager;

            // parent is solution task
            rcTask.Parent = SolutionTask;

            // inherit verbose setting from solution task
            rcTask.Verbose = SolutionTask.Verbose;

            // make sure framework specific information is set
            rcTask.InitializeTaskConfiguration();

            // set parent of child elements
            rcTask.IncludeDirs.Parent = rcTask;

            // inherit project from solution task for child elements
            rcTask.IncludeDirs.Project = rcTask.Project;

            // set namespace manager of child elements
            rcTask.IncludeDirs.NamespaceManager = rcTask.NamespaceManager;

            // set base directories
            rcTask.IncludeDirs.BaseDirectory = ProjectDirectory;

            // Store the options to pass to the resource compiler in the options variable
            StringBuilder options = new StringBuilder();

            // Collect options

            string ignoreStandardIncludePath = fileConfig.GetToolSetting(VcConfigurationBase.ResourceCompilerTool, "IgnoreStandardIncludePath");
            if (ignoreStandardIncludePath != null && string.Compare(ignoreStandardIncludePath, "true", true, CultureInfo.InvariantCulture) == 0) {
                options.Append("/X ");
            }

            string culture = fileConfig.GetToolSetting(VcConfigurationBase.ResourceCompilerTool, "Culture");
            if (!String.IsNullOrEmpty(culture)) {
                int cultureId = Convert.ToInt32(culture);
                rcTask.LangId = cultureId;
            }

            string preprocessorDefs = fileConfig.GetToolSetting(VcConfigurationBase.ResourceCompilerTool, "PreprocessorDefinitions");
            if (!String.IsNullOrEmpty(preprocessorDefs)) {
                foreach (string preprocessorDef in preprocessorDefs.Split(';')) {
                    if (preprocessorDef.Length == 0) {
                        continue;
                    }
                    Option op = new Option();
                    op.OptionName = preprocessorDef;
                    rcTask.Defines.Add(op);
                }
            }

            string showProgress = fileConfig.GetToolSetting(VcConfigurationBase.ResourceCompilerTool, "ShowProgress");
            if (showProgress != null && string.Compare(showProgress, "true", true, CultureInfo.InvariantCulture) == 0) {
                rcTask.Verbose = true;
            }

            string addIncludeDirs = MergeToolSetting(projectConfig, fileConfig, VcConfigurationBase.ResourceCompilerTool, "AdditionalIncludeDirectories");
            if (!String.IsNullOrEmpty(addIncludeDirs)) {
                foreach (string includeDir in addIncludeDirs.Split(';')) {
                    if (includeDir.Length == 0) {
                        continue;
                    }
                    rcTask.IncludeDirs.DirectoryNames.Add(FileUtils.CombinePaths(
                        ProjectDirectory.FullName, CleanPath(includeDir)));
                }
            }

            // check for shared MFC
            if (projectConfig.UseOfMFC == UseOfMFC.Shared) {
                options.AppendFormat("/d \"_AFXDLL\"");
            }

            if (options.Length > 0) {
                rcTask.Options = options.ToString();
            }

            // Compile each resource file
            foreach (string rcFile in fileNames) {
                rcTask.OutputFile = new FileInfo(GetResourceOutputFile(rcFile, fileConfig));
                rcTask.RcFile = new FileInfo(FileUtils.CombinePaths(ProjectDirectory.FullName, rcFile));

                // execute the task
                ExecuteInProjectDirectory(rcTask);
            }
        }
Exemple #11
0
        /// <summary>
        /// Build Interface Definition Language files for the given
        /// configuration.
        /// </summary>
        /// <param name="fileNames">The IDL files to build.</param>
        /// <param name="projectConfig">The project configuration.</param>
        /// <param name="fileConfig">The build configuration.</param>
        /// <remarks>
        /// TODO: refactor this as we should always get only one element in the
        /// <paramref name="fileNames" /> list. Each IDL file should be built
        /// with its own file configuration.
        /// </remarks>
        private void BuildIDLFiles(ArrayList fileNames, VcProjectConfiguration projectConfig, VcConfigurationBase fileConfig)
        {
            // create instance of MIDL task
            MidlTask midlTask = new MidlTask();

            // inherit project from solution task
            midlTask.Project = SolutionTask.Project;

            // Set the base directory
            midlTask.BaseDirectory = ProjectDirectory;

            // inherit namespace manager from solution task
            midlTask.NamespaceManager = SolutionTask.NamespaceManager;

            // parent is solution task
            midlTask.Parent = SolutionTask;

            // inherit verbose setting from solution task
            midlTask.Verbose = SolutionTask.Verbose;

            // make sure framework specific information is set
            midlTask.InitializeTaskConfiguration();

            // set parent of child elements
            midlTask.IncludeDirs.Parent = midlTask;

            // inherit project from solution task for child elements
            midlTask.IncludeDirs.Project = midlTask.Project;

            // set namespace manager of child elements
            midlTask.IncludeDirs.NamespaceManager = midlTask.NamespaceManager;

            // set base directories
            midlTask.IncludeDirs.BaseDirectory = ProjectDirectory;

            // If outputDirectory is not supplied in the configuration, assume
            // it's the project directory
            string outputDirectory = fileConfig.GetToolSetting(VcConfigurationBase.MIDLTool, "OutputDirectory");
            if (String.IsNullOrEmpty(outputDirectory)) {
                outputDirectory = ProjectDirectory.FullName;
            } else {
                outputDirectory = FileUtils.CombinePaths(ProjectDirectory.FullName,
                    outputDirectory);
            }

            // ensure output directory exists
            if (!LongPathDirectory.Exists(outputDirectory)) {
                LongPathDirectory.Create(outputDirectory);
            }

            midlTask.Arguments.Add(new Argument("/out"));
            midlTask.Arguments.Add(new Argument(outputDirectory));

            string typeLibraryName = fileConfig.GetToolSetting(VcConfigurationBase.MIDLTool,
                "TypeLibraryName", "$(IntDir)/$(ProjectName).tlb");
            if (!String.IsNullOrEmpty(typeLibraryName)) {
                midlTask.Tlb = new FileInfo(FileUtils.CombinePaths(outputDirectory,
                    typeLibraryName));

                // ensure tlb directory exists
                if (!midlTask.Tlb.Directory.Exists) {
                    midlTask.Tlb.Directory.Create();
                    midlTask.Tlb.Directory.Refresh();
                }
            }

            string proxyFileName = fileConfig.GetToolSetting(VcConfigurationBase.MIDLTool, "ProxyFileName");
            if (!String.IsNullOrEmpty(proxyFileName)) {
                midlTask.Proxy = new FileInfo(FileUtils.CombinePaths(outputDirectory,
                    proxyFileName));

                // ensure proxy directory exists
                if (!midlTask.Proxy.Directory.Exists) {
                    midlTask.Proxy.Directory.Create();
                    midlTask.Proxy.Directory.Refresh();
                }
            }

            string interfaceIdentifierFileName = fileConfig.GetToolSetting(VcConfigurationBase.MIDLTool, "InterfaceIdentifierFileName");
            if (!String.IsNullOrEmpty(interfaceIdentifierFileName)) {
                midlTask.Iid = new FileInfo(FileUtils.CombinePaths(outputDirectory,
                    interfaceIdentifierFileName));

                // ensure IID directory exists
                if (!midlTask.Iid.Directory.Exists) {
                    midlTask.Iid.Directory.Create();
                    midlTask.Iid.Directory.Refresh();
                }
            }

            string dllDataFileName = fileConfig.GetToolSetting(VcConfigurationBase.MIDLTool, "DLLDataFileName");
            if (!String.IsNullOrEmpty(dllDataFileName)) {
                midlTask.DllData = new FileInfo(FileUtils.CombinePaths(outputDirectory,
                    dllDataFileName));

                // ensure DllData directory exists
                if (!midlTask.DllData.Directory.Exists) {
                    midlTask.DllData.Directory.Create();
                    midlTask.DllData.Directory.Refresh();
                }
            }

            string headerFileName = fileConfig.GetToolSetting(VcConfigurationBase.MIDLTool, "HeaderFileName");
            if (!String.IsNullOrEmpty(headerFileName)) {
                midlTask.Header = new FileInfo(FileUtils.CombinePaths(outputDirectory,
                    headerFileName));

                // ensure Header directory exists
                if (!midlTask.Header.Directory.Exists) {
                    midlTask.Header.Directory.Create();
                    midlTask.Header.Directory.Refresh();
                }
            }

            string preprocessorDefs = MergeToolSetting(projectConfig, fileConfig,
                VcConfigurationBase.MIDLTool, "PreprocessorDefinitions");
            if (!String.IsNullOrEmpty(preprocessorDefs)) {
                foreach (string preprocessorDef in preprocessorDefs.Split(';')) {
                    if (preprocessorDef.Length == 0) {
                        continue;
                    }
                    Option op = new Option();
                    op.OptionName = preprocessorDef;
                    midlTask.Defines.Add(op);
                }
            }

            string undefinePreprocessorDefs = MergeToolSetting(projectConfig, fileConfig,
                VcConfigurationBase.MIDLTool, "UndefinePreprocessorDefinitions");
            if (!String.IsNullOrEmpty(undefinePreprocessorDefs)) {
                foreach (string undefinePreprocessorDef in undefinePreprocessorDefs.Split(';')) {
                    if (undefinePreprocessorDef.Length == 0) {
                        continue;
                    }
                    Option op = new Option();
                    op.OptionName = undefinePreprocessorDef;
                    midlTask.Undefines.Add(op);
                }
            }

            string additionalIncludeDirs = MergeToolSetting(projectConfig, fileConfig,
                VcConfigurationBase.MIDLTool, "AdditionalIncludeDirectories");
            if (!String.IsNullOrEmpty(additionalIncludeDirs)) {
                foreach (string includeDir in additionalIncludeDirs.Split(';')) {
                    if (includeDir.Length == 0) {
                        continue;
                    }
                    midlTask.IncludeDirs.DirectoryNames.Add(FileUtils.CombinePaths(
                        ProjectDirectory.FullName, CleanPath(includeDir)));
                }
            }

            string cPreprocessOptions = MergeToolSetting(projectConfig, fileConfig,
                VcConfigurationBase.MIDLTool, "CPreprocessOptions");
            if (!String.IsNullOrEmpty(cPreprocessOptions)) {
                foreach (string cPreprocessOption in cPreprocessOptions.Split(';')) {
                    if (cPreprocessOption.Length == 0) {
                        continue;
                    }
                    midlTask.Arguments.Add(new Argument(string.Format("/cpp_opt\"{0}\"", cPreprocessOption)));
                }
            }

            Hashtable midlArgs = fileConfig.GetToolArguments(VcConfigurationBase.MIDLTool, _midlArgMap);
            foreach (string key in midlArgs.Keys) {
                switch (key) {
                    case "TargetEnvironment":
                        midlTask.Env = (string) midlArgs[key];
                        break;
                    case "DefaultCharType":
                        midlTask.Char = (string) midlArgs[key];
                        break;
                    default:
                        Argument midlArg = new Argument();
                        midlArg.Line = (string) midlArgs[key];
                        midlTask.Arguments.Add(midlArg);
                        break;
                }
            }

            // Compile each idl file
            foreach (string idlFile in fileNames) {
                midlTask.Filename = new FileInfo(FileUtils.CombinePaths(
                    ProjectDirectory.FullName, idlFile));

                // execute the task
                ExecuteInProjectDirectory(midlTask);
            }
        }
 internal LinkerConfig(VcProjectConfiguration projectConfig)
 {
     _projectConfig = projectConfig;
 }
Exemple #13
0
 internal LinkerConfig(VcProjectConfiguration projectConfig)
 {
     _projectConfig = projectConfig;
 }