controlpanelui/cpcfg_win.pl
changeset 10 0a74be98a8bc
child 11 10d0dd0e43f1
equal deleted inserted replaced
0:254040eb3b7d 10:0a74be98a8bc
       
     1 
       
     2 # description: copy all cpcfg files to destination directory when building control panel in window envionment
       
     3 # usage: go to control panel source directory, 
       
     4 # run cpcfg_win.pl if you want to build control panel in debug mode or cpcfg_win -R in release mode.
       
     5 
       
     6 use File::Path qw (mkpath);
       
     7 
       
     8 #default debug dir
       
     9 $config_dir = "C:\\ControlPanel\\debug\\bin\\config";
       
    10 if ($ARGV[0] =~ m/^-R$/i) { #release dir
       
    11 	$config_dir = "C:\\ControlPanel\\release\\bin\\config";
       
    12 } 
       
    13 
       
    14 sub go_through_dir {  
       
    15  my @arr, $j = 0;  
       
    16  for ($i=0;$i<=$#_;$i++) {  
       
    17   if (-d $_[$i]) {  
       
    18    if (opendir($handle, $_[$i])) {  
       
    19     while ($entry = readdir($handle)) {  
       
    20      if (!($entry =~ m/^\.$/) and !($entry =~ m/^(\.\.)$/)) {   
       
    21       if (-d $_[$i]."\\$entry") {  # is a directory, push to @arr
       
    22        $arr[$j++] = $_[$i]."\\$entry";   
       
    23       }  
       
    24       else {   # is a file
       
    25       	if ($entry =~ m/\.cpcfg$/i) { # is a .cpcfg file, copy it
       
    26       		$cmd = "copy ";
       
    27       		$cmd .= $_[$i]."\\$entry ";
       
    28       		$cmd .= $config_dir."\\$entry";
       
    29       		print ("$cmd\n");
       
    30       		system($cmd);
       
    31       	}
       
    32       }
       
    33      }  
       
    34     }  
       
    35     closedir($handle);  
       
    36    }  
       
    37   }  
       
    38  }  
       
    39  if ($j>0) {  
       
    40   go_through_dir (@arr);  
       
    41  }  
       
    42 }
       
    43 
       
    44 # create target directory if it doesn't exist
       
    45 print ("Creating direcotry... $config_dir \n");
       
    46 mkpath $config_dir;
       
    47 
       
    48 # go through source directories recrusively
       
    49 go_through_dir ".\\src\\cpapplication",".\\src\\cpplugins";