Mxx_ru 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/THANKS +1 -1
- data/lib/mxx_ru/cpp/rucodegen.rb +3 -1
- data/lib/mxx_ru/cpp/target.rb +12 -1
- data/lib/mxx_ru/cpp/toolset.rb +49 -23
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +10 -10
- data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +9 -9
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +14 -14
- data/lib/mxx_ru/cpp/toolsets/vc_family.rb +10 -10
- data/lib/mxx_ru/generators/cpp-build-root/g.rb +173 -0
- data/lib/mxx_ru/generators/cpp-build-root/template.erb +15 -0
- data/lib/mxx_ru/version.rb +2 -2
- data/tests/cpp/custom_target_prefix/dll.cpp +8 -0
- data/tests/cpp/custom_target_prefix/dll.rb +13 -0
- data/tests/cpp/custom_target_prefix/tc_custom_target_prefix.rb +22 -0
- metadata +26 -2
data/THANKS
CHANGED
data/lib/mxx_ru/cpp/rucodegen.rb
CHANGED
@@ -127,10 +127,12 @@ class RuCodeGen < AbstractGenerator
|
|
127
127
|
alias_method :add, :<<
|
128
128
|
|
129
129
|
# Adding a name of next embeded code generation script.
|
130
|
-
def
|
130
|
+
def add_embedded( script )
|
131
131
|
@scripts << Embedded.new( @target.create_full_src_file_name( script ) )
|
132
132
|
end
|
133
133
|
|
134
|
+
alias_method :add_embeded, :add_embedded
|
135
|
+
|
134
136
|
# Perform code generation.
|
135
137
|
def build( target )
|
136
138
|
@scripts.each do |s|
|
data/lib/mxx_ru/cpp/target.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -457,6 +457,11 @@ module MxxRu
|
|
457
457
|
# Otherwise the value of mxx_target_root is concatenated with a given
|
458
458
|
# target name.
|
459
459
|
attr_reader :mxx_target_root
|
460
|
+
# Custom prefix for target.
|
461
|
+
# NIL, if custom prefix not defined.
|
462
|
+
#
|
463
|
+
# Since v.1.4.2
|
464
|
+
attr_reader :mxx_target_prefix
|
460
465
|
# Custom extension for target.
|
461
466
|
# NIL, if custom extension not defined.
|
462
467
|
attr_reader :mxx_target_ext
|
@@ -743,10 +748,16 @@ module MxxRu
|
|
743
748
|
@mxx_target_name = create_full_target_file_name( a_target )
|
744
749
|
end
|
745
750
|
|
751
|
+
# Set a custom prefix for target.
|
752
|
+
def target_prefix( ext )
|
753
|
+
@mxx_target_prefix = ext
|
754
|
+
end
|
755
|
+
|
746
756
|
# Set a custom extension for target.
|
747
757
|
def target_ext( ext )
|
748
758
|
@mxx_target_ext = ext
|
749
759
|
end
|
760
|
+
alias_method :target_suffix, :target_ext
|
750
761
|
|
751
762
|
# Change source files path.
|
752
763
|
# If empty string is set, then full file names are required.
|
data/lib/mxx_ru/cpp/toolset.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -267,7 +267,7 @@ module MxxRu
|
|
267
267
|
# There are possible situations where non-standard tool must be run
|
268
268
|
# instead of standard one. For example, a patched compiler that has name
|
269
269
|
# 'gcc-patched' instead of 'gcc'. It isn't appropriate to create new
|
270
|
-
# toolset for this. More easy to set
|
270
|
+
# toolset for this. More easy to set the name of a custom tool in
|
271
271
|
# MXX_RU_CPP_TOOLSET environment variable:
|
272
272
|
#
|
273
273
|
# export MXX_RU_CPP_TOOLSET=gcc_linux compiler_name=gcc-patched
|
@@ -788,7 +788,7 @@ module MxxRu
|
|
788
788
|
#
|
789
789
|
# AbstractMethodEx exception is thrown in a base class.
|
790
790
|
#
|
791
|
-
def lib_file_name( source_name )
|
791
|
+
def lib_file_name( source_name, target )
|
792
792
|
raise AbstractMethodEx.new(
|
793
793
|
"MxxRu::Cpp::Toolset::lib_file_name" )
|
794
794
|
end
|
@@ -797,7 +797,7 @@ module MxxRu
|
|
797
797
|
#
|
798
798
|
# AbstractMethodEx exception is thrown in a base class.
|
799
799
|
#
|
800
|
-
def lib_link_name( source_name )
|
800
|
+
def lib_link_name( source_name, target )
|
801
801
|
raise AbstractMethodEx.new(
|
802
802
|
"MxxRu::Cpp::Toolset::lib_link_name" )
|
803
803
|
end
|
@@ -826,7 +826,7 @@ module MxxRu
|
|
826
826
|
#
|
827
827
|
# AbstractMethodEx exception is thrown in a base class.
|
828
828
|
#
|
829
|
-
def dll_file_name( source_name )
|
829
|
+
def dll_file_name( source_name, target )
|
830
830
|
raise AbstractMethodEx.new(
|
831
831
|
"MxxRu::Cpp::Toolset::dll_file_name" )
|
832
832
|
end
|
@@ -909,7 +909,7 @@ module MxxRu
|
|
909
909
|
#
|
910
910
|
# AbstractMethodEx exception is thrown in a base class.
|
911
911
|
#
|
912
|
-
def exe_file_name( source_name )
|
912
|
+
def exe_file_name( source_name, target )
|
913
913
|
raise AbstractMethodEx.new(
|
914
914
|
"MxxRu::Cpp::Toolset::exe_file_name" )
|
915
915
|
end
|
@@ -1043,10 +1043,8 @@ module MxxRu
|
|
1043
1043
|
source_name = File::basename( lib_name )
|
1044
1044
|
source_path = File::dirname( lib_name )
|
1045
1045
|
|
1046
|
-
real_name =
|
1047
|
-
|
1048
|
-
target )
|
1049
|
-
link_name = lib_link_name( source_name )
|
1046
|
+
real_name = lib_file_name( source_name, target )
|
1047
|
+
link_name = lib_link_name( source_name, target )
|
1050
1048
|
dest_path = target.mxx_obj_placement.get_lib(
|
1051
1049
|
source_path, self, target )
|
1052
1050
|
|
@@ -1060,9 +1058,7 @@ module MxxRu
|
|
1060
1058
|
source_name = File::basename( dll_name )
|
1061
1059
|
source_path = File::dirname( dll_name )
|
1062
1060
|
|
1063
|
-
dll_real_name =
|
1064
|
-
dll_file_name( source_name ),
|
1065
|
-
target )
|
1061
|
+
dll_real_name = dll_file_name( source_name, target )
|
1066
1062
|
dll_dest_path = target.mxx_obj_placement.get_dll(
|
1067
1063
|
source_path, self, target )
|
1068
1064
|
|
@@ -1083,9 +1079,7 @@ module MxxRu
|
|
1083
1079
|
source_name = File::basename( exe_name )
|
1084
1080
|
source_path = File::dirname( exe_name )
|
1085
1081
|
|
1086
|
-
real_name =
|
1087
|
-
exe_file_name( source_name ),
|
1088
|
-
target )
|
1082
|
+
real_name = exe_file_name( source_name, target )
|
1089
1083
|
dest_path = target.mxx_obj_placement.get_exe(
|
1090
1084
|
source_path, self, target )
|
1091
1085
|
|
@@ -1139,14 +1133,46 @@ module MxxRu
|
|
1139
1133
|
end
|
1140
1134
|
|
1141
1135
|
protected
|
1142
|
-
#
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1136
|
+
# There isn't a prefix for target name
|
1137
|
+
#
|
1138
|
+
# Since v.1.4.2
|
1139
|
+
NO_PREFIX = nil
|
1140
|
+
|
1141
|
+
# There isn't a suffix for target name
|
1142
|
+
#
|
1143
|
+
# Since v.1.4.2
|
1144
|
+
NO_SUFFIX = nil
|
1148
1145
|
|
1149
|
-
|
1146
|
+
# Helper method for creating name of target with consideration
|
1147
|
+
# of target's custom prefix and/or suffix.
|
1148
|
+
#
|
1149
|
+
# Should be used in derived classes. Example of usage:
|
1150
|
+
#
|
1151
|
+
# # For GCC family on Unix.
|
1152
|
+
# def lib_file_name( source_name, target )
|
1153
|
+
# construct_target_name( source_name, 'lib', '.a', target )
|
1154
|
+
# end
|
1155
|
+
# # For Visual C++ family on Windows.
|
1156
|
+
# def lib_file_name( source_name, target )
|
1157
|
+
# construct_target_name( source_name, NO_PREFIX, '.lib', target )
|
1158
|
+
# end
|
1159
|
+
#
|
1160
|
+
# Since v.1.4.2
|
1161
|
+
#
|
1162
|
+
def construct_target_name(
|
1163
|
+
# Base name for target name construction.
|
1164
|
+
source_name,
|
1165
|
+
# Default prefix for target. nil if there isn't such prefix.
|
1166
|
+
default_prefix,
|
1167
|
+
# Default suffix for target. nil if there isn't such suffix.
|
1168
|
+
default_suffix,
|
1169
|
+
# Target for which resulting name is being constructed.
|
1170
|
+
target )
|
1171
|
+
p = target.mxx_target_prefix
|
1172
|
+
p = ( default_prefix.nil? ? '' : default_prefix ) unless p
|
1173
|
+
s = target.mxx_target_ext
|
1174
|
+
s = ( default_suffix.nil? ? '' : default_suffix ) unless s
|
1175
|
+
p + source_name + s
|
1150
1176
|
end
|
1151
1177
|
|
1152
1178
|
end # class Toolset
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -244,13 +244,13 @@ module MxxRu
|
|
244
244
|
end
|
245
245
|
|
246
246
|
# See description at MxxRu::Cpp::Toolset#lib_file_name.
|
247
|
-
def lib_file_name( source_name )
|
248
|
-
return source_name
|
247
|
+
def lib_file_name( source_name, target )
|
248
|
+
return construct_target_name( source_name, NO_PREFIX, ".lib", target )
|
249
249
|
end
|
250
250
|
|
251
251
|
# See description at MxxRu::Cpp::Toolset#lib_link_name.
|
252
|
-
def lib_link_name( source_name )
|
253
|
-
return lib_file_name( source_name )
|
252
|
+
def lib_link_name( source_name, target )
|
253
|
+
return lib_file_name( source_name, target )
|
254
254
|
end
|
255
255
|
|
256
256
|
# See description at MxxRu::Cpp::Toolset#make_lib_command_lines.
|
@@ -274,8 +274,8 @@ module MxxRu
|
|
274
274
|
end
|
275
275
|
|
276
276
|
# See description at MxxRu::Cpp::Toolset#dll_file_name.
|
277
|
-
def dll_file_name( source_name )
|
278
|
-
return source_name
|
277
|
+
def dll_file_name( source_name, target )
|
278
|
+
return construct_target_name( source_name, NO_PREFIX, ".dll", target )
|
279
279
|
end
|
280
280
|
|
281
281
|
# See description at MxxRu::Cpp::Toolset#implib_link_name.
|
@@ -285,7 +285,7 @@ module MxxRu
|
|
285
285
|
|
286
286
|
# Import library name should be defined explicitly for Visual C++
|
287
287
|
if nil != target.mxx_implib_path
|
288
|
-
return lib_file_name( target.mxx_target_name )
|
288
|
+
return lib_file_name( target.mxx_target_name, target )
|
289
289
|
end
|
290
290
|
|
291
291
|
return nil
|
@@ -351,8 +351,8 @@ module MxxRu
|
|
351
351
|
end
|
352
352
|
|
353
353
|
# See description at MxxRu::Cpp::Toolset#exe_file_name.
|
354
|
-
def exe_file_name( source_name )
|
355
|
-
return source_name
|
354
|
+
def exe_file_name( source_name, target )
|
355
|
+
return construct_target_name( source_name, NO_PREFIX, ".exe", target )
|
356
356
|
end
|
357
357
|
|
358
358
|
# See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -145,12 +145,12 @@ module MxxRu
|
|
145
145
|
end
|
146
146
|
|
147
147
|
# See description at MxxRu::Cpp::Toolset#lib_file_name.
|
148
|
-
def lib_file_name( source_name )
|
149
|
-
return "lib"
|
148
|
+
def lib_file_name( source_name, target )
|
149
|
+
return construct_target_name( source_name, "lib", ".a", target )
|
150
150
|
end
|
151
151
|
|
152
152
|
# See description at MxxRu::Cpp::Toolset#lib_link_name.
|
153
|
-
def lib_link_name( source_name )
|
153
|
+
def lib_link_name( source_name, target )
|
154
154
|
return source_name
|
155
155
|
end
|
156
156
|
|
@@ -168,8 +168,8 @@ module MxxRu
|
|
168
168
|
end
|
169
169
|
|
170
170
|
# See description at MxxRu::Cpp::Toolset#dll_file_name.
|
171
|
-
def dll_file_name( source_name )
|
172
|
-
return
|
171
|
+
def dll_file_name( source_name, target )
|
172
|
+
return construct_target_name( source_name, 'lib', '.so', target )
|
173
173
|
end
|
174
174
|
|
175
175
|
# See description at MxxRu::Cpp::Toolset#implib_link_name.
|
@@ -179,7 +179,7 @@ module MxxRu
|
|
179
179
|
|
180
180
|
# Target name should be passed to linker on UNIX platform
|
181
181
|
return lib_link_name(
|
182
|
-
File.basename( target.mxx_target_name ) )
|
182
|
+
File.basename( target.mxx_target_name ), target )
|
183
183
|
end
|
184
184
|
|
185
185
|
# See description at MxxRu::Cpp::Toolset#implib_link_path.
|
@@ -240,8 +240,8 @@ module MxxRu
|
|
240
240
|
end
|
241
241
|
|
242
242
|
# See description at MxxRu::Cpp::Toolset#exe_file_name.
|
243
|
-
def exe_file_name( source_name )
|
244
|
-
return source_name
|
243
|
+
def exe_file_name( source_name, target )
|
244
|
+
return construct_target_name( source_name, NO_PREFIX, NO_SUFFIX, target )
|
245
245
|
end
|
246
246
|
|
247
247
|
# See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -146,12 +146,12 @@ module MxxRu
|
|
146
146
|
end
|
147
147
|
|
148
148
|
# See description at MxxRu::Cpp::Toolset#lib_file_name.
|
149
|
-
def lib_file_name( source_name )
|
150
|
-
return
|
149
|
+
def lib_file_name( source_name, target )
|
150
|
+
return construct_target_name( source_name, 'lib', '.a', target )
|
151
151
|
end
|
152
152
|
|
153
153
|
# See description at MxxRu::Cpp::Toolset#lib_link_name.
|
154
|
-
def lib_link_name( source_name )
|
154
|
+
def lib_link_name( source_name, target )
|
155
155
|
return source_name
|
156
156
|
end
|
157
157
|
|
@@ -169,8 +169,8 @@ module MxxRu
|
|
169
169
|
end
|
170
170
|
|
171
171
|
# See description at MxxRu::Cpp::Toolset#dll_file_name.
|
172
|
-
def dll_file_name( source_name )
|
173
|
-
return
|
172
|
+
def dll_file_name( source_name, target )
|
173
|
+
return construct_target_name( source_name, 'lib', '.so', target )
|
174
174
|
end
|
175
175
|
|
176
176
|
# See description at MxxRu::Cpp::Toolset#implib_link_name.
|
@@ -180,7 +180,7 @@ module MxxRu
|
|
180
180
|
|
181
181
|
# Target name should be passed to linker on UNIX platform
|
182
182
|
return lib_link_name(
|
183
|
-
File.basename( target.mxx_target_name ) )
|
183
|
+
File.basename( target.mxx_target_name ), target )
|
184
184
|
end
|
185
185
|
|
186
186
|
# See description at MxxRu::Cpp::Toolset#implib_link_path.
|
@@ -244,8 +244,8 @@ module MxxRu
|
|
244
244
|
end
|
245
245
|
|
246
246
|
# See description at MxxRu::Cpp::Toolset#exe_file_name.
|
247
|
-
def exe_file_name( source_name )
|
248
|
-
return source_name
|
247
|
+
def exe_file_name( source_name, target )
|
248
|
+
return construct_target_name( source_name, NO_PREFIX, NO_SUFFIX, target )
|
249
249
|
end
|
250
250
|
|
251
251
|
# See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
|
@@ -318,8 +318,8 @@ module MxxRu
|
|
318
318
|
public
|
319
319
|
|
320
320
|
# See description at MxxRu::Cpp::Toolset#exe_file_name.
|
321
|
-
def exe_file_name( source_name )
|
322
|
-
return source_name
|
321
|
+
def exe_file_name( source_name, target )
|
322
|
+
return construct_target_name( source_name, NO_PREFIX, ".exe", target )
|
323
323
|
end
|
324
324
|
|
325
325
|
# See description at MxxRu::Cpp::Toolset#clean_dll_specific_files.
|
@@ -333,7 +333,7 @@ module MxxRu
|
|
333
333
|
# Delete import library if exists.
|
334
334
|
if nil != a_dll_info.link_name
|
335
335
|
implib_name = File.join( [ a_dll_info.link_path,
|
336
|
-
lib_file_name( a_dll_info.link_name ) ] )
|
336
|
+
lib_file_name( a_dll_info.link_name, a_target ) ] )
|
337
337
|
MxxRu::Util::delete_file( implib_name )
|
338
338
|
end
|
339
339
|
end
|
@@ -345,7 +345,7 @@ module MxxRu
|
|
345
345
|
|
346
346
|
# It's required to pass import library name to linker on mswin platform
|
347
347
|
if nil != target.mxx_implib_path
|
348
|
-
return lib_link_name( target.mxx_target_name )
|
348
|
+
return lib_link_name( target.mxx_target_name, target )
|
349
349
|
end
|
350
350
|
|
351
351
|
return nil
|
@@ -388,7 +388,7 @@ module MxxRu
|
|
388
388
|
# Build import library if it's required.
|
389
389
|
if nil != a_dll_info.link_name
|
390
390
|
full_lib_name = File.join( [ a_dll_info.link_path,
|
391
|
-
lib_file_name( a_dll_info.link_name ) ] )
|
391
|
+
lib_file_name( a_dll_info.link_name, a_target ) ] )
|
392
392
|
|
393
393
|
return "-Wl,--out-implib=#{full_lib_name}" +
|
394
394
|
",--export-all-symbols"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -244,13 +244,13 @@ module MxxRu
|
|
244
244
|
end
|
245
245
|
|
246
246
|
# See description at MxxRu::Cpp::Toolset#lib_file_name.
|
247
|
-
def lib_file_name( source_name )
|
248
|
-
return source_name
|
247
|
+
def lib_file_name( source_name, target )
|
248
|
+
return construct_target_name( source_name, NO_PREFIX, '.lib', target )
|
249
249
|
end
|
250
250
|
|
251
251
|
# See description at MxxRu::Cpp::Toolset#lib_link_name.
|
252
|
-
def lib_link_name( source_name )
|
253
|
-
return lib_file_name( source_name )
|
252
|
+
def lib_link_name( source_name, target )
|
253
|
+
return lib_file_name( source_name, target )
|
254
254
|
end
|
255
255
|
|
256
256
|
# See description at MxxRu::Cpp::Toolset#make_lib_command_lines.
|
@@ -268,8 +268,8 @@ module MxxRu
|
|
268
268
|
end
|
269
269
|
|
270
270
|
# See description at MxxRu::Cpp::Toolset#dll_file_name.
|
271
|
-
def dll_file_name( source_name )
|
272
|
-
return source_name
|
271
|
+
def dll_file_name( source_name, target )
|
272
|
+
return construct_target_name( source_name, NO_PREFIX, ".dll", target )
|
273
273
|
end
|
274
274
|
|
275
275
|
# See description at MxxRu::Cpp::Toolset#implib_link_name.
|
@@ -279,7 +279,7 @@ module MxxRu
|
|
279
279
|
|
280
280
|
# Import library should be defined explicitly for Visual C++.
|
281
281
|
if nil != target.mxx_implib_path
|
282
|
-
return lib_file_name( target.mxx_target_name )
|
282
|
+
return lib_file_name( target.mxx_target_name, target )
|
283
283
|
end
|
284
284
|
|
285
285
|
return nil
|
@@ -348,8 +348,8 @@ module MxxRu
|
|
348
348
|
end
|
349
349
|
|
350
350
|
# See description at MxxRu::Cpp::Toolset#exe_file_name.
|
351
|
-
def exe_file_name( source_name )
|
352
|
-
return source_name
|
351
|
+
def exe_file_name( source_name, target )
|
352
|
+
return construct_target_name( source_name, NO_PREFIX, ".exe", target )
|
353
353
|
end
|
354
354
|
|
355
355
|
# See description at MxxRu::Cpp::Toolset#make_exe_command_lines.
|
@@ -0,0 +1,173 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
|
+
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
+
# Copyright (c) 2006-2008, 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
|
+
# Since v.1.4.2
|
30
|
+
#
|
31
|
+
# Implementation of project's stabs generation for C++ build.rb root project file.
|
32
|
+
|
33
|
+
require 'erb'
|
34
|
+
require 'optparse'
|
35
|
+
|
36
|
+
require 'mxx_ru/generators/impl/std_receiver'
|
37
|
+
|
38
|
+
module MxxRu
|
39
|
+
|
40
|
+
module Generators
|
41
|
+
|
42
|
+
module CppBuildRoot
|
43
|
+
|
44
|
+
# Class for storing command-line arguments as options.
|
45
|
+
#
|
46
|
+
# Usage:
|
47
|
+
# options = Options.parse( args, banner )
|
48
|
+
#
|
49
|
+
class Options
|
50
|
+
# Name of output file (-o, --output-file). nil if missing.
|
51
|
+
attr_accessor :output_file
|
52
|
+
|
53
|
+
# Parsing command-line arguments and returning Options instance.
|
54
|
+
#
|
55
|
+
# Calls exit(1) if --help present in _args_.
|
56
|
+
#
|
57
|
+
def Options.parse( args, banner )
|
58
|
+
parser = OptionParser.new
|
59
|
+
|
60
|
+
result = Options.new
|
61
|
+
|
62
|
+
parser.banner = banner
|
63
|
+
|
64
|
+
parser.on( '-o', '--output-file FILE', 'Output file name' ) do |p|
|
65
|
+
result.output_file = p
|
66
|
+
end
|
67
|
+
|
68
|
+
parser.on_tail( '-h', '--help', 'Show this message' ) do
|
69
|
+
puts parser
|
70
|
+
exit(1)
|
71
|
+
end
|
72
|
+
|
73
|
+
parser.parse!( args )
|
74
|
+
result
|
75
|
+
end
|
76
|
+
end # class Options
|
77
|
+
|
78
|
+
# Class to be used in ERb template generation.
|
79
|
+
#
|
80
|
+
# Usage:
|
81
|
+
# template_params = TemplateParams.new( target_type, options )
|
82
|
+
# template = ERb.new( IO.read( some_template_file ) )
|
83
|
+
# result = template.generate( template.get_binding )
|
84
|
+
#
|
85
|
+
class TemplateParams
|
86
|
+
# For a case when output_file is undetectable.
|
87
|
+
DEFAULT_BUILD_ROOT = 'build.rb'
|
88
|
+
|
89
|
+
# Name of build root file.
|
90
|
+
attr_reader :build_root_project
|
91
|
+
|
92
|
+
# Param target_type must be present in @@setup_target_functions.
|
93
|
+
def initialize( options )
|
94
|
+
@build_root_project = try_detect_build_root_project( options )
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns binding to use in ERb generation.
|
98
|
+
def get_binding
|
99
|
+
binding
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
# Try to setup name of build root project file.
|
104
|
+
#
|
105
|
+
# If --output-file specified then its value used.
|
106
|
+
# Otherwise value 'build.rb' is used.
|
107
|
+
#
|
108
|
+
def try_detect_build_root_project( options )
|
109
|
+
options.output_file ?
|
110
|
+
File.basename( options.output_file ) :
|
111
|
+
DEFAULT_BUILD_ROOT
|
112
|
+
end
|
113
|
+
|
114
|
+
end # class TemplateParams
|
115
|
+
|
116
|
+
# Main class for code generation of binary unit test projects.
|
117
|
+
#
|
118
|
+
# Usage:
|
119
|
+
# receiver = StdReceiver.new
|
120
|
+
# generator = Generator.new( args, receiver )
|
121
|
+
# generator.run
|
122
|
+
#
|
123
|
+
class Generator
|
124
|
+
def initialize( args, receiver )
|
125
|
+
@args = args
|
126
|
+
@receiver = receiver
|
127
|
+
end
|
128
|
+
|
129
|
+
def run
|
130
|
+
options = Options.parse( @args,
|
131
|
+
"Stubs for C++ build root file generator\n\n" +
|
132
|
+
"Usage:\n" +
|
133
|
+
"mxxrugen [<mxxrugen-options>] cpp-build-root [<options>]\n\n" )
|
134
|
+
result = do_generation( options )
|
135
|
+
@receiver.receive( result, options.output_file )
|
136
|
+
end
|
137
|
+
|
138
|
+
private
|
139
|
+
# Performs main generation actions.
|
140
|
+
#
|
141
|
+
# Returns generation result as String.
|
142
|
+
def do_generation( options )
|
143
|
+
template = IO.read( File.join( File.dirname( __FILE__ ), 'template.erb' ) )
|
144
|
+
generator = ERB.new( template )
|
145
|
+
|
146
|
+
params = TemplateParams.new( options )
|
147
|
+
generator.result( params.get_binding ).gsub( /\n\n\n+/, "\n\n" )
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Helper method for generation.
|
152
|
+
#
|
153
|
+
# Usage:
|
154
|
+
# # For using StdReceiver.
|
155
|
+
# generate_for( ARGV )
|
156
|
+
#
|
157
|
+
# # For using custom Receiver.
|
158
|
+
# generate_for( ARGV, CustomReceiver.new )
|
159
|
+
#
|
160
|
+
def CppBuildRoot.generate_for( args, receiver = nil )
|
161
|
+
generator = Generator.new( args,
|
162
|
+
receiver ? receiver : MxxRu::Generators::Impl::StdReceiver.new )
|
163
|
+
generator.run
|
164
|
+
end
|
165
|
+
|
166
|
+
end # module BinaryUnittest
|
167
|
+
|
168
|
+
end # module Generators
|
169
|
+
|
170
|
+
end # module MxxRu
|
171
|
+
|
172
|
+
MxxRu::Generators::CppBuildRoot::generate_for( ARGV )
|
173
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
gem 'Mxx_ru', '>= 1.3.0'
|
4
|
+
|
5
|
+
require 'mxx_ru/cpp'
|
6
|
+
|
7
|
+
MxxRu::Cpp::composite_target( MxxRu::BUILD_ROOT ) {
|
8
|
+
global_inclide_path '.'
|
9
|
+
default_runtime_mode MxxRu::Cpp::RUNTIME_RELEASE
|
10
|
+
MxxRu::enable_show_brief
|
11
|
+
|
12
|
+
# Include your projects here:
|
13
|
+
# require_prj 'your-project.rb'
|
14
|
+
}
|
15
|
+
|
data/lib/mxx_ru/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 1996-2004, Yauheni Akhotnikau
|
3
3
|
# Copyright (c) 2004-2006, JSC Intervale
|
4
|
-
# Copyright (c) 2006, The Mxx_ru Project
|
4
|
+
# Copyright (c) 2006-2008, The Mxx_ru Project
|
5
5
|
# All rights reserved.
|
6
6
|
#
|
7
7
|
# Redistribution and use in source and binary forms, with or without modification,
|
@@ -34,5 +34,5 @@
|
|
34
34
|
#
|
35
35
|
# puts 'Mxx_ru version is: ' + MXX_RU_VERSION
|
36
36
|
#
|
37
|
-
MXX_RU_VERSION = '1.4.
|
37
|
+
MXX_RU_VERSION = '1.4.2'
|
38
38
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname( __FILE__ ) + '/../../test_with_compilation'
|
4
|
+
|
5
|
+
class TC_CustomTargetPrefix < Test::Unit::TestCase
|
6
|
+
include TestWithCompilation
|
7
|
+
|
8
|
+
EXPECTED_NAME = 'p-dll.s'
|
9
|
+
|
10
|
+
test_path 'tests/cpp/custom_target_prefix'
|
11
|
+
|
12
|
+
test_case :build_and_clean do
|
13
|
+
build( 'dll.rb' )
|
14
|
+
|
15
|
+
assert( File.exists?( EXPECTED_NAME ),
|
16
|
+
"Expected name is '#{EXPECTED_NAME}'" )
|
17
|
+
|
18
|
+
clean( 'dll.rb' )
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: Mxx_ru
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.4.
|
7
|
-
date:
|
6
|
+
version: 1.4.2
|
7
|
+
date: 2008-02-15 00:00:00 +03:00
|
8
8
|
summary: Mxx_ru (Make++ on Ruby) is a cross-platform build tool
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -58,16 +58,25 @@ files:
|
|
58
58
|
- tests/cpp/cpp_sources_glob/some/module
|
59
59
|
- tests/cpp/cpp_sources_glob/some/module/1
|
60
60
|
- tests/cpp/cpp_sources_glob/some/module/1/f1.cpp
|
61
|
+
- tests/cpp/cpp_sources_glob/some/module/1/o
|
61
62
|
- tests/cpp/cpp_sources_glob/some/module/2
|
62
63
|
- tests/cpp/cpp_sources_glob/some/module/2/f2.cpp
|
64
|
+
- tests/cpp/cpp_sources_glob/some/module/2/o
|
63
65
|
- tests/cpp/cpp_sources_glob/some/module/3
|
64
66
|
- tests/cpp/cpp_sources_glob/some/module/3/f3.cpp
|
67
|
+
- tests/cpp/cpp_sources_glob/some/module/3/o
|
65
68
|
- tests/cpp/cpp_sources_glob/some/module/4
|
66
69
|
- tests/cpp/cpp_sources_glob/some/module/4/f4.cpp
|
70
|
+
- tests/cpp/cpp_sources_glob/some/module/4/o
|
67
71
|
- tests/cpp/cpp_sources_glob/some/module/funcs.hpp
|
68
72
|
- tests/cpp/cpp_sources_glob/some/module/main.cpp
|
73
|
+
- tests/cpp/cpp_sources_glob/some/module/o
|
69
74
|
- tests/cpp/cpp_sources_glob/some/module/prj.rb
|
70
75
|
- tests/cpp/cpp_sources_glob/tc_cpp_sources_glob.rb
|
76
|
+
- tests/cpp/custom_target_prefix
|
77
|
+
- tests/cpp/custom_target_prefix/dll.cpp
|
78
|
+
- tests/cpp/custom_target_prefix/dll.rb
|
79
|
+
- tests/cpp/custom_target_prefix/tc_custom_target_prefix.rb
|
71
80
|
- tests/cpp/mswin_res_dll
|
72
81
|
- tests/cpp/mswin_res_dll/build.rb
|
73
82
|
- tests/cpp/mswin_res_dll/dll.cpp
|
@@ -96,6 +105,7 @@ files:
|
|
96
105
|
- tests/cpp/mswin_res_exe/src
|
97
106
|
- tests/cpp/mswin_res_exe/src/main.cpp
|
98
107
|
- tests/cpp/mswin_res_exe/src/main.rc
|
108
|
+
- tests/cpp/mswin_res_exe/src/o
|
99
109
|
- tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb
|
100
110
|
- tests/cpp/o
|
101
111
|
- tests/cpp/rucodegen
|
@@ -204,6 +214,7 @@ files:
|
|
204
214
|
- tests/mxx_ru/lib_collection/i.rb
|
205
215
|
- tests/mxx_ru/lib_collection/main.cpp
|
206
216
|
- tests/mxx_ru/lib_collection/main.rb
|
217
|
+
- tests/mxx_ru/lib_collection/o
|
207
218
|
- tests/mxx_ru/lib_collection/tc_lib_collection.rb
|
208
219
|
- tests/mxx_ru/lib_path
|
209
220
|
- tests/mxx_ru/lib_path/build.rb
|
@@ -215,6 +226,7 @@ files:
|
|
215
226
|
- tests/mxx_ru/lib_path/hi_lib
|
216
227
|
- tests/mxx_ru/lib_path/main.c
|
217
228
|
- tests/mxx_ru/lib_path/main.rb
|
229
|
+
- tests/mxx_ru/lib_path/o
|
218
230
|
- tests/mxx_ru/lib_path/tc_lib_path.rb
|
219
231
|
- tests/mxx_ru/obj_placements
|
220
232
|
- tests/mxx_ru/obj_placements/tc_custom_subdir.rb
|
@@ -224,6 +236,7 @@ files:
|
|
224
236
|
- tests/mxx_ru/opt_lib_ext/hi.h
|
225
237
|
- tests/mxx_ru/opt_lib_ext/hi.rb
|
226
238
|
- tests/mxx_ru/opt_lib_ext/main.c
|
239
|
+
- tests/mxx_ru/opt_lib_ext/o
|
227
240
|
- tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb
|
228
241
|
- tests/mxx_ru/opt_lib_ext/test-no-ext.rb
|
229
242
|
- tests/mxx_ru/opt_lib_ext/test-with-ext.rb
|
@@ -235,6 +248,7 @@ files:
|
|
235
248
|
- tests/mxx_ru/target_ext/dll_hi.cpp
|
236
249
|
- tests/mxx_ru/target_ext/exe_hi.cpp
|
237
250
|
- tests/mxx_ru/target_ext/lib_hi.cpp
|
251
|
+
- tests/mxx_ru/target_ext/o
|
238
252
|
- tests/mxx_ru/target_ext/prj_dll.rb
|
239
253
|
- tests/mxx_ru/target_ext/prj_exe.rb
|
240
254
|
- tests/mxx_ru/target_ext/prj_lib.rb
|
@@ -353,6 +367,9 @@ files:
|
|
353
367
|
- lib/mxx_ru/generators/bin-unittest
|
354
368
|
- lib/mxx_ru/generators/bin-unittest/g.rb
|
355
369
|
- lib/mxx_ru/generators/bin-unittest/template.erb
|
370
|
+
- lib/mxx_ru/generators/cpp-build-root
|
371
|
+
- lib/mxx_ru/generators/cpp-build-root/g.rb
|
372
|
+
- lib/mxx_ru/generators/cpp-build-root/template.erb
|
356
373
|
- lib/mxx_ru/generators/cpp-composite
|
357
374
|
- lib/mxx_ru/generators/cpp-composite/g.rb
|
358
375
|
- lib/mxx_ru/generators/cpp-dll
|
@@ -388,6 +405,8 @@ files:
|
|
388
405
|
- examples/exe_dll_lib/say.hpp
|
389
406
|
- examples/exe_dll_lib/say.rb
|
390
407
|
- examples/exe_dll_lib_2
|
408
|
+
- examples/exe_dll_lib_2/bin
|
409
|
+
- examples/exe_dll_lib_2/bin/lib
|
391
410
|
- examples/exe_dll_lib_2/build.rb
|
392
411
|
- examples/exe_dll_lib_2/inout
|
393
412
|
- examples/exe_dll_lib_2/inout/inout.cpp
|
@@ -404,6 +423,11 @@ files:
|
|
404
423
|
- examples/exe_dll_lib_2/say/prj.rb
|
405
424
|
- examples/exe_dll_lib_2/say/say.cpp
|
406
425
|
- examples/exe_dll_lib_2/say/say.hpp
|
426
|
+
- examples/exe_dll_lib_2/tmp
|
427
|
+
- examples/exe_dll_lib_2/tmp/output
|
428
|
+
- examples/exe_dll_lib_2/tmp/output/inout
|
429
|
+
- examples/exe_dll_lib_2/tmp/output/main
|
430
|
+
- examples/exe_dll_lib_2/tmp/output/say
|
407
431
|
- examples/simple_exe
|
408
432
|
- examples/simple_exe/main.cpp
|
409
433
|
- examples/simple_exe/prj.rb
|