module Ryb::VisualStudio::Compiler

Constants

STANDARD_FLAGS

Public Class Methods

architecture_to_flags(architecture) click to toggle source
# File lib/ryb/visual_studio.rb, line 66
def self.architecture_to_flags(architecture)
  case architecture
    when :x86
      %w{/arch:IA32}
    when :x86_64
      # TODO(mtwilliams): Determine if we can specify a minimum of SSE2?
      []
    else
      []
    end
end
defines_to_flags(defines) click to toggle source
# File lib/ryb/visual_studio.rb, line 21
def self.defines_to_flags(defines)
  return [] unless defines
  (defines.map do |name, value|
    case value
      when TrueClass
        "/D#{name}=1"
      when FalseClass
        "/D#{name}=0"
      when Integer
        "/D#{name}=#{value}"
      when String
        "/D#{name}=#{value.to_s}"
      else
        nil
      end
  end).compact
end
generate_debug_symbols_to_flag(enabled) click to toggle source
# File lib/ryb/visual_studio.rb, line 43
def self.generate_debug_symbols_to_flag(enabled)
  # TODO(mtwilliams): Don't link to debug runtime.
   # Do I need to expose another flag?
  # HACK(mtwilliams): Force writes to PDBs to be serialized.
  # Refer to https://msdn.microsoft.com/en-us/library/dn502518.aspx.
  enabled ? %w{/MDd /Zi /FS} : %w{/MD}
end
include_paths_to_flags(paths) click to toggle source
# File lib/ryb/visual_studio.rb, line 17
def self.include_paths_to_flags(paths)
  [*paths].map{|path| "/I\"#{path}\""}
end
optimization_to_flags(optimization) click to toggle source
# File lib/ryb/visual_studio.rb, line 55
def self.optimization_to_flags(optimization)
  case
    when :nothing
      %w{/Od /RTCsu /fp:precise /fp:except}
    when :size
      %w{/Os /fp:fast /fp:except-}
    when :speed
      %w{/Ox /fp:fast /fp:except-}
    end
end
treat_warnings_as_errors_to_flag(enabled) click to toggle source
# File lib/ryb/visual_studio.rb, line 39
def self.treat_warnings_as_errors_to_flag(enabled)
  enabled ? %w{/WX} : []
end