class MxxRu::Cpp::Toolsets::Vc8Family

Toolset implementation for Visual C++ 2005 (8.0) and above.

Constants

Actual_manifest

Actual manifest description.

MT_NAME_TAG

Tag name for a custom manifest tool name.

Since v.1.4.0

Public Class Methods

default_manifest() click to toggle source

Get default manifest.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 295
def self.default_manifest
  @@default_manifest
end
manifest( params ) click to toggle source

Make manifest description.

Examples:

# Autogenerate manifest for target. Do not embed into executable.
# Manifest stored in <target>.manifest file.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :autogen => :to_default_file )

# Autogenerate manifest for target. Embed into executable.
# Autogenerated manifest will be deleted after embeding.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :autogen => :to_default_file,
  :mt => {} )

# Autogenerate manifest for target. Embed into executable.
# Autogenerated manifest will be kept after embeding.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :autogen => :to_default_file,
  :mt => { :keep_manifest_file => true } )

# Autogenerate manifest for target. Embed into executable as
# resource with id CREATEPROCESS_MANIFEST_RESOURCE_ID id.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :autogen => :to_default_file,
  :mt => { :resource_id => :process_manifest } )

# Autogenerate manifest for target. Store manifest into
# file 'hello_world.exe.manifest'. Embed info executable.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :autogen => 'hello_world.exe.manifest',
  :mt => {} )

# Embed manifest from file 'hello_world.exe.manifest' into
# target executable.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :mt => { :manifest => 'hello_world.exe.manifest' } )
# Embed manifest from file 'hello_world.dll.manifest' into
# target executable as resource with
# ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID id.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :target => self,
  :mt => { :manifest => 'hello_world.exe.manifest',
    :resource_id => :isolationaware_nonstaticimport } )

# Autogenerate manifest for all targets in build. Store manifest
# in default files. Do not embed manifest into executable.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :autogen => :to_default_file )

# Autogenerate manifest for all targets in build. Store manifest
# in default files. Embed manifest into executable.
MxxRu::Cpp::Toolsets::Vc8::manifest(
  :autogen => :to_default_file,
  :mt => {} )

# Drop default manifest for build. Only explicitly specified
# manifest will be generated.
MxxRu::Cpp::Toolsets::Vc8::manifest( nil )
# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 250
def self.manifest( params )
  if nil == params
    # No default manifest.
    @@default_manifest = nil
  else
    check_manifest_params( params )

    d = OpenStruct.new( :keep_manifest_file => true )
    
    if params.key?( :autogen )
      d.autogen = true
      d.manifest_file = ( params[ :autogen ] == :to_default_file ?
        :default : params[ :autogen ] )
      d.keep_manifest_file = false
    else
      d.autogen = false
    end

    if params.key?( :mt ) && nil != params[ :mt ]
      d.mt = true
      mt_params = params[ :mt ]
      d.manifest_file = mt_params[ :manifest ] if
        mt_params.key?( :manifest )
      d.resource_id = ( mt_params.key?( :resource_id ) ?
        mt_params[ :resource_id ] : :default )

      if mt_params.key?( :keep_manifest_file ) and
        params.key?( :autogen )
        d.keep_manifest_file = mt_params[ :keep_manifest_file ]
      end
    else
      d.mt = false
    end

    if params.key?( :target )
      # Source manifest must be set for specified target.
      params[ :target ].vc8_source_manifest = d
    else
      # This is new default manifest.
      @@default_manifest = d
    end
  end
end
new( a_name = "vc" ) click to toggle source
Calls superclass method MxxRu::Cpp::Toolsets::VcFamily::new
# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 121
def initialize( a_name = "vc" )
  super( a_name )
end

Protected Class Methods

check_manifest_params( params ) click to toggle source

Checking manifest params validity.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 401
def self.check_manifest_params( params )
  if nil != params
    if params.key?( :mt )
      mt_hash = params[ :mt ]

      # :resource_id must have one of avaliable values.
      if mt_hash.key?( :resource_id ) and
          !@@resource_id_names.member?( mt_hash[ :resource_id ] )
        raise InvalidValueEx.new(
          "invalid value for :resource_id key: " +
            "'#{mt_hash[:resource_id]}'" ) 
      end

      if !mt_hash.key?( :manifest ) and
        !params.key?( :autogen )

        raise InvalidValueEx.new(
          "no manifest file name specified" )
      end

      # :keep_manifest_file should be Bool.
      if mt_hash.key?( :keep_manifest_file ) and
        true != mt_hash[ :keep_manifest_file ] and
        false != mt_hash[ :keep_manifest_file ]
        raise InvalidValueEx.new(
          "value for :keep_manifest_file should be 'true' " +
          "or 'false'" )
      end
    end

    if params.key?( :autogen )
      v = params[ :autogen ]
      if !( v == :to_default_file or
        v.kind_of?( String ) )
        raise InvalidValueEx.new(
          "invalid value for :autogen (must be " +
          ":to_default_file or String instance)" )
      end
    end
  end
end

Public Instance Methods

