Mxx_ru 1.4.6 → 1.4.7

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.
@@ -0,0 +1,31 @@
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
+ require 'mxx_ru/cpp/qt4details'
30
+ include MxxRu::Cpp::Qt4Modules
31
+
@@ -0,0 +1,571 @@
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
+ require 'pathname'
30
+ require 'rexml/document'
31
+ require 'set'
32
+
33
+ require 'mxx_ru/cpp'
34
+
35
+ module MxxRu
36
+ module Cpp
37
+
38
+ # Auxilary module with classes and constants for Qt4 modules support
39
+ #
40
+ module Qt4Modules
41
+ # Class for objects whose purpose is setting up an appropriate
42
+ # define and a library for target.
43
+ #
44
+ # Usage:
45
+ # QT_GUI = ModuleBinder.new( 'QT_GUI_LIB', 'QtGui4' )
46
+ # ...
47
+ # QT_GUI.setup( target )
48
+ #
49
+ class ModuleBinder
50
+ def initialize( a_define, a_library )
51
+ @define = a_define
52
+ @library = a_library
53
+ end
54
+
55
+ def setup( a_target )
56
+ a_target.define @define
57
+ a_target.lib @library
58
+ end
59
+ end
60
+
61
+ # Qt3Support component.
62
+ QT_QT3SUPPORT = ModuleBinder.new( 'QT_QT3SUPPORT_LIB', 'Qt3Support4' )
63
+ # QtCore component.
64
+ QT_CORE = ModuleBinder.new( 'QT_CORE_LIB', 'QtCore4' )
65
+ # QtDesigner component.
66
+ QT_DESIGNER = ModuleBinder.new( 'QT_DESIGNER_LIB', 'QtDesigner4' )
67
+ # QtDesignerComponents component.
68
+ QT_DESIGNER_COMPONENTS = ModuleBinder.new(
69
+ 'QT_DESIGNERCOMPONENTS_LIB', 'QtDesignerComponents4' )
70
+ # QtGui component.
71
+ QT_GUI = ModuleBinder.new( 'QT_GUI_LIB', 'QtGui4' )
72
+ # QtHelp component.
73
+ QT_HELP = ModuleBinder.new( 'QT_HELP_LIB', 'QtHelp4' )
74
+ # Network component.
75
+ QT_NETWORK = ModuleBinder.new( 'QT_NETWORK_LIB', 'QtNetwork4' )
76
+ # QtOpenGL component.
77
+ QT_OPENGL = ModuleBinder.new( 'QT_OPENGL_LIB', 'QtOpenGL4' )
78
+ # QtScript component.
79
+ QT_SCRIPT = ModuleBinder.new( 'QT_SCRIPT_LIB', 'QtScript4' )
80
+ # QtSql component.
81
+ QT_SQL = ModuleBinder.new( 'QT_SQL_LIB', 'QtSql4' )
82
+ # QtSvg component.
83
+ QT_SVG = ModuleBinder.new( 'QT_SVG_LIB', 'QtSvg4' )
84
+ # QtTest component.
85
+ QT_TEST = ModuleBinder.new( 'QT_TEST_LIB', 'QtTest4' )
86
+ # QtXml component.
87
+ QT_XML = ModuleBinder.new( 'QT_XML_LIB', 'QtXml4' )
88
+ # QtXmlPatterns component.
89
+ QT_XML_PATTERNS = ModuleBinder.new(
90
+ 'QT_XMLPATTERNS_LIB',
91
+ 'QtXmlPatterns4' )
92
+ # QtWebKit component.
93
+ QT_WEB_KIT = ModuleBinder.new(
94
+ 'QT_WEBKIT_LIB',
95
+ 'QtWebKit4' )
96
+ # Phonon component.
97
+ QT_PHONON = ModuleBinder.new(
98
+ 'QT_PHONON_LIB',
99
+ 'phonon4' )
100
+ end
101
+
102
+ # Files generator for Qt4 class.
103
+ #
104
+ # Main features:
105
+ #
106
+ # - building of moc-files using moc tool.
107
+ # Generation from source and header files is supported.
108
+ # - building header files from ui-files using uic-compiler.
109
+ #
110
+ # Generated source files automatically added into
111
+ # cpp_source list of target.
112
+ #
113
+ # Local list defines is supported.
114
+ #
115
+ # If only pointer to the target passed into contructor,
116
+ # default list of defines is used. If it's required to change
117
+ # default list, new list should be passed through a second argument:
118
+ #
119
+ # generator( MxxRu::Cpp::Qt4.new( self, [ "QT_DEPRECATED_WARNINGS" ] ) )
120
+ #
121
+ class Qt4 < MxxRu::AbstractGenerator
122
+ # Default list of defines.
123
+ # QT_DLL
124
+ DEFAULT_DEFINES = [ 'QT_DLL', 'QT_THREAD_SUPPORT' ]
125
+
126
+ # moc tool executable
127
+ # Default: moc
128
+ attr_accessor :moc_name
129
+
130
+ # uic tool executable
131
+ # Default: uic.
132
+ attr_accessor :uic_name
133
+
134
+ # rcc tool executable
135
+ # Default: rcc.
136
+ attr_accessor :rcc_name
137
+
138
+ # File extension for source files generated.
139
+ # Used in both moc and uic tools.
140
+ # Default: .cpp
141
+ attr_accessor :cpp_ext
142
+
143
+ # File extension for header files generated.
144
+ # Used in uic tool.
145
+ # Default: .h
146
+ attr_accessor :hpp_ext
147
+
148
+ # File extension for moc files generated.
149
+ # Used in moc tool.
150
+ # Default: .moc
151
+ attr_accessor :moc_ext
152
+
153
+ # Subfolder name where moc generated files would be located.
154
+ # If nil, generated files would be in the same folder
155
+ # where source files were.
156
+ # Default: nil
157
+ attr_accessor :moc_result_subdir
158
+
159
+ # Subfolder name where results of uic invokation must be placed.
160
+ # If nil, generated files would be in the same folder where
161
+ # source ui files were.
162
+ attr_accessor :uic_result_subdir
163
+
164
+ # Subfolder name where results of rcc invokation must be placed.
165
+ # If nil, generated files would be in the same folder where
166
+ # source qrc files were.
167
+ # Used only for qrc2cpp translation.
168
+ attr_accessor :qrc_result_subdir
169
+
170
+ # Files list for generating moc files from header files.
171
+ #
172
+ # More exact: a.hpp -> moc_a.cpp. moc_a.cpp file is added
173
+ # to cpp_source list of a target.
174
+ attr_reader :qt_h2moc_files
175
+
176
+ # Files list for generating moc files from source files.
177
+ #
178
+ # More exact: a.cpp -> a.moc.
179
+ attr_reader :qt_cpp2moc_files
180
+
181
+ # Files list for generating header files from ui files.
182
+ #
183
+ # More exact: a.ui -> ui_a.hpp
184
+ attr_reader :qt_ui_files
185
+
186
+ # Files list for generating source files from qrc files.
187
+ #
188
+ # More exact: a.qrc -> qrc_a.cpp
189
+ attr_reader :qt_qrc2cpp_files
190
+
191
+ # Files list for generating binary resource files from qrc files.
192
+ #
193
+ # More exact: a.qrc -> a.rcc
194
+ attr_reader :qt_qrc2rcc_files
195
+
196
+ # Target, generator is created for.
197
+ attr :target
198
+
199
+ # Constructor.
200
+ def initialize( a_target, a_defines = DEFAULT_DEFINES )
201
+ @moc_name = "moc"
202
+ @uic_name = "uic"
203
+ @rcc_name = "rcc"
204
+ @cpp_ext = ".cpp"
205
+ @hpp_ext = ".h"
206
+ @moc_ext = ".moc"
207
+ @moc_result_subdir = nil
208
+ @uic_result_subdir = nil
209
+ @qrc_result_subdir = nil
210
+
211
+ # If uic_result_subdir not nil than we must add
212
+ # uic_result_subdir into
213
+ # target include_path. But must do this only one time.
214
+ @uic_result_subdir_include_paths = Set.new
215
+
216
+ @qt_h2moc_files = []
217
+ @qt_cpp2moc_files = []
218
+ @qt_ui_files = []
219
+ @qt_qrc2cpp_files = []
220
+ @qt_qrc2rcc_files = []
221
+
222
+ defines_to_set = a_defines.flatten
223
+ defines_to_set.each { |d| a_target.define( d ) }
224
+
225
+ @target = a_target
226
+
227
+ # QtCore must be used.
228
+ use_module Qt4Modules::QT_CORE
229
+ end
230
+
231
+ # Add a file for hpp to moc generation.
232
+ def h2moc( a_file )
233
+ @qt_h2moc_files << @target.create_full_src_file_name( a_file )
234
+ end
235
+
236
+ # Add a file for cpp to moc generation.
237
+ def cpp2moc( a_file )
238
+ @qt_cpp2moc_files << @target.create_full_src_file_name( a_file )
239
+ end
240
+
241
+ # Add a file for ui to hpp generation.
242
+ def ui( a_file )
243
+ full_file_name = @target.create_full_src_file_name( a_file )
244
+ @qt_ui_files << full_file_name
245
+ if @uic_result_subdir
246
+ uic_result_path = make_uic_result_path_for( full_file_name )
247
+
248
+ if !@uic_result_subdir_include_paths.member?( uic_result_path )
249
+ @target.include_path( uic_result_path )
250
+ @uic_result_subdir_include_paths.add( uic_result_path )
251
+ end
252
+ end
253
+ end
254
+
255
+ # Add a file for qrc to cpp generation.
256
+ def qrc2cpp( a_file )
257
+ full_file_name = @target.create_full_src_file_name( a_file )
258
+ @qt_qrc2cpp_files << full_file_name
259
+ end
260
+
261
+ # Add a file for qrc to rcc generation.
262
+ def qrc2rcc( a_file )
263
+ full_file_name = @target.create_full_src_file_name( a_file )
264
+ @qt_qrc2rcc_files << full_file_name
265
+ end
266
+
267
+ # Add a Qt4 module to target.
268
+ #
269
+ # a_module -- an instance of Qt4Modules::ModuleBinder.
270
+ def use_module( a_module )
271
+ a_module.setup( @target )
272
+ end
273
+
274
+ # Add some Qt4 modules to target.
275
+ #
276
+ # a_modules -- an enumeration of Qt4Modules::ModuleBinder instances.
277
+ #
278
+ def use_modules( *a_modules )
279
+ a_modules.each { |m| use_module( m ) }
280
+ end
281
+
282
+ # Perform files generation.
283
+ def build( a_target )
284
+ build_from_ui( a_target )
285
+ build_from_qrc2cpp( a_target )
286
+ build_from_qrc2rcc( a_target )
287
+ build_from_h( a_target )
288
+ build_from_cpp( a_target )
289
+ end
290
+
291
+ # Perform generated files cleanup.
292
+ def clean( a_target )
293
+ clean_from_ui( a_target )
294
+ clean_from_qrc2cpp( a_target )
295
+ clean_from_qrc2rcc( a_target )
296
+ clean_from_h( a_target )
297
+ clean_from_cpp( a_target )
298
+ end
299
+
300
+ # Add qtmain component for target.
301
+ def lib_qtmain
302
+ @target.lib 'qtmain'
303
+ self
304
+ end
305
+
306
+ protected
307
+
308
+ # Perform generation from ui-files.
309
+ def build_from_ui( a_target )
310
+ @qt_ui_files.each { |ui|
311
+ ui_header = header_from_ui( ui, a_target )
312
+ MxxRu::Util::ensure_path_exists( File.dirname( ui_header ) )
313
+
314
+ # Checking what files are changed and running generation
315
+ # from them if necessary.
316
+ if TargetState::EXISTS != TargetState.detect(
317
+ ui_header, [ ui ] ).state
318
+ MxxRu::AbstractTarget::run(
319
+ [ "#{@uic_name} -o #{ui_header} #{ui}" ],
320
+ [ ui_header ],
321
+ "building header file #{ui_header}" )
322
+ end
323
+ }
324
+ end
325
+
326
+ # Perform cleanup of files, generated from ui files.
327
+ def clean_from_ui( a_target )
328
+ @qt_ui_files.each { |ui|
329
+ ui_header = header_from_ui( ui, a_target )
330
+
331
+ MxxRu::Util::delete_file( ui_header )
332
+ }
333
+ end
334
+
335
+ # Getting file name, generated by uic tool.
336
+ #
337
+ def header_from_ui( a_ui_file, a_target )
338
+ path, file_name = File.split( a_ui_file )
339
+ updated_file_name = 'ui_' +
340
+ MxxRu::Util::remove_file_ext( file_name ) +
341
+ @hpp_ext
342
+
343
+ if @uic_result_subdir then
344
+ result = File.join( path, @uic_result_subdir, updated_file_name )
345
+ else
346
+ result = File.join( path, updated_file_name )
347
+ end
348
+
349
+ result
350
+ end
351
+
352
+ # Perform generation from qrc-files.
353
+ def build_from_qrc2cpp( a_target )
354
+ @qt_qrc2cpp_files.each { |qrc_file|
355
+ name = File.basename( MxxRu::Util::remove_file_ext( qrc_file ) )
356
+ qrc_cpp = source_from_qrc( qrc_file, a_target )
357
+ MxxRu::Util::ensure_path_exists( File.dirname( qrc_cpp ) )
358
+
359
+ # Checking what files are changed and running generation
360
+ # from them if necessary.
361
+ if TargetState::EXISTS != TargetState.detect(
362
+ qrc_cpp,
363
+ [ qrc_file ] + Qt4.detect_qrc_file_dependencies( qrc_file ) ).state
364
+ MxxRu::AbstractTarget::run(
365
+ [ "#{@rcc_name} -name #{name} -o #{qrc_cpp} #{qrc_file}" ],
366
+ [ qrc_cpp ],
367
+ "building source file #{qrc_cpp}" )
368
+ end
369
+
370
+ add_cpp_source( a_target, qrc_cpp )
371
+ }
372
+ end
373
+
374
+ # Perform cleanup of files, generated from qrc files.
375
+ #
376
+ def clean_from_qrc2cpp( a_target )
377
+ @qt_qrc2cpp_files.each { |qrc_file|
378
+ qrc_cpp = source_from_qrc( qrc_file, a_target )
379
+
380
+ # It is necessary to delete obj-file.
381
+ add_cpp_source( a_target, qrc_cpp )
382
+
383
+ MxxRu::Util::delete_file( qrc_cpp )
384
+ }
385
+ end
386
+
387
+ # Getting file name, generated by rcc tool.
388
+ #
389
+ def source_from_qrc( a_qrc_file, a_target )
390
+ path, file_name = File.split( a_qrc_file )
391
+ updated_file_name = 'qrc_' +
392
+ MxxRu::Util::remove_file_ext( file_name ) +
393
+ @cpp_ext
394
+
395
+ if @qrc_result_subdir then
396
+ result = File.join( path, @qrc_result_subdir, updated_file_name )
397
+ else
398
+ result = File.join( path, updated_file_name )
399
+ end
400
+
401
+ result
402
+ end
403
+
404
+ # Perform generation from qrc-files.
405
+ def build_from_qrc2rcc( a_target )
406
+ @qt_qrc2rcc_files.each { |qrc_file|
407
+ name = File.basename( MxxRu::Util::remove_file_ext( qrc_file ) )
408
+ target_path =
409
+ File.dirname( a_target.create_full_result_target_file_name )
410
+ MxxRu::Util::ensure_path_exists( target_path )
411
+
412
+ rcc_file = File.join( target_path, name + '.rcc' )
413
+
414
+ # Checking what files are changed and running generation
415
+ # from them if necessary.
416
+ if TargetState::EXISTS != TargetState.detect(
417
+ rcc_file,
418
+ [ qrc_file ] + Qt4.detect_qrc_file_dependencies( qrc_file ) ).state
419
+ MxxRu::AbstractTarget::run(
420
+ [ "#{@rcc_name} -binary -name #{name} -o #{rcc_file} #{qrc_file}" ],
421
+ [ rcc_file ],
422
+ "building Qt4 resource file #{rcc_file}" )
423
+ end
424
+ }
425
+ end
426
+
427
+ # Perform cleanup of files, generated from qrc files.
428
+ #
429
+ def clean_from_qrc2rcc( a_target )
430
+ @qt_qrc2rcc_files.each { |qrc_file|
431
+ name = File.basename( MxxRu::Util::remove_file_ext( qrc_file ) )
432
+ target_path =
433
+ File.dirname( a_target.create_full_result_target_file_name )
434
+ rcc_file = File.join( target_path, name + '.rcc' )
435
+
436
+ MxxRu::Util::delete_file( rcc_file )
437
+ }
438
+ end
439
+
440
+ # Perform generation from hpp file using moc tool.
441
+ def build_from_h( a_target )
442
+ @qt_h2moc_files.each { |header_full|
443
+ moc_full = moc_from_h( header_full, a_target )
444
+
445
+ if TargetState::EXISTS != TargetState.detect(
446
+ moc_full, [ header_full ] ).state
447
+ MxxRu::AbstractTarget::run(
448
+ [ "#{moc_name} -o #{moc_full} " +
449
+ "#{header_full}" ],
450
+ [ moc_full ],
451
+ "building moc file #{moc_full}" )
452
+ end
453
+
454
+ add_cpp_source( a_target, moc_full )
455
+ }
456
+ end
457
+
458
+ # Perform cleanup of files produced by generation from hpp file.
459
+ def clean_from_h( a_target )
460
+ @qt_h2moc_files.each { |h|
461
+ moc = moc_from_h( h, a_target )
462
+
463
+ MxxRu::Util::delete_file( moc )
464
+
465
+ add_cpp_source( a_target, moc )
466
+ }
467
+ end
468
+
469
+ # Formatting file name, which is generated from hpp file by moc tool
470
+ def moc_from_h( a_h_file, a_target )
471
+ path = File.dirname( a_h_file )
472
+
473
+ # If path == ".", then Qt will generate wrong include directive
474
+ path = "" if path == "./"
475
+ path = make_moc_result_path_for( path )
476
+
477
+ MxxRu::Util::ensure_path_exists( path )
478
+
479
+ r = File.join( path, "moc_" + File.basename(
480
+ MxxRu::Util::remove_file_ext( a_h_file ) ) + @cpp_ext )
481
+ end
482
+
483
+ # Perform generation from cpp file using moc tool.
484
+ def build_from_cpp( a_target )
485
+ @qt_cpp2moc_files.each { |cpp_full|
486
+ moc_full = moc_from_cpp( cpp_full, a_target )
487
+
488
+ if TargetState::EXISTS != TargetState.detect(
489
+ moc_full, [ cpp_full ] ).state
490
+ MxxRu::AbstractTarget::run(
491
+ [ "#{moc_name} -o #{moc_full} " +
492
+ "#{cpp_full}" ],
493
+ [ moc_full ],
494
+ "building moc file #{moc_full}" )
495
+ end
496
+ }
497
+ end
498
+
499
+ # Perform cleanup of files produced by generation from cpp file.
500
+ def clean_from_cpp( a_target )
501
+ @qt_cpp2moc_files.each { |cpp|
502
+ moc = moc_from_cpp( cpp, a_target )
503
+
504
+ MxxRu::Util::delete_file( moc )
505
+ }
506
+ end
507
+
508
+ # Formatting file name, which is generated from cpp file by moc tool
509
+ def moc_from_cpp( a_cpp_file, a_target )
510
+ path = make_moc_result_path_for( File.dirname( a_cpp_file ) )
511
+
512
+ MxxRu::Util::ensure_path_exists( path )
513
+
514
+ r = File.join( path, File.basename(
515
+ MxxRu::Util::remove_file_ext( a_cpp_file ) ) + @moc_ext )
516
+
517
+ return r
518
+ end
519
+
520
+ # Setting C++ file name, ignoring current sources_root value.
521
+ def add_cpp_source( a_target, a_file )
522
+ old_root = a_target.sources_root( "" )
523
+ a_target.cpp_source( a_file )
524
+ a_target.sources_root( old_root )
525
+ end
526
+
527
+ # Calculating path for moc results.
528
+ def make_moc_result_path_for( path )
529
+ if @moc_result_subdir
530
+ if path.length > 0
531
+ File.join( path, @moc_result_subdir )
532
+ else
533
+ @moc_result_subdir
534
+ end
535
+ else
536
+ path
537
+ end
538
+ end
539
+
540
+ # Calculating path for uic results.
541
+ def make_uic_result_path_for( file )
542
+ File.join( File.dirname( file ), @uic_result_subdir )
543
+ end
544
+
545
+ # Detect list of dependencies for .qrc file.
546
+ def Qt4.detect_qrc_file_dependencies( a_qrc_file )
547
+ qrc_file_path = File.dirname( a_qrc_file )
548
+ result = []
549
+ File.open( a_qrc_file, 'r' ) do |file|
550
+ doc = REXML::Document.new( file )
551
+ result = doc.elements[ '/RCC/qresource/file' ].inject( [] ) do
552
+ |list, item|
553
+ s = item.value
554
+ p = Pathname.new( s )
555
+ if !p.absolute?
556
+ list << File.join( qrc_file_path, s )
557
+ else
558
+ list << s
559
+ end
560
+ list
561
+ end
562
+ end
563
+
564
+ result
565
+ end
566
+
567
+ end # class Qt4
568
+
569
+ end
570
+ end
571
+