Mxx_ru 1.4.9 → 1.4.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -0
- data/lib/mxx_ru/cpp/target.rb +79 -7
- data/lib/mxx_ru/cpp/toolsets/gcc_darwin.rb +15 -0
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +3 -2
- data/lib/mxx_ru/version.rb +1 -1
- data/tests/cpp/lib_from_lib_dependecies/a.cpp +3 -3
- data/tests/darwin/bundle_target_type/my_test_bundle.c +5 -0
- data/tests/darwin/bundle_target_type/my_test_bundle.rb +6 -0
- data/tests/darwin/bundle_target_type/tc_normal_build.rb +15 -0
- metadata +7 -2
data/Rakefile
CHANGED
@@ -49,6 +49,10 @@ test = Rake::TestTask.new do |t|
|
|
49
49
|
test_files = test_files.delete_if { |n| /unix/ =~ n } if
|
50
50
|
/^mswin/ =~ Config::CONFIG[ 'host_os' ]
|
51
51
|
|
52
|
+
# Darwin specific files must be excluded if not MacOS platform.
|
53
|
+
test_files = test_files.delete_if { |n| /darwin/ =~ n } unless
|
54
|
+
/^darwin/ =~ Config::CONFIG[ 'host_os' ]
|
55
|
+
|
52
56
|
t.test_files = test_files
|
53
57
|
t.verbose = true
|
54
58
|
end
|
data/lib/mxx_ru/cpp/target.rb
CHANGED
@@ -392,6 +392,21 @@ module MxxRu
|
|
392
392
|
# For compatibility with previous versions.
|
393
393
|
Dll_target_type = DllTargetType
|
394
394
|
|
395
|
+
# Target type is MacOS bundle (.bundle is a kind of dll on MacOS).
|
396
|
+
#
|
397
|
+
# Since v.1.4.10
|
398
|
+
#
|
399
|
+
class MacOSBundleTargetType < TargetType
|
400
|
+
TYPE = "macos_bundle"
|
401
|
+
|
402
|
+
def name
|
403
|
+
return TYPE
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
# For compatibility with previous versions.
|
408
|
+
Macos_bundle_target_type = MacOSBundleTargetType
|
409
|
+
|
395
410
|
# Base class for all targets of C/C++ projects.
|
396
411
|
class Target < MxxRu::BinaryTarget
|
397
412
|
# Description of obj_placement object installed.
|
@@ -961,6 +976,7 @@ module MxxRu
|
|
961
976
|
do_target_type_depending_actions(
|
962
977
|
:lib => lambda { |toolset| toolset.full_lib_name( self ) },
|
963
978
|
:dll => lambda { |toolset| toolset.full_dll_name( self ) },
|
979
|
+
:macos_bundle => lambda { |toolset| toolset.full_dll_name( self ) },
|
964
980
|
:exe => lambda { |toolset| toolset.full_exe_name( self ) } )
|
965
981
|
end
|
966
982
|
|
@@ -1124,6 +1140,8 @@ module MxxRu
|
|
1124
1140
|
toolset.make_lib( self, rebuilding_needed ) },
|
1125
1141
|
:dll => lambda { |toolset|
|
1126
1142
|
toolset.make_dll( self, rebuilding_needed ) },
|
1143
|
+
:macos_bundle => lambda { |toolset|
|
1144
|
+
toolset.make_dll( self, rebuilding_needed ) },
|
1127
1145
|
:exe => lambda { |toolset|
|
1128
1146
|
toolset.make_exe( self, rebuilding_needed ) } )
|
1129
1147
|
|
@@ -1148,6 +1166,7 @@ module MxxRu
|
|
1148
1166
|
do_target_type_depending_actions(
|
1149
1167
|
:lib => lambda { |toolset| toolset.clean_lib( self ) },
|
1150
1168
|
:dll => lambda { |toolset| toolset.clean_dll( self ) },
|
1169
|
+
:macos_bundle => lambda { |toolset| toolset.clean_dll( self ) },
|
1151
1170
|
:exe => lambda { |toolset| toolset.clean_exe( self ) } )
|
1152
1171
|
end
|
1153
1172
|
|
@@ -1162,6 +1181,7 @@ module MxxRu
|
|
1162
1181
|
# do_target_type_depending_actions(
|
1163
1182
|
# :lib => lambda { |toolset| toolset.clean_lib(self) },
|
1164
1183
|
# :dll => lambda { |toolset| toolset.clean_dll(self) },
|
1184
|
+
# :macos_bundle => lambda { |toolset| toolset.clean_dll(self) },
|
1165
1185
|
# :exe => lambda { |toolset| toolset.clean_exe(self) }
|
1166
1186
|
# )
|
1167
1187
|
#
|
@@ -1174,6 +1194,8 @@ module MxxRu
|
|
1174
1194
|
a_type_actions[ :lib ].call( toolset )
|
1175
1195
|
elsif target_type.name == DllTargetType::TYPE
|
1176
1196
|
a_type_actions[ :dll ].call( toolset )
|
1197
|
+
elsif target_type.name == MacOSBundleTargetType::TYPE
|
1198
|
+
a_type_actions[ :macos_bundle ].call( toolset )
|
1177
1199
|
elsif target_type.name == ExeTargetType::TYPE
|
1178
1200
|
a_type_actions[ :exe ].call( toolset )
|
1179
1201
|
else
|
@@ -1190,7 +1212,7 @@ module MxxRu
|
|
1190
1212
|
|
1191
1213
|
end # class Target
|
1192
1214
|
|
1193
|
-
# Base class for targets that may be lib or dll.
|
1215
|
+
# Base class for targets that may be lib or dll, or MacOS bundle.
|
1194
1216
|
#
|
1195
1217
|
# In that cases for a project should be defined special target class.
|
1196
1218
|
# The class constructor should define two blocks:
|
@@ -1199,6 +1221,9 @@ module MxxRu
|
|
1199
1221
|
# * second is called if developer wants to build target
|
1200
1222
|
# as a shared library. Block is run during as_dll method call;
|
1201
1223
|
#
|
1224
|
+
# Starting from version 1.4.10 this approach could also be used for
|
1225
|
+
# bulding MacOS bundles.
|
1226
|
+
#
|
1202
1227
|
# For example:
|
1203
1228
|
#
|
1204
1229
|
# class Prj < MxxRu::Cpp::LibOrDllTarget
|
@@ -1216,6 +1241,12 @@ module MxxRu
|
|
1216
1241
|
# implib_path( "lib" )
|
1217
1242
|
# define( "THREADS_1__DLL", OPT_UPSPREAD )
|
1218
1243
|
# })
|
1244
|
+
# # This is avaliable from v.1.4.10
|
1245
|
+
# init_macos_bundle_block(
|
1246
|
+
# Proc.new {
|
1247
|
+
# rtl_mode( MxxRu::Cpp::RTL_SHARED )
|
1248
|
+
# }
|
1249
|
+
# )
|
1219
1250
|
#
|
1220
1251
|
# cpp_source( "threads.cpp" )
|
1221
1252
|
# cpp_source( "micro_time.cpp" )
|
@@ -1234,11 +1265,11 @@ module MxxRu
|
|
1234
1265
|
# After definition of such class for the target, project may allow
|
1235
1266
|
# to use itself by the other projects using two methods.
|
1236
1267
|
#
|
1237
|
-
# == Manual execution of as_lib, as_dll methods
|
1268
|
+
# == Manual execution of as_lib, as_dll, as_macos_bundle methods
|
1238
1269
|
#
|
1239
1270
|
# If project defines one class only, inherited from LibOrDllTarget,
|
1240
|
-
# then all clients of that project should explicitly call as_lib or as_dll
|
1241
|
-
# method during a reference to required_prj:
|
1271
|
+
# then all clients of that project should explicitly call as_lib or as_dll,
|
1272
|
+
# or as_macos_bundle method during a reference to required_prj:
|
1242
1273
|
#
|
1243
1274
|
# class MyPrj < MxxRu::Cpp::ExeTarget
|
1244
1275
|
# def initialize( a_alias = "my_prj.rb" )
|
@@ -1255,8 +1286,8 @@ module MxxRu
|
|
1255
1286
|
# == Definition of auxiliary target classes
|
1256
1287
|
#
|
1257
1288
|
# To make usage of target that may be lib or dll easier, project may
|
1258
|
-
# define two auxiliary classes, which would call methods as_lib
|
1259
|
-
# inside their constructors:
|
1289
|
+
# define two auxiliary classes, which would call methods as_lib, as_dll
|
1290
|
+
# and as_macos_bundle inside their constructors:
|
1260
1291
|
#
|
1261
1292
|
# class Prj < MxxRu::Cpp::LibOrDllTarget
|
1262
1293
|
# def initialize( a_alias = "threads_1/prj.rb" )
|
@@ -1276,6 +1307,12 @@ module MxxRu
|
|
1276
1307
|
# as_dll
|
1277
1308
|
# end
|
1278
1309
|
# end
|
1310
|
+
# class MacOSBundle < Prj
|
1311
|
+
# def super( a_alias = "threads_1/macos_bundle.rb" )
|
1312
|
+
# super( a_alias )
|
1313
|
+
# as_macos_bundle
|
1314
|
+
# end
|
1315
|
+
# end
|
1279
1316
|
#
|
1280
1317
|
# Then for using the target it would be enough to do that:
|
1281
1318
|
# class MyPrj < MxxRu::Cpp::ExeTarget
|
@@ -1323,6 +1360,7 @@ module MxxRu
|
|
1323
1360
|
# class Prj < MxxRu::Cpp::LibOrDllTarget ... end
|
1324
1361
|
# class Lib < Prj ... end
|
1325
1362
|
# class Dll < Prj ... end
|
1363
|
+
# class MacOSBundle < Prj ... end
|
1326
1364
|
# class MyExe < MxxRu::Cpp::ExeTarget
|
1327
1365
|
# def initialize( a_alias = "my_exe.rb" )
|
1328
1366
|
# super( a_alias )
|
@@ -1346,7 +1384,10 @@ module MxxRu
|
|
1346
1384
|
@mxx_init_lib_block = nil
|
1347
1385
|
# Block, which is run if dll is a target.
|
1348
1386
|
@mxx_init_dll_block = nil
|
1349
|
-
#
|
1387
|
+
# Block, which is run if MacOS bundle is a target.
|
1388
|
+
@mxx_init_macos_bundle_block = nil
|
1389
|
+
# Target type should be defined or by as_lib method, or by as_dll method,
|
1390
|
+
# or by as_macos_bundle.
|
1350
1391
|
@mxx_target_type = nil
|
1351
1392
|
|
1352
1393
|
end
|
@@ -1371,6 +1412,16 @@ module MxxRu
|
|
1371
1412
|
end
|
1372
1413
|
end
|
1373
1414
|
|
1415
|
+
# Set MacOS bundle as target type.
|
1416
|
+
def as_macos_bundle
|
1417
|
+
if ensure_type_not_set_yet( MacOSBundleTargetType::TYPE )
|
1418
|
+
@mxx_target_type = MacOSBundleTargetType.new
|
1419
|
+
if nil != @mxx_init_macos_bundle_block
|
1420
|
+
@mxx_init_macos_bundle_block.call
|
1421
|
+
end
|
1422
|
+
end
|
1423
|
+
end
|
1424
|
+
|
1374
1425
|
# Return current value of mxx_target_type.
|
1375
1426
|
def target_type
|
1376
1427
|
if nil == @mxx_target_type
|
@@ -1393,6 +1444,12 @@ module MxxRu
|
|
1393
1444
|
@mxx_init_dll_block = a_block
|
1394
1445
|
end
|
1395
1446
|
|
1447
|
+
# Set initialization block for MacOS bundle.
|
1448
|
+
# This block will be executed in as_macos_bundle method.
|
1449
|
+
def init_macos_bundle_block( a_block )
|
1450
|
+
@mxx_init_macos_bundle_block = a_block
|
1451
|
+
end
|
1452
|
+
|
1396
1453
|
private
|
1397
1454
|
# If someone already defined other target type, exception is thrown.
|
1398
1455
|
# If already defined target type is the same, false returned.
|
@@ -1443,6 +1500,20 @@ module MxxRu
|
|
1443
1500
|
# For compatibility with previous versions.
|
1444
1501
|
Dll_target = DllTarget
|
1445
1502
|
|
1503
|
+
# MacOS bundle is a target type.
|
1504
|
+
class MacOSBundleTarget < LibOrDllTarget
|
1505
|
+
def initialize( a_prj_alias, &block )
|
1506
|
+
super( a_prj_alias, a_prj_alias )
|
1507
|
+
|
1508
|
+
as_macos_bundle
|
1509
|
+
|
1510
|
+
instance_eval( &block ) if block
|
1511
|
+
end
|
1512
|
+
end
|
1513
|
+
|
1514
|
+
# For compatibility with previous versions.
|
1515
|
+
Macos_bundle_target = MacOSBundleTarget
|
1516
|
+
|
1446
1517
|
# Exe is a target type.
|
1447
1518
|
class ExeTarget < Target
|
1448
1519
|
|
@@ -1473,6 +1544,7 @@ module MxxRu
|
|
1473
1544
|
|
1474
1545
|
generate_simple_target_method :lib_target
|
1475
1546
|
generate_simple_target_method :dll_target
|
1547
|
+
generate_simple_target_method :macos_bundle_target
|
1476
1548
|
generate_simple_target_method :exe_target
|
1477
1549
|
|
1478
1550
|
end # module Cpp
|
@@ -51,6 +51,10 @@ module MxxRu
|
|
51
51
|
target.linker_option( "-prebind" )
|
52
52
|
target.linker_option( "-dynamiclib" )
|
53
53
|
target.linker_option( "-single_module" )
|
54
|
+
elsif target.target_type.name == MacOSBundleTargetType::TYPE
|
55
|
+
target.linker_option( "-prebind" )
|
56
|
+
target.linker_option( "-bundle" )
|
57
|
+
target.linker_option( "-single_module" )
|
54
58
|
elsif target.target_type.name == ExeTargetType::TYPE
|
55
59
|
target.linker_option( "-prebind" )
|
56
60
|
end
|
@@ -60,6 +64,17 @@ module MxxRu
|
|
60
64
|
def enclose_linker_include_lib_options_into_brackes( options )
|
61
65
|
options
|
62
66
|
end
|
67
|
+
|
68
|
+
# See description at MxxRu::Cpp::Toolset#dll_file_name.
|
69
|
+
#
|
70
|
+
# If we are building bundle then extension should be '.bundle'
|
71
|
+
def dll_file_name( source_name, target )
|
72
|
+
if target.target_type.name == MacOSBundleTargetType::TYPE
|
73
|
+
construct_target_name( source_name, 'lib', '.bundle', target )
|
74
|
+
else
|
75
|
+
super
|
76
|
+
end
|
77
|
+
end
|
63
78
|
end # class GccDarwin
|
64
79
|
|
65
80
|
end # module Toolsets
|
@@ -96,7 +96,8 @@ module MxxRu
|
|
96
96
|
end
|
97
97
|
|
98
98
|
# This is not required on mswin platform.
|
99
|
-
if target.target_type.name == DllTargetType::TYPE
|
99
|
+
if target.target_type.name == DllTargetType::TYPE ||
|
100
|
+
target.target_type.name == MacOSBundleTargetType::TYPE
|
100
101
|
target.compiler_option( "-fPIC" )
|
101
102
|
end
|
102
103
|
|
@@ -229,7 +230,7 @@ module MxxRu
|
|
229
230
|
|
230
231
|
# This library, as a first one.
|
231
232
|
result.add_libs( [
|
232
|
-
|
233
|
+
BinaryLibrary.new( a_dll_info.link_name, BinaryLibrary::SHARED ) ] )
|
233
234
|
result.add_lib_paths( [ a_dll_info.link_path ] )
|
234
235
|
|
235
236
|
# And all required libraries.
|
data/lib/mxx_ru/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#include <cstdio>
|
2
|
-
|
3
|
-
void A() { std::printf( "A2\n" ); }
|
1
|
+
#include <cstdio>
|
2
|
+
|
3
|
+
void A() { std::printf( "A2\n" ); }
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require File.dirname( __FILE__ ) + '/../../test_with_compilation'
|
4
|
+
|
5
|
+
class TC_Darwin_BundleTargetType_NormalBuild < Test::Unit::TestCase
|
6
|
+
include TestWithCompilation
|
7
|
+
|
8
|
+
test_path 'tests/darwin/bundle_target_type'
|
9
|
+
|
10
|
+
test_case :successful_build do
|
11
|
+
tests = [ 'my_test_bundle.rb' ]
|
12
|
+
build *tests
|
13
|
+
clean *tests
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Mxx_ru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Mxx_ru Project
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-24 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -154,6 +154,11 @@ files:
|
|
154
154
|
- tests/cpp/vc_cleanup/prj_lib_with_simple_target_root.rb
|
155
155
|
- tests/cpp/vc_cleanup/simple_target_root
|
156
156
|
- tests/cpp/vc_cleanup/tc_vc_cleanup.rb
|
157
|
+
- tests/darwin
|
158
|
+
- tests/darwin/bundle_target_type
|
159
|
+
- tests/darwin/bundle_target_type/my_test_bundle.c
|
160
|
+
- tests/darwin/bundle_target_type/my_test_bundle.rb
|
161
|
+
- tests/darwin/bundle_target_type/tc_normal_build.rb
|
157
162
|
- tests/mxx_ru
|
158
163
|
- tests/mxx_ru/binary_library
|
159
164
|
- tests/mxx_ru/binary_library/tc_binary_library.rb
|