Subversion Repositories DevTools

Rev

Rev 7300 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7300 Rev 7312
Line 10... Line 10...
10
#                 Provides methods to create, maintain and read the file
10
#                 Provides methods to create, maintain and read the file
11
#                 
11
#                 
12
#                 ToolsetFiles::AddFile
12
#                 ToolsetFiles::AddFile
13
#                 ToolsetFiles::AddDir
13
#                 ToolsetFiles::AddDir
14
#                 ToolsetFiles::GetFiles
14
#                 ToolsetFiles::GetFiles
-
 
15
#                 ToolsetFiles::GetBuildDirs
15
#                 ToolsetFiles::GetSubTrees
16
#                 ToolsetFiles::GetSubTrees
16
#                 ToolsetFiles::GetDataFile
17
#                 ToolsetFiles::GetDataFile
17
#                 
18
#                 
18
#           Internal Use Only
19
#           Internal Use Only
19
#                 readData
20
#                 readData
20
#                 writeData
21
#                 writeData
21
#                 rebuildSubdirList
22
#                 rebuildSubdirList
-
 
23
#                 rebuildParentDirList
22
#
24
#
23
#......................................................................#
25
#......................................................................#
24
 
26
 
25
require 5.008_002;
27
require 5.008_002;
26
use strict;
28
use strict;
Line 102... Line 104...
102
#-------------------------------------------------------------------------------
104
#-------------------------------------------------------------------------------
103
# Function        : GetFiles 
105
# Function        : GetFiles 
104
#
106
#
105
# Description     : Return an array of files from the stored data structure
107
# Description     : Return an array of files from the stored data structure
106
#
108
#
107
# Inputs          : None
109
# Inputs          : $interface  - (Optional) Path to the interface directory
-
 
110
#                   $abs        - (Optional) True: Return Abs paths
108
#
111
#
109
# Returns         : An array of files
112
# Returns         : An array of files
110
#
113
#
111
sub GetFiles
114
sub GetFiles
112
{
115
{
-
 
116
    my ($interface, $abs) = @_;
-
 
117
    readData($interface) || Error ("Internal: ToolsetFiles::GetFiles - GbeFiles not found");
-
 
118
 
113
    readData();
119
    unless ($abs) {
114
    return keys %{$GBE_TOOLSETFiles{Files}}
120
        return keys %{$GBE_TOOLSETFiles{Files}};
-
 
121
    }
-
 
122
 
-
 
123
    my @newList;
-
 
124
    foreach my $dir (keys %{$GBE_TOOLSETFiles{Files}} ) {
-
 
125
        push @newList,CleanPath(catdir($GBE_TOOLSETFiles{Root}, $dir)); 
-
 
126
    }
-
 
127
 
-
 
128
    return @newList;
115
}
129
}
116
 
130
 
117
#-------------------------------------------------------------------------------
131
#-------------------------------------------------------------------------------
-
 
132
# Function        : GetBuildDirs
-
 
133
#
-
 
134
# Description     : Return an array the internal directories from the stored data structure
-
 
135
#
-
 
136
# Inputs          : $interface  - (Optional) Path to the interface directory
-
 
137
#
-
 
138
# Returns         : An array of files
-
 
139
#
-
 
140
sub GetBuildDirs
-
 
141
{
-
 
142
    my ($interface) = @_;
-
 
143
    readData($interface) || Error ("Internal: ToolsetFiles::GetBuildDirs - GbeFiles not found");
-
 
144
 
-
 
145
    my @newList;
-
 
146
    foreach my $dir (@{$GBE_TOOLSETFiles{Dirs}{Internal}} ) {
-
 
147
        push @newList,CleanPath(catdir($GBE_TOOLSETFiles{Root}, $dir)); 
-
 
148
    }
-
 
149
 
-
 
150
    return @newList;
-
 
151
}
-
 
152
 
-
 
153
 
-
 
154
#-------------------------------------------------------------------------------
118
# Function        : ToolsetFiles::AddDir
155
# Function        : ToolsetFiles::AddDir
119
#
156
#
120
# Description     : Maintain a data structure of directories that are used
157
# Description     : Maintain a data structure of directories that are used
121
#                   by the makefile creation process.
158
#                   by the makefile creation process.
122
#
159
#
Line 179... Line 216...
179
        #
216
        #
180
        #   Ignore Src directories that are a subdirectory of the current root dir
217
        #   Ignore Src directories that are a subdirectory of the current root dir
181
        #
218
        #
182
        if (($relDir =~ m~^\.\.(/|$)~) || ($dirList eq 'Internal'))
219
        if (($relDir =~ m~^\.\.(/|$)~) || ($dirList eq 'Internal'))
