blob: 18bf72419402db4ceeb1d9f39e75d14e490450d7 [file] [log] [blame]
#!/usr/bin/perl -w
#use strict;
use lib "tools/perl";
use Spreadsheet::ParseExcel;
my $CUSTOMDIR;
if ($#ARGV == 0) {
$CUSTOMDIR = $ARGV[0];
} else {
$CUSTOMDIR = "$ENV{'WORKDIR'}/custom/build";
}
my $FileName = "$CUSTOMDIR/flash_partition.xls";
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse($FileName);
die $parser->error(), ".\n" if ( !defined $workbook );
# Iterate through all worksheets
system("rm -rf $CUSTOMDIR/*.cfg");
for my $worksheet ( $workbook->worksheets() ) {
# Find out the worksheet ranges
my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();
my $FILE = "$CUSTOMDIR/$worksheet->{Name}.cfg";
open (MYFILE, ">$FILE");
print MYFILE "############################################################################################################\n";
print MYFILE "#\n";
print MYFILE "# Android Region Setting\n";
print MYFILE "#\n";
print MYFILE "############################################################################################################\n";
print MYFILE "linux_region:\n";
print MYFILE " partitions:\n";
for my $row ( $row_min .. $row_max ) {
next if ($row == 0);
print MYFILE " - partition:\n";
for my $col ( $col_min .. $col_max ) {
# Return the cell object at $row and $col
my $cell = $worksheet->get_cell( $row, $col );
next unless $cell;
if ($col == 0) { print MYFILE " name: ", $cell->value(), "\n"}
if ($col == 1) { print MYFILE " file: ", $cell->value(), "\n"}
if ($col == 3) { print MYFILE " address: 0x", sprintf("%X", $cell->value()*1024*1024), "\n";}
if ($col == 4) { print MYFILE " type: ", $cell->value(), "\t\t#raw, yaffs, yaffs2\n"}
}
}
print MYFILE "\n";
close (MYFILE);
}