yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/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) 2006
|
| 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 | #*
|
| 37 | #* Filename:
|
| 38 | #* ---------
|
| 39 | #* sysInit.pl
|
| 40 | #*
|
| 41 | #* Project:
|
| 42 | #* --------
|
| 43 | #*
|
| 44 | #*
|
| 45 | #* Description:
|
| 46 | #* ------------
|
| 47 | #* This script will copy files from mcu\custom\system to build folder
|
| 48 | #*
|
| 49 | #*
|
| 50 | #* Author:
|
| 51 | #* -------
|
| 52 | #* Amber Su (mtk03389)
|
| 53 | #*
|
| 54 | #*============================================================================
|
| 55 | #* HISTORY
|
| 56 | #* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 57 | #*------------------------------------------------------------------------------
|
| 58 | #* $Revision$
|
| 59 | #* $Modtime$
|
| 60 | #* $Log$
|
| 61 | #*
|
| 62 | #* 09 05 2016 chi-chun.lu
|
| 63 | #* [MOLY00200780] [MakeFile] [UMOLY] [Modify Makefile Rules]fix smart new false alarm of sysgen
|
| 64 | #*
|
| 65 | #* .
|
| 66 | #*
|
| 67 | #* 09 02 2016 chi-chun.lu
|
| 68 | #* [MOLY00200780] [MakeFile] [UMOLY] [Modify Makefile Rules]fix smart new false alarm of sysgen
|
| 69 | #*
|
| 70 | #* (rollback).
|
| 71 | #*
|
| 72 | #* 06 16 2016 wcpadmin
|
| 73 | #* smart new env.
|
| 74 | #*
|
| 75 | #* 10 20 2013 qmei.yang
|
| 76 | #* [MOLY00037376] [SystemService][Auto-Gen][Request For Design Change] Support Secure_RO on MOLY
|
| 77 | #* .
|
| 78 | #*
|
| 79 | #* 09 16 2013 qmei.yang
|
| 80 | #* [MOLY00037954] [SystemService][Auto-Gen][KAL][Request For Design Change] Support cross core ctrl buff, shared buffer, autogen, dump md32
|
| 81 | #* .
|
| 82 | #*
|
| 83 | #* 09 11 2013 ray.lin-wang
|
| 84 | #* [MOLY00034122] [Build Environment] phase in MD32/CR4 flow
|
| 85 | #* integrate from reorg CBr.
|
| 86 | #*
|
| 87 | #* 01 24 2013 amber.su
|
| 88 | #* [MOLY00009227] [SystemService][AAPMC][Internal Refinement] Support AAPMC to auto-adjust Modem Image Layout
|
| 89 | #* .
|
| 90 | #*
|
| 91 | #* 01 09 2013 amber.su
|
| 92 | #* .
|
| 93 | #*
|
| 94 | #* 08 03 2012 ray.lin-wang
|
| 95 | #* [MOLY00000043] [GCC on Linux] build flow related porting
|
| 96 | #* modify chmod solution.
|
| 97 | #* sysgen_init.pl => only chmod on windows
|
| 98 | #* build.mak => remove files before copying
|
| 99 | #*
|
| 100 | #*
|
| 101 | #*------------------------------------------------------------------------------
|
| 102 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
|
| 103 | #*============================================================================
|
| 104 | #****************************************************************************/
|
| 105 | #****************************************************************************
|
| 106 | # Included Modules
|
| 107 | #****************************************************************************
|
| 108 | BEGIN { push @INC , './tools/' } # add additional library path
|
| 109 | use auto_adjust_mem; #pm file name without case sensitivity
|
| 110 | use File::Path;
|
| 111 | use File::Copy;
|
| 112 | #****************************************************************************
|
| 113 | # Input and Parameters initialization
|
| 114 | #****************************************************************************
|
| 115 | my ($input_folder, $output_folder, $smart_new) = @ARGV;
|
| 116 | my $extension = AAPMC_COPYER::THEONE;
|
| 117 | my $Debug = 1;
|
| 118 |
|
| 119 | print "Original System Folder Path: $input_folder\n" if($Debug);
|
| 120 | print "Output System Folder Path: $output_folder\n" if($Debug);
|
| 121 |
|
| 122 | #****************************************************************************
|
| 123 | # Main Flow
|
| 124 | #****************************************************************************
|
| 125 | rmtree("$output_folder/Template") if(-d "$output_folder/Template");
|
| 126 | if ($smart_new ne "TRUE") {
|
| 127 | &delete_process if(-d $output_folder);
|
| 128 | }
|
| 129 | mkpath($output_folder) or &error_handler("create $output_folder folder failed!", __FILE__, __LINE__) if(!-d $output_folder);
|
| 130 |
|
| 131 | opendir (DIR, $input_folder) or &error_handler("cannot open $input_folder!", __FILE__, __LINE__);
|
| 132 | my @files = grep { /\.conf$/ } readdir (DIR);
|
| 133 | close DIR;
|
| 134 |
|
| 135 | print "===== Copy process =====\n";
|
| 136 | foreach (@files) {
|
| 137 | $replaced_filename = $_;
|
| 138 | if($_ =~ /(.+)\.conf$/i) {
|
| 139 | $replaced_filename = $1;
|
| 140 | }
|
| 141 | print "[$replaced_filename] ";
|
| 142 | if(-e "$output_folder/$replaced_filename")
|
| 143 | {
|
| 144 | print "Skip\n";
|
| 145 | }
|
| 146 | else
|
| 147 | {
|
| 148 | print "Need to Copy\n";
|
| 149 | print "Copy from $input_folder/$_ to $output_folder/$replaced_filename\n" if($Debug);
|
| 150 | copy("$input_folder/$_", "$output_folder/$replaced_filename") or &error_handler("copy $_ file failed!", __FILE__, __LINE__);
|
| 151 |
|
| 152 | # chmod for read-only codebase
|
| 153 | chmod(0640, "$output_folder/$replaced_filename") if($^O eq "MSWin32");
|
| 154 | }
|
| 155 | }
|
| 156 |
|
| 157 | exit 0;
|
| 158 |
|
| 159 | #*************************************************************************************************
|
| 160 | # Delete build\xxx\yyy\custom\system before copy operation
|
| 161 | #*************************************************************************************************
|
| 162 | sub delete_process
|
| 163 | {
|
| 164 | print "===== Delete process =====\n";
|
| 165 | opendir (DIR, $output_folder) or &error_handler("cannot open $output_folder!", __FILE__, __LINE__);
|
| 166 | my @out_files = grep { !/^\.{1,2}$/ } readdir (DIR);
|
| 167 | close DIR;
|
| 168 |
|
| 169 | foreach my $file(@out_files)
|
| 170 | {
|
| 171 | if(-d "$output_folder/$file")
|
| 172 | {
|
| 173 | rmtree("$output_folder/$file");
|
| 174 | print "delete folder: $output_folder/$file\n";
|
| 175 | next;
|
| 176 | }
|
| 177 | if($file =~ /\d$/)
|
| 178 | {
|
| 179 | print "skip $file\n";
|
| 180 | next;
|
| 181 | }
|
| 182 | if($file =~ /$extension$/)
|
| 183 | {
|
| 184 | my $org_file =~ s/$extension$//;
|
| 185 | if(!-e "$output_folder/$org_file")
|
| 186 | {
|
| 187 | unlink "$output_folder/$file";
|
| 188 | print "delete $output_folder/$file\n";
|
| 189 | }
|
| 190 | else
|
| 191 | {
|
| 192 | print "skip $file\n";
|
| 193 | }
|
| 194 | next;
|
| 195 | }
|
| 196 | if(&AAPMC_COPYER::IsNeededToCopy($output_folder,$input_folder,$file))
|
| 197 | {
|
| 198 | unlink "$output_folder/$file";
|
| 199 | print "delete $file\n";
|
| 200 | }
|
| 201 | else
|
| 202 | {
|
| 203 | print "skip $file\n";
|
| 204 | }
|
| 205 | }
|
| 206 | }
|
| 207 | #*************************************************************************************************
|
| 208 | # Error Handling Message
|
| 209 | #*************************************************************************************************
|
| 210 | sub error_handler
|
| 211 | {
|
| 212 | my ($error_msg, $file, $line_no) = @_;
|
| 213 | my $final_error_msg = "Error: $error_msg at $file line $line_no\n";
|
| 214 | print "$final_error_msg";
|
| 215 | exit 3;
|
| 216 | }
|