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.
- data/NEWS +38 -0
- data/Rakefile +29 -2
- data/examples/exe_dll_lib_2/build.rb +4 -1
- data/examples/exe_dll_lib_2/inout/prj.rb +1 -1
- data/examples/exe_dll_lib_2/main/prj.rb +1 -1
- data/examples/exe_dll_lib_2/say/prj.rb +1 -1
- data/lib/mxx_ru/abstract_target.rb +71 -49
- data/lib/mxx_ru/binary_library.rb +106 -0
- data/lib/mxx_ru/binary_target.rb +91 -7
- data/lib/mxx_ru/binary_unittest.rb +30 -17
- data/lib/mxx_ru/compat.rb +33 -0
- data/lib/mxx_ru/cpp/analyzer.rb +16 -9
- data/lib/mxx_ru/cpp/composite.rb +24 -13
- data/lib/mxx_ru/cpp/detect_toolset.rb +7 -7
- data/lib/mxx_ru/cpp/mode.rb +11 -6
- data/lib/mxx_ru/cpp/obj_placement.rb +42 -33
- data/lib/mxx_ru/cpp/obj_placements/custom_subdir.rb +155 -0
- data/lib/mxx_ru/cpp/qt.rb +97 -68
- data/lib/mxx_ru/cpp/rucodegen.rb +56 -19
- data/lib/mxx_ru/cpp/source_file.rb +14 -6
- data/lib/mxx_ru/cpp/target.rb +341 -226
- data/lib/mxx_ru/cpp/toolset.rb +188 -145
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_5.rb +5 -4
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +42 -35
- data/lib/mxx_ru/cpp/toolsets/c89_etk_nsk.rb +8 -5
- data/lib/mxx_ru/cpp/toolsets/c89_nsk.rb +8 -5
- data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +24 -20
- data/lib/mxx_ru/cpp/toolsets/gcc_cygwin.rb +9 -5
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +61 -38
- data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +10 -6
- data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +17 -15
- data/lib/mxx_ru/cpp/toolsets/gcc_sparc_solaris.rb +11 -7
- data/lib/mxx_ru/cpp/toolsets/gcc_unix_family.rb +84 -0
- data/lib/mxx_ru/cpp/toolsets/vc7.rb +4 -4
- data/lib/mxx_ru/cpp/toolsets/vc8.rb +33 -30
- data/lib/mxx_ru/cpp/toolsets/vc_family.rb +70 -50
- data/lib/mxx_ru/cpp.rb +3 -1
- data/lib/mxx_ru/ex.rb +44 -13
- data/lib/mxx_ru/makestyle_generator.rb +17 -12
- data/lib/mxx_ru/textfile_unittest.rb +46 -27
- data/lib/mxx_ru/util.rb +51 -26
- data/tests/cpp/cpp_sources_glob/tc_cpp_sources_glob.rb +18 -0
- data/tests/cpp/mswin_res_dll/tc_mswin_res_dll.rb +18 -0
- data/tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb +18 -0
- data/tests/cpp/rucodegen/prj.rb +1 -2
- data/tests/cpp/rucodegen/tc_rucodegen.rb +18 -0
- data/tests/cpp/rucodegen.embedded/host_config.cpp +32 -0
- data/tests/cpp/rucodegen.embedded/impl/conn_params.cpp +7 -0
- data/tests/cpp/rucodegen.embedded/impl/conn_params.rb +14 -0
- data/tests/cpp/rucodegen.embedded/impl/h/conn_params.hpp +10 -0
- data/tests/cpp/rucodegen.embedded/prj.rb +16 -0
- data/tests/cpp/rucodegen.embedded/tc_rucodegen.rb +18 -0
- data/tests/cpp/textfile_unittest/tc_textfile_unittest.rb +18 -0
- data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +7 -44
- data/tests/mxx_ru/binary_library/tc_binary_library.rb +57 -0
- data/tests/mxx_ru/binary_library/tc_binary_target_lib_methods.rb +114 -0
- data/tests/mxx_ru/lib_path/build.rb +8 -0
- data/tests/mxx_ru/lib_path/bye.c +3 -0
- data/tests/mxx_ru/lib_path/bye.rb +8 -0
- data/tests/mxx_ru/lib_path/hi.c +3 -0
- data/tests/mxx_ru/lib_path/hi.rb +8 -0
- data/tests/mxx_ru/lib_path/main.c +9 -0
- data/tests/mxx_ru/lib_path/main.rb +12 -0
- data/tests/mxx_ru/lib_path/tc_lib_path.rb +18 -0
- data/tests/mxx_ru/obj_placements/tc_custom_subdir.rb +58 -0
- data/tests/mxx_ru/opt_lib_ext/build.rb +7 -0
- data/tests/mxx_ru/opt_lib_ext/hi.c +3 -0
- data/tests/mxx_ru/opt_lib_ext/hi.h +1 -0
- data/tests/mxx_ru/opt_lib_ext/hi.rb +7 -0
- data/tests/mxx_ru/opt_lib_ext/main.c +7 -0
- data/tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb +18 -0
- data/tests/mxx_ru/opt_lib_ext/test-no-ext.rb +9 -0
- data/tests/mxx_ru/opt_lib_ext/test-with-ext.rb +13 -0
- data/tests/mxx_ru/qt_gen/tc_uic_result_subdir.rb +76 -0
- data/tests/mxx_ru/target_ext/dll_hi.cpp +1 -0
- data/tests/mxx_ru/target_ext/exe_hi.cpp +4 -0
- data/tests/mxx_ru/target_ext/lib_hi.cpp +1 -0
- data/tests/mxx_ru/target_ext/prj_dll.rb +8 -0
- data/tests/mxx_ru/target_ext/prj_exe.rb +8 -0
- data/tests/mxx_ru/target_ext/prj_lib.rb +8 -0
- data/tests/mxx_ru/target_ext/tc_target_ext.rb +24 -0
- data/tests/qt/toplevel/prj.rb +1 -0
- data/tests/test_with_compilation.rb +110 -0
- data/tests/unix/lib_linking_mode/a.hpp +12 -0
- data/tests/unix/lib_linking_mode/a_shared.cpp +8 -0
- data/tests/unix/lib_linking_mode/a_shared.rb +7 -0
- data/tests/unix/lib_linking_mode/a_static.cpp +7 -0
- data/tests/unix/lib_linking_mode/a_static.rb +7 -0
- data/tests/unix/lib_linking_mode/etalon/shared.txt +2 -0
- data/tests/unix/lib_linking_mode/etalon/static.txt +2 -0
- data/tests/unix/lib_linking_mode/main.impl.cpp +7 -0
- data/tests/unix/lib_linking_mode/main_conflict.cpp +2 -0
- data/tests/unix/lib_linking_mode/main_conflict.rb +12 -0
- data/tests/unix/lib_linking_mode/main_conflict_2.rb +11 -0
- data/tests/unix/lib_linking_mode/main_shared.cpp +2 -0
- data/tests/unix/lib_linking_mode/main_shared.rb +9 -0
- data/tests/unix/lib_linking_mode/main_shared.ut.rb +11 -0
- data/tests/unix/lib_linking_mode/main_shared_2.cpp +2 -0
- data/tests/unix/lib_linking_mode/main_shared_2.rb +10 -0
- data/tests/unix/lib_linking_mode/main_shared_2.ut.rb +11 -0
- data/tests/unix/lib_linking_mode/main_static.cpp +2 -0
- data/tests/unix/lib_linking_mode/main_static.rb +9 -0
- data/tests/unix/lib_linking_mode/main_static.ut.rb +11 -0
- data/tests/unix/lib_linking_mode/main_static_2.cpp +2 -0
- data/tests/unix/lib_linking_mode/main_static_2.rb +10 -0
- data/tests/unix/lib_linking_mode/main_static_2.ut.rb +11 -0
- data/tests/unix/lib_linking_mode/tc_conflicted_build.rb +18 -0
- data/tests/unix/lib_linking_mode/tc_normal_build.rb +18 -0
- metadata +90 -11
- data/tests/cpp/vc_cleanup/cout.log +0 -72
- 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
|
-
|
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 =
|
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
|
-
|
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
|
}
|
@@ -30,13 +30,13 @@ require 'mxx_ru/ex'
|
|
30
30
|
|
31
31
|
require 'mxx_ru/util'
|
32
32
|
|
33
|
-
module
|
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
|
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
|
-
#
|
54
|
+
# TargetState object returned.
|
55
55
|
#
|
56
56
|
# [_name_] Target name.
|
57
57
|
# [_depends_] Dependencies list. Array of String.
|
58
|
-
def
|
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 !
|
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
|
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
|
83
|
+
return TargetState.new( state )
|
84
84
|
end
|
85
85
|
|
86
|
-
end # Class
|
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
|
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
|
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
|
113
|
-
# then we will load root project file and start build process
|
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
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
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
|
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
|
146
|
+
raise TargetUnknownEx.new( prj_alias )
|
141
147
|
end
|
142
148
|
|
143
149
|
return target
|
144
150
|
end
|
145
151
|
|
146
|
-
def
|
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
|
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
|
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
|
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
|
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
|
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
|
-
|
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 !
|
235
|
+
if !MxxRu::target_defined_for?( a_prj )
|
227
236
|
require a_prj
|
228
237
|
end
|
229
238
|
|
230
|
-
target =
|
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
|
-
#
|
260
|
+
# TargetState object is returned.
|
252
261
|
def build
|
253
|
-
raise
|
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
|
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
|
265
|
-
#
|
266
|
-
#
|
267
|
-
|
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
|
-
|
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
|
289
|
+
if MxxRu::Util::Mode.instance.is_show_cmd
|
275
290
|
|
276
291
|
# Do not actually execute in dry-run mode.
|
277
|
-
if !
|
292
|
+
if !MxxRu::Util::Mode.instance.is_dry_run
|
278
293
|
if !system( c )
|
279
294
|
a_to_destroy_on_fail.each { |d|
|
280
|
-
|
281
|
-
raise
|
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
|
304
|
+
# Returns MxxRu::TargetState.
|
290
305
|
def build_required_projects
|
291
|
-
state =
|
306
|
+
state = MxxRu::TargetState::EXISTS
|
292
307
|
@mxx_required_prjs.each { |p|
|
293
|
-
prj_state =
|
294
|
-
if
|
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
|
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 !
|
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
|
-
|
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
|
data/lib/mxx_ru/binary_target.rb
CHANGED
@@ -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
|
33
|
-
# binary static libraries.
|
34
|
-
|
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
|
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
|
-
#
|
71
|
-
|
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
|