Mxx_ru 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/NEWS +38 -0
  2. data/Rakefile +29 -2
  3. data/examples/exe_dll_lib_2/build.rb +4 -1
  4. data/examples/exe_dll_lib_2/inout/prj.rb +1 -1
  5. data/examples/exe_dll_lib_2/main/prj.rb +1 -1
  6. data/examples/exe_dll_lib_2/say/prj.rb +1 -1
  7. data/lib/mxx_ru/abstract_target.rb +71 -49
  8. data/lib/mxx_ru/binary_library.rb +106 -0
  9. data/lib/mxx_ru/binary_target.rb +91 -7
  10. data/lib/mxx_ru/binary_unittest.rb +30 -17
  11. data/lib/mxx_ru/compat.rb +33 -0
  12. data/lib/mxx_ru/cpp/analyzer.rb +16 -9
  13. data/lib/mxx_ru/cpp/composite.rb +24 -13
  14. data/lib/mxx_ru/cpp/detect_toolset.rb +7 -7
  15. data/lib/mxx_ru/cpp/mode.rb +11 -6
  16. data/lib/mxx_ru/cpp/obj_placement.rb +42 -33
  17. data/lib/mxx_ru/cpp/obj_placements/custom_subdir.rb +155 -0
  18. data/lib/mxx_ru/cpp/qt.rb +97 -68
  19. data/lib/mxx_ru/cpp/rucodegen.rb +56 -19
  20. data/lib/mxx_ru/cpp/source_file.rb +14 -6
  21. data/lib/mxx_ru/cpp/target.rb +341 -226
  22. data/lib/mxx_ru/cpp/toolset.rb +188 -145
  23. data/lib/mxx_ru/cpp/toolsets/bcc_win32_5.rb +5 -4
  24. data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +42 -35
  25. data/lib/mxx_ru/cpp/toolsets/c89_etk_nsk.rb +8 -5
  26. data/lib/mxx_ru/cpp/toolsets/c89_nsk.rb +8 -5
  27. data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +24 -20
  28. data/lib/mxx_ru/cpp/toolsets/gcc_cygwin.rb +9 -5
  29. data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +61 -38
  30. data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +10 -6
  31. data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +17 -15
  32. data/lib/mxx_ru/cpp/toolsets/gcc_sparc_solaris.rb +11 -7
  33. data/lib/mxx_ru/cpp/toolsets/gcc_unix_family.rb +84 -0
  34. data/lib/mxx_ru/cpp/toolsets/vc7.rb +4 -4
  35. data/lib/mxx_ru/cpp/toolsets/vc8.rb +33 -30
  36. data/lib/mxx_ru/cpp/toolsets/vc_family.rb +70 -50
  37. data/lib/mxx_ru/cpp.rb +3 -1
  38. data/lib/mxx_ru/ex.rb +44 -13
  39. data/lib/mxx_ru/makestyle_generator.rb +17 -12
  40. data/lib/mxx_ru/textfile_unittest.rb +46 -27
  41. data/lib/mxx_ru/util.rb +51 -26
  42. data/tests/cpp/cpp_sources_glob/tc_cpp_sources_glob.rb +18 -0
  43. data/tests/cpp/mswin_res_dll/tc_mswin_res_dll.rb +18 -0
  44. data/tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb +18 -0
  45. data/tests/cpp/rucodegen/prj.rb +1 -2
  46. data/tests/cpp/rucodegen/tc_rucodegen.rb +18 -0
  47. data/tests/cpp/rucodegen.embedded/host_config.cpp +32 -0
  48. data/tests/cpp/rucodegen.embedded/impl/conn_params.cpp +7 -0
  49. data/tests/cpp/rucodegen.embedded/impl/conn_params.rb +14 -0
  50. data/tests/cpp/rucodegen.embedded/impl/h/conn_params.hpp +10 -0
  51. data/tests/cpp/rucodegen.embedded/prj.rb +16 -0
  52. data/tests/cpp/rucodegen.embedded/tc_rucodegen.rb +18 -0
  53. data/tests/cpp/textfile_unittest/tc_textfile_unittest.rb +18 -0
  54. data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +7 -44
  55. data/tests/mxx_ru/binary_library/tc_binary_library.rb +57 -0
  56. data/tests/mxx_ru/binary_library/tc_binary_target_lib_methods.rb +114 -0
  57. data/tests/mxx_ru/lib_path/build.rb +8 -0
  58. data/tests/mxx_ru/lib_path/bye.c +3 -0
  59. data/tests/mxx_ru/lib_path/bye.rb +8 -0
  60. data/tests/mxx_ru/lib_path/hi.c +3 -0
  61. data/tests/mxx_ru/lib_path/hi.rb +8 -0
  62. data/tests/mxx_ru/lib_path/main.c +9 -0
  63. data/tests/mxx_ru/lib_path/main.rb +12 -0
  64. data/tests/mxx_ru/lib_path/tc_lib_path.rb +18 -0
  65. data/tests/mxx_ru/obj_placements/tc_custom_subdir.rb +58 -0
  66. data/tests/mxx_ru/opt_lib_ext/build.rb +7 -0
  67. data/tests/mxx_ru/opt_lib_ext/hi.c +3 -0
  68. data/tests/mxx_ru/opt_lib_ext/hi.h +1 -0
  69. data/tests/mxx_ru/opt_lib_ext/hi.rb +7 -0
  70. data/tests/mxx_ru/opt_lib_ext/main.c +7 -0
  71. data/tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb +18 -0
  72. data/tests/mxx_ru/opt_lib_ext/test-no-ext.rb +9 -0
  73. data/tests/mxx_ru/opt_lib_ext/test-with-ext.rb +13 -0
  74. data/tests/mxx_ru/qt_gen/tc_uic_result_subdir.rb +76 -0
  75. data/tests/mxx_ru/target_ext/dll_hi.cpp +1 -0
  76. data/tests/mxx_ru/target_ext/exe_hi.cpp +4 -0
  77. data/tests/mxx_ru/target_ext/lib_hi.cpp +1 -0
  78. data/tests/mxx_ru/target_ext/prj_dll.rb +8 -0
  79. data/tests/mxx_ru/target_ext/prj_exe.rb +8 -0
  80. data/tests/mxx_ru/target_ext/prj_lib.rb +8 -0
  81. data/tests/mxx_ru/target_ext/tc_target_ext.rb +24 -0
  82. data/tests/qt/toplevel/prj.rb +1 -0
  83. data/tests/test_with_compilation.rb +110 -0
  84. data/tests/unix/lib_linking_mode/a.hpp +12 -0
  85. data/tests/unix/lib_linking_mode/a_shared.cpp +8 -0
  86. data/tests/unix/lib_linking_mode/a_shared.rb +7 -0
  87. data/tests/unix/lib_linking_mode/a_static.cpp +7 -0
  88. data/tests/unix/lib_linking_mode/a_static.rb +7 -0
  89. data/tests/unix/lib_linking_mode/etalon/shared.txt +2 -0
  90. data/tests/unix/lib_linking_mode/etalon/static.txt +2 -0
  91. data/tests/unix/lib_linking_mode/main.impl.cpp +7 -0
  92. data/tests/unix/lib_linking_mode/main_conflict.cpp +2 -0
  93. data/tests/unix/lib_linking_mode/main_conflict.rb +12 -0
  94. data/tests/unix/lib_linking_mode/main_conflict_2.rb +11 -0
  95. data/tests/unix/lib_linking_mode/main_shared.cpp +2 -0
  96. data/tests/unix/lib_linking_mode/main_shared.rb +9 -0
  97. data/tests/unix/lib_linking_mode/main_shared.ut.rb +11 -0
  98. data/tests/unix/lib_linking_mode/main_shared_2.cpp +2 -0
  99. data/tests/unix/lib_linking_mode/main_shared_2.rb +10 -0
  100. data/tests/unix/lib_linking_mode/main_shared_2.ut.rb +11 -0
  101. data/tests/unix/lib_linking_mode/main_static.cpp +2 -0
  102. data/tests/unix/lib_linking_mode/main_static.rb +9 -0
  103. data/tests/unix/lib_linking_mode/main_static.ut.rb +11 -0
  104. data/tests/unix/lib_linking_mode/main_static_2.cpp +2 -0
  105. data/tests/unix/lib_linking_mode/main_static_2.rb +10 -0
  106. data/tests/unix/lib_linking_mode/main_static_2.ut.rb +11 -0
  107. data/tests/unix/lib_linking_mode/tc_conflicted_build.rb +18 -0
  108. data/tests/unix/lib_linking_mode/tc_normal_build.rb +18 -0
  109. metadata +90 -11
  110. data/tests/cpp/vc_cleanup/cout.log +0 -72
  111. data/tests/qt/toplevel/options.ui.h +0 -98
