class MxxRu::Cpp::RuntimeSubdirObjPlacement

The generator of folder name for compilation results, building a hierarchy of subfolders in a special folder, which name is choosen based on runtime mode.

For example, let src/lib/l.cpp and src/main/m.cpp files would be the sources of lib/l.lib library and m.exe application. If project is compiled in RELEASE mode, then following files would be created: release/src/lib/l.obj, release/src/main/m.obj, release/lib/l.lib and release/m.exe. Thus the presence of subfolders required will be supervised (for example, release/src/lib, release/src/main,…). If some subfolder doesn't exist, it will be created.

An example of usage:

class  Build < MxxRu::Cpp::Composite_target
  def initialize( a_alias = MxxRu::BUILD_ROOT )
    global_obj_placement(
      MxxRu::Cpp::RuntimeSubdirObjPlacement.new(
        "output" ) )

    required_prj( "src/lib/prj.rb" )
    required_prj( "src/main/prj.rb" )
  end
end

Attributes

debug_subdir[R]

A name of subfolder, which will ve created in a root_dir for MxxRu::Cpp::RUNTIME_DEBUG mode.

default_subdir[R]

A name of subfolder, which will ve created in a root_dir for MxxRu::Cpp::RUNTIME_DEFAULT mode.

release_subdir[R]

A name of subfolder, which will ve created in a root_dir for MxxRu::Cpp::RUNTIME_RELEASE mode.

root_dir[R]

Folder name, where subfolders for exact runtime-modes will be created.

Public Class Methods

new( a_root_dir = nil, a_debug_subdir = "debug", a_default_subdir = "default", a_release_subdir = "release" ) click to toggle source

a_root_dir A folder, where subfolders for exact runtime-modes will be created. If contains nil, subfolders are created in current folder.

a_debug_subdir

Subfolder name for MxxRu::Cpp::RUNTIME_DEBUG mode.

a_default_subdir

Subfolder name for MxxRu::Cpp::RUNTIME_DEFAULT mode.

a_release_subdir

Subfolder name for MxxRu::Cpp::RUNTIME_RELEASE mode.

# File lib/mxx_ru/cpp/obj_placement.rb, line 227
def initialize(
  a_root_dir = nil,
  a_debug_subdir = "debug",
  a_default_subdir = "default",
  a_release_subdir = "release" )

  if a_root_dir
    @root_dir = a_root_dir
  else
    @root_dir = "./"
  end

  @debug_subdir = a_debug_subdir
  @default_subdir = a_default_subdir
  @release_subdir = a_release_subdir
end

Public Instance Methods

get_dll( source_path_name, toolset, target ) click to toggle source

Returns result of get_obj method.

# File lib/mxx_ru/cpp/obj_placement.rb, line 283
def get_dll(
  source_path_name,
  toolset,
  target )

  return get_obj( source_path_name, toolset, target )
end
get_exe( source_path_name, toolset, target ) click to toggle source

Returns result of get_obj method.

# File lib/mxx_ru/cpp/obj_placement.rb, line 292
def get_exe(
  source_path_name,
  toolset,
  target )

  return get_obj( source_path_name, toolset, target )
end
get_lib( source_path_name, toolset, target ) click to toggle source

Returns result of get_obj method.

# File lib/mxx_ru/cpp/obj_placement.rb, line 274
def get_lib(
  source_path_name,
  toolset,
  target )

  return get_obj( source_path_name, toolset, target )
end
get_mswin_res( source_path_name, toolset, target ) click to toggle source

Returns result of get_obj method.

# File lib/mxx_ru/cpp/obj_placement.rb, line 265
def get_mswin_res(
  source_path_name,
  toolset,
  target )

  return get_obj( source_path_name, toolset, target )
end
get_obj( source_path_name, toolset, target ) click to toggle source

It's the only method running something.

# File lib/mxx_ru/cpp/obj_placement.rb, line 245
def get_obj(
  source_path_name,
  toolset,
  target )

  if source_path_name &&
    "" != source_path_name &&
    "." != source_path_name
    result = File.join( @root_dir, runtime_mode_path( target ),
      source_path_name )
  else
    result = File.join( @root_dir, runtime_mode_path( target ) )
  end

  MxxRu::Util.ensure_path_exists( result )

  return result
end

Protected Instance Methods

runtime_mode_path( a_target ) click to toggle source

Returns folder name, which is used for target's runtime mode.

a_target

Target, actions are performed for.

# File lib/mxx_ru/cpp/obj_placement.rb, line 304
def runtime_mode_path( a_target )
  case a_target.mxx_runtime_mode
    when MxxRu::Cpp::RUNTIME_DEBUG
      return @debug_subdir

    when MxxRu::Cpp::RUNTIME_RELEASE
      return @release_subdir

    else
      return @default_subdir
  end
end