blob: 92103e7e61abc027574b0cc8868a60aab1388a21 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/usr/bin/perl -w
2
3####################################
4#
5# Modified by mtk80507 2009/11/17
6# Modification: Skip cheking SWITCHABLE_FEATURE related features
7# E.g.: Feature 'GEMINI' is set as SWITCHABLE_FEATURE, that means it could be turned ON or OFF by customer
8# 'GEMINI' will be skipped from switchable checking
9# Note that there are some other features which have dependency with 'GEMINI' and SHOULD be changed along with it
10# BUT, such condition is not handled so error will occur
11# while in fact it is actually not 'error'
12# The modification made will bypass such features while 'ckmake'.
13#
14####################################
15
16use strict;
17use Cwd;
18&Usage if ($#ARGV < 2);
19
20my $theMF = $ARGV[0];
21my $theMFBAK = $ARGV[1];
22my $ChkFTsFile = $ARGV[2];
23
24my %NewFTSetTbl = ();
25my %OrgFTSetTbl = ();
26my @ChkList = ();
27my $dir = getcwd;
28
29#******************************************************************************
30# Read feature options which need to check
31#******************************************************************************
32open(CHKFILE, "<$ChkFTsFile") or die "Can NOT open $ChkFTsFile\n";
33while(<CHKFILE>)
34{
35 chomp $_;
36 $_ =~ s/\s*//g;
37 unshift(@ChkList, uc($_));
38}
39close(CHKFILE);
40
41#******************************************************************************
42# Read Original feature set
43#******************************************************************************
44my $OrgFTSetTblRef = &ReadFTSet($theMFBAK, \%OrgFTSetTbl);
45
46#******************************************************************************
47# Skip check SWITCHABLE_FEATURE related features
48#******************************************************************************
49my @skipChkLst = &GetSkipChkLst($OrgFTSetTblRef);
50
51#******************************************************************************
52# Read New feature set
53#******************************************************************************
54my $NewFTSetTblRef = &ReadFTSet($theMF, \%NewFTSetTbl);
55
56#******************************************************************************
57# Prevent customer from switching options which can NOT be switched
58# in any custom release package
59#******************************************************************************
60&DepChk($OrgFTSetTblRef, $NewFTSetTblRef, @ChkList);
61
62exit 0;
63
64
65sub ReadFTSet
66{
67 my ($file, $HashRef) = @_;
68 open (FH, "<$file") or die "Can NOT open $file\n";
69 while (<FH>)
70 {
71 $HashRef->{$1} = uc($2) if (/^(\S+)\s*=\s*(\S+)/);
72 }
73 close FH;
74 return $HashRef;
75}
76
77sub DepChk
78{
79 my ($OrgFTSetTblRef, $NewFTSetTblRef, @ChkList) = @_;
80 foreach my $f (@ChkList)
81 {
82 if (exists $OrgFTSetTblRef->{SWITCHABLE_FEATURE} &&
83 $OrgFTSetTblRef->{SWITCHABLE_FEATURE} =~ /^$f$/)
84 {
85 next;
86 }
87 if (exists $OrgFTSetTblRef->{SWITCHABLE_FEATURE_2ND} &&
88 $OrgFTSetTblRef->{SWITCHABLE_FEATURE_2ND} =~ /^$f$/)
89 {
90 next;
91 }
92
93 if (exists $OrgFTSetTblRef->{$f} &&
94 grep (/\b$f\b/, @skipChkLst))
95 {
96 next;
97 }
98
99 if (exists $OrgFTSetTblRef->{$f} &&
100 exists $NewFTSetTblRef->{$f} &&
101 ($OrgFTSetTblRef->{$f} !~ /^$NewFTSetTblRef->{$f}$/))
102 {
103 die "$f can NOT be switched in custom release code base!!!\n";
104 }
105 }
106}
107
108sub Usage {
109 print "perl SpecialDepChk.pl <New_MakeFile> <Org_MakeFile> <Check_Feature_List_File>\n";
110 exit 1;
111}
112
113
114sub GetSkipChkLst
115{
116 # get the defined SWITCHABLE_FEATURE and the SWITCHABLE_FEATURE_2ND
117 my ($HashRef) = @_;
118 my @swtchLst = qw();
119 if (exists $HashRef->{SWITCHABLE_FEATURE})
120 {
121 push (@swtchLst, $HashRef->{SWITCHABLE_FEATURE});
122 }
123 if (exists $HashRef->{SWITCHABLE_FEATURE_2ND})
124 {
125 push (@swtchLst, $HashRef->{SWITCHABLE_FEATURE_2ND});
126 }
127
128 my @skpLst = qw();
129 my $file = "$dir"."\\pcore\\tools\\special_feature_dep.ini";
130 open (FH, "<$file") or warn "Can NOT open $file\n";
131 while (<FH>)
132 {
133 if (/^#/) # skip parse the comment line which start with '#'
134 {
135 next;
136 }
137 if (/\s?([\S]*)\s?:\s?(.*)/) # match with lines with 'XXX : xxxxx xxxx xxx' pattern
138 {
139# print "\<", $1, "\> depends on ", $2, "\n";
140 my @tmpLst = qw();
141 if (grep (/\b$1\b/, @swtchLst))
142 {
143 @tmpLst = split (/\s+/, $2);
144 }
145
146 foreach (@tmpLst)
147 {
148 push (@skpLst, $_)
149 }
150 }
151 }
152 return @skpLst;
153}
154