data/NEWS CHANGED
@@ -1,5 +1,43 @@
1
1
  Changes in Mxx_ru
2
2
 
3
+ 1.3.0 version (2006.05.15)
4
+
5
+ New command line argument --mxx-rebuild.
6
+
7
+ Added support for RuCodeGen 0.2.0.
8
+
9
+ New methods Mxx_ru::BinaryTarget#lib_static, Mxx_ru::BinaryTarget#lib_shared.
10
+ For now, they only make sense for Unix and GCC toolsets.
11
+
12
+ New method QtGen#uic_result_subdir for specifying custom path to store
13
+ uic results.
14
+
15
+ Qt support improvement: Now, during a building of *.cpp file from *.ui,
16
+ short form of *.hpp file name is specified in '-i' argument in order to get
17
+ correct include definition.
18
+ (e.g. 'some_header.hpp' instead of 'src/module/some_header.hpp').
19
+
20
+ Task 'test' is added into Rakefile for unit test automation. Some tests
21
+ converted into unit-tests. Special mix-in TestWithCompilation (in
22
+ tests/test_with_compilation.rb) added for this purpose.
23
+
24
+ New Methods BinaryTarget#lib_path, BinaryTarget#lib_paths.
25
+
26
+ Improvement: under mswin no longer necessary to specify library name with
27
+ '.lib' extension. This extension automatically added by Visual C++ toolset
28
+ if needed.
29
+
30
+ Method Mxx_ru::Cpp::Target#target_ext and possibility for changing default
31
+ target extension added.
32
+
33
+ Added 'option extraction mode' for C/C++ targets (command-line argument
34
+ '--mxx-cpp-extract-options' and its processing in Mxx_ru::Cpp::Target).
35
+
36
+ New class for controlling ObjPlacement for C/C++ targets
37
+ Mxx_ru::Cpp::CustomSubdirObjPlacement added.
38
+
39
+ Refactoring: names of all classes converted into standard Ruby convention.
40
+
3
41
  1.2.0 version (2006.04.15)
