sbsv1/abld/e32util/createrfifile.pl
author William Roberts <williamr@symbian.org>
Fri, 22 Oct 2010 12:33:01 +0100
changeset 651 0d0d83e3702d
parent 606 30b30f9da0b7
permissions -rw-r--r--
Enhance buildrom.pm to enable final OBY file to be converted into acceptable input for buildrom (Bug 3862)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     1
#!/usr/bin/perl
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     2
# Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     3
# All rights reserved.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     8
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
     9
# Initial Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    11
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    12
# Contributors:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    13
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    14
# Description:
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    15
#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    16
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    17
use File::Basename;
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    18
# Version
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    19
my $MajorVersion = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    20
my $MinorVersion = 1;
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    21
my $PatchVersion = 0;
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    22
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    23
if (@ARGV <2)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    24
	{
606
30b30f9da0b7 Add ..\dev\.. to path
jjkang
parents: 599
diff changeset
    25
	print (STDERR "\nCREATERFIFILE resource files combine tool V$MajorVersion.$MinorVersion.$PatchVersion\n");
599
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    26
	print STDERR << 'END_OF_HELP';
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    27
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    28
Usage: createrfifile.pl rss_cpp_deps_file.d output_file.rfi [exclude path]
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    29
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    30
Takes a file containing CPP dependency output from the preprocessing of a .rss file and
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    31
generates a "combined resource" .rfi that can  be consumed by CDB.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    32
Optionally takes an exclusion path under which "found" dependencies are then ignored.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    33
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    34
END_OF_HELP
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    35
	exit(0);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    36
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    37
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    38
my ($deps, $rfi, $exclude) = @ARGV;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    39
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    40
if ($exclude)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    41
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    42
	$exclude =~ s/\\/\//g;			# Ensure consistent slashes
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    43
	$exclude =~ s/\/\//\//g;		# Remove double slashes
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    44
	$exclude = quotemeta($exclude);	# Convert for regex match
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    45
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    46
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    47
print ("RFI : exclude under - \"$exclude\"\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    48
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    49
my @resources;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    50
open DEPS, "< $deps" or die "\nCannot read \"$deps\"!\n\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    51
while (<DEPS>)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    52
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    53
	# .d file format - whitespace at front is key, path format varies depending on platform
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    54
	# the aim is to get a list of the "real" files. Missing files can appear "unpathed", although
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    55
	# this isn't currently dealt with.
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    56
	#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    57
	#HelloWorld_reg.o:  \
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    58
	# F:/source/personal/misc/filenamepolicy/ported/examples/helloworld/HelloWorld_reg.rss \
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    59
	#  F:/builds/sbs/9.5/epoc32/include/variant/Symbian_OS.hrh \
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    60
	#  F:/builds/sbs/9.5/epoc32/include/appinfo.rh \
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    61
	#  F:/builds/sbs/9.5/epoc32/include/helloworld.rsg
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    62
	#
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    63
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    64
	s/^.*\.o\://;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    65
	s/^\s+//;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    66
	s/\s*\\$//;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    67
	s/\/\//\//g;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    68
	chomp ($_);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    69
	next if !/\S/;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    70
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    71
	print ("WARNING: Could not find dependency \"$_\" in \"$deps\"\n") if !(-e $_);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    72
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    73
	print ("RFI : processing - \"$_\"\n");
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    74
	next if ($exclude && /^$exclude/i);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    75
	push @resources,$_;	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    76
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    77
close DEPS;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    78
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    79
open RFI, "> $rfi" or die "\nCannot write \"$deps\"!\n\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    80
foreach my $resource (@resources)
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    81
	{
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    82
	print RFI "\n\n/* GXP ***********************\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    83
	print RFI " * ".basename($resource)."\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    84
	print RFI " ****************************/\n\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    85
	
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    86
	open RESOURCE, "< $resource" or die "\nCannot read \"$resource\"!\n\n";
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    87
	print RFI $_ while (<RESOURCE>);
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    88
	close RESOURCE;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    89
	}
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    90
close RFI;
fa7a3cc6effd Add sbsv1 to new structure
jjkang
parents:
diff changeset
    91