Mxx_ru 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +26 -26
- data/NEWS +107 -107
- data/README +21 -21
- data/Rakefile +56 -59
- data/examples/exe_and_lib/prj.rb +11 -11
- data/examples/exe_and_lib/say.rb +7 -7
- data/examples/exe_dll_lib/inout.rb +18 -18
- data/examples/exe_dll_lib/prj.rb +11 -11
- data/examples/exe_dll_lib/say.rb +9 -9
- data/examples/exe_dll_lib_2/build.rb +10 -10
- data/examples/exe_dll_lib_2/inout/prj.rb +16 -16
- data/examples/exe_dll_lib_2/main/prj.rb +9 -9
- data/examples/exe_dll_lib_2/say/prj.rb +8 -8
- data/examples/simple_exe/prj.rb +7 -7
- data/lib/mxx_ru/abstract_target.rb +335 -335
- data/lib/mxx_ru/binary_library.rb +106 -106
- data/lib/mxx_ru/binary_target.rb +173 -173
- data/lib/mxx_ru/binary_unittest.rb +143 -143
- data/lib/mxx_ru/compat.rb +33 -33
- data/lib/mxx_ru/cpp.rb +38 -38
- data/lib/mxx_ru/cpp/analyzer.rb +237 -237
- data/lib/mxx_ru/cpp/composite.rb +118 -118
- data/lib/mxx_ru/cpp/detect_toolset.rb +122 -122
- data/lib/mxx_ru/cpp/mode.rb +90 -90
- data/lib/mxx_ru/cpp/obj_placement.rb +330 -330
- data/lib/mxx_ru/cpp/obj_placements/custom_subdir.rb +155 -155
- data/lib/mxx_ru/cpp/qt.rb +366 -366
- data/lib/mxx_ru/cpp/rucodegen.rb +157 -157
- data/lib/mxx_ru/cpp/source_file.rb +79 -79
- data/lib/mxx_ru/cpp/target.rb +1523 -1523
- data/lib/mxx_ru/cpp/toolset.rb +1087 -1087
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_5.rb +53 -53
- data/lib/mxx_ru/cpp/toolsets/bcc_win32_family.rb +460 -460
- data/lib/mxx_ru/cpp/toolsets/c89_etk_nsk.rb +59 -59
- data/lib/mxx_ru/cpp/toolsets/c89_nsk.rb +59 -59
- data/lib/mxx_ru/cpp/toolsets/c89_nsk_family.rb +277 -277
- data/lib/mxx_ru/cpp/toolsets/gcc_cygwin.rb +58 -58
- data/lib/mxx_ru/cpp/toolsets/gcc_family.rb +420 -424
- data/lib/mxx_ru/cpp/toolsets/gcc_linux.rb +64 -64
- data/lib/mxx_ru/cpp/toolsets/gcc_mingw.rb +150 -150
- data/lib/mxx_ru/cpp/toolsets/gcc_sparc_solaris.rb +91 -91
- data/lib/mxx_ru/cpp/toolsets/gcc_unix_family.rb +103 -84
- data/lib/mxx_ru/cpp/toolsets/vc7.rb +62 -62
- data/lib/mxx_ru/cpp/toolsets/vc8.rb +455 -455
- data/lib/mxx_ru/cpp/toolsets/vc_family.rb +448 -448
- data/lib/mxx_ru/ex.rb +165 -165
- data/lib/mxx_ru/makestyle_generator.rb +146 -146
- data/lib/mxx_ru/textfile_unittest.rb +303 -303
- data/lib/mxx_ru/util.rb +340 -340
- data/tests/c/pcre/chartables.c +183 -183
- data/tests/c/pcre/config.h +99 -99
- data/tests/c/pcre/dftables.c +167 -167
- data/tests/c/pcre/get.c +349 -349
- data/tests/c/pcre/internal.h +677 -677
- data/tests/c/pcre/maketables.c +140 -140
- data/tests/c/pcre/pcre.c +8304 -8304
- data/tests/c/pcre/pcre.h +193 -193
- data/tests/c/pcre/pcre.rb +14 -14
- data/tests/c/pcre/pcredemo.c +316 -316
- data/tests/c/pcre/pcregrep.c +642 -642
- data/tests/c/pcre/pcreposix.c +305 -305
- data/tests/c/pcre/pcreposix.h +88 -88
- data/tests/c/pcre/pcretest.c +1483 -1483
- data/tests/c/pcre/perltest +211 -211
- data/tests/c/pcre/printint.c +360 -360
- data/tests/c/pcre/study.c +472 -472
- data/tests/cpp/cpp_sources_glob/build.rb +7 -7
- data/tests/cpp/cpp_sources_glob/some/module/prj.rb +10 -10
- data/tests/cpp/cpp_sources_glob/tc_cpp_sources_glob.rb +18 -18
- data/tests/cpp/mswin_res_dll/build.rb +14 -14
- data/tests/cpp/mswin_res_dll/dll.cpp +17 -17
- data/tests/cpp/mswin_res_dll/dll.rb +29 -29
- data/tests/cpp/mswin_res_dll/dll.rc +48 -48
- data/tests/cpp/mswin_res_dll/h/dll.hpp +8 -8
- data/tests/cpp/mswin_res_dll/h/res.h +3 -3
- data/tests/cpp/mswin_res_dll/main.cpp +13 -13
- data/tests/cpp/mswin_res_dll/main.rb +19 -19
- data/tests/cpp/mswin_res_dll/tc_mswin_res_dll.rb +18 -18
- data/tests/cpp/mswin_res_exe/build.rb +23 -23
- data/tests/cpp/mswin_res_exe/h/res.h +3 -3
- data/tests/cpp/mswin_res_exe/main.cpp +17 -17
- data/tests/cpp/mswin_res_exe/main.rc +48 -48
- data/tests/cpp/mswin_res_exe/tc_mswin_res_exe.rb +18 -18
- data/tests/cpp/rucodegen.embedded/host_config.cpp +32 -32
- data/tests/cpp/rucodegen.embedded/impl/conn_params.cpp +7 -7
- data/tests/cpp/rucodegen.embedded/impl/conn_params.rb +14 -14
- data/tests/cpp/rucodegen.embedded/impl/h/conn_params.hpp +10 -10
- data/tests/cpp/rucodegen.embedded/prj.rb +16 -16
- data/tests/cpp/rucodegen.embedded/tc_rucodegen.rb +18 -18
- data/tests/cpp/rucodegen/host_config.cpp +20 -20
- data/tests/cpp/rucodegen/host_config.rb +14 -14
- data/tests/cpp/rucodegen/impl/conn_params.cpp +7 -7
- data/tests/cpp/rucodegen/impl/conn_params.rb +14 -14
- data/tests/cpp/rucodegen/impl/h/conn_params.hpp +10 -10
- data/tests/cpp/rucodegen/prj.rb +16 -16
- data/tests/cpp/rucodegen/tc_rucodegen.rb +18 -18
- data/tests/cpp/textfile_unittest/build.rb +8 -8
- data/tests/cpp/textfile_unittest/etalons/out_1.txt +1 -1
- data/tests/cpp/textfile_unittest/etalons/out_128.txt +128 -128
- data/tests/cpp/textfile_unittest/main.cpp +89 -89
- data/tests/cpp/textfile_unittest/prj.rb +8 -8
- data/tests/cpp/textfile_unittest/prj.ut.rb +18 -18
- data/tests/cpp/textfile_unittest/tc_textfile_unittest.rb +18 -18
- data/tests/cpp/toolset_name.rb +6 -6
- data/tests/cpp/vc_cleanup/prj_dll_no_implib.rb +10 -10
- data/tests/cpp/vc_cleanup/prj_dll_no_implib_simple_target_root.rb +11 -11
- data/tests/cpp/vc_cleanup/prj_dll_with_implib.rb +11 -11
- data/tests/cpp/vc_cleanup/prj_dll_with_implib_simple_target_root.rb +14 -14
- data/tests/cpp/vc_cleanup/prj_exe_no_implib.rb +10 -10
- data/tests/cpp/vc_cleanup/prj_exe_no_implib_simple_target_root.rb +11 -11
- data/tests/cpp/vc_cleanup/prj_lib.rb +10 -10
- data/tests/cpp/vc_cleanup/prj_lib_with_simple_target_root.rb +11 -11
- data/tests/cpp/vc_cleanup/tc_vc_cleanup.rb +23 -23
- data/tests/mxx_ru/binary_library/tc_binary_library.rb +57 -57
- data/tests/mxx_ru/binary_library/tc_binary_target_lib_methods.rb +114 -114
- data/tests/mxx_ru/change_default_value/ignoring_by_build_root/build.rb +8 -8
- data/tests/mxx_ru/change_default_value/ignoring_by_build_root/child_1.rb +5 -5
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/build.rb +7 -7
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_1.rb +5 -5
- data/tests/mxx_ru/change_default_value/ignoring_by_child_1/child_2.rb +5 -5
- data/tests/mxx_ru/change_default_value/ok/build.rb +8 -8
- data/tests/mxx_ru/change_default_value/ok/child_1.rb +8 -8
- data/tests/mxx_ru/lib_path/build.rb +8 -8
- data/tests/mxx_ru/lib_path/bye.rb +8 -8
- data/tests/mxx_ru/lib_path/hi.rb +8 -8
- data/tests/mxx_ru/lib_path/main.rb +12 -12
- data/tests/mxx_ru/lib_path/tc_lib_path.rb +18 -18
- data/tests/mxx_ru/obj_placements/tc_custom_subdir.rb +58 -58
- data/tests/mxx_ru/opt_lib_ext/build.rb +7 -7
- data/tests/mxx_ru/opt_lib_ext/hi.rb +7 -7
- data/tests/mxx_ru/opt_lib_ext/tc_opt_lib_ext.rb +18 -18
- data/tests/mxx_ru/opt_lib_ext/test-no-ext.rb +9 -9
- data/tests/mxx_ru/opt_lib_ext/test-with-ext.rb +13 -13
- data/tests/mxx_ru/plural_form_methods/tc.rb +72 -72
- data/tests/mxx_ru/qt_gen/tc_uic_result_subdir.rb +76 -76
- data/tests/mxx_ru/target_ext/prj_dll.rb +8 -8
- data/tests/mxx_ru/target_ext/prj_exe.rb +8 -8
- data/tests/mxx_ru/target_ext/prj_lib.rb +8 -8
- data/tests/mxx_ru/target_ext/tc_target_ext.rb +24 -24
- data/tests/mxx_ru/tc_makestyle_generator.rb +117 -117
- data/tests/mxx_ru/vc8/tc_actual_manifest.rb +230 -230
- data/tests/mxx_ru/vc8/tc_append_mt_commands.rb +104 -104
- data/tests/mxx_ru/vc8/tc_default_manifest.rb +17 -17
- data/tests/mxx_ru/vc8/tc_define_manifest.rb +173 -173
- data/tests/mxx_ru/vc8/tc_drop_default_manifest.rb +16 -16
- data/tests/mxx_ru/vc8/tc_invalid_params.rb +81 -81
- data/tests/mxx_ru/vc8/ts_vc8.rb +10 -10
- data/tests/qt/aclock/aclock.cpp +148 -148
- data/tests/qt/aclock/aclock.h +45 -45
- data/tests/qt/aclock/main.cpp +28 -28
- data/tests/qt/aclock/prj.rb +21 -21
- data/tests/qt/iconview/main.cpp +76 -76
- data/tests/qt/iconview/prj.rb +21 -21
- data/tests/qt/toplevel/main.cpp +9 -9
- data/tests/qt/toplevel/options.ui +587 -587
- data/tests/qt/toplevel/prj.rb +22 -22
- data/tests/test_with_compilation.rb +110 -110
- data/tests/unix/lib_linking_mode/a_shared.rb +7 -7
- data/tests/unix/lib_linking_mode/a_static.rb +7 -7
- data/tests/unix/lib_linking_mode/etalon/shared.txt +2 -2
- data/tests/unix/lib_linking_mode/etalon/static.txt +2 -2
- data/tests/unix/lib_linking_mode/main_conflict.rb +12 -12
- data/tests/unix/lib_linking_mode/main_conflict_2.rb +11 -11
- data/tests/unix/lib_linking_mode/main_shared.rb +9 -9
- data/tests/unix/lib_linking_mode/main_shared.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/main_shared_2.rb +10 -10
- data/tests/unix/lib_linking_mode/main_shared_2.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/main_static.rb +9 -9
- data/tests/unix/lib_linking_mode/main_static.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/main_static_2.rb +10 -10
- data/tests/unix/lib_linking_mode/main_static_2.ut.rb +11 -11
- data/tests/unix/lib_linking_mode/tc_conflicted_build.rb +18 -18
- data/tests/unix/lib_linking_mode/tc_normal_build.rb +18 -18
- data/tests/unix/lib_order/a.cpp +4 -0
- data/tests/unix/lib_order/a.hpp +1 -0
- data/tests/unix/lib_order/a.rb +8 -0
- data/tests/unix/lib_order/b.cpp +10 -0
- data/tests/unix/lib_order/b.hpp +1 -0
- data/tests/unix/lib_order/b.rb +8 -0
- data/tests/unix/lib_order/build.rb +9 -0
- data/tests/unix/lib_order/c.cpp +12 -0
- data/tests/unix/lib_order/c.hpp +2 -0
- data/tests/unix/lib_order/c.rb +8 -0
- data/tests/unix/lib_order/d.cpp +7 -0
- data/tests/unix/lib_order/d.hpp +1 -0
- data/tests/unix/lib_order/d.rb +8 -0
- data/tests/unix/lib_order/main.cpp +7 -0
- data/tests/unix/lib_order/main.rb +14 -0
- data/tests/unix/lib_order/tc_normal_build.rb +16 -0
- metadata +342 -319
data/lib/mxx_ru/util.rb
CHANGED
@@ -1,340 +1,340 @@
|
|
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 'rbconfig'
|
30
|
-
require 'singleton'
|
31
|
-
|
32
|
-
require 'mxx_ru/ex'
|
33
|
-
|
34
|
-
module MxxRu
|
35
|
-
|
36
|
-
module Util
|
37
|
-
# Regular expression to divide file name and it's extension.
|
38
|
-
MATCH_FILE_EXT_REGEX = Regexp.new( "^(.+)\\.([^\\./]+)$" )
|
39
|
-
|
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'
|
47
|
-
MXXARG_BRIEF_DESC = '--mxx-brief-show'
|
48
|
-
MXXARG_BRIEF_DESC_DISABLED = '--mxx-brief-hide'
|
49
|
-
|
50
|
-
# OS name, script is run on.
|
51
|
-
@@host_os = nil
|
52
|
-
|
53
|
-
# Regular expression to parse entries in Kernel#caller result.
|
54
|
-
CALLER_ENTRY_REGEX = /^(.+):\d+(:in\s.+){0,1}$/
|
55
|
-
|
56
|
-
# Class, which detects MxxRu current mode.
|
57
|
-
class Mode
|
58
|
-
include Singleton
|
59
|
-
|
60
|
-
attr_reader :is_clean
|
61
|
-
attr_reader :is_rebuild
|
62
|
-
attr_reader :is_show_cmd
|
63
|
-
attr_reader :is_keep_tmps
|
64
|
-
attr_reader :is_show_tmps
|
65
|
-
attr_reader :is_brief_desc
|
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
|
-
# Constructor checks for special arguments in command line.
|
77
|
-
def initialize
|
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
|
-
|
82
|
-
@is_show_cmd = ARGV.include?( MXXARG_SHOW_CMD )
|
83
|
-
@is_keep_tmps = ARGV.include?( MXXARG_KEEP_TMPS )
|
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 )
|
88
|
-
|
89
|
-
@is_brief_desc = false if @is_brief_desc_disabled
|
90
|
-
|
91
|
-
@is_manual_dry_run = false
|
92
|
-
end
|
93
|
-
|
94
|
-
# Is dry-run mode set?
|
95
|
-
# Dry-run mode is set, if --mxx-dry-run command line parameter is set,
|
96
|
-
# or if it's manually set.
|
97
|
-
def is_dry_run
|
98
|
-
return ( @is_dry_run || @is_manual_dry_run )
|
99
|
-
end
|
100
|
-
|
101
|
-
# On/Off manual dry-run mode.
|
102
|
-
# In some cases it's efficient to turn it on for some time.
|
103
|
-
# For example, it's used to handle subprojects with --mxx-cpp-1 option
|
104
|
-
# set.
|
105
|
-
def manual_dry_run( a_is_manual_dry_run )
|
106
|
-
@is_manual_dry_run = a_is_manual_dry_run
|
107
|
-
end
|
108
|
-
|
109
|
-
# Try to manually enable 'show-brief' mode. Attempt ignored if
|
110
|
-
# '--mxx-show-brief-disabled' was specified.
|
111
|
-
def try_enable_show_brief
|
112
|
-
@is_brief_desc = true unless @is_brief_desc_disabled
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
# Returns file name without last extension.
|
118
|
-
def Util.remove_file_ext( a_name )
|
119
|
-
match_result = MATCH_FILE_EXT_REGEX.match( a_name )
|
120
|
-
if nil == match_result
|
121
|
-
# No extension was present.
|
122
|
-
return String.new( a_name )
|
123
|
-
end
|
124
|
-
|
125
|
-
return match_result[ 1 ]
|
126
|
-
end
|
127
|
-
|
128
|
-
# Returns filename with new last extension.
|
129
|
-
def Util.change_file_ext( name, ext )
|
130
|
-
remove_file_ext( name ) + ext
|
131
|
-
end
|
132
|
-
|
133
|
-
# Deleting file name without exception.
|
134
|
-
def Util.delete_file( a_name )
|
135
|
-
if FileTest.exists?( a_name )
|
136
|
-
File.delete( a_name )
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# Class, responsible for creation and removal of temporary files.
|
141
|
-
# Temporary files are created in current folder.
|
142
|
-
# Temporary files are removed before application is exitted,
|
143
|
-
# if --mxx-keep-tmps option isn't set.
|
144
|
-
class TmpFiles
|
145
|
-
include Singleton
|
146
|
-
|
147
|
-
# Temporary file names.
|
148
|
-
@@names = Array.new
|
149
|
-
|
150
|
-
def initialize
|
151
|
-
if !Mode.instance.is_keep_tmps
|
152
|
-
ObjectSpace.define_finalizer( self, Proc.new{ TmpFiles.finalizer } )
|
153
|
-
end
|
154
|
-
|
155
|
-
# Counter to ensure unique file names.
|
156
|
-
@current = 0
|
157
|
-
|
158
|
-
# Indicies stack in @@names for push and pop methods.
|
159
|
-
@index_stack = Array.new
|
160
|
-
end
|
161
|
-
|
162
|
-
def TmpFiles.finalizer
|
163
|
-
@@names.each { |d|
|
164
|
-
begin
|
165
|
-
File.delete( d )
|
166
|
-
rescue Exception => e
|
167
|
-
puts e
|
168
|
-
end
|
169
|
-
}
|
170
|
-
end
|
171
|
-
|
172
|
-
# Temporary file creation.
|
173
|
-
# The string given is stored to the temporary file.
|
174
|
-
# The name of temporary file is returned.
|
175
|
-
#
|
176
|
-
# [_a_content_] Should be an object of String type.
|
177
|
-
def create( a_content )
|
178
|
-
|
179
|
-
current = (@current += 1)
|
180
|
-
file_name = "tmpmxx_ru.#{$$}.#{current}"
|
181
|
-
file = File.new( file_name, "w" )
|
182
|
-
@@names << file_name
|
183
|
-
file << a_content
|
184
|
-
file.close
|
185
|
-
|
186
|
-
if Mode.instance.is_show_tmps
|
187
|
-
puts "<<<[#{file_name}]\t #{a_content}>>>"
|
188
|
-
end
|
189
|
-
|
190
|
-
return file_name
|
191
|
-
end
|
192
|
-
|
193
|
-
# Storing current vector size to the indicies stack.
|
194
|
-
def push()
|
195
|
-
if !Mode.instance.is_keep_tmps
|
196
|
-
@index_stack.push( @@names.size() )
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
# Removing all files, which are stored in a file names vector
|
201
|
-
# starting from first element from @index_stack position.
|
202
|
-
def pop()
|
203
|
-
if !Mode.instance.is_keep_tmps
|
204
|
-
index = @index_stack.pop
|
205
|
-
while @@names.size > index
|
206
|
-
file_to_delete = @@names.pop
|
207
|
-
MxxRu::Util::delete_file( file_to_delete )
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
end # class TmpFiles
|
213
|
-
|
214
|
-
# For compatibility with previous versions.
|
215
|
-
Tmp_files = TmpFiles
|
216
|
-
|
217
|
-
# Auxiliary function for correct execution of build method of target
|
218
|
-
# object. Before execution TmpFiles.push is executed, and after execution
|
219
|
-
# of build method TmpFiles.pop is called. This way we are removing
|
220
|
-
# temporary files created during a compilation of given target.
|
221
|
-
def Util.build_call_wrapper( a_target )
|
222
|
-
begin
|
223
|
-
TmpFiles.instance.push
|
224
|
-
state = a_target.build
|
225
|
-
return state
|
226
|
-
ensure
|
227
|
-
TmpFiles.instance.pop
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
# Create folder if it isn't exist.
|
232
|
-
#
|
233
|
-
# All chain of names is tracked. For example, if we trying to create
|
234
|
-
# output/release/lib folder, and only output is exists, then release/lib
|
235
|
-
# folders are created.
|
236
|
-
def Util.create_dir( a_name )
|
237
|
-
# Dividing the chain.
|
238
|
-
chain = Array.new
|
239
|
-
chain.unshift( a_name )
|
240
|
-
|
241
|
-
to_split = a_name.clone
|
242
|
-
while to_split != '.'
|
243
|
-
r = File.split( to_split )
|
244
|
-
|
245
|
-
# We must stop if to_split cannot be splitted anymore
|
246
|
-
# (when working with absolute paths in to_split can be drive name
|
247
|
-
# on Windows platform (e.g. 'D:\') or root directory on Unix).
|
248
|
-
# In this case r will be equal to [ <something>, '/' ].
|
249
|
-
break if 2 == r.size and ( '\\' == r[ 1 ] or '/' == r[ 1 ] )
|
250
|
-
|
251
|
-
chain.unshift( to_split = r[ 0 ] )
|
252
|
-
end
|
253
|
-
|
254
|
-
chain.each { |d|
|
255
|
-
if !FileTest.exists?( d )
|
256
|
-
Dir.mkdir( d )
|
257
|
-
end
|
258
|
-
}
|
259
|
-
end
|
260
|
-
|
261
|
-
# To ensure folder is exist.
|
262
|
-
#
|
263
|
-
# If dry-run mode wasn't set, checking for existance.
|
264
|
-
# If it isn't exists, trying to create it.
|
265
|
-
#
|
266
|
-
# In a dry-run mode MxxRu always assumes folder is exists, even if it
|
267
|
-
# isn't.
|
268
|
-
def Util.ensure_path_exists( a_path_name )
|
269
|
-
if !MxxRu::Util::Mode.instance.is_dry_run
|
270
|
-
if !FileTest.exists?( a_path_name )
|
271
|
-
MxxRu::Util.create_dir( a_path_name )
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|
275
|
-
|
276
|
-
# Get OS name where script is exeuted.
|
277
|
-
def Util.host_os
|
278
|
-
if !@@host_os
|
279
|
-
@@host_os = Config::CONFIG[ "host_os" ]
|
280
|
-
end
|
281
|
-
|
282
|
-
return @@host_os
|
283
|
-
end
|
284
|
-
|
285
|
-
# Transform separators in file names to correct ones on the given platform.
|
286
|
-
#
|
287
|
-
# For example on mswin32 we change "/" to "\".
|
288
|
-
#
|
289
|
-
# [_a_pathname_] Path to the file in unix style.
|
290
|
-
#
|
291
|
-
# *IMPORTANT! In current version only mswin32 platform is tracked!*
|
292
|
-
def Util.native_pathname( a_pathname )
|
293
|
-
if "mswin32" == Util::host_os
|
294
|
-
return a_pathname.gsub( "/", "\\" )
|
295
|
-
end
|
296
|
-
|
297
|
-
return a_pathname
|
298
|
-
end
|
299
|
-
|
300
|
-
# Extract file name from 'Kernel#caller' result for using this
|
301
|
-
# name as project alias.
|
302
|
-
def Util.prj_alias_form_caller( caller_result )
|
303
|
-
r = CALLER_ENTRY_REGEX.match( caller_result[ 0 ] )[ 1 ]
|
304
|
-
# Name can starts with './' ('./some/module/prj.rb'). That name
|
305
|
-
# must be transformed to 'some/module/prj.rb'.
|
306
|
-
if r[ 0..1 ] == './'
|
307
|
-
r[ 2...r.size ]
|
308
|
-
else
|
309
|
-
r
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
end # module Util
|
314
|
-
|
315
|
-
# Manually enable 'show-brief' mode.
|
316
|
-
#
|
317
|
-
# Intended to use in project files:
|
318
|
-
# MxxRu::Cpp::exe_target( 'some.prj' ) {
|
319
|
-
# ...
|
320
|
-
# MxxRu::enable_show_brief
|
321
|
-
# ...
|
322
|
-
# }
|
323
|
-
# 'show-brief' is global mode. Once enabled it cannot be disabled
|
324
|
-
# form inside another project file.
|
325
|
-
#
|
326
|
-
# Call to MxxRu::enable_show_brief ignored if '--mxx-show-brief-disabled'
|
327
|
-
# specified in command-line.
|
328
|
-
#
|
329
|
-
def MxxRu.enable_show_brief
|
330
|
-
Util::Mode.instance.try_enable_show_brief
|
331
|
-
end
|
332
|
-
|
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
|
340
|
-
|
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 'rbconfig'
|
30
|
+
require 'singleton'
|
31
|
+
|
32
|
+
require 'mxx_ru/ex'
|
33
|
+
|
34
|
+
module MxxRu
|
35
|
+
|
36
|
+
module Util
|
37
|
+
# Regular expression to divide file name and it's extension.
|
38
|
+
MATCH_FILE_EXT_REGEX = Regexp.new( "^(.+)\\.([^\\./]+)$" )
|
39
|
+
|
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'
|
47
|
+
MXXARG_BRIEF_DESC = '--mxx-brief-show'
|
48
|
+
MXXARG_BRIEF_DESC_DISABLED = '--mxx-brief-hide'
|
49
|
+
|
50
|
+
# OS name, script is run on.
|
51
|
+
@@host_os = nil
|
52
|
+
|
53
|
+
# Regular expression to parse entries in Kernel#caller result.
|
54
|
+
CALLER_ENTRY_REGEX = /^(.+):\d+(:in\s.+){0,1}$/
|
55
|
+
|
56
|
+
# Class, which detects MxxRu current mode.
|
57
|
+
class Mode
|
58
|
+
include Singleton
|
59
|
+
|
60
|
+
attr_reader :is_clean
|
61
|
+
attr_reader :is_rebuild
|
62
|
+
attr_reader :is_show_cmd
|
63
|
+
attr_reader :is_keep_tmps
|
64
|
+
attr_reader :is_show_tmps
|
65
|
+
attr_reader :is_brief_desc
|
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
|
+
# Constructor checks for special arguments in command line.
|
77
|
+
def initialize
|
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
|
+
|
82
|
+
@is_show_cmd = ARGV.include?( MXXARG_SHOW_CMD )
|
83
|
+
@is_keep_tmps = ARGV.include?( MXXARG_KEEP_TMPS )
|
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 )
|
88
|
+
|
89
|
+
@is_brief_desc = false if @is_brief_desc_disabled
|
90
|
+
|
91
|
+
@is_manual_dry_run = false
|
92
|
+
end
|
93
|
+
|
94
|
+
# Is dry-run mode set?
|
95
|
+
# Dry-run mode is set, if --mxx-dry-run command line parameter is set,
|
96
|
+
# or if it's manually set.
|
97
|
+
def is_dry_run
|
98
|
+
return ( @is_dry_run || @is_manual_dry_run )
|
99
|
+
end
|
100
|
+
|
101
|
+
# On/Off manual dry-run mode.
|
102
|
+
# In some cases it's efficient to turn it on for some time.
|
103
|
+
# For example, it's used to handle subprojects with --mxx-cpp-1 option
|
104
|
+
# set.
|
105
|
+
def manual_dry_run( a_is_manual_dry_run )
|
106
|
+
@is_manual_dry_run = a_is_manual_dry_run
|
107
|
+
end
|
108
|
+
|
109
|
+
# Try to manually enable 'show-brief' mode. Attempt ignored if
|
110
|
+
# '--mxx-show-brief-disabled' was specified.
|
111
|
+
def try_enable_show_brief
|
112
|
+
@is_brief_desc = true unless @is_brief_desc_disabled
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
# Returns file name without last extension.
|
118
|
+
def Util.remove_file_ext( a_name )
|
119
|
+
match_result = MATCH_FILE_EXT_REGEX.match( a_name )
|
120
|
+
if nil == match_result
|
121
|
+
# No extension was present.
|
122
|
+
return String.new( a_name )
|
123
|
+
end
|
124
|
+
|
125
|
+
return match_result[ 1 ]
|
126
|
+
end
|
127
|
+
|
128
|
+
# Returns filename with new last extension.
|
129
|
+
def Util.change_file_ext( name, ext )
|
130
|
+
remove_file_ext( name ) + ext
|
131
|
+
end
|
132
|
+
|
133
|
+
# Deleting file name without exception.
|
134
|
+
def Util.delete_file( a_name )
|
135
|
+
if FileTest.exists?( a_name )
|
136
|
+
File.delete( a_name )
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# Class, responsible for creation and removal of temporary files.
|
141
|
+
# Temporary files are created in current folder.
|
142
|
+
# Temporary files are removed before application is exitted,
|
143
|
+
# if --mxx-keep-tmps option isn't set.
|
144
|
+
class TmpFiles
|
145
|
+
include Singleton
|
146
|
+
|
147
|
+
# Temporary file names.
|
148
|
+
@@names = Array.new
|
149
|
+
|
150
|
+
def initialize
|
151
|
+
if !Mode.instance.is_keep_tmps
|
152
|
+
ObjectSpace.define_finalizer( self, Proc.new{ TmpFiles.finalizer } )
|
153
|
+
end
|
154
|
+
|
155
|
+
# Counter to ensure unique file names.
|
156
|
+
@current = 0
|
157
|
+
|
158
|
+
# Indicies stack in @@names for push and pop methods.
|
159
|
+
@index_stack = Array.new
|
160
|
+
end
|
161
|
+
|
162
|
+
def TmpFiles.finalizer
|
163
|
+
@@names.each { |d|
|
164
|
+
begin
|
165
|
+
File.delete( d )
|
166
|
+
rescue Exception => e
|
167
|
+
puts e
|
168
|
+
end
|
169
|
+
}
|
170
|
+
end
|
171
|
+
|
172
|
+
# Temporary file creation.
|
173
|
+
# The string given is stored to the temporary file.
|
174
|
+
# The name of temporary file is returned.
|
175
|
+
#
|
176
|
+
# [_a_content_] Should be an object of String type.
|
177
|
+
def create( a_content )
|
178
|
+
|
179
|
+
current = (@current += 1)
|
180
|
+
file_name = "tmpmxx_ru.#{$$}.#{current}"
|
181
|
+
file = File.new( file_name, "w" )
|
182
|
+
@@names << file_name
|
183
|
+
file << a_content
|
184
|
+
file.close
|
185
|
+
|
186
|
+
if Mode.instance.is_show_tmps
|
187
|
+
puts "<<<[#{file_name}]\t #{a_content}>>>"
|
188
|
+
end
|
189
|
+
|
190
|
+
return file_name
|
191
|
+
end
|
192
|
+
|
193
|
+
# Storing current vector size to the indicies stack.
|
194
|
+
def push()
|
195
|
+
if !Mode.instance.is_keep_tmps
|
196
|
+
@index_stack.push( @@names.size() )
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Removing all files, which are stored in a file names vector
|
201
|
+
# starting from first element from @index_stack position.
|
202
|
+
def pop()
|
203
|
+
if !Mode.instance.is_keep_tmps
|
204
|
+
index = @index_stack.pop
|
205
|
+
while @@names.size > index
|
206
|
+
file_to_delete = @@names.pop
|
207
|
+
MxxRu::Util::delete_file( file_to_delete )
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
end # class TmpFiles
|
213
|
+
|
214
|
+
# For compatibility with previous versions.
|
215
|
+
Tmp_files = TmpFiles
|
216
|
+
|
217
|
+
# Auxiliary function for correct execution of build method of target
|
218
|
+
# object. Before execution TmpFiles.push is executed, and after execution
|
219
|
+
# of build method TmpFiles.pop is called. This way we are removing
|
220
|
+
# temporary files created during a compilation of given target.
|
221
|
+
def Util.build_call_wrapper( a_target )
|
222
|
+
begin
|
223
|
+
TmpFiles.instance.push
|
224
|
+
state = a_target.build
|
225
|
+
return state
|
226
|
+
ensure
|
227
|
+
TmpFiles.instance.pop
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# Create folder if it isn't exist.
|
232
|
+
#
|
233
|
+
# All chain of names is tracked. For example, if we trying to create
|
234
|
+
# output/release/lib folder, and only output is exists, then release/lib
|
235
|
+
# folders are created.
|
236
|
+
def Util.create_dir( a_name )
|
237
|
+
# Dividing the chain.
|
238
|
+
chain = Array.new
|
239
|
+
chain.unshift( a_name )
|
240
|
+
|
241
|
+
to_split = a_name.clone
|
242
|
+
while to_split != '.'
|
243
|
+
r = File.split( to_split )
|
244
|
+
|
245
|
+
# We must stop if to_split cannot be splitted anymore
|
246
|
+
# (when working with absolute paths in to_split can be drive name
|
247
|
+
# on Windows platform (e.g. 'D:\') or root directory on Unix).
|
248
|
+
# In this case r will be equal to [ <something>, '/' ].
|
249
|
+
break if 2 == r.size and ( '\\' == r[ 1 ] or '/' == r[ 1 ] )
|
250
|
+
|
251
|
+
chain.unshift( to_split = r[ 0 ] )
|
252
|
+
end
|
253
|
+
|
254
|
+
chain.each { |d|
|
255
|
+
if !FileTest.exists?( d )
|
256
|
+
Dir.mkdir( d )
|
257
|
+
end
|
258
|
+
}
|
259
|
+
end
|
260
|
+
|
261
|
+
# To ensure folder is exist.
|
262
|
+
#
|
263
|
+
# If dry-run mode wasn't set, checking for existance.
|
264
|
+
# If it isn't exists, trying to create it.
|
265
|
+
#
|
266
|
+
# In a dry-run mode MxxRu always assumes folder is exists, even if it
|
267
|
+
# isn't.
|
268
|
+
def Util.ensure_path_exists( a_path_name )
|
269
|
+
if !MxxRu::Util::Mode.instance.is_dry_run
|
270
|
+
if !FileTest.exists?( a_path_name )
|
271
|
+
MxxRu::Util.create_dir( a_path_name )
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
# Get OS name where script is exeuted.
|
277
|
+
def Util.host_os
|
278
|
+
if !@@host_os
|
279
|
+
@@host_os = Config::CONFIG[ "host_os" ]
|
280
|
+
end
|
281
|
+
|
282
|
+
return @@host_os
|
283
|
+
end
|
284
|
+
|
285
|
+
# Transform separators in file names to correct ones on the given platform.
|
286
|
+
#
|
287
|
+
# For example on mswin32 we change "/" to "\".
|
288
|
+
#
|
289
|
+
# [_a_pathname_] Path to the file in unix style.
|
290
|
+
#
|
291
|
+
# *IMPORTANT! In current version only mswin32 platform is tracked!*
|
292
|
+
def Util.native_pathname( a_pathname )
|
293
|
+
if "mswin32" == Util::host_os
|
294
|
+
return a_pathname.gsub( "/", "\\" )
|
295
|
+
end
|
296
|
+
|
297
|
+
return a_pathname
|
298
|
+
end
|
299
|
+
|
300
|
+
# Extract file name from 'Kernel#caller' result for using this
|
301
|
+
# name as project alias.
|
302
|
+
def Util.prj_alias_form_caller( caller_result )
|
303
|
+
r = CALLER_ENTRY_REGEX.match( caller_result[ 0 ] )[ 1 ]
|
304
|
+
# Name can starts with './' ('./some/module/prj.rb'). That name
|
305
|
+
# must be transformed to 'some/module/prj.rb'.
|
306
|
+
if r[ 0..1 ] == './'
|
307
|
+
r[ 2...r.size ]
|
308
|
+
else
|
309
|
+
r
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
end # module Util
|
314
|
+
|
315
|
+
# Manually enable 'show-brief' mode.
|
316
|
+
#
|
317
|
+
# Intended to use in project files:
|
318
|
+
# MxxRu::Cpp::exe_target( 'some.prj' ) {
|
319
|
+
# ...
|
320
|
+
# MxxRu::enable_show_brief
|
321
|
+
# ...
|
322
|
+
# }
|
323
|
+
# 'show-brief' is global mode. Once enabled it cannot be disabled
|
324
|
+
# form inside another project file.
|
325
|
+
#
|
326
|
+
# Call to MxxRu::enable_show_brief ignored if '--mxx-show-brief-disabled'
|
327
|
+
# specified in command-line.
|
328
|
+
#
|
329
|
+
def MxxRu.enable_show_brief
|
330
|
+
Util::Mode.instance.try_enable_show_brief
|
331
|
+
end
|
332
|
+
|
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
|
340
|
+
|