blob: 59c6d3e5fc674fbb6bf04837b8a7fea8deda3cb0 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/usr/bin/perl
2#
3# Copyright Statement:
4# --------------------
5# This software is protected by Copyright and the information contained
6# herein is confidential. The software may not be copied and the information
7# contained herein may not be used or disclosed except with the written
8# permission of MediaTek Inc. (C) 2008
9#
10# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
11# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
12# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
13# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
14# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
15# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
16# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
17# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
18# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
19# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
20# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
21# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
22#
23# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
24# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
25# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
26# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
27# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
28#
29# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
30# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
31# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
32# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
33# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
34#
35#
36# To process CustImgNamesExt and put image information to ExtractObj.ini.
37#******************************************************************************
38# Subroutine: Usage
39#******************************************************************************
40sub usage {
41 print "perl processExtractObj.pl ProcdFile ExtractObj.ini\n";
42 exit 1;
43}
44
45#$NvramCustPack = $ARGV[0];
46$NvramLidSize = $ARGV[0];
47$NvramTmp = $ARGV[1];
48$CustomWapCustPack = $ARGV[2];
49$custom = $ARGV[3];
50$project = $ARGV[4];
51$outputdir = $ARGV[5];
52$ExtractObjFile = $ARGV[6];
53$var=0;
54$new_line = "";
55chomp($cwd = `cd`);
56if ($cwd =~ /.*\\$/){
57 chop($cwd);
58}
59
60# Process ~nvram_lid_size.log to get custpack needed LID names.
61# Use LID names to get LID variable names from ~nvram_tmp.c.
62
63open (F1,"<$NvramLidSize") || die "Cannot open ~nvram_lid_size.log, please execute nvram_auto_gen first:$!\n";
64while (<F1>)
65{
66 if (/(\d+)\s*(\d+)\s*(\w.+\w)\s*\bCUSTPACK\b/){
67 $nvram_name{$3} = 1;
68 }
69}
70close(F1);
71
72open (nvramtmp,"<$NvramTmp") || die "Cannot open ~nvram_cust_pack.c\n";
73$backup = $/;
74undef $/;
75$reading = <nvramtmp>;
76$/ = $backup;
77close nvramtmp;
78
79open (ExtractObjFile,">$ExtractObjFile") || die "Cannot open $ExtractObjFile:$!\n";
80print ExtractObjFile "[VAR_NAME]\n";
81
82if ($reading =~ /const custpack_nvram_header custpack_nvram_ptr\s*=\s*\{.+?\{(.+?)\}/s) {
83 $nvram_variable = $1;
84}
85
86while($nvram_variable =~ /(\w+)[,|\s]/){
87 $nvram_variable=$';
88 $var++;
89 print ExtractObjFile "Var$var = \"$1\"\n";
90}
91
92# Process custom\common\custom_wap_cust_pack.c to get custpack_wap_ptr variable names.
93open (F2,"<$CustomWapCustPack") || die "Cannot open $CustomWapCustPack:$!\n";
94$backup = $/;
95undef $/;
96$reading=<F2>;
97$/ = $backup;
98close(F2);
99
100if ($reading =~ /const wap_custpack_header custpack_wap_ptr\s*=\s*\{([\w|\s|,|&]+)\}/) {
101 $custpack_wap_ptr = $1;
102}
103
104while($custpack_wap_ptr =~ /&(.+?)[,|\s]/){
105 $custpack_wap_ptr = $';
106 $var++;
107 print ExtractObjFile "Var$var = \"$1\"\n";
108}
109
110# Write [EXTRACTOBJ_PERL_SCRIPT] section to extractObj.ini
111print ExtractObjFile "\n\[EXTRACTOBJ_PERL_SCRIPT\]\n";
112print ExtractObjFile "CUSTOM = \"$custom\"\n";
113print ExtractObjFile "PROJECT = \"$project\"\n";
114print ExtractObjFile "OUTPUTDIR = \"$cwd\\$outputdir\"\n";
115print ExtractObjFile "OBJ1 = \"custom_wap_cust_pack.obj\"\n";
116print ExtractObjFile "OBJ2 = \"nvram_cust_pack.obj\"\n";
117close(ExtractObjFile);
118