4
42
 
5
43
  Added command-line arguments --mxx-brief-show, --mxx-brief-hide and
data/Rakefile CHANGED
@@ -2,13 +2,14 @@ require 'rubygems'
2
2
  Gem::manage_gems
3
3
 
4
4
  require 'rake/gempackagetask'
5
+ require 'rake/testtask'
5
6
 
6
7
  PKG_NAME =
7
- PKG_VERSION = '1.2.1'
8
+ RKG_VERSION = '1.3.0'
8
9
 
9
10
  spec = Gem::Specification.new do |s|
10
11
  s.name = "Mxx_ru"
11
- s.version = PKG_VERSION
12
+ s.version = "1.3.0"
12
13
  s.author = "The Mxx_ru Project"
13
14
  s.email = "eao197@yahoo.com"
14
15
  s.homepage = "http://www.rubyforge.com/projects/mxx-ru"
@@ -29,4 +30,30 @@ gem = Rake::GemPackageTask.new( spec ) do |pkg|
29
30
  pkg.need_tar = true
30
31
  end
31
32
 
33
+ test = Rake::TestTask.new do |t|
34
+ test_files = FileList[ 'tests/**/{tc,ts}*.rb' ]
35
+
36
+ # Visual C++ 8.0 specific files must be excluded when working with
37
+ # another compiler.
38
+ test_files = test_files.delete_if { |n| /\/vc8/ =~ n } unless
39
+ /(mxx_ru\/cpp\/toolsets\/){0,1}vc8/ =~ ENV[ 'MXX_RU_CPP_TOOLSET' ]
40
+
41
+ # Visual C++ specific files must be excluded when working with
42
+ # another compiler.
43
+ test_files = test_files.delete_if { |n| /\/vc/ =~ n } unless
44
+ /(mxx_ru\/cpp\/toolsets\/){0,1}vc\d/ =~ ENV[ 'MXX_RU_CPP_TOOLSET' ]
45
+
46
+ # MSWin specific files must be excluded if not Windows platform.
47
+ test_files = test_files.delete_if { |n| /mswin/ =~ n } unless
48
+ /^mswin/ =~ Config::CONFIG[ 'host_os' ]
49
+
50
+ # Unix specific files must be excluded on Windows platform.
51
+ test_files = test_files.delete_if { |n| /unix/ =~ n } if
52
+ /^mswin/ =~ Config::CONFIG[ 'host_os' ]
53
+
54
+ t.test_files = test_files
55
+ t.verbose = true
56
+ end
57
+
32
58
  task :default => [ gem.package_dir + "/" + gem.name + "-" + gem.version.version + ".gem" ]
59
+
@@ -1,7 +1,10 @@
1
1
  require 'mxx_ru/cpp'
2
2
 
