Mxx_ru 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +4 -3
- data/bin/mxxrugen +197 -0
- data/lib/mxx_ru/cmd_line_option_processor.rb +126 -0
- data/lib/mxx_ru/cpp.rb +1 -0
- data/lib/mxx_ru/cpp/composite.rb +2 -12
- data/lib/mxx_ru/cpp/lib_collection.rb +96 -0
- data/lib/mxx_ru/cpp/mode.rb +72 -10
- data/lib/mxx_ru/cpp/target.rb +85 -136
- data/lib/mxx_ru/cpp/toolset.rb +96 -9
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +5 -5
- data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +5 -5
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +5 -5
- data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +2 -2
- data/lib/mxx_ru/cpp/toolsets/vc8.rb +6 -1
- data/lib/mxx_ru/cpp/toolsets/vc_family.rb +4 -4
- data/lib/mxx_ru/generators/bin-unittest/g.rb +200 -0
- data/lib/mxx_ru/generators/bin-unittest/template.erb +16 -0
- data/lib/mxx_ru/generators/cpp-composite/g.rb +37 -0
- data/lib/mxx_ru/generators/cpp-dll/g.rb +37 -0
- data/lib/mxx_ru/generators/cpp-exe/g.rb +37 -0
- data/lib/mxx_ru/generators/cpp-lib-collection/g.rb +37 -0
- data/lib/mxx_ru/generators/cpp-lib/g.rb +37 -0
- data/lib/mxx_ru/generators/impl/cpp/generation.rb +291 -0
- data/lib/mxx_ru/generators/impl/cpp/template.erb +27 -0
- data/lib/mxx_ru/generators/impl/std_receiver.rb +80 -0
- data/lib/mxx_ru/util.rb +110 -22
- data/lib/mxx_ru/version.rb +38 -0
- data/tests/mxx_ru/generators/cpp/tc_generator.rb +34 -0
- data/tests/mxx_ru/generators/cpp/tc_options.rb +79 -0
- data/tests/mxx_ru/generators/cpp/tc_template_params.rb +45 -0
- data/tests/mxx_ru/lib_collection/a.cpp +8 -0
- data/tests/mxx_ru/lib_collection/a.hpp +8 -0
- data/tests/mxx_ru/lib_collection/a.rb +8 -0
- data/tests/mxx_ru/lib_collection/b.cpp +8 -0
- data/tests/mxx_ru/lib_collection/b.hpp +8 -0
- data/tests/mxx_ru/lib_collection/b.rb +8 -0
- data/tests/mxx_ru/lib_collection/c.cpp +8 -0
- data/tests/mxx_ru/lib_collection/c.hpp +8 -0
- data/tests/mxx_ru/lib_collection/c.rb +8 -0
- data/tests/mxx_ru/lib_collection/collection_a_b.rb +7 -0
- data/tests/mxx_ru/lib_collection/collection_c_d.rb +7 -0
- data/tests/mxx_ru/lib_collection/collection_c_d_e.rb +7 -0
- data/tests/mxx_ru/lib_collection/collection_f.rb +6 -0
- data/tests/mxx_ru/lib_collection/collection_i.rb +6 -0
- data/tests/mxx_ru/lib_collection/d.cpp +8 -0
- data/tests/mxx_ru/lib_collection/d.hpp +8 -0
- data/tests/mxx_ru/lib_collection/d.rb +8 -0
- data/tests/mxx_ru/lib_collection/e.cpp +8 -0
- data/tests/mxx_ru/lib_collection/e.hpp +8 -0
- data/tests/mxx_ru/lib_collection/e.rb +8 -0
- data/tests/mxx_ru/lib_collection/f.cpp +8 -0
- data/tests/mxx_ru/lib_collection/f.hpp +8 -0
- data/tests/mxx_ru/lib_collection/f.rb +7 -0
- data/tests/mxx_ru/lib_collection/g.cpp +8 -0
- data/tests/mxx_ru/lib_collection/g.hpp +8 -0
- data/tests/mxx_ru/lib_collection/g.rb +7 -0
- data/tests/mxx_ru/lib_collection/i.cpp +10 -0
- data/tests/mxx_ru/lib_collection/i.hpp +16 -0
- data/tests/mxx_ru/lib_collection/i.rb +17 -0
- data/tests/mxx_ru/lib_collection/main.cpp +18 -0
- data/tests/mxx_ru/lib_collection/main.rb +12 -0
- data/tests/mxx_ru/lib_collection/tc_lib_collection.rb +17 -0
- data/tests/mxx_ru/toolset/tc_tag_search.rb +68 -0
- data/tests/test_with_compilation.rb +1 -1
- metadata +67 -14
- data/tests/cpp/mswin_res_dll/o/dll.o +0 -0
- data/tests/cpp/mswin_res_exe/o/main.o +0 -0
data/lib/mxx_ru/util.rb
CHANGED
@@ -30,6 +30,7 @@ require 'rbconfig'
|
|
30
30
|
require 'singleton'
|
31
31
|
|
32
32
|
require 'mxx_ru/ex'
|
33
|
+
require 'mxx_ru/cmd_line_option_processor'
|
33
34
|
|
34
35
|
module MxxRu
|
35
36
|
|
@@ -57,36 +58,119 @@ module MxxRu
|
|
57
58
|
class Mode
|
58
59
|
include Singleton
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
# Option parser for common Mxx_ru options.
|
62
|
+
#
|
63
|
+
# Since v.1.4.0
|
64
|
+
class OptionParser
|
65
|
+
include Singleton
|
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
|
+
|
76
|
+
attr_reader :is_brief_desc
|
77
|
+
attr_reader :is_brief_desc_disabled
|
78
|
+
attr_reader :is_clean
|
79
|
+
attr_reader :is_dry_run
|
80
|
+
attr_reader :is_keep_tmps
|
81
|
+
attr_reader :is_rebuild
|
82
|
+
attr_reader :is_show_cmd
|
83
|
+
attr_reader :is_show_tmps
|
66
84
|
|
67
|
-
# Exception for case when '--mxx-clean' and '--mxx-rebuild' used
|
68
|
-
# together.
|
69
|
-
class CleanAndRebuildUsedTogetherEx < Ex
|
70
85
|
def initialize
|
71
|
-
|
72
|
-
|
86
|
+
@is_brief_desc = false
|
87
|
+
@is_brief_desc_disabled = false
|
88
|
+
@is_clean = false
|
89
|
+
@is_dry_run = false
|
90
|
+
@is_keep_tmps = false
|
91
|
+
@is_rebuild = false
|
92
|
+
@is_show_cmd = false
|
93
|
+
@is_show_tmps = false
|
94
|
+
end
|
95
|
+
|
96
|
+
def prepare( parser )
|
97
|
+
parser.separator ''
|
98
|
+
parser.separator 'Common Mxx_ru options:'
|
99
|
+
|
100
|
+
parser.on( MXXARG_CLEAN, 'Clean up project' ) do
|
101
|
+
@is_clean = true
|
102
|
+
check_clean_and_rebuild_correctness
|
103
|
+
end
|
104
|
+
|
105
|
+
parser.on( MXXARG_REBUILD,
|
106
|
+
'Clean up and then build project again' ) do
|
107
|
+
@is_rebuild = true
|
108
|
+
check_clean_and_rebuild_correctness
|
109
|
+
end
|
110
|
+
|
111
|
+
parser.on( MXXARG_SHOW_CMD,
|
112
|
+
'Show commands during build process' ) do
|
113
|
+
@is_show_cmd = true
|
114
|
+
end
|
115
|
+
|
116
|
+
parser.on( MXXARG_KEEP_TMPS,
|
117
|
+
'Keep temporary files after build finihed' ) do
|
118
|
+
@is_keep_tmps = true
|
119
|
+
end
|
120
|
+
|
121
|
+
parser.on( MXXARG_SHOW_TMPS,
|
122
|
+
'Show content of temporary files during build process' ) do
|
123
|
+
@is_show_tmps = true
|
124
|
+
end
|
125
|
+
|
126
|
+
parser.on( MXXARG_BRIEF_DESC,
|
127
|
+
'Enable displaying short description of build steps' ) do
|
128
|
+
@is_brief_desc = true
|
129
|
+
end
|
130
|
+
|
131
|
+
parser.on( MXXARG_BRIEF_DESC_DISABLED,
|
132
|
+
'Disable displaying short description of build steps' ) do
|
133
|
+
@is_brief_desc_disabled = true
|
134
|
+
end
|
135
|
+
|
136
|
+
parser.on( MXXARG_DRY_RUN,
|
137
|
+
'Build imitation mode, no actual actions perfomed' ) do
|
138
|
+
@is_dry_run = true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
# Throws exception if --mxx-clean and --mxx-rebuild specified
|
144
|
+
# at the same time.
|
145
|
+
def check_clean_and_rebuild_correctness
|
146
|
+
raise CleanAndRebuildUsedTogetherEx.new if @is_clean && @is_rebuild
|
147
|
+
end
|
148
|
+
end # class OptionParser
|
149
|
+
|
150
|
+
# Method for generation methods like is_clean, is_rebuild, etc.
|
151
|
+
def Mode.generate_option_reader( option )
|
152
|
+
class_eval do
|
153
|
+
define_method( option ) do
|
154
|
+
OptionParser.instance.send( option )
|
155
|
+
end
|
73
156
|
end
|
74
157
|
end
|
75
158
|
|
159
|
+
generate_option_reader :is_clean
|
160
|
+
generate_option_reader :is_rebuild
|
161
|
+
generate_option_reader :is_show_cmd
|
162
|
+
generate_option_reader :is_keep_tmps
|
163
|
+
generate_option_reader :is_show_tmps
|
164
|
+
attr_reader :is_brief_desc
|
165
|
+
|
76
166
|
# Constructor checks for special arguments in command line.
|
77
167
|
def initialize
|
78
|
-
|
79
|
-
@is_rebuild = ARGV.include?( MXXARG_REBUILD )
|
80
|
-
raise CleanAndRebuildUsedTogetherEx.new if @is_clean and @is_rebuild
|
168
|
+
CmdLineOptionProcessor.instance.parse
|
81
169
|
|
82
|
-
@
|
83
|
-
@
|
84
|
-
@is_show_tmps = ARGV.include?( MXXARG_SHOW_TMPS )
|
85
|
-
@is_dry_run = ARGV.include?( MXXARG_DRY_RUN )
|
86
|
-
@is_brief_desc = ARGV.include?( MXXARG_BRIEF_DESC )
|
87
|
-
@is_brief_desc_disabled = ARGV.include?( MXXARG_BRIEF_DESC_DISABLED )
|
170
|
+
@is_brief_desc = OptionParser.instance.is_brief_desc
|
171
|
+
@is_brief_desc = false if OptionParser.instance.is_brief_desc_disabled
|
88
172
|
|
89
|
-
@
|
173
|
+
@is_dry_run = OptionParser.instance.is_dry_run
|
90
174
|
|
91
175
|
@is_manual_dry_run = false
|
92
176
|
end
|
@@ -109,7 +193,7 @@ module MxxRu
|
|
109
193
|
# Try to manually enable 'show-brief' mode. Attempt ignored if
|
110
194
|
# '--mxx-show-brief-disabled' was specified.
|
111
195
|
def try_enable_show_brief
|
112
|
-
@is_brief_desc = true unless
|
196
|
+
@is_brief_desc = true unless OptionParser.instance.is_brief_desc_disabled
|
113
197
|
end
|
114
198
|
|
115
199
|
end
|
@@ -338,3 +422,7 @@ module MxxRu
|
|
338
422
|
|
339
423
|
end # module MxxRu
|
340
424
|
|
425
|
+
# Common Mxx_ru option parser must be added.
|
426
|
+
MxxRu::CmdLineOptionProcessor.instance.add_processor(
|
427
|
+
MxxRu::Util::Mode::OptionParser.instance )
|
428
|
+
|
@@ -0,0 +1,38 @@
|
|
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
|
+
# Must be used anywhere where version of Mxx_ru required.
|
30
|
+
#
|
31
|
+
# For example:
|
32
|
+
#
|
33
|
+
# require 'mxx_ru/version'
|
34
|
+
#
|
35
|
+
# puts 'Mxx_ru version is: ' + MXX_RU_VERSION
|
36
|
+
#
|
37
|
+
MXX_RU_VERSION = '1.4.0'
|
38
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'mxx_ru/generators/impl/cpp/generation'
|
4
|
+
|
5
|
+
class TC_GeneratorsCppTemplateParams < Test::Unit::TestCase
|
6
|
+
MODULE = MxxRu::Generators::Impl::Cpp
|
7
|
+
|
8
|
+
class TestReceiver
|
9
|
+
attr_reader :result
|
10
|
+
|
11
|
+
def receive( generation_result, output_file_name )
|
12
|
+
@result = generation_result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_empty_args
|
17
|
+
r = TestReceiver.new
|
18
|
+
assert_nothing_raised do
|
19
|
+
MODULE.generate_for( MODULE::EXE, [], r )
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_implib_path_defined
|
24
|
+
r = TestReceiver.new
|
25
|
+
path = 'lib'
|
26
|
+
|
27
|
+
assert_nothing_raised do
|
28
|
+
MODULE.generate_for( MODULE::EXE, ['--implib-path', path], r )
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_equal( true, r.result.include?( "implib_path '#{path}'" ) )
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'mxx_ru/generators/impl/cpp/generation'
|
4
|
+
|
5
|
+
class TC_GeneratorsCpp < Test::Unit::TestCase
|
6
|
+
MODULE = MxxRu::Generators::Impl::Cpp
|
7
|
+
|
8
|
+
def test_empty_args
|
9
|
+
# All values expected to be nil.
|
10
|
+
|
11
|
+
result = MODULE::Options.parse( [], 'dummy banner', {} )
|
12
|
+
|
13
|
+
assert_nil( result.target_name )
|
14
|
+
assert_nil( result.project_path )
|
15
|
+
assert_nil( result.implib_path )
|
16
|
+
assert_nil( result.output_file )
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_target_name
|
20
|
+
result = MODULE::Options.parse(
|
21
|
+
%w{-t some_target_name},
|
22
|
+
'',
|
23
|
+
{} )
|
24
|
+
|
25
|
+
assert_equal( 'some_target_name', result.target_name )
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_target_name_and_project_path
|
29
|
+
result1 = MODULE::Options.parse(
|
30
|
+
%w{some/path --target some_target},
|
31
|
+
'',
|
32
|
+
{} )
|
33
|
+
|
34
|
+
assert_equal( 'some/path', result1.project_path )
|
35
|
+
assert_equal( 'some_target', result1.target_name )
|
36
|
+
|
37
|
+
result2 = MODULE::Options.parse(
|
38
|
+
%w{--target another_target another/path},
|
39
|
+
'',
|
40
|
+
{} )
|
41
|
+
|
42
|
+
assert_equal( 'another/path', result2.project_path )
|
43
|
+
assert_equal( 'another_target', result2.target_name )
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_output_file
|
47
|
+
result = MODULE::Options.parse(
|
48
|
+
%w{some/path -t some_target -o out.rb},
|
49
|
+
'',
|
50
|
+
{} )
|
51
|
+
|
52
|
+
assert_equal( 'some/path', result.project_path )
|
53
|
+
assert_equal( 'some_target', result.target_name )
|
54
|
+
assert_equal( 'out.rb', result.output_file )
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_implib_path_disabled
|
58
|
+
assert_raise( OptionParser::InvalidOption ) do
|
59
|
+
result = MODULE::Options.parse(
|
60
|
+
%w{--implib-path lib}, '', {} )
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_raise( OptionParser::InvalidOption ) do
|
64
|
+
result = MODULE::Options.parse(
|
65
|
+
%w{--implib-path lib}, '', { :implib_path => false } )
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_implib_path_enabled
|
70
|
+
result = nil
|
71
|
+
assert_nothing_raised( OptionParser::InvalidOption ) do
|
72
|
+
result = MODULE::Options.parse(
|
73
|
+
%w{--implib-path lib}, '', { :implib_path => true } )
|
74
|
+
|
75
|
+
assert_equal( 'lib', result.implib_path )
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'mxx_ru/generators/impl/cpp/generation'
|
4
|
+
|
5
|
+
class TC_GeneratorsCppTemplateParams < Test::Unit::TestCase
|
6
|
+
MODULE = MxxRu::Generators::Impl::Cpp
|
7
|
+
|
8
|
+
def test_empty_options
|
9
|
+
t1 = MODULE::TemplateParams.new( MODULE::LIB, MODULE::Options.new )
|
10
|
+
assert_equal( 'lib_target', t1.setup_target_function )
|
11
|
+
assert_equal( false, t1.has_or_require_implib )
|
12
|
+
assert_equal( MODULE::TemplateParams::YOUR_TARGET_NAME, t1.target_name )
|
13
|
+
|
14
|
+
t2 = MODULE::TemplateParams.new( MODULE::DLL, MODULE::Options.new )
|
15
|
+
assert_equal( 'dll_target', t2.setup_target_function )
|
16
|
+
assert_equal( true, t2.has_or_require_implib )
|
17
|
+
assert_equal( MODULE::TemplateParams::YOUR_IMPLIB_PATH, t2.implib_path )
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_target_name_in_options
|
21
|
+
o = MODULE::Options.new
|
22
|
+
o.target_name = 'my.target'
|
23
|
+
o.project_path = 'some/path'
|
24
|
+
t = MODULE::TemplateParams.new( MODULE::LIB, o )
|
25
|
+
|
26
|
+
assert_equal( o.target_name, t.target_name )
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_project_path_in_options
|
30
|
+
o = MODULE::Options.new
|
31
|
+
o.project_path = 'some/path\for/target'
|
32
|
+
t = MODULE::TemplateParams.new( MODULE::LIB, o )
|
33
|
+
|
34
|
+
assert_equal( 'some.path.for.target', t.target_name )
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_implib_path_in_options
|
38
|
+
o = MODULE::Options.new
|
39
|
+
o.implib_path = 'some/path'
|
40
|
+
t = MODULE::TemplateParams.new( MODULE::EXE, o )
|
41
|
+
|
42
|
+
assert_equal( o.implib_path, t.implib_path )
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|