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/lib/mxx_ru/ex.rb
CHANGED
@@ -26,51 +26,66 @@
|
|
26
26
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
27
|
#++
|
28
28
|
|
29
|
-
module
|
29
|
+
module MxxRu
|
30
30
|
|
31
31
|
# Base class for all exceptions.
|
32
32
|
class Ex < Exception
|
33
33
|
end
|
34
34
|
|
35
35
|
# Exception, thrown on execution of 'pure abstract method'.
|
36
|
-
class
|
36
|
+
class AbstractMethodEx < Ex
|
37
37
|
def initialize( method_name )
|
38
38
|
super( "Pure virtual method call: " + method_name )
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
# For compatibility with previous versions.
|
43
|
+
Abstract_method_ex = AbstractMethodEx
|
44
|
+
|
42
45
|
# Exception, thrown if returned object type is not expected.
|
43
|
-
class
|
46
|
+
class InvalidCastEx < Ex
|
44
47
|
def initialize( msg )
|
45
48
|
super( msg )
|
46
49
|
end
|
47
50
|
end
|
48
51
|
|
52
|
+
# For compatibility with previous versions.
|
53
|
+
Invalid_cast_ex = InvalidCastEx
|
54
|
+
|
49
55
|
# Exception, thrown if build commands fail.
|
50
|
-
class
|
56
|
+
class BuildEx < Ex
|
51
57
|
def initialize( cmd_line, desc )
|
52
58
|
super( "Build error: '#{cmd_line}' returns '#{desc}'" )
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
62
|
+
# For compatibility with previous versions.
|
63
|
+
Build_ex = BuildEx
|
64
|
+
|
56
65
|
# Exception, thrown if unknown target type is detected.
|
57
|
-
class
|
66
|
+
class UnsupportedTargetTypeEx < Ex
|
58
67
|
def initialize( target_class, target_type )
|
59
68
|
super( "Unsupported target type '#{target_type}'" +
|
60
69
|
" in '#{target_class}'" )
|
61
70
|
end
|
62
71
|
end
|
63
72
|
|
73
|
+
# For compatibility with previous versions.
|
74
|
+
Unsupported_target_type_ex = UnsupportedTargetTypeEx
|
75
|
+
|
64
76
|
# Exception, thrown if no target object is found for given alias.
|
65
|
-
class
|
77
|
+
class TargetUnknownEx < Ex
|
66
78
|
def initialize( target_name )
|
67
79
|
super( "Target unknown for: " + target_name )
|
68
80
|
end
|
69
81
|
end
|
70
82
|
|
83
|
+
# For compatibility with previous versions.
|
84
|
+
Target_unknown_ex = TargetUnknownEx
|
85
|
+
|
71
86
|
# Exception, thrown if value conflict for global options such as
|
72
87
|
# runtime_mode, rtl_mode, etc is detected
|
73
|
-
class
|
88
|
+
class GlobalOptionConflictEx < Ex
|
74
89
|
# [_a_name_] Option name.
|
75
90
|
# [_a_current_] Current option value.
|
76
91
|
# [_a_current_owner_] Who was set current value.
|
@@ -89,9 +104,12 @@ module Mxx_ru
|
|
89
104
|
end
|
90
105
|
end
|
91
106
|
|
92
|
-
#
|
93
|
-
|
94
|
-
|
107
|
+
# For compatibility with previous versions.
|
108
|
+
Global_option_conflict_ex = GlobalOptionConflictEx
|
109
|
+
|
110
|
+
# Exception, thrown if anyone tries to set invalid value to global options
|
111
|
+
# such as runtime_mode, rtl_mode, etc.
|
112
|
+
class GlobalOptionDisallowedValueEx < Ex
|
95
113
|
# [_a_name_] Option name.
|
96
114
|
# [_a_available_values_] Available values list. Should be Array of String.
|
97
115
|
# [_a_new_] New option value.
|
@@ -108,27 +126,40 @@ module Mxx_ru
|
|
108
126
|
end
|
109
127
|
end
|
110
128
|
|
129
|
+
# For compatibility with previous versions.
|
130
|
+
Global_option_disallowed_value_ex = GlobalOptionDisallowedValueEx
|
131
|
+
|
111
132
|
# Exception, thrown if some mode is not supported by the toolset.
|
112
|
-
class
|
133
|
+
class UnsupportedModeEx < Ex
|
113
134
|
def initialize( msg )
|
114
135
|
super( msg )
|
115
136
|
end
|
116
137
|
end
|
117
138
|
|
139
|
+
# For compatibility with previous versions.
|
140
|
+
Unsupported_mode_ex = UnsupportedModeEx
|
141
|
+
|
118
142
|
# Exception, thrown if some dependency file is missing.
|
119
|
-
class
|
143
|
+
class MissingDependFileEx < Ex
|
120
144
|
def initialize( missing_file, depend_for )
|
121
145
|
super( "File '#{missing_file}' required by '#{depend_for}' " +
|
122
146
|
"missing" )
|
123
147
|
end
|
124
148
|
end
|
125
149
|
|
150
|
+
# For compatibility with previous versions.
|
151
|
+
Missing_depend_file_ex = MissingDependFileEx
|
152
|
+
|
126
153
|
# Exception, thrown if some value is invalid in current context.
|
127
|
-
class
|
154
|
+
class InvalidValueEx < Ex
|
128
155
|
def initialize( msg )
|
129
156
|
super( msg )
|
130
157
|
end
|
131
158
|
end
|
132
159
|
|
160
|
+
# For compatibility with previous versions.
|
161
|
+
Invalid_value_ex = InvalidValueEx
|
162
|
+
|
133
163
|
end
|
134
164
|
|
165
|
+
load File.dirname( __FILE__ ) + '/compat.rb'
|
@@ -28,19 +28,19 @@
|
|
28
28
|
|
29
29
|
require 'mxx_ru/abstract_target.rb'
|
30
30
|
|
31
|
-
module
|
31
|
+
module MxxRu
|
32
32
|
|
33
33
|
# A Generator, which allows to define simple make rules in a project.
|
34
34
|
#
|
35
35
|
# For example, if it's needed to get from ddl file two other files,
|
36
36
|
# cpp and hpp, using typegen program, it should be done like that:
|
37
|
-
# generator(
|
37
|
+
# generator( MxxRu::MakestyleGenerator.new(
|
38
38
|
# [ "myfile.cpp", "myfile.hpp" ],
|
39
39
|
# [ "myfile.ddl" ],
|
40
40
|
# [ "typegen --from myfile.ddl --cpp myfile.cpp --header myfile.hpp" ] ) )
|
41
41
|
#
|
42
42
|
# NOTE: For C++ projects current value of sources_root isn't taken into account.
|
43
|
-
class
|
43
|
+
class MakestyleGenerator < AbstractGenerator
|
44
44
|
# File names list, which should be built by given generator.
|
45
45
|
attr_reader :target_files
|
46
46
|
|
@@ -52,21 +52,25 @@ class Makestyle_generator < Abstract_generator
|
|
52
52
|
|
53
53
|
# Command list, which should be ran in a sequence to remove result files.
|
54
54
|
#
|
55
|
-
# If this list is empty, removal of result files would occur on clean
|
55
|
+
# If this list is empty, removal of result files would occur on clean
|
56
|
+
# operation.
|
56
57
|
attr_reader :clean_cmds
|
57
58
|
|
58
59
|
# Constructor.
|
59
60
|
#
|
60
61
|
# [_a_target_files_] Result files list.
|
61
62
|
# [_a_dependencies_] Dependencies list.
|
62
|
-
# [_a_build_cmds_] Command list, which should be ran in a sequence to get
|
63
|
-
#
|
63
|
+
# [_a_build_cmds_] Command list, which should be ran in a sequence to get
|
64
|
+
# result files.
|
65
|
+
# [_a_clean_cmds_] Command list, which should be ran in a sequence to remove
|
66
|
+
# result files.
|
64
67
|
#
|
65
|
-
# NOTE: Single values may be defined as a strings instead of vectors. For
|
66
|
-
#
|
68
|
+
# NOTE: Single values may be defined as a strings instead of vectors. For
|
69
|
+
# example:
|
70
|
+
# MxxRu::MakestyleGenerator.new( "myfile.cpp", "myfile.ddl",
|
67
71
|
# [ "typegen --from myfile.ddl --to myfile.cpp" ] )
|
68
72
|
# It's the same as:
|
69
|
-
#
|
73
|
+
# MxxRu::MakestyleGenerator.new( [ "myfile.cpp" ], [ "myfile.ddl" ],
|
70
74
|
# "typegen --from myfile.ddl --to myfile.cpp" )
|
71
75
|
#
|
72
76
|
def initialize(
|
@@ -90,7 +94,7 @@ class Makestyle_generator < Abstract_generator
|
|
90
94
|
# Checking all result files. If one of them is obsolete, performing rebuild.
|
91
95
|
index = 0
|
92
96
|
while !need_build && index != @target_files.size
|
93
|
-
if
|
97
|
+
if TargetState::EXISTS != TargetState.detect(
|
94
98
|
@target_files[ index ], @dependencies ).state
|
95
99
|
need_build = true
|
96
100
|
else
|
@@ -100,7 +104,7 @@ class Makestyle_generator < Abstract_generator
|
|
100
104
|
|
101
105
|
if need_build
|
102
106
|
# It's required to run all commands to build target.
|
103
|
-
|
107
|
+
AbstractTarget.run(
|
104
108
|
@build_cmds,
|
105
109
|
[],
|
106
110
|
"building #{@target_files.join(', ')}" )
|
@@ -137,5 +141,6 @@ protected
|
|
137
141
|
end
|
138
142
|
end
|
139
143
|
|
144
|
+
# For compatibility with previous versions.
|
145
|
+
Makestyle_generator = MakestyleGenerator
|
140
146
|
end
|
141
|
-
|
@@ -29,30 +29,31 @@
|
|
29
29
|
require 'mxx_ru/ex'
|
30
30
|
require 'mxx_ru/abstract_target'
|
31
31
|
|
32
|
-
module
|
32
|
+
module MxxRu
|
33
33
|
|
34
34
|
# The class of a target, which is binary unit-test application, which create
|
35
35
|
# one or many text files.
|
36
|
-
# Given target performs a build of application, and then runs it and compares results
|
37
|
-
# with files which contains correct results.
|
38
36
|
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
37
|
+
# Given target performs a build of application, and then runs it and compares
|
38
|
+
# results with files which contains correct results.
|
39
|
+
#
|
40
|
+
# The basic idea consists in the presence of project file, which controls the
|
41
|
+
# build of unit-test application. In that project file, target object is
|
42
|
+
# created, inherited from MxxRu::BinaryTarget. To start unit-test it's
|
43
|
+
# necessary to create one more file, where target object of
|
44
|
+
# MxxRu::TextfileUnittestTarget class is created.
|
44
45
|
# For example:
|
45
46
|
#
|
46
47
|
# Unit-test application build file:
|
47
|
-
#
|
48
|
-
#
|
48
|
+
# MxxRu::setup_target(
|
49
|
+
# MxxRu::Cpp::ExeTarget.new( "test/pack/prj.rb" ) {
|
49
50
|
# ...
|
50
51
|
# }
|
51
52
|
# )
|
52
53
|
#
|
53
54
|
# File to run unit-test:
|
54
|
-
#
|
55
|
-
#
|
55
|
+
# MxxRu::setup_target(
|
56
|
+
# MxxRu::TextfileUnittestTarget.new(
|
56
57
|
# "test/pack/pack.ut.rb",
|
57
58
|
# "test/pack/prj.rb" ) {
|
58
59
|
#
|
@@ -67,26 +68,29 @@ module Mxx_ru
|
|
67
68
|
# )
|
68
69
|
#
|
69
70
|
# File which is using that unit-test.
|
70
|
-
#
|
71
|
-
#
|
71
|
+
# MxxRu::setup_target(
|
72
|
+
# MxxRu::Cpp::CompositeTarget.new( MxxRu::BUILD_ROOT ) {
|
72
73
|
# required_prj( "some/project/prj.rb" )
|
73
74
|
# required_prj( "test/pack/prj.ut.rb" )
|
74
75
|
# }
|
75
76
|
# )
|
76
77
|
#
|
77
|
-
class
|
78
|
+
class TextfileUnittestTarget < AbstractTarget
|
78
79
|
|
79
80
|
# Exception, thrown if one subordinated project generated more
|
80
81
|
# than one result name.
|
81
|
-
class
|
82
|
+
class MustBeOneTargetNameEx < Ex
|
82
83
|
# [_a_names_] Names generated.
|
83
84
|
def initialize( a_names )
|
84
85
|
super( "Only one name expected in [#{a_names.join(';')}]" )
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
89
|
+
# For compatibility with previous versions.
|
90
|
+
Must_be_one_target_name_ex = MustBeOneTargetNameEx
|
91
|
+
|
88
92
|
# Exception, thrown if files are not equal.
|
89
|
-
class
|
93
|
+
class FileMismatchEx < BuildEx
|
90
94
|
# [_a_cmdline_] Command string of test application.
|
91
95
|
# [_a_produced_] Name of file generated.
|
92
96
|
# [_a_etalon_] Name of file containing correct results.
|
@@ -106,6 +110,9 @@ class Textfile_unittest_target < Abstract_target
|
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
113
|
+
# For compatibility with previous versions.
|
114
|
+
File_mismatch_ex = FileMismatchEx
|
115
|
+
|
109
116
|
# Description of single pair of values compared.
|
110
117
|
class Pair
|
111
118
|
# Name of file generated.
|
@@ -184,7 +191,8 @@ class Textfile_unittest_target < Abstract_target
|
|
184
191
|
|
185
192
|
# Build subordinated project and run it.
|
186
193
|
#
|
187
|
-
# If unit-test application returns exit code not equal to 0, exception is
|
194
|
+
# If unit-test application returns exit code not equal to 0, exception is
|
195
|
+
# thrown.
|
188
196
|
def build
|
189
197
|
if !@mxx_build_state
|
190
198
|
@mxx_target_project.build
|
@@ -192,16 +200,16 @@ class Textfile_unittest_target < Abstract_target
|
|
192
200
|
# Determining the name of application, which should be run.
|
193
201
|
full_names = @mxx_target_project.mxx_full_targets_names
|
194
202
|
if 1 != full_names.size
|
195
|
-
raise
|
203
|
+
raise MustBeOneTargetNameEx.new( full_names )
|
196
204
|
end
|
197
205
|
|
198
206
|
# No execution of commands in dry-run mode.
|
199
|
-
if !
|
207
|
+
if !MxxRu::Util::Mode.instance.is_dry_run
|
200
208
|
puts "running unit test: #{full_names[0]}..."
|
201
209
|
do_all_launches( full_names[ 0 ] )
|
202
210
|
end
|
203
211
|
|
204
|
-
@mxx_build_state =
|
212
|
+
@mxx_build_state = TargetState.new( TargetState::REBUILT )
|
205
213
|
end
|
206
214
|
|
207
215
|
return @mxx_build_state
|
@@ -221,6 +229,12 @@ class Textfile_unittest_target < Abstract_target
|
|
221
229
|
}
|
222
230
|
end
|
223
231
|
|
232
|
+
# Reset build status.
|
233
|
+
def reset
|
234
|
+
@mxx_target_project.reset
|
235
|
+
@mxx_build_state = nil
|
236
|
+
end
|
237
|
+
|
224
238
|
protected
|
225
239
|
# Perform all defined runs of test application.
|
226
240
|
# This method should not be executed in dry-run mode.
|
@@ -235,7 +249,7 @@ protected
|
|
235
249
|
puts "\tlaunching '#{cmdline}'..."
|
236
250
|
if !system( cmdline )
|
237
251
|
puts "\n\nunit test '#{cmdline}' FAILED! #{$?}"
|
238
|
-
raise
|
252
|
+
raise BuildEx.new( cmdline, $? )
|
239
253
|
end
|
240
254
|
|
241
255
|
# Execution of application was successful.
|
@@ -248,9 +262,9 @@ protected
|
|
248
262
|
end
|
249
263
|
|
250
264
|
# Perform comparation of two files.
|
251
|
-
# If they are not identical,
|
265
|
+
# If they are not identical, FileMismatchEx exception is thrown.
|
252
266
|
# If some system exceptions would occur (absence of file for example),
|
253
|
-
#
|
267
|
+
# BuildEx ewxception will be thrown.
|
254
268
|
def do_file_compare( a_cmdline, a_produced, a_etalon )
|
255
269
|
begin
|
256
270
|
produced_file = File.new( a_produced, "r" )
|
@@ -259,10 +273,12 @@ protected
|
|
259
273
|
line_num = 1
|
260
274
|
while true
|
261
275
|
l1 = produced_file.gets
|
276
|
+
l1.chop! if l1
|
262
277
|
l2 = etalon_file.gets
|
278
|
+
l2.chop! if l2
|
263
279
|
|
264
280
|
if l1 != l2
|
265
|
-
raise
|
281
|
+
raise FileMismatchEx.new( a_cmdline,
|
266
282
|
a_produced, a_etalon, line_num,
|
267
283
|
l1, l2 )
|
268
284
|
else
|
@@ -274,11 +290,14 @@ protected
|
|
274
290
|
end
|
275
291
|
|
276
292
|
rescue Exception => ex
|
277
|
-
raise
|
293
|
+
raise BuildEx.new( a_cmdline,
|
278
294
|
"Error during comparing files " +
|
279
295
|
"'#{a_produced}', '#{a_etalon}': #{ex}" )
|
280
296
|
end
|
281
297
|
end
|
282
298
|
end
|
283
299
|
|
284
|
-
|
300
|
+
# For compatibility with previous versions.
|
301
|
+
Textfile_unittest_target = TextfileUnittestTarget
|
302
|
+
|
303
|
+
end # module MxxRu
|
data/lib/mxx_ru/util.rb
CHANGED
@@ -29,18 +29,21 @@
|
|
29
29
|
require 'rbconfig'
|
30
30
|
require 'singleton'
|
31
31
|
|
32
|
-
|
32
|
+
require 'mxx_ru/ex'
|
33
|
+
|
34
|
+
module MxxRu
|
33
35
|
|
34
36
|
module Util
|
35
37
|
# Regular expression to divide file name and it's extension.
|
36
38
|
MATCH_FILE_EXT_REGEX = Regexp.new( "^(.+)\\.([^\\./]+)$" )
|
37
39
|
|
38
|
-
# Ruby command line parameters, handled by
|
39
|
-
MXXARG_CLEAN =
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
# Ruby command line parameters, handled by MxxRu.
|
41
|
+
MXXARG_CLEAN = '--mxx-clean'
|
42
|
+
MXXARG_REBUILD = '--mxx-rebuild'
|
43
|
+
MXXARG_SHOW_CMD = '--mxx-show-cmd'
|
44
|
+
MXXARG_KEEP_TMPS = '--mxx-keep-tmps'
|
45
|
+
MXXARG_SHOW_TMPS = '--mxx-show-tmps'
|
46
|
+
MXXARG_DRY_RUN = '--mxx-dry-run'
|
44
47
|
MXXARG_BRIEF_DESC = '--mxx-brief-show'
|
45
48
|
MXXARG_BRIEF_DESC_DISABLED = '--mxx-brief-hide'
|
46
49
|
|
@@ -50,19 +53,32 @@ module Mxx_ru
|
|
50
53
|
# Regular expression to parse entries in Kernel#caller result.
|
51
54
|
CALLER_ENTRY_REGEX = /^(.+):\d+(:in\s.+){0,1}$/
|
52
55
|
|
53
|
-
# Class, which detects
|
56
|
+
# Class, which detects MxxRu current mode.
|
54
57
|
class Mode
|
55
58
|
include Singleton
|
56
59
|
|
57
60
|
attr_reader :is_clean
|
61
|
+
attr_reader :is_rebuild
|
58
62
|
attr_reader :is_show_cmd
|
59
63
|
attr_reader :is_keep_tmps
|
60
64
|
attr_reader :is_show_tmps
|
61
65
|
attr_reader :is_brief_desc
|
62
66
|
|
67
|
+
# Exception for case when '--mxx-clean' and '--mxx-rebuild' used
|
68
|
+
# together.
|
69
|
+
class CleanAndRebuildUsedTogetherEx < Ex
|
70
|
+
def initialize
|
71
|
+
super "Mode #{MXXARG_CLEAN} and #{MXXARG_REBUILD} cannot be " +
|
72
|
+
"used together"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
63
76
|
# Constructor checks for special arguments in command line.
|
64
77
|
def initialize
|
65
78
|
@is_clean = ARGV.include?( MXXARG_CLEAN )
|
79
|
+
@is_rebuild = ARGV.include?( MXXARG_REBUILD )
|
80
|
+
raise CleanAndRebuildUsedTogetherEx.new if @is_clean and @is_rebuild
|
81
|
+
|
66
82
|
@is_show_cmd = ARGV.include?( MXXARG_SHOW_CMD )
|
67
83
|
@is_keep_tmps = ARGV.include?( MXXARG_KEEP_TMPS )
|
68
84
|
@is_show_tmps = ARGV.include?( MXXARG_SHOW_TMPS )
|
@@ -125,7 +141,7 @@ module Mxx_ru
|
|
125
141
|
# Temporary files are created in current folder.
|
126
142
|
# Temporary files are removed before application is exitted,
|
127
143
|
# if --mxx-keep-tmps option isn't set.
|
128
|
-
class
|
144
|
+
class TmpFiles
|
129
145
|
include Singleton
|
130
146
|
|
131
147
|
# Temporary file names.
|
@@ -133,7 +149,7 @@ module Mxx_ru
|
|
133
149
|
|
134
150
|
def initialize
|
135
151
|
if !Mode.instance.is_keep_tmps
|
136
|
-
ObjectSpace.define_finalizer( self, Proc.new{
|
152
|
+
ObjectSpace.define_finalizer( self, Proc.new{ TmpFiles.finalizer } )
|
137
153
|
end
|
138
154
|
|
139
155
|
# Counter to ensure unique file names.
|
@@ -143,7 +159,7 @@ module Mxx_ru
|
|
143
159
|
@index_stack = Array.new
|
144
160
|
end
|
145
161
|
|
146
|
-
def
|
162
|
+
def TmpFiles.finalizer
|
147
163
|
@@names.each { |d|
|
148
164
|
begin
|
149
165
|
File.delete( d )
|
@@ -188,24 +204,27 @@ module Mxx_ru
|
|
188
204
|
index = @index_stack.pop
|
189
205
|
while @@names.size > index
|
190
206
|
file_to_delete = @@names.pop
|
191
|
-
|
207
|
+
MxxRu::Util::delete_file( file_to_delete )
|
192
208
|
end
|
193
209
|
end
|
194
210
|
end
|
195
211
|
|
196
|
-
end # class
|
212
|
+
end # class TmpFiles
|
213
|
+
|
214
|
+
# For compatibility with previous versions.
|
215
|
+
Tmp_files = TmpFiles
|
197
216
|
|
198
217
|
# Auxiliary function for correct execution of build method of target
|
199
|
-
# object. Before execution
|
200
|
-
# of build method
|
218
|
+
# object. Before execution TmpFiles.push is executed, and after execution
|
219
|
+
# of build method TmpFiles.pop is called. This way we are removing
|
201
220
|
# temporary files created during a compilation of given target.
|
202
221
|
def Util.build_call_wrapper( a_target )
|
203
222
|
begin
|
204
|
-
|
223
|
+
TmpFiles.instance.push
|
205
224
|
state = a_target.build
|
206
225
|
return state
|
207
226
|
ensure
|
208
|
-
|
227
|
+
TmpFiles.instance.pop
|
209
228
|
end
|
210
229
|
end
|
211
230
|
|
@@ -220,7 +239,7 @@ module Mxx_ru
|
|
220
239
|
chain.unshift( a_name )
|
221
240
|
|
222
241
|
to_split = a_name.clone
|
223
|
-
while to_split !=
|
242
|
+
while to_split != '.'
|
224
243
|
r = File.split( to_split )
|
225
244
|
|
226
245
|
# We must stop if to_split cannot be splitted anymore
|
@@ -244,12 +263,12 @@ module Mxx_ru
|
|
244
263
|
# If dry-run mode wasn't set, checking for existance.
|
245
264
|
# If it isn't exists, trying to create it.
|
246
265
|
#
|
247
|
-
# In a dry-run mode
|
266
|
+
# In a dry-run mode MxxRu always assumes folder is exists, even if it
|
248
267
|
# isn't.
|
249
268
|
def Util.ensure_path_exists( a_path_name )
|
250
|
-
if !
|
269
|
+
if !MxxRu::Util::Mode.instance.is_dry_run
|
251
270
|
if !FileTest.exists?( a_path_name )
|
252
|
-
|
271
|
+
MxxRu::Util.create_dir( a_path_name )
|
253
272
|
end
|
254
273
|
end
|
255
274
|
end
|
@@ -296,20 +315,26 @@ module Mxx_ru
|
|
296
315
|
# Manually enable 'show-brief' mode.
|
297
316
|
#
|
298
317
|
# Intended to use in project files:
|
299
|
-
#
|
318
|
+
# MxxRu::Cpp::exe_target( 'some.prj' ) {
|
300
319
|
# ...
|
301
|
-
#
|
320
|
+
# MxxRu::enable_show_brief
|
302
321
|
# ...
|
303
322
|
# }
|
304
323
|
# 'show-brief' is global mode. Once enabled it cannot be disabled
|
305
324
|
# form inside another project file.
|
306
325
|
#
|
307
|
-
# Call to
|
326
|
+
# Call to MxxRu::enable_show_brief ignored if '--mxx-show-brief-disabled'
|
308
327
|
# specified in command-line.
|
309
328
|
#
|
310
|
-
def
|
329
|
+
def MxxRu.enable_show_brief
|
311
330
|
Util::Mode.instance.try_enable_show_brief
|
312
331
|
end
|
313
332
|
|
314
|
-
|
333
|
+
# Show a brief message. The message shown only if 'show-brief' mode is on.
|
334
|
+
def MxxRu.show_brief( message )
|
335
|
+
puts message[ 0, 1 ].capitalize << message[ 1..message.size ] << ' ...' if
|
336
|
+
Util::Mode.instance.is_brief_desc and message
|
337
|
+
end
|
338
|
+
|
339
|
+
end # module MxxRu
|
315
340
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname( __FILE__ ) + '/../../test_with_compilation'
|
4
|
+
|
5
|
+
class TC_CppSourcesGlob < Test::Unit::TestCase
|
6
|
+
include TestWithCompilation
|
7
|
+
|
8
|
+
test_path 'tests/cpp/cpp_sources_glob'
|
9
|
+
|
10
|
+
test_case :successful_compile_and_link do
|
11
|
+
assert_nothing_raised {
|
12
|
+
build( 'build.rb' )
|
13
|
+
clean( 'build.rb' )
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname( __FILE__ ) + '/../../test_with_compilation'
|
4
|
+
|
5
|
+
class TC_MSWinResDll < Test::Unit::TestCase
|
6
|
+
include TestWithCompilation
|
7
|
+
|
8
|
+
test_path 'tests/cpp/mswin_res_dll'
|
9
|
+
|
10
|
+
test_case :successful_compile_and_link do
|
11
|
+
assert_nothing_raised {
|
12
|
+
build( 'build.rb' )
|
13
|
+
clean( 'build.rb' )
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname( __FILE__ ) + '/../../test_with_compilation'
|
4
|
+
|
5
|
+
class TC_MSWinResExe < Test::Unit::TestCase
|
6
|
+
include TestWithCompilation
|
7
|
+
|
8
|
+
test_path 'tests/cpp/mswin_res_exe'
|
9
|
+
|
10
|
+
test_case :successful_compile_and_link do
|
11
|
+
assert_nothing_raised {
|
12
|
+
build( 'build.rb' )
|
13
|
+
clean( 'build.rb' )
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
data/tests/cpp/rucodegen/prj.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'mxx_ru/cpp'
|
2
2
|
require 'mxx_ru/cpp/rucodegen'
|
3
3
|
|
4
|
-
Mxx_ru::
|
4
|
+
Mxx_ru::Cpp::exe_target {
|
5
5
|
target "host_config"
|
6
6
|
|
7
7
|
rucodegen = generator Mxx_ru::Cpp::RuCodeGen.new( self )
|
@@ -14,4 +14,3 @@ Mxx_ru::setup_target Mxx_ru::Cpp::Exe_target.new( "tests/cpp/rucodegen/prj.rb" )
|
|
14
14
|
rucodegen.add "conn_params.rb"
|
15
15
|
}
|
16
16
|
}
|
17
|
-
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname( __FILE__ ) + '/../../test_with_compilation'
|
4
|
+
|
5
|
+
class TC_RuCodeGen < Test::Unit::TestCase
|
6
|
+
include TestWithCompilation
|
7
|
+
|
8
|
+
test_path 'tests/cpp/rucodegen'
|
9
|
+
|
10
|
+
test_case :successful_compile_and_link do
|
11
|
+
assert_nothing_raised {
|
12
|
+
build( 'prj.rb' )
|
13
|
+
clean( 'prj.rb' )
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|