3
- Mxx_ru::Cpp::composite_target( Mxx_ru::BUILD_ROOT ) {
3
+ MxxRu::Cpp::composite_target( Mxx_ru::BUILD_ROOT ) {
4
4
  required_prj( "main/prj.rb" )
5
5
 
6
6
  global_include_path( "." )
7
+
8
+ global_obj_placement(
9
+ Mxx_ru::Cpp::CustomSubdirObjPlacement.new( 'bin', 'tmp/output' ) )
7
10
  }
@@ -1,6 +1,6 @@
1
1
  require 'mxx_ru/cpp'
2
2
 
3
- Mxx_ru::Cpp::dll_target( "inout/prj.rb" ) {
3
+ MxxRu::Cpp::dll_target {
4
4
  target( "inout" )
5
5
  implib_path( "lib" )
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'mxx_ru/cpp'
2
2
 
3
- Mxx_ru::Cpp::exe_target( "main/prj.rb" ) {
3
+ MxxRu::Cpp::exe_target {
4
4
  target( "exe_dll_lib" )
5
5
 
6
6
  required_prj( "inout/prj.rb" )
@@ -1,6 +1,6 @@
1
1
  require 'mxx_ru/cpp'
2
2
 
3
- Mxx_ru::Cpp::lib_target( "say/prj.rb" ) {
3
+ Mxx_ru::Cpp::lib_target {
4
4
  target_root( "lib" )
5
5
  target( "say" )
6
6
 
@@ -30,13 +30,13 @@ require 'mxx_ru/ex'
30
30
 
31
31
  require 'mxx_ru/util'
32
32
 
33
- module Mxx_ru
33
+ module MxxRu
34
34
 
35
35
  # File name of root project file.
36
36
  BUILD_ROOT = "build.rb"
37
37
 
38
38
  # Target status description.
39
- class Target_state
39
+ class TargetState
40
40
  # Target is absent or rebuild is required.
41
41
  ABSENT = 0
42
42
  # Target was rebuilt.
@@ -51,22 +51,22 @@ module Mxx_ru
51
51
  end
52
52
 
53
53
  # Detect target status.
54
- # Target_state object returned.
54
+ # TargetState object returned.
55
55
  #
56
56
  # [_name_] Target name.
57
57
  # [_depends_] Dependencies list. Array of String.
58
- def Target_state.detect( name, depends )
58
+ def TargetState.detect( name, depends )
59
59
 
60
60
  state = ABSENT
61
61
 
62
62
  # In dry-run mode we always return that target is absent.
63
- if !Mxx_ru::Util::Mode.instance.is_dry_run
63
+ if !MxxRu::Util::Mode.instance.is_dry_run
64
64
  if FileTest.exists?( name )
65
65
  # It's necessary to detect time of target and it's dependencies.
66
66
  target_mtime = File.mtime( name )
67
67
  if nil != depends.find { |d|
68
68
  if !FileTest.exists?( d )
69
- raise Mxx_ru::Missing_depend_file_ex.new( d, name )
69
+ raise MxxRu::MissingDependFileEx.new( d, name )
70
70
  end
71
71
  depend_mtime = File.mtime( d )
72
72
  target_mtime < depend_mtime
@@ -80,10 +80,13 @@ module Mxx_ru
80
80
  end
81
81
  end
82
82
 
83
- return Target_state.new( state )
83
+ return TargetState.new( state )
84
84
  end
85
85
 
86
- end # Class Target_state
86
+ end # Class TargetState
87
+
88
+ # For compatibility with previous versions.
89
+ Target_state = TargetState
87
90
 
88
91
  # Map of targets loaded.
89
92
  # Key is target alias -- file name with definition of a target.
@@ -93,13 +96,13 @@ module Mxx_ru
93
96
  # This target will be used in setup_target function to start building process.
94
97
  @@first_target_alias = nil
95
98
 
96
- def Mxx_ru.try_set_first_target_alias( a_alias )
99
+ def MxxRu.try_set_first_target_alias( a_alias )
97
100
  if nil == @@first_target_alias
98
101
  @@first_target_alias = a_alias.clone
99
102
  end
100
103
  end
101
104
 
102
- def Mxx_ru.setup_target( target, build_enabled = true )
105
+ def MxxRu.setup_target( target, build_enabled = true )
103
106
  begin
104
107
  if !( target_defined_for?( target.prj_alias ) )
105
108
  @@defined_targets[ target.prj_alias ] = target;
@@ -109,65 +112,71 @@ module Mxx_ru
109
112
  @@first_target_alias == target.prj_alias
110
113
  # It is a root project, required to build.
111
114
 
112
- # If this project is not root project file and root project file exists,
113
- # then we will load root project file and start build process after that.
115
+ # If this project is not root project file and root project file
116
+ # exists, then we will load root project file and start build process
117
+ # after that.
114
118
  if BUILD_ROOT != target.prj_alias
115
119
  if FileTest.exists?( BUILD_ROOT )
116
120
  require BUILD_ROOT
117
121
  end
118
122
  end
119
123
 
120
- if Mxx_ru::Util::Mode.instance.is_clean
121
- target.clean
122
- else
123
- Mxx_ru::Util::build_call_wrapper( target )
124
- end
124
+ target.clean if MxxRu::Util::Mode.instance.is_clean or
125
+ MxxRu::Util::Mode.instance.is_rebuild
126
+
127
+ target.reset if MxxRu::Util::Mode.instance.is_rebuild
128
+
129
+ MxxRu::Util::build_call_wrapper( target ) if
130
+ !MxxRu::Util::Mode.instance.is_clean
125
131
  end
126
132
 
127
133
  return target
128
- rescue Mxx_ru::Ex => ex
134
+ rescue MxxRu::Ex => ex
129
135
  $stderr.print "<<<[#{ex.class.name}]\t#{ex}>>>\n"
130
136
  exit( -2 )
131
137
  end
132
138
  end
133
139
 
134
- def Mxx_ru.query_target( prj_alias, mandatory )
140
+ def MxxRu.query_target( prj_alias, mandatory )
135
141
  target = @@defined_targets[ prj_alias ]
136
142
 
137
143
  # If target was required, we already should found it.
138
144
  # Build should be stopper otherwise.
139
145
  if target.nil? && mandatory
140
- raise Target_unknown_ex.new( prj_alias )
146
+ raise TargetUnknownEx.new( prj_alias )
141
147
  end
142
148
 
143
149
  return target
144
150
  end
145
151
 
146
- def Mxx_ru.target_defined_for?(prj_alias)
152
+ def MxxRu.target_defined_for?(prj_alias)
147
153
  return true if @@defined_targets.has_key?( prj_alias )
148
154
  return false
149
155
  end
150
156
 
151
157
  # Base class for all source code generators.
152
- class Abstract_generator
158
+ class AbstractGenerator
153
159
  # This method is called to generate source code required.
154
160
  # Should be redefined in a child class.
155
161
  #
156
162
  # [_target_] Target, generator belongs to.
157
163
  def build( target )
158
- raise Abstract_method_ex.new( "Mxx_ru::Abstract_generator::build" )
164
+ raise AbstractMethodEx.new( "MxxRu::AbstractGenerator::build" )
159
165
  end
160
166
 
161
167
  # This method is called to cleanup of generated source code files.
162
168
  #
163
169
  # [_target_] Target, generator belongs to.
164
170
  def clean( target )
165
- raise Abstract_method_ex.new( "Mxx_ru::Abstract_generator::clean" )
171
+ raise AbstractMethodEx.new( "MxxRu::AbstractGenerator::clean" )
166
172
  end
167
173
  end
168
174
 
175
+ # For compatibility with previous versions.
176
+ Abstract_generator = AbstractGenerator
177
+
169
178
  # Base class for all targets.
170
- class Abstract_target
179
+ class AbstractTarget
171
180
  # List of full file names, created during a build of the target.
172
181
  # It may be an empty array if target doesn't create any files.
173
182
  # For example, if target is a composite or unittest.
@@ -190,7 +199,7 @@ module Mxx_ru
190
199
  # required_prjs( items )
191
200
  # cpp_sources( items )
192
201
  #
193
- def Abstract_target.define_plural_form_method( singular_method )
202
+ def AbstractTarget.define_plural_form_method( singular_method )
194
203
  class_eval %Q{
195
204
  def #{singular_method}s(a)
196
205
  a.each { |e| #{singular_method}( e ) }
@@ -204,7 +213,7 @@ module Mxx_ru
204
213
  @mxx_required_prjs = Array.new
205
214
  @mxx_generators = Array.new
206
215
 
207
- Mxx_ru.try_set_first_target_alias( a_prj_alias )
216
+ MxxRu.try_set_first_target_alias( a_prj_alias )
208
217
  end
209
218
 
210
219
  # Add one more file, created during a target build.
@@ -223,11 +232,11 @@ module Mxx_ru
223
232
  # If project is not loaded yet, loding it.
224
233
  # Then adding created target object to the list ofd subordinated projects.
225
234
  # If no target will be created, exception would be thrown.
226
- if !Mxx_ru::target_defined_for?( a_prj )
235
+ if !MxxRu::target_defined_for?( a_prj )
227
236
  require a_prj
228
237
  end
229
238
 
230
- target = Mxx_ru::query_target( a_prj, true )
239
+ target = MxxRu::query_target( a_prj, true )
231
240
  @mxx_required_prjs << target
232
241
 
233
242
  return target
@@ -248,37 +257,43 @@ module Mxx_ru
248
257
  end
249
258
 
250
259
  # Child classes should redefine this method.
251
- # Target_state object is returned.
260
+ # TargetState object is returned.
252
261
  def build
253
- raise Abstract_method_ex.new( "Abstract_target::build" )
262
+ raise AbstractMethodEx.new( "AbstractTarget::build" )
254
263
  end
255
264
 
256
265
  # Child classes should redefine this method.
257
266
  def clean
258
- raise Abstract_method_ex.new( "Abstract_target::clean" )
267
+ raise AbstractMethodEx.new( "AbstractTarget::clean" )
268
+ end
269
+
270
+ # Child classes should redefine this method.
271
+ # Base class does not implement it.
272
+ def reset
259
273
  end
260
274
 
261
275
  # Executing command line given.
262
276
  #
263
277
  # [a_cmd_lines] Array of String
264
- # [a_to_destroy_on_fail] Files required to be cleaned up if any of given command fail.
265
- # [brief_desc] Brief description of command (will be shown if --mxx-brief-desc
266
- # specified in command line)
267
- def Abstract_target.run( a_cmd_lines, a_to_destroy_on_fail, brief_desc = nil )
278
+ # [a_to_destroy_on_fail] Files required to be cleaned up if any of given
279
+ # command fail.
280
+ # [brief_desc] Brief description of command (will be shown if
281
+ # --mxx-brief-show specified in command line)
282
+ def AbstractTarget.run(
283
+ a_cmd_lines, a_to_destroy_on_fail, brief_desc = nil )
268
284
 
269
- puts "#{brief_desc.capitalize} ..." \
270
- if Mxx_ru::Util::Mode.instance.is_brief_desc and nil != brief_desc
285
+ MxxRu.show_brief( brief_desc )
271
286
 
272
287
  a_cmd_lines.each { |c|
273
288
  puts "<<< #{c} >>>" \
274
- if Mxx_ru::Util::Mode.instance.is_show_cmd
289
+ if MxxRu::Util::Mode.instance.is_show_cmd
275
290
 
276
291
  # Do not actually execute in dry-run mode.
277
- if !Mxx_ru::Util::Mode.instance.is_dry_run
292
+ if !MxxRu::Util::Mode.instance.is_dry_run
278
293
  if !system( c )
279
294
  a_to_destroy_on_fail.each { |d|
280
- Mxx_ru::Util::delete_file( d ) }
281
- raise Build_ex.new( c, $? )
295
+ MxxRu::Util::delete_file( d ) }
296
+ raise BuildEx.new( c, $? )
282
297
  end
283
298
  end
284
299
  }
@@ -286,28 +301,35 @@ module Mxx_ru
286
301
 
287
302
  protected
288
303
  # Build of all projects required for the target.
289
- # Returns Mxx_ru::Target_state.
304
+ # Returns MxxRu::TargetState.
290
305
  def build_required_projects
291
- state = Mxx_ru::Target_state::EXISTS
306
+ state = MxxRu::TargetState::EXISTS
292
307
  @mxx_required_prjs.each { |p|
293
- prj_state = Mxx_ru::Util::build_call_wrapper( p )
294
- if Mxx_ru::Target_state::EXISTS != prj_state.state
308
+ prj_state = MxxRu::Util::build_call_wrapper( p )
309
+ if MxxRu::TargetState::EXISTS != prj_state.state
295
310
  state = prj_state.state
296
311
  end
297
312
  }
298
313
 
299
- return Mxx_ru::Target_state.new( state )
314
+ return MxxRu::TargetState.new( state )
300
315
  end
301
316
 
302
317
  # Cleanup of all projects required for the target.
303
318
  # Executed only if dry-run mode is disabled.
304
319
  def clean_required_prjs
305
- if !Mxx_ru::Util::Mode.instance.is_dry_run
320
+ if !MxxRu::Util::Mode.instance.is_dry_run
306
321
  @mxx_required_prjs.each { |p| p.clean }
307
322
  end
308
323
  end
309
324
 
325
+ # Reset build status for all projects required for the target.
326
+ def reset_required_projects
327
+ @mxx_required_prjs.each { |p| p.reset }
328
+ end
329
+
310
330
  end
311
331
 
312
- end
332
+ # For compatibility with previous versions.
333
+ Abstract_target = AbstractTarget
313
334
 
335
+ end
@@ -0,0 +1,106 @@
1
+ #--
2
+ # Copyright (c) 1996-2004, Yauheni Akhotnikau
3
+ # Copyright (c) 2004-2006, JSC Intervale
4
+ # Copyright (c) 2006, The Mxx_ru Project
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without modification,
8
+ # are permitted provided that the following conditions are met:
9
+ #
10
+ # 1. Redistributions of source code must retain the above copyright notice,
11
+ # this list of conditions and the following disclaimer.
12
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ # this list of conditions and the following disclaimer in the documentation
14
+ # and/or other materials provided with the distribution.
15
+ # 3. The name of the author may not be used to endorse or promote products derived
16
+ # from this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
19
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
+ # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
21
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ #++
28
+
29
+ require 'mxx_ru/ex'
30
+
31
+ module MxxRu
32
+
33
+ # Class for description of binary library required to be linked
34
+ # with binary target.
35
+ #
36
+ # Since 1.3.0
37
+ #
38
+ # On Unix platform static and shared library can be specified to linker with
39
+ # same name. For example to link libA.a or libA.so user must specify '-lA'
40
+ # option. Linker selects appropriate library (static or shared version) by
41
+ # it own rules (on most Linux platform ld first looks for shared version, than
42
+ # for static version; this approach can be overriden by '-static' option for
43
+ # gcc or '-Bstatic' for ld).
44
+ #
45
+ # In some cases user may wants to explicitly specify kind of library. For
46
+ # example, if ld by default searches shared libraries than user can specify
47
+ # sequence '-Bstatic -lA -Bdynamic' for ld (or '-Wl,-Bstatic,-lA,-Bdynamic'
48
+ # for gcc). This forces linker for looking only static version of library.
49
+ #
50
+ # In version 1.3.0 Mxx_ru support for explicit static/shared library selection
51
+ # was added. To implement this support required library description was
52
+ # changed. Instead of storing names of required libraries as String they are
53
+ # stored as BinaryLibrary objects.
54
+ class BinaryLibrary
55
+ # Identifier for static library type.
56
+ STATIC = :static
57
+ # Identifier for shared library type.
58
+ SHARED = :shared
59
+ # Identifier for library which type if unknown yet (not explicitly specified).
60
+ ANY = :any
61
+
62
+ # Name of library.
63
+ attr_reader :name
64
+ # Type of library (STATIC/SHARED/ANY).
65
+ attr_reader :type
66
+
67
+ def initialize( name, type )
68
+ raise InvalidValueEx.new( "Unknown BinaryLibrary type: #{type}" ) unless
69
+ [ STATIC, SHARED, ANY ].member?( type )
70
+
71
+ @name = name
72
+ @type = type
73
+ end
74
+
75
+ def to_s
76
+ @name
77
+ end
78
+
79
+ def eql?( another )
80
+ @name.eql?( another.name ) and @type.eql?( another.type )
81
+ end
82
+
83
+ def ==( another )
84
+ self.eql?( another )
85
+ end
86
+
87
+ def <=>( another )
88
+ r = @name <=> another.name
89
+ r = @type <=> another.type if 0 == r
90
+ r
91
+ end
92
+
93
+ end # class BinaryLibrary
94
+
95
+ # Exception for the case where conflict of BinaryLibrary usage detected.
96
+ #
97
+ # Conflict detected if STATIC and SHARED library with same name specified
98
+ # for one target.
99
+ class BinaryLibraryTypeConflictEx < Ex
100
+ def initialize( target_name, library_name )
101
+ super( "Binary library conflict with library '#{library_name}' for " +
102
+ "target '#{target_name}'" )
103
+ end
104
+ end
105
+
106
+ end # module MxxRu
@@ -27,13 +27,17 @@
27
27
  #++
28
28
 
29
29
  require 'mxx_ru/abstract_target'
30
+ require 'mxx_ru/binary_library'
30
31
  require 'mxx_ru/ex'
31
32
 
32
- # Base class for all targets, which are binary executables, binary shared libraries or
33
- # binary static libraries.
34
- module Mxx_ru
33
+ # Base class for all targets, which are binary executables, binary shared
34
+ # libraries or binary static libraries.
35
+ #
36
+ # In version v.1.3 extended by methods lib_path, lib_paths which are
37
+ # user-frendly synonyms for mxx_add_required_lib_path.
38
+ module MxxRu
35
39
 
36
- class Binary_target < Mxx_ru::Abstract_target
40
+ class BinaryTarget < MxxRu::AbstractTarget
37
41
  def initialize( a_prj_alias )
38
42
  super( a_prj_alias )
39
43
 
@@ -43,19 +47,59 @@ module Mxx_ru
43
47
  # dublicates should be removed.
44
48
  @mxx_required_libs_changed = true
45
49
  # Folder list, where libraries, encountered in mxx_required_libs,
46
- # should be searched for
50
+ # should be searched for. Also contain paths specified by
51
+ # lib_path, lib_paths methods.
47
52
  @mxx_required_lib_paths = Array.new
48
53
  # Attribute showing that before return from mxx_required_lib_paths
49
54
  # dublicates should be removed.
50
55
  @mxx_required_lib_paths_changed = true
51
56
  end
52
57
 
58
+ # Add the library required.
59
+ #
60
+ # Type of library must be detect implicitly.
61
+ #
62
+ # If a_path is other then nil, then it's value is added to the list
63
+ # of a folders, the libraries should be searched in.
64
+ def lib( a_library, a_path = nil )
65
+ mxx_add_required_lib(
66
+ BinaryLibrary.new( a_library, BinaryLibrary::ANY ) )
67
+ if a_path
68
+ mxx_add_required_lib_path( a_path )
69
+ end
70
+ end
71
+
72
+ # Add static library required.
73
+ #
74
+ # If a_path is other then nil, then it's value is added to the list
75
+ # of a folders, the libraries should be searched in.
76
+ def lib_static( a_library, a_path = nil )
77
+ mxx_add_required_lib(
78
+ BinaryLibrary.new( a_library, BinaryLibrary::STATIC ) )
79
+ if a_path
80
+ mxx_add_required_lib_path( a_path )
81
+ end
82
+ end
83
+
84
+ # Add shared library required.
85
+ #
86
+ # If a_path is other then nil, then it's value is added to the list
87
+ # of a folders, the libraries should be searched in.
88
+ def lib_shared( a_library, a_path = nil )
89
+ mxx_add_required_lib(
90
+ BinaryLibrary.new( a_library, BinaryLibrary::SHARED ) )
91
+ if a_path
92
+ mxx_add_required_lib_path( a_path )
93
+ end
94
+ end
95
+
53
96
  # Get all libraries list, which are required to be linked to for
54
97
  # correct usage of given target.
55
98
  # Returns array of strings.
56
99
  def mxx_required_libs
57
100
  if @mxx_required_libs_changed
58
101
  @mxx_required_libs.flatten!
102
+ BinaryTarget.check_libraries_types( prj_alias, @mxx_required_libs )
59
103
  @mxx_required_libs_changed = false
60
104
  end
61
105
  return @mxx_required_libs
@@ -63,12 +107,18 @@ module Mxx_ru
63
107
 
64
108
  # Add library to list of requirements.
65
109
  def mxx_add_required_lib( a_lib )
110
+ a_lib = BinaryLibrary.new( a_lib, BinaryLibrary::ANY ) if
111
+ a_lib.kind_of?( String )
112
+
66
113
  @mxx_required_libs << a_lib
67
114
  @mxx_required_libs_changed = true
68
115
  end
69
116
 
70
- # Get list of all paths to libraries, which should be used to search libraries,
71
- # returned by mxx_required_libs method.
117
+ # Plural form of mxx_add_required_lib.
118
+ define_plural_form_method :mxx_add_required_lib
119
+
120
+ # Get list of all paths to libraries, which should be used to search
121
+ # libraries, returned by mxx_required_libs method.
72
122
  # Returns array of strings.
73
123
  def mxx_required_lib_paths
74
124
  if @mxx_required_lib_paths_changed
@@ -84,6 +134,40 @@ module Mxx_ru
84
134
  @mxx_required_lib_paths_changed = true
85
135
  end
86
136
 
137
+ # Plural form of mxx_add_required_lib_path.
138
+ define_plural_form_method :mxx_add_required_lib_path
139
+
140
+ alias_method :lib_path, :mxx_add_required_lib_path
141
+
142
+ # Plural form of lib_path.
143
+ define_plural_form_method :lib_path
144
+
145
+ # Checks types of libraries. Should not exists two instance of
146
+ # same library with STATIC and SHARED types at one time.
147
+ #
148
+ # Raises BinaryLibraryTypeConflictEx if conflict detected.
149
+ def BinaryTarget.check_libraries_types( prj_alias, libs )
150
+ if libs.size
151
+ names_and_types = Hash.new( BinaryLibrary::ANY )
152
+ libs.each { |l|
153
+ k = names_and_types[ l.name ]
154
+ if BinaryLibrary::ANY != l.type
155
+
156
+ if BinaryLibrary::ANY != k
157
+ raise BinaryLibraryTypeConflictEx.new( prj_alias, l.name ) if
158
+ k != l.type
159
+ else
160
+ names_and_types[ l.name ] = l.type
161
+ end
162
+
163
+ end
164
+ }
165
+ end
166
+ end
167
+
87
168
  end
88
169
 
170
+ # For compatilibily with previous versions.
171
+ Binary_target = BinaryTarget
172
+
89
173
  end