Class VisualStudioNETProjectWriter

  • All Implemented Interfaces:
    ProjectWriter

    public final class VisualStudioNETProjectWriter
    extends java.lang.Object
    implements ProjectWriter
    Writes a Visual Studio.NET project file.
    • Field Detail

      • version

        private final java.lang.String version
        Version of VisualStudio.NET.
      • trueLiteral

        private final java.lang.String trueLiteral
        Literal to represent a true value.
      • falseLiteral

        private final java.lang.String falseLiteral
        Literal to represent a false value.
    • Constructor Detail

      • VisualStudioNETProjectWriter

        public VisualStudioNETProjectWriter​(java.lang.String versionArg,
                                            java.lang.String trueArg,
                                            java.lang.String falseArg)
        Constructor.
        Parameters:
        versionArg - String VisualStudio.NET version
        trueArg - literal to represent true, "true" in VC 2005.
        falseArg - literal to represent false, "false" in VC 2005.
    • Method Detail

      • getConfigurationType

        private java.lang.String getConfigurationType​(CCTask task)
        Gets the configuration type.
        Parameters:
        task - cc task, may not be null.
        Returns:
        configuration type
      • getCharacterSet

        private java.lang.String getCharacterSet​(CommandLineCompilerConfiguration compilerConfig)
        Get character set for Windows API.
        Parameters:
        compilerConfig - compiler configuration, may not be null.
        Returns:
        "1" is TCHAR is unicode, "0" if TCHAR is multi-byte.
      • writeConfigurationStartTag

        private void writeConfigurationStartTag​(org.xml.sax.ContentHandler content,
                                                boolean isDebug,
                                                CCTask task,
                                                CommandLineCompilerConfiguration compilerConfig)
                                         throws org.xml.sax.SAXException
        Write the start tag of the Configuration element.
        Parameters:
        content - serialization content handler.
        isDebug - if true, write a debug configuration.
        task - cc task.
        compilerConfig - compiler configuration.
        Throws:
        org.xml.sax.SAXException - thrown if serialization error.
      • getOptimization

        private java.lang.String getOptimization​(CommandLineCompilerConfiguration compilerConfig)
        Get value of Optimization property.
        Parameters:
        compilerConfig - compiler configuration, may not be null.
        Returns:
        value of Optimization property.
      • getAdditionalIncludeDirectories

        private java.lang.String getAdditionalIncludeDirectories​(java.lang.String baseDir,
                                                                 CommandLineCompilerConfiguration compilerConfig)
        Get value of AdditionalIncludeDirectories property.
        Parameters:
        compilerConfig - compiler configuration.
        baseDir - base for relative paths.
        Returns:
        value of AdditionalIncludeDirectories property.
      • getPreprocessorDefinitions

        private java.lang.String getPreprocessorDefinitions​(CommandLineCompilerConfiguration compilerConfig,
                                                            boolean isDebug)
        Get value of PreprocessorDefinitions property.
        Parameters:
        compilerConfig - compiler configuration.
        isDebug - true if generating debug configuration.
        Returns:
        value of PreprocessorDefinitions property.
      • getRuntimeLibrary

        private java.lang.String getRuntimeLibrary​(CommandLineCompilerConfiguration compilerConfig,
                                                   boolean isDebug)
        Get value of RuntimeLibrary property.
        Parameters:
        compilerConfig - compiler configuration.
        isDebug - true if generating debug configuration.
        Returns:
        value of RuntimeLibrary property.
      • getUsePrecompiledHeader

        private java.lang.String getUsePrecompiledHeader​(CommandLineCompilerConfiguration compilerConfig)
        Get value of UsePrecompiledHeader property.
        Parameters:
        compilerConfig - compiler configuration.
        Returns:
        value of UsePrecompiledHeader property.
      • getPrecompiledHeaderFile

        private java.lang.String getPrecompiledHeaderFile​(CommandLineCompilerConfiguration compilerConfig)
        Get value of PrecompiledHeaderFile property.
        Parameters:
        compilerConfig - compiler configuration.
        Returns:
        value of PrecompiledHeaderFile property.
      • getBasicRuntimeChecks

        private java.lang.String getBasicRuntimeChecks​(CommandLineCompilerConfiguration compilerConfig)
        Get value of BasicRuntimeChecks property.
        Parameters:
        compilerConfig - compiler configuration.
        Returns:
        value of BasicRuntimeChecks property.
      • getWarningLevel

        private java.lang.String getWarningLevel​(CommandLineCompilerConfiguration compilerConfig)
        Get value of WarningLevel property.
        Parameters:
        compilerConfig - compiler configuration.
        Returns:
        value of WarningLevel property.
      • getDetect64BitPortabilityProblems

        private java.lang.String getDetect64BitPortabilityProblems​(CommandLineCompilerConfiguration compilerConfig)
        Get value of Detect64BitPortabilityProblems property.
        Parameters:
        compilerConfig - compiler configuration.
        Returns:
        value of Detect64BitPortabilityProblems property.
      • getDebugInformationFormat

        private java.lang.String getDebugInformationFormat​(CommandLineCompilerConfiguration compilerConfig)
        Get value of DebugInformationFormat property.
        Parameters:
        compilerConfig - compiler configuration.
        Returns:
        value of DebugInformationFormat property.
      • writeCompilerElement

        private void writeCompilerElement​(org.xml.sax.ContentHandler content,
                                          boolean isDebug,
                                          java.lang.String basePath,
                                          CommandLineCompilerConfiguration compilerConfig)
                                   throws org.xml.sax.SAXException
        write the Compiler element.
        Parameters:
        content - serialization content handler.
        isDebug - true if generating debug configuration.
        basePath - base for relative file paths.
        compilerConfig - compiler configuration.
        Throws:
        org.xml.sax.SAXException - thrown if error during serialization.
      • getLinkIncremental

        private java.lang.String getLinkIncremental​(CommandLineLinkerConfiguration linkerConfig)
        Get value of LinkIncremental property.
        Parameters:
        linkerConfig - linker configuration.
        Returns:
        value of LinkIncremental property
      • getSubsystem

        private java.lang.String getSubsystem​(CommandLineLinkerConfiguration linkerConfig)
        Get value of Subsystem property.
        Parameters:
        linkerConfig - linker configuration.
        Returns:
        value of Subsystem property
      • getTargetMachine

        private java.lang.String getTargetMachine​(CommandLineLinkerConfiguration linkerConfig)
        Get value of TargetMachine property.
        Parameters:
        linkerConfig - linker configuration.
        Returns:
        value of TargetMachine property
      • getAdditionalDependencies

        private java.lang.String getAdditionalDependencies​(TargetInfo linkTarget,
                                                           java.util.List projectDependencies,
                                                           java.util.Map targets,
                                                           java.lang.String basePath)
        Get value of AdditionalDependencies property.
        Parameters:
        linkTarget - link target.
        projectDependencies - dependencies declared in project.
        targets - all targets.
        basePath - path to directory containing project file.
        Returns:
        value of AdditionalDependencies property.
      • writeLinkerElement

        private void writeLinkerElement​(org.xml.sax.ContentHandler content,
                                        boolean isDebug,
                                        java.util.List dependencies,
                                        java.lang.String basePath,
                                        TargetInfo linkTarget,
                                        java.util.Map targets)
                                 throws org.xml.sax.SAXException
        Write Tool element for linker.
        Parameters:
        content - serialization content handler.
        isDebug - true if generating debug configuration.
        dependencies - project dependencies.
        basePath - path to directory containing project file.
        linkTarget - link target.
        targets - all targets.
        Throws:
        org.xml.sax.SAXException - thrown if error during serialization.
      • writeProject

        public void writeProject​(java.io.File fileName,
                                 CCTask task,
                                 ProjectDef projectDef,
                                 java.util.List sources,
                                 java.util.Hashtable targets,
                                 TargetInfo linkTarget)
                          throws java.io.IOException,
                                 org.xml.sax.SAXException
        Writes a project definition file.
        Specified by:
        writeProject in interface ProjectWriter
        Parameters:
        fileName - project name for file, should has .cbx extension
        task - cc task for which to write project
        projectDef - project element
        sources - source files
        targets - compilation targets
        linkTarget - link target
        Throws:
        java.io.IOException - if I/O error
        org.xml.sax.SAXException - if XML serialization error
      • writeFilteredSources

        private void writeFilteredSources​(java.lang.String name,
                                          java.lang.String filter,
                                          java.lang.String basePath,
                                          java.io.File[] sortedSources,
                                          org.xml.sax.ContentHandler content)
                                   throws org.xml.sax.SAXException
        Writes a cluster of source files to the project.
        Parameters:
        name - name of filter
        filter - file extensions
        basePath - base path for files
        sortedSources - array of source files
        content - generated project
        Throws:
        org.xml.sax.SAXException - if invalid content
      • isGroupMember

        private boolean isGroupMember​(java.lang.String filter,
                                      java.io.File candidate)
        Returns true if the file has an extension that appears in the group filter.
        Parameters:
        filter - String group filter
        candidate - File file
        Returns:
        boolean true if member of group
      • addAttribute

        private static void addAttribute​(org.xml.sax.helpers.AttributesImpl attributes,
                                         java.lang.String attrName,
                                         java.lang.String attrValue)
        Adds an non-namespace-qualified attribute to attribute list.
        Parameters:
        attributes - list of attributes.
        attrName - attribute name, may not be null.
        attrValue - attribute value, if null attribute is not added.
      • getBaseCompilerConfiguration

        private CommandLineCompilerConfiguration getBaseCompilerConfiguration​(java.util.Hashtable targets)
        Gets the first recognized compiler from the compilation targets.
        Parameters:
        targets - compilation targets
        Returns:
        representative (hopefully) compiler configuration