clean_dll_specific_files( dll_file, dll_info, target ) click to toggle source

Remove autogenerated manifest file if any.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 147
def clean_dll_specific_files( dll_file, dll_info, target )
  super( dll_file, dll_info, target )
  clean_autogenerated_manifest( target )
end
clean_exe_specific_files( exe_file, exe_info, target ) click to toggle source

Remove autogenerated manifest file if any.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 153
def clean_exe_specific_files( exe_file, exe_info, target )
  super( exe_file, exe_info, target )
  clean_autogenerated_manifest( target )
end
make_dll_command_lines( dll_name, dll_info, linker_lists, target ) click to toggle source

Append command line for embeding manifest file to result of super class implementation.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 160
def make_dll_command_lines(
    dll_name,
    dll_info,
    linker_lists,
    target )

  append_mt_command_lines(
    super( dll_name, dll_info, linker_lists, target ),
    dll_name,
    target )
end
make_exe_command_lines( exe_name, exe_info, linker_lists, target ) click to toggle source

Append command line for embeding manifest file to result of super class implementation.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 174
def make_exe_command_lines(
    exe_name,
    exe_info,
    linker_lists,
    target )
  append_mt_command_lines(
    super( exe_name, exe_info, linker_lists, target ),
    exe_name,
    target )
end
setup_mandatory_options( target ) click to toggle source

Check some VC8.0 constraints before calling superclass implementation

VC8.0 does not support Single-Thread Run-Time.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 129
def setup_mandatory_options( target )
  if THREADING_SINGLE == target.mxx_threading_mode
    raise MxxRu::UnsupportedModeEx.new(
      "Visual C++ 2005 and above doesn't support " +
      "single-threaded static RTL" )
  elsif THREADING_DEFAULT == target.mxx_threading_mode
    # Because VC8.0 doesn't support Single Thread Run-Time then
    # by default we must use Mutli-Threading Run-Time.
    target.threading_mode( THREADING_MULTI )
  end

  super( target )

  setup_manifest( target )
  setup_manifest_params( target )
end

Protected Instance Methods

append_mt_command_lines( cmd_lines, target_name, target ) click to toggle source

Append command line for embeding manifest file to end of specified command line list.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 374
def append_mt_command_lines(
    cmd_lines,
    target_name,
    target )

  m = target.vc8_actual_manifest
  if nil != m and m.mt?
    cmd_lines << "#{mt_name} /nologo " +
      "/outputresource:\"#{target_name};\#" +
          "#{m.digital_resource_id}\" " +
      "/manifest \"#{m.manifest_file}\""

    if !m.keep_manifest_file?
      # del utility doesn't work with unix slashes
      cmd_lines << "del \"#{MxxRu::Util::native_pathname(m.manifest_file)}\""
    end
  end

  cmd_lines
end
clean_autogenerated_manifest( target ) click to toggle source

Remove autogenerated manifest file if any.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 366
def clean_autogenerated_manifest( target )
  m = target.vc8_actual_manifest
  MxxRu::Util::delete_file( m.manifest_file ) if
    m != nil and m.autogen?
end
mt_name() click to toggle source

Name of manifest tool executable

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 396
def mt_name
  tag( MT_NAME_TAG, "mt" )
end
setup_manifest( target ) click to toggle source

Set actual manifest for target if source manifest defined (or default manifest exists).

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 302
def setup_manifest( target )
  # Manifest can be set only for EXE or DLL.
  if ExeTargetType::TYPE == target.target_type.name or
    DllTargetType::TYPE == target.target_type.name
    desc = target.vc8_source_manifest

    if nil != desc
      # Actual manifest must be created for target.
      manifest_file =
        if :default == desc.manifest_file
          # We must create name for manifest.
          if ExeTargetType::TYPE == target.target_type.name
            full_exe_name( target )
          else
            full_dll_name( target )
          end + ".manifest"
        else
          # Manifest filename already specified.
          desc.manifest_file
        end

      # If mt.exe will be used then we must determine
      # digital resource_id for manifest resource.
      digital_resource_id =
        if desc.mt
          case desc.resource_id
            when :default
              # Resource ID must be caclulated based on
              # target type.
              ExeTargetType::TYPE == target.target_type.name ? 1 : 2
            when :process_manifest
              1
            when :isolationaware_manifest
              2
            else
              # :isolationaware_nostaticimport_manifest
              3
          end
        else
          nil
        end

      target.vc8_actual_manifest = ActualManifest.new(
          desc,
          manifest_file,
          digital_resource_id )
    end
  end
end
setup_manifest_params( target ) click to toggle source

Setup linker params for processing target manifest.

# File lib/mxx_ru/cpp/toolsets/vc8_family.rb, line 353
def setup_manifest_params( target )
  m = target.vc8_actual_manifest
  if nil != m and m.autogen?
    # Linker must generate manifest.
    target.linker_option( '/MANIFEST' )
    target.linker_option( '/MANIFESTFILE:' + m.manifest_file )
  else
    # Linker should not generate manifest.
    target.linker_option( '/MANIFEST:NO' )
  end
end