Class VisualStudioNETProjectWriter

java.lang.Object
net.sf.antcontrib.cpptasks.devstudio.VisualStudioNETProjectWriter
All Implemented Interfaces:
ProjectWriter

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

    • version

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

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

      private final String falseLiteral
      Literal to represent a false value.
  • Constructor Details

    • VisualStudioNETProjectWriter

      public VisualStudioNETProjectWriter(String versionArg, String trueArg, 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 Details

    • getConfigurationType

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

      private 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(ContentHandler content, boolean isDebug, CCTask task, CommandLineCompilerConfiguration compilerConfig) throws 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:
      SAXException - thrown if serialization error.
    • getOptimization

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

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

      private 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 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 String getUsePrecompiledHeader(CommandLineCompilerConfiguration compilerConfig)
      Get value of UsePrecompiledHeader property.
      Parameters:
      compilerConfig - compiler configuration.
      Returns:
      value of UsePrecompiledHeader property.
    • getPrecompiledHeaderFile

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

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

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

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

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

      private void writeCompilerElement(ContentHandler content, boolean isDebug, String basePath, CommandLineCompilerConfiguration compilerConfig) throws 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:
      SAXException - thrown if error during serialization.
    • getLinkIncremental

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

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

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

      private String getAdditionalDependencies(TargetInfo linkTarget, List projectDependencies, Map targets, 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(ContentHandler content, boolean isDebug, List dependencies, String basePath, TargetInfo linkTarget, Map targets) throws 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:
      SAXException - thrown if error during serialization.
    • writeProject

      public void writeProject(File fileName, CCTask task, ProjectDef projectDef, List sources, Hashtable targets, TargetInfo linkTarget) throws IOException, 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:
      IOException - if I/O error
      SAXException - if XML serialization error
    • writeFilteredSources

      private void writeFilteredSources(String name, String filter, String basePath, File[] sortedSources, ContentHandler content) throws 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:
      SAXException - if invalid content
    • isGroupMember

      private boolean isGroupMember(String filter, 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(AttributesImpl attributes, String attrName, 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(Hashtable targets)
      Gets the first recognized compiler from the compilation targets.
      Parameters:
      targets - compilation targets
      Returns:
      representative (hopefully) compiler configuration