class MxxRu::Cpp::PrjAwareRuntimeSubdirObjPlacement
Since v.1.6.12
This class is similar to RuntimeSubdirObjPlacement
and ToolsetRuntimeSubdirObjPlacement
but stores intermediate files (like object files, compiled resources and so on) in special subfolders.
These subfoldes use special naming in forms:
<final_path>/_objs/<runtime>/<prj_alias>/<subdir> <final_path>/_objs/<toolset>/<runtime>/<prj_alias>/<subdir>
where subdir is created from a path to source file. A path is transformed (all separators like / or :) is changed to _. It means that so_5/rt/impl will be transformed to so_5_rt_impl. If the result is too long it is transformed another time: part of result name will be changed to SHA1 digest. For example a name so_5/disp/prio_one_thread/quoted_round_robin will be transformed to so_5_disp_prio_one_thread_quoted_round_robin and then to so_5__robin-8f160349ec35.
Usage example:
MxxRu::Cpp::composite_target { global_obj_placement MxxRu::Cpp::PrjAwareRuntimeSubdirObjPlacement.new( # Final resuls going here. 'bin32' ) required_prj 'so_5/prj.rb' required_prj 'so_5/prj_s.rb' ... }
The directory structure could looks like:
bin32/ `- _objs/ `- release/ `- so_5_prj_rb/ `- ... `- so_5_prj_s_rb/ `- ... `- release/
This ObjPlacement
also allows to use toolset id in directory structure:
MxxRu::Cpp::composite_target { global_obj_placement MxxRu::Cpp::PrjAwareRuntimeSubdirObjPlacement.new( # Final resuls going here. 'bin32', # Enable toolset identification MxxRu::Cpp::PrjAwareRuntimeSubdirObjPlacement::USE_COMPILER_ID ) required_prj 'so_5/prj.rb' required_prj 'so_5/prj_s.rb' ... }
The directory structure could looks like:
bin32/ `- _objs/ `- gcc_4_8_2__x86_64_w64_mingw32/ `- release/ `- so_5_prj_rb/ `- ... `- so_5_prj_s_rb/ `- ... `- gcc_4_8_2__x86_64_w64_mingw32/ `- release/
Constants
- DO_NOT_USE_COMPILER_ID
- USE_COMPILER_ID
Public Class Methods
Constructor
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 114 def initialize( final_results_path, use_compiler_id = DO_NOT_USE_COMPILER_ID ) @final_results_path = final_results_path @intermediate_path = File.join( @final_results_path, '_objs' ) @use_compiler_id = use_compiler_id end
Public Instance Methods
Returns final_results_path
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 152 def get_dll( source_path_name, toolset, target ) final_result_path_component( source_path_name, toolset, target ) end
Returns final_results_path
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 157 def get_exe( source_path_name, toolset, target ) final_result_path_component( source_path_name, toolset, target ) end
Returns final_results_path
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 147 def get_lib( source_path_name, toolset, target ) final_result_path_component( source_path_name, toolset, target ) end
Returns result of get_obj
method.
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 142 def get_mswin_res( source_path_name, toolset, target ) get_obj( source_path_name, toolset, target ) end
Make name for obj file.
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 121 def get_obj( source_path_name, toolset, target ) root_path = USE_COMPILER_ID == @use_compiler_id ? File.join( @intermediate_path, toolset.make_identification_string ) : @intermediate_path target_tmps = create_target_tmps_name( target ) result = if source_path_name && "" != source_path_name && "." != source_path_name File.join( root_path, runtime_mode_path( target ), target_tmps, transform_path( source_path_name ) ) else File.join( root_path, target_tmps, runtime_mode_path( target ) ) end MxxRu::Util.ensure_path_exists( result ) result end
Protected Instance Methods
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 207 def create_target_tmps_name( target ) transform_path( target.prj_alias ) end
Make final_results_path if needed and return name of it
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 163 def final_result_path_component( target_root, toolset, target ) root_path = USE_COMPILER_ID == @use_compiler_id ? File.join( @final_results_path, toolset.make_identification_string ) : @final_results_path result = if target_root && "" != target_root && "." != target_root File.join( root_path, runtime_mode_path( target ), target_root ) else File.join( root_path, runtime_mode_path( target ) ) end MxxRu::Util.ensure_path_exists( result ) result end
Returns folder name, which is used for target's runtime mode.
- a_target
-
Target
, actions are performed for.
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 184 def runtime_mode_path( a_target ) case a_target.mxx_runtime_mode when MxxRu::Cpp::RUNTIME_DEBUG return 'debug' when MxxRu::Cpp::RUNTIME_RELEASE return 'release' else return 'default' end end
# File lib/mxx_ru/cpp/obj_placements/prj_aware_runtime_subdir.rb, line 197 def transform_path( path ) normalized_value = path.gsub( /[\\\/\.:]/, '_' ) if 24 < normalized_value.size r = normalized_value[ 0..3 ] + '__' + normalized_value[ -5..-1 ] + '-' + Digest::SHA1.new.update(normalized_value).hexdigest[ 0..11 ] normalized_value = r end normalized_value end