Mxx_ru 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +26 -0
- data/NEWS +52 -0
- data/README +21 -0
- data/Rakefile +32 -0
- data/examples/exe_and_lib/main.cpp +15 -0
- data/examples/exe_and_lib/prj.rb +11 -0
- data/examples/exe_and_lib/say.cpp +13 -0
- data/examples/exe_and_lib/say.hpp +11 -0
- data/examples/exe_and_lib/say.rb +7 -0
- data/examples/exe_dll_lib/inout.cpp +15 -0
- data/examples/exe_dll_lib/inout.hpp +26 -0
- data/examples/exe_dll_lib/inout.rb +18 -0
- data/examples/exe_dll_lib/main.cpp +23 -0
- data/examples/exe_dll_lib/prj.rb +11 -0
- data/examples/exe_dll_lib/say.cpp +13 -0
- data/examples/exe_dll_lib/say.hpp +12 -0
- data/examples/exe_dll_lib/say.rb +9 -0
- data/examples/exe_dll_lib_2/build.rb +7 -0
- data/examples/exe_dll_lib_2/inout/inout.cpp +15 -0
- data/examples/exe_dll_lib_2/inout/inout.hpp +26 -0
- data/examples/exe_dll_lib_2/inout/prj.rb +16 -0
- data/examples/exe_dll_lib_2/main/main.cpp +23 -0
- data/examples/exe_dll_lib_2/main/prj.rb +9 -0
- data/examples/exe_dll_lib_2/say/prj.rb +8 -0
- data/examples/exe_dll_lib_2/say/say.cpp +13 -0
- data/examples/exe_dll_lib_2/say/say.hpp +12 -0
- data/examples/simple_exe/main.cpp +26 -0
- data/examples/simple_exe/prj.rb +7 -0
- data/lib/mxx_ru/abstract_target.rb +283 -0
- data/lib/mxx_ru/binary_target.rb +89 -0
- data/lib/mxx_ru/binary_unittest.rb +130 -0
- data/lib/mxx_ru/cpp/analyzer.rb +230 -0
- data/lib/mxx_ru/cpp/composite.rb +106 -0
- data/lib/mxx_ru/cpp/detect_toolset.rb +122 -0
- data/lib/mxx_ru/cpp/mode.rb +85 -0
- data/lib/mxx_ru/cpp/obj_placement.rb +321 -0
- data/lib/mxx_ru/cpp/qt.rb +333 -0
- data/lib/mxx_ru/cpp/rucodegen.rb +114 -0
- data/lib/mxx_ru/cpp/source_file.rb +71 -0
- data/lib/mxx_ru/cpp/target.rb +1371 -0
- data/lib/mxx_ru/cpp/toolset.rb +1029 -0
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_5.rb +52 -0
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +451 -0
- data/lib/mxx_ru/cpp/toolsets/c89_etk_nsk.rb +56 -0
- data/lib/mxx_ru/cpp/toolsets/c89_nsk.rb +56 -0
- data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +273 -0
- data/lib/mxx_ru/cpp/toolsets/gcc_cygwin.rb +54 -0
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +382 -0
- data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +60 -0
- data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +144 -0
- data/lib/mxx_ru/cpp/toolsets/gcc_sparc_solaris.rb +87 -0
- data/lib/mxx_ru/cpp/toolsets/vc7.rb +62 -0
- data/lib/mxx_ru/cpp/toolsets/vc8.rb +452 -0
- data/lib/mxx_ru/cpp/toolsets/vc_family.rb +428 -0
- data/lib/mxx_ru/cpp.rb +36 -0
- data/lib/mxx_ru/ex.rb +134 -0
- data/lib/mxx_ru/makestyle_generator.rb +138 -0
- data/lib/mxx_ru/textfile_unittest.rb +284 -0
- data/lib/mxx_ru/util.rb +258 -0
- data/tests/c/pcre/chartables.c +183 -0
- data/tests/c/pcre/config.h +99 -0
- data/tests/c/pcre/dftables.c +167 -0
- data/tests/c/pcre/get.c +349 -0
- data/tests/c/pcre/internal.h +677 -0
- data/tests/c/pcre/maketables.c +140 -0
- data/tests/c/pcre/pcre.c +8304 -0
- data/tests/c/pcre/pcre.h +193 -0
- data/tests/c/pcre/pcre.rb +14 -0
- data/tests/c/pcre/pcredemo.c +316 -0
- data/tests/c/pcre/pcregrep.c +642 -0
- data/tests/c/pcre/pcreposix.c +305 -0
- data/tests/c/pcre/pcreposix.h +88 -0
- data/tests/c/pcre/pcretest.c +1483 -0
- data/tests/c/pcre/perltest +211 -0
- data/tests/c/pcre/printint.c +360 -0
- data/tests/c/pcre/study.c +472 -0
- data/tests/cpp/mswin_res_dll/build.rb +14 -0
- data/tests/cpp/mswin_res_dll/dll.cpp +17 -0
- data/tests/cpp/mswin_res_dll/dll.rb +30 -0
- data/tests/cpp/mswin_res_dll/dll.rc +48 -0
- data/tests/cpp/mswin_res_dll/h/dll.hpp +8 -0
- data/tests/cpp/mswin_res_dll/h/res.h +3 -0
- data/tests/cpp/mswin_res_dll/main.cpp +13 -0
- data/tests/cpp/mswin_res_dll/main.rb +20 -0
- data/tests/cpp/mswin_res_dll/res/tree_fol.bmp +0 -0
- data/tests/cpp/mswin_res_dll/res/tree_state_1.bmp +0 -0
- data/tests/cpp/mswin_res_dll/res/tree_state_2.bmp +0 -0
- data/tests/cpp/mswin_res_exe/build.rb +23 -0
- data/tests/cpp/mswin_res_exe/h/res.h +3 -0
- data/tests/cpp/mswin_res_exe/main.cpp +17 -0
- data/tests/cpp/mswin_res_exe/main.rc +48 -0
- data/tests/cpp/mswin_res_exe/res/tree_fol.bmp +0 -0
- data/tests/cpp/mswin_res_exe/res/tree_state_1.bmp +0 -0
- data/tests/cpp/mswin_res_exe/res/tree_state_2.bmp +0 -0
- data/tests/cpp/rucodegen/host_config.cpp +20 -0
- data/tests/cpp/rucodegen/host_config.rb +14 -0
- data/tests/cpp/rucodegen/impl/conn_params.cpp +7 -0
- data/tests/cpp/rucodegen/impl/conn_params.rb +14 -0
- data/tests/cpp/rucodegen/impl/h/conn_params.hpp +10 -0
- data/tests/cpp/rucodegen/prj.rb +17 -0
- data/tests/cpp/textfile_unittest/build.rb +8 -0
- data/tests/cpp/textfile_unittest/etalons/out_0.txt +0 -0
- data/tests/cpp/textfile_unittest/etalons/out_1.txt +1 -0
- data/tests/cpp/textfile_unittest/etalons/out_128.txt +128 -0
- data/tests/cpp/textfile_unittest/main.cpp +89 -0
- data/tests/cpp/textfile_unittest/prj.rb +8 -0
- data/tests/cpp/textfile_unittest/prj.ut.rb +18 -0
- data/tests/cpp/toolset_name.rb +6 -0
- data/tests/cpp/vc_cleanup/cout.log +72 -0
- data/tests/cpp/vc_cleanup/dll_hi.cpp +5 -0
- data/tests/cpp/vc_cleanup/exe_hi.cpp +10 -0
- data/tests/cpp/vc_cleanup/lib_hi.cpp +5 -0
- data/tests/cpp/vc_cleanup/prj_dll_no_implib.rb +10 -0
- data/tests/cpp/vc_cleanup/prj_dll_no_implib_simple_target_root.rb +11 -0
- data/tests/cpp/vc_cleanup/prj_dll_with_implib.rb +11 -0
- data/tests/cpp/vc_cleanup/prj_dll_with_implib_simple_target_root.rb +14 -0
- data/tests/cpp/vc_cleanup/prj_exe_no_implib.rb +10 -0
- data/tests/cpp/vc_cleanup/prj_exe_no_implib_simple_target_root.rb +11 -0
- data/tests/cpp/vc_cleanup/prj_lib.rb +10 -0
- data/tests/cpp/vc_cleanup/prj_lib_with_simple_target_root.rb +11 -0
- data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +60 -0
- data/tests/mxx_ru/change_default_value/ignoring_by_build_root/build.rb +8 -0
- data/tests/mxx_ru/change_default_value/ignoring_by_build_root/child_1.rb +5 -0
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/build.rb +7 -0
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_1.rb +5 -0
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_2.rb +5 -0
- data/tests/mxx_ru/change_default_value/ok/build.rb +8 -0
- data/tests/mxx_ru/change_default_value/ok/child_1.rb +8 -0
- data/tests/mxx_ru/tc_makestyle_generator.rb +117 -0
- data/tests/mxx_ru/vc8/tc_actual_manifest.rb +230 -0
- data/tests/mxx_ru/vc8/tc_append_mt_commands.rb +104 -0
- data/tests/mxx_ru/vc8/tc_default_manifest.rb +17 -0
- data/tests/mxx_ru/vc8/tc_define_manifest.rb +173 -0
- data/tests/mxx_ru/vc8/tc_drop_default_manifest.rb +16 -0
- data/tests/mxx_ru/vc8/tc_invalid_params.rb +81 -0
- data/tests/mxx_ru/vc8/ts_vc8.rb +10 -0
- data/tests/qt/aclock/aclock.cpp +148 -0
- data/tests/qt/aclock/aclock.h +45 -0
- data/tests/qt/aclock/main.cpp +28 -0
- data/tests/qt/aclock/prj.rb +21 -0
- data/tests/qt/iconview/main.cpp +76 -0
- data/tests/qt/iconview/prj.rb +21 -0
- data/tests/qt/toplevel/main.cpp +9 -0
- data/tests/qt/toplevel/options.ui +587 -0
- data/tests/qt/toplevel/options.ui.h +98 -0
- data/tests/qt/toplevel/prj.rb +21 -0
- metadata +241 -0
@@ -0,0 +1,283 @@
|
|
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
|
+
require 'mxx_ru/util'
|
32
|
+
|
33
|
+
module Mxx_ru
|
34
|
+
|
35
|
+
# File name of root project file.
|
36
|
+
BUILD_ROOT = "build.rb"
|
37
|
+
|
38
|
+
# Target status description.
|
39
|
+
class Target_state
|
40
|
+
# Target is absent or rebuild is required.
|
41
|
+
ABSENT = 0
|
42
|
+
# Target was rebuilt.
|
43
|
+
REBUILT = 1
|
44
|
+
# Target exists and up-to-date.
|
45
|
+
EXISTS = 2
|
46
|
+
|
47
|
+
attr_reader :state
|
48
|
+
|
49
|
+
def initialize( a_state = ABSENT )
|
50
|
+
@state = a_state
|
51
|
+
end
|
52
|
+
|
53
|
+
# Detect target status.
|
54
|
+
# Target_state object returned.
|
55
|
+
#
|
56
|
+
# [_name_] Target name.
|
57
|
+
# [_depends_] Dependencies list. Array of String.
|
58
|
+
def Target_state.detect( name, depends )
|
59
|
+
|
60
|
+
state = ABSENT
|
61
|
+
|
62
|
+
# In dry-run mode we always return that target is absent.
|
63
|
+
if !Mxx_ru::Util::Mode.instance.is_dry_run
|
64
|
+
if FileTest.exists?( name )
|
65
|
+
# It's necessary to detect time of target and it's dependencies.
|
66
|
+
target_mtime = File.mtime( name )
|
67
|
+
if nil != depends.find { |d|
|
68
|
+
if !FileTest.exists?( d )
|
69
|
+
raise Mxx_ru::Missing_depend_file_ex.new( d, name )
|
70
|
+
end
|
71
|
+
depend_mtime = File.mtime( d )
|
72
|
+
target_mtime < depend_mtime
|
73
|
+
}
|
74
|
+
# More young dependency found.
|
75
|
+
state = REBUILT
|
76
|
+
else
|
77
|
+
# Target is up-to-date.
|
78
|
+
state = EXISTS
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
return Target_state.new( state )
|
84
|
+
end
|
85
|
+
|
86
|
+
end # Class Target_state
|
87
|
+
|
88
|
+
# Map of targets loaded.
|
89
|
+
# Key is target alias -- file name with definition of a target.
|
90
|
+
@@defined_targets = Hash.new
|
91
|
+
|
92
|
+
# Root target alias.
|
93
|
+
# This target will be used in setup_target function to start building process.
|
94
|
+
@@first_target_alias = nil
|
95
|
+
|
96
|
+
def Mxx_ru.try_set_first_target_alias( a_alias )
|
97
|
+
if nil == @@first_target_alias
|
98
|
+
@@first_target_alias = a_alias.clone
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def Mxx_ru.setup_target( target, build_enabled = true )
|
103
|
+
begin
|
104
|
+
if !( target_defined_for?( target.prj_alias ) )
|
105
|
+
@@defined_targets[ target.prj_alias ] = target;
|
106
|
+
end
|
107
|
+
|
108
|
+
if build_enabled && nil != @@first_target_alias &&
|
109
|
+
@@first_target_alias == target.prj_alias
|
110
|
+
# It is a root project, required to build.
|
111
|
+
|
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.
|
114
|
+
if BUILD_ROOT != target.prj_alias
|
115
|
+
if FileTest.exists?( BUILD_ROOT )
|
116
|
+
require BUILD_ROOT
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if Mxx_ru::Util::Mode.instance.is_clean
|
121
|
+
target.clean
|
122
|
+
else
|
123
|
+
Mxx_ru::Util::build_call_wrapper( target )
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
return target
|
128
|
+
rescue Mxx_ru::Ex => ex
|
129
|
+
$stderr.print "<<<[#{ex.class.name}]\t#{ex}>>>\n"
|
130
|
+
exit( -2 )
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def Mxx_ru.query_target( prj_alias, mandatory )
|
135
|
+
target = @@defined_targets[ prj_alias ]
|
136
|
+
|
137
|
+
# If target was required, we already should found it.
|
138
|
+
# Build should be stopper otherwise.
|
139
|
+
if target.nil? && mandatory
|
140
|
+
raise Target_unknown_ex.new( prj_alias )
|
141
|
+
end
|
142
|
+
|
143
|
+
return target
|
144
|
+
end
|
145
|
+
|
146
|
+
def Mxx_ru.target_defined_for?(prj_alias)
|
147
|
+
return true if @@defined_targets.has_key?( prj_alias )
|
148
|
+
return false
|
149
|
+
end
|
150
|
+
|
151
|
+
# Base class for all source code generators.
|
152
|
+
class Abstract_generator
|
153
|
+
# This method is called to generate source code required.
|
154
|
+
# Should be redefined in a child class.
|
155
|
+
#
|
156
|
+
# [_target_] Target, generator belongs to.
|
157
|
+
def build( target )
|
158
|
+
raise Abstract_method_ex.new( "Mxx_ru::Abstract_generator::build" )
|
159
|
+
end
|
160
|
+
|
161
|
+
# This method is called to cleanup of generated source code files.
|
162
|
+
#
|
163
|
+
# [_target_] Target, generator belongs to.
|
164
|
+
def clean( target )
|
165
|
+
raise Abstract_method_ex.new( "Mxx_ru::Abstract_generator::clean" )
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Base class for all targets.
|
170
|
+
class Abstract_target
|
171
|
+
# List of full file names, created during a build of the target.
|
172
|
+
# It may be an empty array if target doesn't create any files.
|
173
|
+
# For example, if target is a composite or unittest.
|
174
|
+
attr_reader :mxx_full_targets_names
|
175
|
+
|
176
|
+
# Vector of subordinated projects.
|
177
|
+
attr_reader :mxx_required_prjs
|
178
|
+
|
179
|
+
# Vector of source code generators.
|
180
|
+
attr_reader :mxx_generators
|
181
|
+
|
182
|
+
def initialize( a_prj_alias )
|
183
|
+
@mxx_full_targets_names = Array.new
|
184
|
+
@mxx_prj_alias = a_prj_alias
|
185
|
+
@mxx_required_prjs = Array.new
|
186
|
+
@mxx_generators = Array.new
|
187
|
+
|
188
|
+
Mxx_ru.try_set_first_target_alias( a_prj_alias )
|
189
|
+
end
|
190
|
+
|
191
|
+
# Add one more file, created during a target build.
|
192
|
+
def mxx_add_full_target_name( a_full_name )
|
193
|
+
@mxx_full_targets_names << a_full_name
|
194
|
+
end
|
195
|
+
|
196
|
+
def prj_alias
|
197
|
+
return @mxx_prj_alias
|
198
|
+
end
|
199
|
+
|
200
|
+
# Add one more project in a list of subordinated projects.
|
201
|
+
#
|
202
|
+
# Returns target object, which is defined in subordinated project.
|
203
|
+
def required_prj( a_prj )
|
204
|
+
# If project is not loaded yet, loding it.
|
205
|
+
# Then adding created target object to the list ofd subordinated projects.
|
206
|
+
# If no target will be created, exception would be thrown.
|
207
|
+
if !Mxx_ru::target_defined_for?( a_prj )
|
208
|
+
require a_prj
|
209
|
+
end
|
210
|
+
|
211
|
+
target = Mxx_ru::query_target( a_prj, true )
|
212
|
+
@mxx_required_prjs << target
|
213
|
+
|
214
|
+
return target
|
215
|
+
end
|
216
|
+
|
217
|
+
# Add one more generator to the target.
|
218
|
+
# Reference to the target is returned.
|
219
|
+
def generator( a_generator )
|
220
|
+
@mxx_generators << a_generator
|
221
|
+
return a_generator
|
222
|
+
end
|
223
|
+
|
224
|
+
# Child classes should redefine this method.
|
225
|
+
# Target_state object is returned.
|
226
|
+
def build
|
227
|
+
raise Abstract_method_ex.new( "Abstract_target::build" )
|
228
|
+
end
|
229
|
+
|
230
|
+
# Child classes should redefine this method.
|
231
|
+
def clean
|
232
|
+
raise Abstract_method_ex.new( "Abstract_target::clean" )
|
233
|
+
end
|
234
|
+
|
235
|
+
# Executing command line given.
|
236
|
+
#
|
237
|
+
# [a_cmd_lines] Array of String
|
238
|
+
# [a_to_destroy_on_fail] Files required to be cleaned up if any of given command fail.
|
239
|
+
def Abstract_target.run( a_cmd_lines, a_to_destroy_on_fail )
|
240
|
+
|
241
|
+
a_cmd_lines.each { |c|
|
242
|
+
if Mxx_ru::Util::Mode.instance.is_show_cmd
|
243
|
+
puts "<<< #{c} >>>"
|
244
|
+
end
|
245
|
+
|
246
|
+
# Do not actually execute in dry-run mode.
|
247
|
+
if !Mxx_ru::Util::Mode.instance.is_dry_run
|
248
|
+
if !system( c )
|
249
|
+
a_to_destroy_on_fail.each { |d|
|
250
|
+
Mxx_ru::Util::delete_file( d ) }
|
251
|
+
raise Build_ex.new( c, $? )
|
252
|
+
end
|
253
|
+
end
|
254
|
+
}
|
255
|
+
end
|
256
|
+
|
257
|
+
protected
|
258
|
+
# Build of all projects required for the target.
|
259
|
+
# Returns Mxx_ru::Target_state.
|
260
|
+
def build_required_projects
|
261
|
+
state = Mxx_ru::Target_state::EXISTS
|
262
|
+
@mxx_required_prjs.each { |p|
|
263
|
+
prj_state = Mxx_ru::Util::build_call_wrapper( p )
|
264
|
+
if Mxx_ru::Target_state::EXISTS != prj_state.state
|
265
|
+
state = prj_state.state
|
266
|
+
end
|
267
|
+
}
|
268
|
+
|
269
|
+
return Mxx_ru::Target_state.new( state )
|
270
|
+
end
|
271
|
+
|
272
|
+
# Cleanup of all projects required for the target.
|
273
|
+
# Executed only if dry-run mode is disabled.
|
274
|
+
def clean_required_prjs
|
275
|
+
if !Mxx_ru::Util::Mode.instance.is_dry_run
|
276
|
+
@mxx_required_prjs.each { |p| p.clean }
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
283
|
+
|
@@ -0,0 +1,89 @@
|
|
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/abstract_target'
|
30
|
+
require 'mxx_ru/ex'
|
31
|
+
|
32
|
+
# Base class for all targets, which are binary executables, binary shared libraries or
|
33
|
+
# binary static libraries.
|
34
|
+
module Mxx_ru
|
35
|
+
|
36
|
+
class Binary_target < Mxx_ru::Abstract_target
|
37
|
+
def initialize( a_prj_alias )
|
38
|
+
super( a_prj_alias )
|
39
|
+
|
40
|
+
# Libraries list, which would be required to the user of current target.
|
41
|
+
@mxx_required_libs = Array.new
|
42
|
+
# Attribute showing that before return from mxx_required_libs
|
43
|
+
# dublicates should be removed.
|
44
|
+
@mxx_required_libs_changed = true
|
45
|
+
# Folder list, where libraries, encountered in mxx_required_libs,
|
46
|
+
# should be searched for
|
47
|
+
@mxx_required_lib_paths = Array.new
|
48
|
+
# Attribute showing that before return from mxx_required_lib_paths
|
49
|
+
# dublicates should be removed.
|
50
|
+
@mxx_required_lib_paths_changed = true
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get all libraries list, which are required to be linked to for
|
54
|
+
# correct usage of given target.
|
55
|
+
# Returns array of strings.
|
56
|
+
def mxx_required_libs
|
57
|
+
if @mxx_required_libs_changed
|
58
|
+
@mxx_required_libs.flatten!
|
59
|
+
@mxx_required_libs_changed = false
|
60
|
+
end
|
61
|
+
return @mxx_required_libs
|
62
|
+
end
|
63
|
+
|
64
|
+
# Add library to list of requirements.
|
65
|
+
def mxx_add_required_lib( a_lib )
|
66
|
+
@mxx_required_libs << a_lib
|
67
|
+
@mxx_required_libs_changed = true
|
68
|
+
end
|
69
|
+
|
70
|
+
# Get list of all paths to libraries, which should be used to search libraries,
|
71
|
+
# returned by mxx_required_libs method.
|
72
|
+
# Returns array of strings.
|
73
|
+
def mxx_required_lib_paths
|
74
|
+
if @mxx_required_lib_paths_changed
|
75
|
+
@mxx_required_lib_paths.flatten!
|
76
|
+
@mxx_required_lib_paths_changed = false
|
77
|
+
end
|
78
|
+
return @mxx_required_lib_paths
|
79
|
+
end
|
80
|
+
|
81
|
+
# Add folder to search folders list.
|
82
|
+
def mxx_add_required_lib_path( a_path )
|
83
|
+
@mxx_required_lib_paths << a_path
|
84
|
+
@mxx_required_lib_paths_changed = true
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,130 @@
|
|
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
|
+
require 'mxx_ru/abstract_target'
|
31
|
+
|
32
|
+
module Mxx_ru
|
33
|
+
|
34
|
+
# Class describing a target, which is unit-test binary application.
|
35
|
+
#
|
36
|
+
# The idea is, that there is project file, which controls the build process
|
37
|
+
# of unit-test application. In that project file target object is created,
|
38
|
+
# inherited from Mxx_ru::Binary_target.
|
39
|
+
# To initialize unit-test it's required to create one more file, where
|
40
|
+
# target object of Mxx_ru::Binary_unittest_target class is created.
|
41
|
+
# For example:
|
42
|
+
#
|
43
|
+
# File to compile unit-test.
|
44
|
+
# Mxx_ru::setup_target(
|
45
|
+
# Mxx_ru::Cpp::Exe_target.new( "test/pack/prj.rb" ) {
|
46
|
+
# ...
|
47
|
+
# }
|
48
|
+
# )
|
49
|
+
#
|
50
|
+
# File to run unit-test.
|
51
|
+
# Mxx_ru::setup_target(
|
52
|
+
# Mxx_ru::Binary_unittest_target.new(
|
53
|
+
# "test/pack/ut.rb",
|
54
|
+
# "test/pack/prj.rb ) )
|
55
|
+
#
|
56
|
+
# File to use unit-test.
|
57
|
+
# Mxx_ru::setup_target(
|
58
|
+
# Mxx_ru::Cpp::Composite_target( Mxx_ru::BUILD_ROOT ) {
|
59
|
+
# required_prj( "some/project/prj.rb" )
|
60
|
+
# required_prj( "test/pack/ut.rb" )
|
61
|
+
# }
|
62
|
+
# )
|
63
|
+
#
|
64
|
+
class Binary_unittest_target < Abstract_target
|
65
|
+
|
66
|
+
# Exception, thrown if subordinated project created more then one result name.
|
67
|
+
class Must_be_one_target_name_ex < Ex
|
68
|
+
# [_a_names_] Generated result names.
|
69
|
+
def initialize( a_names )
|
70
|
+
super( "Only one name expected in [#{a_names.join(';')}]" )
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Target, responsible for build of unit-test application.
|
75
|
+
attr_reader :mxx_target_project
|
76
|
+
# Attribute, showing that build method was already executed.
|
77
|
+
attr_reader :mxx_build_state
|
78
|
+
|
79
|
+
# Constructor.
|
80
|
+
#
|
81
|
+
# [_a_alias_] Self alias.
|
82
|
+
# [_a_target_project_] Project, responsible for build of unit-test
|
83
|
+
# application.
|
84
|
+
def initialize( a_alias, a_target_project )
|
85
|
+
super( a_alias )
|
86
|
+
|
87
|
+
@mxx_build_state = nil
|
88
|
+
|
89
|
+
@mxx_target_project = required_prj( a_target_project )
|
90
|
+
end
|
91
|
+
|
92
|
+
# Build subordinated project and run it.
|
93
|
+
#
|
94
|
+
# If unit-test application returns result, other then 0,
|
95
|
+
# exception is thrown.
|
96
|
+
def build
|
97
|
+
if !@mxx_build_state
|
98
|
+
@mxx_target_project.build
|
99
|
+
|
100
|
+
# Determining application name.
|
101
|
+
full_names = @mxx_target_project.mxx_full_targets_names
|
102
|
+
if 1 != full_names.size
|
103
|
+
raise Must_be_one_target_name_ex.new( full_names )
|
104
|
+
end
|
105
|
+
|
106
|
+
# In dry-run do not actually execute anything.
|
107
|
+
if !Mxx_ru::Util::Mode.instance.is_dry_run
|
108
|
+
puts "running unit test: #{full_names[0]}..."
|
109
|
+
if !system( full_names[ 0 ] )
|
110
|
+
puts "\n\nunit test '#{full_names[0]}' FAILED! #{$?}"
|
111
|
+
raise Build_ex.new( full_names[ 0 ], $? )
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
@mxx_build_state = Target_state.new( Target_state::REBUILT )
|
116
|
+
end
|
117
|
+
|
118
|
+
return @mxx_build_state
|
119
|
+
end
|
120
|
+
|
121
|
+
# Project cleanup.
|
122
|
+
#
|
123
|
+
# Just execute clean method from subordinated project.
|
124
|
+
def clean
|
125
|
+
@mxx_target_project.clean
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
end
|
130
|
+
|