Logo Search packages:      
Sourcecode: nant version File versions  Download package

void NAnt::VSNet::VcProject::BuildIDLFiles ( ArrayList  fileNames,
VcProjectConfiguration  projectConfig,
VcConfigurationBase  fileConfig 
) [inline, private]

Build Interface Definition Language files for the given configuration.

Parameters:
fileNames The IDL files to build.
projectConfig The project configuration.
fileConfig The build configuration.

TODO: refactor this as we should always get only one element in the fileNames list. Each IDL file should be built with its own file configuration.

Definition at line 980 of file VcProject.cs.

References NAnt::Core::Types::OptionCollection::Add(), NAnt::Core::Types::ArgumentCollection::Add(), NAnt::Core::Tasks::ExternalProgramBase::Arguments, NAnt::Core::Types::FileSet::BaseDirectory, NAnt::Core::Tasks::ExternalProgramBase::BaseDirectory, NAnt::VisualCpp::Tasks::MidlTask::Char, NAnt::VisualCpp::Tasks::MidlTask::Defines, NAnt::Core::Types::FileSet::DirectoryNames, NAnt::VisualCpp::Tasks::MidlTask::DllData, NAnt::VisualCpp::Tasks::MidlTask::Env, NAnt::VisualCpp::Tasks::MidlTask::Filename, NAnt::VSNet::VcConfigurationBase::GetToolArguments(), NAnt::VSNet::VcConfigurationBase::GetToolSetting(), NAnt::VisualCpp::Tasks::MidlTask::Header, NAnt::VisualCpp::Tasks::MidlTask::Iid, NAnt::VisualCpp::Tasks::MidlTask::IncludeDirs, NAnt::Core::Task::InitializeTaskConfiguration(), NAnt::Core::Element::NamespaceManager, NAnt::Core::Types::Option::OptionName, NAnt::Core::Element::Parent, NAnt::Core::Project::Project(), NAnt::Core::Element::Project, NAnt::VisualCpp::Tasks::MidlTask::Proxy, NAnt::VisualCpp::Tasks::MidlTask::Tlb, NAnt::VisualCpp::Tasks::MidlTask::Undefines, and NAnt::Core::Task::Verbose.

                                                                                                                              {
            const string compilerTool = "VCMIDLTool";

            // 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(compilerTool, "OutputDirectory");
            if (StringUtils.IsNullOrEmpty(outputDirectory)) {
                outputDirectory = ProjectDirectory.FullName;
            } else {
                outputDirectory = FileUtils.CombinePaths(ProjectDirectory.FullName, 
                    outputDirectory);
            }

            // ensure output directory exists
            if (!Directory.Exists(outputDirectory)) {
                Directory.CreateDirectory(outputDirectory);
            }

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

            string typeLibraryName = fileConfig.GetToolSetting(compilerTool, 
                "TypeLibraryName", "$(IntDir)/$(ProjectName).tlb");
            if (!StringUtils.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(compilerTool, "ProxyFileName");
            if (!StringUtils.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(compilerTool, "InterfaceIdentifierFileName");
            if (!StringUtils.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(compilerTool, "DLLDataFileName");
            if (!StringUtils.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(compilerTool, "HeaderFileName");
            if (!StringUtils.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,
                compilerTool, "PreprocessorDefinitions");
            if (!StringUtils.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,
                compilerTool, "UndefinePreprocessorDefinitions");
            if (!StringUtils.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,
                compilerTool, "AdditionalIncludeDirectories");
            if (!StringUtils.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,
                compilerTool, "CPreprocessOptions");
            if (!StringUtils.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(compilerTool, _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);
            }
        }


Generated by  Doxygen 1.6.0   Back to index