| 1148 |
dpurdie |
1 |
########################################################################
|
| 1152 |
dpurdie |
2 |
# Copyright (C) 1998-2012 Vix Technology, All rights reserved
|
| 1148 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : qt-builder.pm
|
|
|
5 |
# Module type : Makefile system
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : Provide JATS build support for the QT SDK
|
| 1152 |
dpurdie |
10 |
# This module hooks into the internals of JATS
|
| 1148 |
dpurdie |
11 |
# It tries to be generic, buts its not easy
|
|
|
12 |
#
|
|
|
13 |
#......................................................................#
|
|
|
14 |
|
|
|
15 |
require 5.008_002;
|
|
|
16 |
use strict;
|
|
|
17 |
use warnings;
|
|
|
18 |
use MakeEntry;
|
|
|
19 |
|
|
|
20 |
#
|
|
|
21 |
# Global Varibales
|
|
|
22 |
#
|
|
|
23 |
our %SRC_DEPEND; # Source file dependencies
|
|
|
24 |
our %SRC_ARGS; # Source file arguments
|
| 5842 |
dpurdie |
25 |
our @RCC; # List of compiled resource files
|
| 1148 |
dpurdie |
26 |
|
|
|
27 |
#
|
|
|
28 |
# Local variables
|
|
|
29 |
#
|
|
|
30 |
my $qt_package; # Ref to package containing QT
|
|
|
31 |
my %qt_used; # Track Used items
|
| 1152 |
dpurdie |
32 |
my @moc_defs; # Defines for MOC
|
| 1148 |
dpurdie |
33 |
|
|
|
34 |
#-------------------------------------------------------------------------------
|
|
|
35 |
# Function : BEGIN
|
|
|
36 |
#
|
|
|
37 |
# Description : Setup directive hooks
|
|
|
38 |
# Register to be told about source files that are QT specific
|
|
|
39 |
#
|
|
|
40 |
# Inputs : None
|
|
|
41 |
#
|
|
|
42 |
# Returns : None
|
|
|
43 |
#
|
|
|
44 |
BEGIN
|
|
|
45 |
{
|
|
|
46 |
#
|
| 1150 |
dpurdie |
47 |
# Locate the QT package
|
|
|
48 |
# Done by looking for the include/QtGui directory
|
|
|
49 |
# If we don't find it then don't install the Qt hooks
|
|
|
50 |
# Generate a warning when Qt is 'Used'
|
|
|
51 |
# This allows for the building of packages that have Qt and Non-Qt parts
|
|
|
52 |
#
|
|
|
53 |
foreach my $entry ( getPackageList() )
|
|
|
54 |
{
|
|
|
55 |
foreach my $path ( $entry->getIncDirs(1) )
|
|
|
56 |
{
|
|
|
57 |
if ( -d "$path/QtGui" )
|
|
|
58 |
{
|
|
|
59 |
$qt_package = $entry;
|
|
|
60 |
last;
|
|
|
61 |
}
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
#
|
|
|
66 |
# Qt not supported in this type of a build
|
|
|
67 |
# Just exist now. Will create an error if QtUses is activated
|
|
|
68 |
#
|
|
|
69 |
return
|
|
|
70 |
unless ( $qt_package );
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
#
|
| 1148 |
dpurdie |
74 |
# Define QT specfic rules.
|
|
|
75 |
# Will be found in the same directory as this file
|
|
|
76 |
#
|
|
|
77 |
Rules ( StripFileExt( __FILE__ ), 'qt.rul' );
|
|
|
78 |
|
|
|
79 |
#
|
|
|
80 |
# Register interest in various types of source file
|
|
|
81 |
# Currently only header files are examined for MOC processing
|
|
|
82 |
#
|
|
|
83 |
RegisterSrcHook ('.qrc', \&src_hook_qrc );
|
|
|
84 |
RegisterSrcHook ('.ui', \&src_hook_ui );
|
|
|
85 |
RegisterSrcHook ('.h', \&src_hook_h );
|
|
|
86 |
RegisterSrcHook ('.cpp', \&src_hook_cpp );
|
| 1150 |
dpurdie |
87 |
RegisterSrcHook ('.ts', \&src_hook_ts );
|
| 1148 |
dpurdie |
88 |
|
| 1152 |
dpurdie |
89 |
# Register a function to be called just before we start to
|
|
|
90 |
# generate makefiles. This will be used to process the data
|
| 1148 |
dpurdie |
91 |
#
|
| 1152 |
dpurdie |
92 |
RegisterMakefileGenerate (\&qtBuilder_Generate);
|
|
|
93 |
|
|
|
94 |
#
|
| 1148 |
dpurdie |
95 |
# Files will be placed into the OBJDIR
|
|
|
96 |
# Ensure that the compiler searches this directory
|
|
|
97 |
#
|
|
|
98 |
AddIncDir( '*' , "\$(OBJDIR)", '--NoWarn' );
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
#-------------------------------------------------------------------------------
|
|
|
102 |
# Function : QtUses
|
|
|
103 |
#
|
|
|
104 |
# Description : User directive to provide information as to which parts of
|
|
|
105 |
# Qt are being used.
|
|
|
106 |
#
|
|
|
107 |
# Done this way for two reasons:
|
|
|
108 |
# 1) Allow the Include path to be extended
|
|
|
109 |
# Qt has a lot of subdirs in 'include'
|
|
|
110 |
# Placing all of these in the include path
|
|
|
111 |
# slows down the compilation
|
|
|
112 |
#
|
|
|
113 |
# 2) Allow JATS to provide a '--Uses' construct for
|
|
|
114 |
# programs and shared libraries taht provide a machine
|
|
|
115 |
# independent mechanism for adding the required libs
|
|
|
116 |
#
|
|
|
117 |
# Inputs : $platforms - Platform predicate
|
|
|
118 |
# @components - Compoents to use
|
|
|
119 |
#
|
|
|
120 |
# Returns :
|
|
|
121 |
#
|
|
|
122 |
sub QtUses
|
|
|
123 |
{
|
|
|
124 |
my ($platforms, @components) = @_;
|
|
|
125 |
Debug( "QtUses: ",$platforms, @components );
|
|
|
126 |
return if ( ! ActivePlatform($platforms) );
|
|
|
127 |
|
| 1150 |
dpurdie |
128 |
Error ("Cannot find the Qt Base Package, or Qt is not supported", "on this platform") unless ( $qt_package );
|
|
|
129 |
|
| 1148 |
dpurdie |
130 |
foreach my $component ( @components )
|
|
|
131 |
{
|
|
|
132 |
#
|
|
|
133 |
# Only do it once
|
|
|
134 |
#
|
|
|
135 |
next if ( exists $qt_used{$component} );
|
|
|
136 |
$qt_used{$component} = 1;
|
|
|
137 |
|
|
|
138 |
#
|
|
|
139 |
# Extend the header search path to include the required headers
|
|
|
140 |
#
|
|
|
141 |
my $dir;
|
|
|
142 |
foreach my $path ( $qt_package->getIncDirs(2) )
|
|
|
143 |
{
|
|
|
144 |
if ( -d "$path/$component" )
|
|
|
145 |
{
|
|
|
146 |
$dir = "$path/$component";
|
|
|
147 |
last;
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
Error ("Qt component not supported: $component")
|
|
|
151 |
unless ( $dir );
|
|
|
152 |
AddIncDir ('*', '--NoWarn','--System', $dir );
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
################################################################################
|
|
|
156 |
#
|
|
|
157 |
# Following code currently not active
|
|
|
158 |
# There is no one-one relationship between QT include dirs and libraries
|
|
|
159 |
#
|
|
|
160 |
# Dont know how Trolltech do it. Might be hard coded
|
|
|
161 |
#
|
|
|
162 |
################################################################################
|
|
|
163 |
#
|
|
|
164 |
# #
|
|
|
165 |
# # Extend a --Users(QT) definition to provide libraries for the user
|
|
|
166 |
# # There are problems
|
|
|
167 |
# # Under windows, some of the libraries have a 4 suffix
|
|
|
168 |
# # Need to determine the exact name of the library
|
|
|
169 |
# # Normally this knowledge is buried within the compiler/linker and
|
|
|
170 |
# # some JATS tools.
|
|
|
171 |
# #
|
|
|
172 |
# # Algorithm:
|
|
|
173 |
# # Given a library name, determine if the file exists
|
|
|
174 |
# # under both windows and linux
|
|
|
175 |
# # If Unix - prefix with lib
|
|
|
176 |
# # If Unix - try shared-lib, static lib suffix
|
|
|
177 |
# # If Windows - try static lib suffix
|
|
|
178 |
# #
|
|
|
179 |
# my @prefix = ('', 'lib');
|
|
|
180 |
# my @suffix = ($::so, $::a );
|
|
|
181 |
# my $found;
|
|
|
182 |
# HUNT:
|
|
|
183 |
# foreach my $qtsuf ( '4', '' )
|
|
|
184 |
# {
|
|
|
185 |
# foreach my $suffix ( @suffix )
|
|
|
186 |
# {
|
|
|
187 |
# foreach my $prefix ( @prefix )
|
|
|
188 |
# {
|
|
|
189 |
# my $cname = $prefix . $component . $qtsuf . '.' . $suffix;
|
|
|
190 |
# foreach my $path ( $qt_package->getLibDirs(2) )
|
|
|
191 |
# {
|
|
|
192 |
# if ( -f "$path/$cname" )
|
|
|
193 |
# {
|
|
|
194 |
# $found = $component . $qtsuf;
|
|
|
195 |
# last HUNT;
|
|
|
196 |
# }
|
|
|
197 |
# }
|
|
|
198 |
# }
|
|
|
199 |
# }
|
|
|
200 |
# }
|
|
|
201 |
#
|
|
|
202 |
# Error ("QT library component not supported: $component")
|
|
|
203 |
# unless ( $found );
|
|
|
204 |
#
|
|
|
205 |
# MakeIf::Libaries ( 'QT', '*', "-L$found");
|
|
|
206 |
################################################################################
|
|
|
207 |
}
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
#-------------------------------------------------------------------------------
|
| 1152 |
dpurdie |
211 |
# Function : AddMocFlags
|
|
|
212 |
#
|
|
|
213 |
# Description : Provide a definition to the MOC file genorator AND the
|
|
|
214 |
# C / C++ compiler
|
|
|
215 |
#
|
|
|
216 |
# Inputs : $platforms - Standard platform args
|
|
|
217 |
# @defs - Flags passed to the Moc
|
|
|
218 |
#
|
|
|
219 |
# Returns : Nothing
|
|
|
220 |
#
|
|
|
221 |
sub AddMocFlags
|
|
|
222 |
{
|
|
|
223 |
my ($platforms, @args) = @_;
|
|
|
224 |
Debug( "AddMocFlags: ",$platforms, @args );
|
|
|
225 |
return if ( ! ActivePlatform($platforms) );
|
|
|
226 |
|
|
|
227 |
#
|
|
|
228 |
# Save for later
|
|
|
229 |
#
|
|
|
230 |
push @moc_defs, @args;
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
#-------------------------------------------------------------------------------
|
| 1148 |
dpurdie |
236 |
# Function : src_hook_qrc
|
|
|
237 |
#
|
|
|
238 |
# Description : This function will be invoked when a .QRC file
|
|
|
239 |
# is encountered in the Src directive
|
|
|
240 |
#
|
|
|
241 |
# .qrc file are QT resource files
|
| 5842 |
dpurdie |
242 |
# There are two processing options
|
|
|
243 |
# Default : Proccess into a .cpp file
|
|
|
244 |
# and then compiled into a .obj file
|
|
|
245 |
# --Binary : Process directly into a .rcc file
|
|
|
246 |
# These are loaded at runtime by the QT application
|
|
|
247 |
# Also made available via the global @RCC varaible to assist packaging
|
| 1148 |
dpurdie |
248 |
#
|
|
|
249 |
# Inputs : $path - Source path
|
|
|
250 |
# $path - Source file name
|
|
|
251 |
# $obj - Base file name (no dir or ext)
|
|
|
252 |
# $ext - Extension
|
|
|
253 |
#
|
|
|
254 |
# Returns :
|
|
|
255 |
#
|
|
|
256 |
sub src_hook_qrc
|
|
|
257 |
{
|
|
|
258 |
Debug ("src_hook_qrc: @_");
|
|
|
259 |
my ( $srcfile ,$path, $obj, $ext ) = @_;
|
|
|
260 |
my @dlist = ();
|
| 5842 |
dpurdie |
261 |
my $csource;
|
|
|
262 |
my $buildDirName;
|
|
|
263 |
my $isBinary = ($SRC_ARGS{ $path } && grep (/^--Binary$/i, split( /$;/, $SRC_ARGS{$path} ) ) ) ? 1 : 0;
|
| 1148 |
dpurdie |
264 |
|
|
|
265 |
#
|
|
|
266 |
# The .qrc file will be converted into a cpp file
|
|
|
267 |
# Treat the .cpp file as a source file in its own right
|
|
|
268 |
#
|
| 5842 |
dpurdie |
269 |
if ($isBinary)
|
|
|
270 |
{
|
|
|
271 |
#
|
|
|
272 |
# Binary resource
|
|
|
273 |
# Treat it a bit like a program
|
|
|
274 |
# Put its name into an @RCC array to simplify packaging
|
|
|
275 |
# Tag it as a source file so that it can be packaged
|
|
|
276 |
my $oName = $obj . '.rcc';
|
|
|
277 |
$csource = '$(BINDIR)/' . $oName;
|
|
|
278 |
$buildDirName = '$(GBE_BINDIR)';
|
|
|
279 |
ToolsetGenerate($csource);
|
|
|
280 |
push @RCC, $oName;
|
|
|
281 |
Src ('*', $csource);
|
| 1148 |
dpurdie |
282 |
|
| 5842 |
dpurdie |
283 |
} else {
|
|
|
284 |
#
|
|
|
285 |
# Compiled resource
|
|
|
286 |
# Convert to a .cpp, which will then be made available
|
|
|
287 |
# Give the object a different name incase the user has a resource file and a
|
|
|
288 |
# program file of the same name.
|
|
|
289 |
#
|
|
|
290 |
$csource = '$(OBJDIR)/' . $obj . '.cpp';
|
|
|
291 |
$buildDirName = '$(GBE_OBJDIR)';
|
|
|
292 |
$obj = 'qrc_' . $obj;
|
|
|
293 |
GenerateSrcFile ( 1, $csource );
|
|
|
294 |
}
|
|
|
295 |
|
| 1148 |
dpurdie |
296 |
#
|
|
|
297 |
# The user may have specified some dependencies
|
|
|
298 |
# Create a list of these to be a part of the generated Rule
|
|
|
299 |
#
|
|
|
300 |
@dlist = split( /$;/, $SRC_DEPEND{$path} )
|
|
|
301 |
if ( exists $SRC_DEPEND{$path} );
|
|
|
302 |
|
|
|
303 |
#
|
|
|
304 |
# Parse the source file and extract dependencies
|
|
|
305 |
# The file is of a known XML format
|
|
|
306 |
# Depenedencies are not nested
|
|
|
307 |
# Implement a simple parser
|
|
|
308 |
#
|
|
|
309 |
# Look for lines of the form:
|
|
|
310 |
# <file ....>FileName</file>
|
|
|
311 |
#
|
|
|
312 |
# The source file may not acually exist. It may be symbolic
|
|
|
313 |
# If the file doesn't exist, then don't complain.
|
|
|
314 |
#
|
|
|
315 |
if ( -e $srcfile )
|
|
|
316 |
{
|
|
|
317 |
if (open (SF, '<', $srcfile ))
|
|
|
318 |
{
|
|
|
319 |
my $srcdir = StripFileExt( $srcfile );
|
|
|
320 |
$srcdir .= '/' if ( $srcdir );
|
|
|
321 |
while ( <SF> )
|
|
|
322 |
{
|
|
|
323 |
if ( m~<file.*>(.*)</file>~ )
|
|
|
324 |
{
|
|
|
325 |
my $name = $1;
|
|
|
326 |
$name =~ s~([ ,])~\\$1~g;
|
|
|
327 |
push @dlist, "$srcdir$name";
|
|
|
328 |
}
|
|
|
329 |
}
|
|
|
330 |
close SF;
|
|
|
331 |
}
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
#
|
|
|
335 |
# Create a Rule to build this file
|
|
|
336 |
# Will be placed in the Rules section
|
|
|
337 |
#
|
|
|
338 |
my $var;
|
|
|
339 |
my $me = MakeEntry::New (\$var, $csource );
|
| 5842 |
dpurdie |
340 |
$me->AddComment ("QT Resource Compiler: $path" );
|
| 1148 |
dpurdie |
341 |
$me->AddDependancy ( $srcfile );
|
|
|
342 |
$me->AddDependancy ( @dlist );
|
| 5842 |
dpurdie |
343 |
$me->AddDependancy ( '$(SCM_MAKEFILE)', $buildDirName );
|
|
|
344 |
if ($isBinary) {
|
|
|
345 |
$me->AddRecipe ( '$(XX_PRE)$(QT_RCCBIN)' );
|
|
|
346 |
} else {
|
|
|
347 |
$me->AddRecipe ( '$(XX_PRE)$(QT_RCC)' );
|
|
|
348 |
}
|
| 1148 |
dpurdie |
349 |
$me->Print();
|
|
|
350 |
|
|
|
351 |
ToolsetRule ( $var );
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
#-------------------------------------------------------------------------------
|
|
|
355 |
# Function : src_hook_ui
|
|
|
356 |
#
|
|
|
357 |
# Description : This function will be invoked when a .UI file
|
|
|
358 |
# is encountered in the Src directive
|
|
|
359 |
#
|
|
|
360 |
# .ui file are QT User Interface files
|
|
|
361 |
# These need to be processed into header files
|
|
|
362 |
# by the User Interface Compiler
|
|
|
363 |
#
|
|
|
364 |
# Inputs : $path - Source path
|
|
|
365 |
# $path - Source file name
|
|
|
366 |
# $obj - Base file name (no dir or ext)
|
|
|
367 |
# $ext - Extension
|
|
|
368 |
#
|
|
|
369 |
# Returns :
|
|
|
370 |
#
|
|
|
371 |
sub src_hook_ui
|
|
|
372 |
{
|
|
|
373 |
Debug ("src_hook_ui: @_");
|
|
|
374 |
my ( $srcfile ,$path, $obj, $ext ) = @_;
|
|
|
375 |
|
|
|
376 |
#
|
|
|
377 |
# Convert the UI file into a header file
|
|
|
378 |
# Place the header file in the OBJ directory
|
|
|
379 |
#
|
|
|
380 |
my $target = "\$(OBJDIR)/ui_$obj.h";
|
|
|
381 |
GenerateSrcFile ( 1, $target );
|
|
|
382 |
|
|
|
383 |
#
|
|
|
384 |
# The user may have specified some dependencies
|
|
|
385 |
# Create a list of these to be a part of the generated Rule
|
|
|
386 |
#
|
|
|
387 |
my @dlist = split( /$;/, $SRC_DEPEND{$path} )
|
|
|
388 |
if ( exists $SRC_DEPEND{$path} );
|
|
|
389 |
|
|
|
390 |
#
|
|
|
391 |
# Create a Rule to build this file
|
|
|
392 |
# Will be placed in the Rules section
|
|
|
393 |
#
|
|
|
394 |
my $var;
|
|
|
395 |
my $me = MakeEntry::New (\$var, $target );
|
|
|
396 |
# $me->AddComment ("QT User Interface File: $path" );
|
|
|
397 |
$me->AddDependancy ( $srcfile );
|
|
|
398 |
$me->AddDependancy ( @dlist );
|
|
|
399 |
$me->AddDependancy ( '$(SCM_MAKEFILE)' );
|
|
|
400 |
$me->AddDependancy ( '$(GBE_OBJDIR)' );
|
|
|
401 |
$me->AddRecipe ( '$(XX_PRE)$(QT_UIC)' );
|
|
|
402 |
$me->Print();
|
|
|
403 |
|
|
|
404 |
ToolsetRule ( $var );
|
|
|
405 |
}
|
|
|
406 |
|
|
|
407 |
#-------------------------------------------------------------------------------
|
|
|
408 |
# Function : src_hook_h
|
|
|
409 |
#
|
|
|
410 |
# Description : This function will be invoked when a .h file
|
|
|
411 |
# is encountered in the Src directive
|
|
|
412 |
#
|
|
|
413 |
# If the file is flagged as --Moc then it will treated
|
|
|
414 |
# by the MOC processor
|
|
|
415 |
#
|
|
|
416 |
# Inputs : $path - Source path
|
|
|
417 |
# $path - Source file name
|
|
|
418 |
# $obj - Base file name (no dir or ext)
|
|
|
419 |
# $ext - Extension
|
|
|
420 |
#
|
|
|
421 |
# Returns :
|
|
|
422 |
#
|
|
|
423 |
sub src_hook_h
|
|
|
424 |
{
|
|
|
425 |
Debug ("src_hook_h: @_");
|
|
|
426 |
my ( $srcfile ,$path, $obj, $ext ) = @_;
|
|
|
427 |
|
|
|
428 |
#
|
|
|
429 |
# Only interested in files that are flagged as --Moc
|
|
|
430 |
#
|
|
|
431 |
return unless ( $SRC_ARGS{ $path } && grep (/^--Moc$/i, split( /$;/, $SRC_ARGS{$path} ) ) );
|
|
|
432 |
|
|
|
433 |
#
|
|
|
434 |
# The file will be converted into a cpp file
|
|
|
435 |
# Treat the .cpp file as a source file in its own right
|
|
|
436 |
#
|
|
|
437 |
$obj = 'moc_' . $obj;
|
|
|
438 |
my $csource = '$(OBJDIR)/' . $obj . '.cpp' ;
|
|
|
439 |
GenerateSrcFile ( 1, $csource );
|
|
|
440 |
|
|
|
441 |
#
|
|
|
442 |
# The user may have specified some dependencies
|
|
|
443 |
# Create a list of these to be a part of the generated Rule
|
|
|
444 |
#
|
|
|
445 |
my @dlist = split( /$;/, $SRC_DEPEND{$path} )
|
|
|
446 |
if ( exists $SRC_DEPEND{$path} );
|
|
|
447 |
|
|
|
448 |
#
|
|
|
449 |
# Create a Rule to build this file
|
|
|
450 |
# Will be placed in the Rules section
|
|
|
451 |
#
|
|
|
452 |
my $var;
|
|
|
453 |
my $me = MakeEntry::New (\$var, $csource );
|
|
|
454 |
# $me->AddComment ("QT Meta Object Compiler: $path" );
|
|
|
455 |
$me->AddDependancy ( $srcfile );
|
|
|
456 |
$me->AddDependancy ( @dlist );
|
|
|
457 |
$me->AddDependancy ( '$(SCM_MAKEFILE)' );
|
|
|
458 |
$me->AddDependancy ( '$(GBE_OBJDIR)' );
|
|
|
459 |
$me->AddRecipe ( '$(XX_PRE)$(QT_MOC)' );
|
|
|
460 |
$me->Print();
|
|
|
461 |
|
|
|
462 |
ToolsetRule ( $var );
|
|
|
463 |
|
|
|
464 |
}
|
|
|
465 |
|
|
|
466 |
#-------------------------------------------------------------------------------
|
|
|
467 |
# Function : src_hook_cpp
|
|
|
468 |
#
|
|
|
469 |
# Description : This function will be invoked when a .cpp file
|
|
|
470 |
# is encountered in the Src directive
|
|
|
471 |
#
|
|
|
472 |
# If the file is flagged as --Moc then it will treated
|
|
|
473 |
# by the MOC processor
|
|
|
474 |
#
|
|
|
475 |
# Inputs : $path - Source path
|
|
|
476 |
# $path - Source file name
|
|
|
477 |
# $obj - Base file name (no dir or ext)
|
|
|
478 |
# $ext - Extension
|
|
|
479 |
#
|
|
|
480 |
# Returns :
|
|
|
481 |
#
|
|
|
482 |
sub src_hook_cpp
|
|
|
483 |
{
|
|
|
484 |
Debug ("src_hook_cpp: @_");
|
|
|
485 |
my ( $srcfile ,$path, $obj, $ext ) = @_;
|
|
|
486 |
|
|
|
487 |
#
|
|
|
488 |
# Only interested in files that are flagged as --Moc
|
|
|
489 |
#
|
|
|
490 |
return unless ( $SRC_ARGS{ $path } && grep (/^--Moc$/i, split( /$;/, $SRC_ARGS{$path} ) ) );
|
|
|
491 |
|
|
|
492 |
#
|
|
|
493 |
# The file will be converted into a .moc file as shown in the QT doco
|
|
|
494 |
# Treat the .moc file as a source file in its own right
|
|
|
495 |
#
|
|
|
496 |
my $csource = '$(OBJDIR)/' . $obj . '.moc' ;
|
|
|
497 |
GenerateSrcFile ( 1, $csource );
|
|
|
498 |
|
|
|
499 |
#
|
|
|
500 |
# The user may have specified some dependencies
|
|
|
501 |
# Create a list of these to be a part of the generated Rule
|
|
|
502 |
#
|
|
|
503 |
my @dlist = split( /$;/, $SRC_DEPEND{$path} )
|
|
|
504 |
if ( exists $SRC_DEPEND{$path} );
|
|
|
505 |
|
|
|
506 |
#
|
|
|
507 |
# Create a Rule to build this file
|
|
|
508 |
# Will be placed in the Rules section
|
|
|
509 |
#
|
|
|
510 |
my $var;
|
|
|
511 |
my $me = MakeEntry::New (\$var, $csource );
|
|
|
512 |
# $me->AddComment ("QT Meta Object Compiler: $path" );
|
|
|
513 |
$me->AddDependancy ( $srcfile );
|
|
|
514 |
$me->AddDependancy ( @dlist );
|
|
|
515 |
$me->AddDependancy ( '$(SCM_MAKEFILE)' );
|
|
|
516 |
$me->AddDependancy ( '$(GBE_OBJDIR)' );
|
|
|
517 |
$me->AddRecipe ( '$(XX_PRE)$(QT_MOC)' );
|
|
|
518 |
$me->Print();
|
|
|
519 |
|
|
|
520 |
ToolsetRule ( $var );
|
|
|
521 |
}
|
|
|
522 |
|
| 1150 |
dpurdie |
523 |
#-------------------------------------------------------------------------------
|
|
|
524 |
# Function : src_hook_ts
|
|
|
525 |
#
|
|
|
526 |
# Description : This function will be invoked when a .TS file
|
|
|
527 |
# is encountered in the Src directive
|
|
|
528 |
#
|
|
|
529 |
# .TS file are QT Translation Source Files
|
|
|
530 |
# These need to be processed into .qm files
|
|
|
531 |
# by the lrelease tool
|
|
|
532 |
#
|
|
|
533 |
# Inputs : $path - Source path
|
|
|
534 |
# $path - Source file name
|
|
|
535 |
# $base - Base file name (no dir or ext)
|
|
|
536 |
# $ext - Extension
|
|
|
537 |
#
|
|
|
538 |
# Returns :
|
|
|
539 |
#
|
|
|
540 |
sub src_hook_ts
|
|
|
541 |
{
|
|
|
542 |
Debug ("src_hook_ts: @_");
|
|
|
543 |
my ( $srcfile ,$path, $base, $ext ) = @_;
|
| 1148 |
dpurdie |
544 |
|
| 1150 |
dpurdie |
545 |
#
|
|
|
546 |
# Convert the TS file into a QM file
|
|
|
547 |
# Place the QM file in the BIN directory
|
|
|
548 |
#
|
|
|
549 |
my $target = "\$(BINDIR)/${base}.qm";
|
|
|
550 |
GenerateSrcFile ( 1, $target );
|
|
|
551 |
|
|
|
552 |
#
|
|
|
553 |
# The user may have specified some dependencies
|
|
|
554 |
# Create a list of these to be a part of the generated Rule
|
|
|
555 |
#
|
|
|
556 |
my @dlist = split( /$;/, $SRC_DEPEND{$path} )
|
|
|
557 |
if ( exists $SRC_DEPEND{$path} );
|
|
|
558 |
|
|
|
559 |
#
|
|
|
560 |
# Create a Rule to build this file
|
|
|
561 |
# Will be placed in the Rules section
|
|
|
562 |
#
|
|
|
563 |
my $var;
|
|
|
564 |
my $me = MakeEntry::New (\$var, $target );
|
|
|
565 |
$me->AddComment ("QT Translation File: $path" );
|
|
|
566 |
$me->AddDependancy ( $srcfile );
|
|
|
567 |
$me->AddDependancy ( @dlist );
|
|
|
568 |
$me->AddDependancy ( '$(SCM_MAKEFILE)' );
|
|
|
569 |
$me->AddDependancy ( '$(GBE_OBJDIR)' );
|
|
|
570 |
$me->AddRecipe ( '$(XX_PRE)$(QT_TRANSLATE)' );
|
|
|
571 |
$me->Print();
|
|
|
572 |
|
|
|
573 |
ToolsetRule ( $var );
|
|
|
574 |
|
|
|
575 |
#
|
|
|
576 |
# Append the generated file to a list
|
|
|
577 |
#
|
|
|
578 |
push( @::QT_PMFILES, "${base}.qm" );
|
|
|
579 |
}
|
|
|
580 |
|
| 1152 |
dpurdie |
581 |
#-------------------------------------------------------------------------------
|
|
|
582 |
# Function : qtBuilder_Generate
|
|
|
583 |
#
|
|
|
584 |
# Description : Insert definitions into the makefile
|
|
|
585 |
# Registered function to be called just before we start
|
|
|
586 |
# creating the makefile
|
|
|
587 |
#
|
|
|
588 |
# Inputs : None
|
|
|
589 |
#
|
|
|
590 |
# Returns :
|
|
|
591 |
#
|
|
|
592 |
sub qtBuilder_Generate
|
|
|
593 |
{
|
|
|
594 |
AddCFlags( '*', '--NoWarn', @moc_defs );
|
|
|
595 |
Define ("# Definitions created by the AddMocFlags directive");
|
|
|
596 |
Define ("MOC_FLAGS =");
|
|
|
597 |
foreach my $flag ( @moc_defs )
|
|
|
598 |
{
|
|
|
599 |
Define ("MOC_FLAGS +=" . $flag);
|
|
|
600 |
}
|
|
|
601 |
}
|
| 1150 |
dpurdie |
602 |
|
| 1148 |
dpurdie |
603 |
1;
|