183
        {
220
        {
-
 
221
            #
-
 
222
            #   Maintain @{$GBE_TOOLSETFiles{Dirs}} as a list of parent directories
-
 
223
            #       The Root directory is assumed
-
 
224
            #
184
 
225
 
185
            # Add the new item and rebuild the subdir list
226
            # Add the new item and rebuild the list
186
            @{$GBE_TOOLSETFiles{Dirs}{$dirList}} = rebuildSubdirList($relDir, @{$GBE_TOOLSETFiles{Dirs}{$dirList}});
227
            @{$GBE_TOOLSETFiles{Dirs}{$dirList}} = rebuildParentDirList($relDir, @{$GBE_TOOLSETFiles{Dirs}{$dirList}});
187
 
228
 
188
            #   Save file
229
            #   Save file
189
            writeData();
230
            writeData();
190
        }
231
        }
191
    }
232
    }
Line 237... Line 278...
237
            push @dirList,CleanPath(catdir($GBE_TOOLSETFiles{Root}, $dir)); 
278
            push @dirList,CleanPath(catdir($GBE_TOOLSETFiles{Root}, $dir)); 
238
        }
279
        }
239
    }
280
    }
240
 
281
 
241
    # Process the complete list to remove subdirectories
282
    # Process the complete list to remove subdirectories
-
 
283
    #   The paths are absolute
242
    @dirList = rebuildSubdirList(@dirList);
284
    @dirList = rebuildSubdirList(@dirList);
243
#DebugDumpData("GetSubTrees", \@dirList);
285
#DebugDumpData("GetSubTrees", \@dirList);
244
    return @dirList;
286
    return @dirList;
245
}
287
}
246
#-------------------------------------------------------------------------------
288
#-------------------------------------------------------------------------------
247
# Function        : rebuildSubdirList 
289
# Function        : rebuildSubdirList 
248
#
290
#
249
# Description     : Internal function - not intended to be used externally
291
# Description     : Internal function - not intended to be used externally
-
 
292
#                   Only work when the @dirlist contains absolute paths
250
# 
293
# 
251
#                   Rebuild the subdirectory list
294
#                   Rebuild the subdirectory list
252
#                   Remove items that are subdirectories of other items
295
#                   Remove items that are subdirectories of other items
253
#                   We only want the parents, not children
296
#                   We only want the parents, not children
254
#
297
#
Line 285... Line 328...
285
 
328
 
286
   return @newList;
329
   return @newList;
287
}
330
}
288
 
331
 
289
#-------------------------------------------------------------------------------
332
#-------------------------------------------------------------------------------
-
 
333
# Function        : rebuildParentDirList 
-
 
334
#
-
 
335
#
-
 
336
# Description     : Internal function - not intended to be used externally
-
 
337
#                   Only work when with relative paths
-
 
338
#                   
-
 
339
#                   Given: .., ../.., ../../AA Result: ../..
-
 
340
#                   Given  .., ../AA, ../BB    Result: .., ../AA, ../BB
-
 
341
#                   
-
 
342
#                   Must handle both parent and child directoires
-
 
343
# 
-
 
344
#                   Rebuild the subdirectory list
-
 
345
#                   Remove items that are subdirectories of other items
-
 
346
#                   We only want the parents, not children
-
 
347
#
-
 
348
# Inputs          : @dirList        - List of items to process 
-
 
349
#
-
 
350
# Returns         : Rebuild list
-
 
351
sub rebuildParentDirList
-
 
352
{
-
 
353
    my (@dirlist) = @_;
-
 
354
 
-
 
355
    #
-
 
356
    #   Convert to absolute
-
 
357
    #   Use rebuildSubdirList
-
 
358
    #   Convert back to relative
-
 
359
    #
-
 
360
    my @newList;
-
 
361
    foreach my $dir ( @dirlist ) {
-
 
362
        push @newList,CleanPath(catdir($GBE_TOOLSETFiles{Root}, $dir)); 
-
 
363
    }
-
 
364
 
-
 
365
    # Process the complete list to remove subdirectories
-
 
366
    #   The paths are now absolute
-
 
367
    @newList = rebuildSubdirList(@newList);
-
 
368
 
-
 
369
    #
-
 
370
    #   Convert back to Relative
-
 
371
    #
-
 
372
    my @relList;
-
 
373
    foreach my $dir ( @newList ) {
-
 
374
        push @relList, RelPath(FullPath($dir), $GBE_TOOLSETFiles{Root} );
-
 
375
    }
-
 
376
 
-
 
377
    return @relList;
-
 
378
}
-
 
379
 
-
 
380
 
-
 
381
#-------------------------------------------------------------------------------
290
# Function        : GetDataFile 
382
# Function        : GetDataFile 
291
#
383
#
292
# Description     : Return the full path to the data file
384
# Description     : Return the full path to the data file
293
#                   May be used to test existence
385
#                   May be used to test existence
294
#
386
#