Major update/rewrite/recombine to get SSDP, and GrowController UI and application shell.
This commit is contained in:
@@ -9,6 +9,8 @@ my $maxCols = 16;
|
||||
my $maxLines = 0;
|
||||
my $ESP = 0;
|
||||
my $DIR = 0;
|
||||
my $ROOT = 0;
|
||||
my $UINT8 = 0;
|
||||
my $file = "";
|
||||
my $ctrlC = 0; # User induced termination
|
||||
my $lineT = 0; # Linecount induced termination
|
||||
@@ -34,7 +36,7 @@ my %FileType = (
|
||||
"ico" => "image/x-icon",
|
||||
"png" => "image/png",
|
||||
"jpg" => "image/jpeg",
|
||||
"js" => "application/javascript",
|
||||
"js" => "text/javascript",
|
||||
);
|
||||
|
||||
|
||||
@@ -45,21 +47,26 @@ if (!@ARGV)
|
||||
$prg [file|<wildcard> [...]] [-n=##] [-l=##] [-ESP] [-DIR] [-o=outfile]
|
||||
version $VERSION
|
||||
|
||||
Dumps out the contents of the [file] as a c array.
|
||||
Dumps out the contents of the [file(s)] as a c array.
|
||||
|
||||
If the file is binary, it emits a hex char-array using
|
||||
the -n and -l settings.
|
||||
If the file is text, it emits as an ascii char-array
|
||||
where each source line is one ascii quoted line.
|
||||
|
||||
-ESP adds the PROGMEM attribte to the byte array data.
|
||||
-ESP adds the PROGMEM attribute to the byte array data.
|
||||
|
||||
-DIR adds a 'directory' at the end of the output, providing
|
||||
a reference to each input file. Most useful for a set
|
||||
of files.
|
||||
|
||||
-ROOT prefixes each entry in the 'directory' with '/',
|
||||
so "index.htm" becomes
|
||||
|
||||
-o=outfile Writes the output to outfile.
|
||||
|
||||
-u overrides the default 'char' array to be 'uint8_t'
|
||||
NOTE that the filename and type info remains 'char'.
|
||||
-n=## sets the byte count for each line, defaults 32.
|
||||
-l=## sets a termination after ## lines have been printed.
|
||||
|
||||
@@ -83,8 +90,12 @@ foreach (@ARGV)
|
||||
{ $outfile = $1; }
|
||||
elsif (/-ESP/)
|
||||
{ $ESP = 1; }
|
||||
elsif (/-ROOT/)
|
||||
{ $ROOT = 1; }
|
||||
elsif (/-DIR/)
|
||||
{ $DIR = 1; }
|
||||
elsif (/-u/)
|
||||
{ $UINT8 = 1; }
|
||||
elsif (-e $_ )
|
||||
{ push @files, $_; }
|
||||
elsif (/[\*\?]/)
|
||||
@@ -114,19 +125,32 @@ if ($outfile ne "") {
|
||||
printf("No outfile, emitting to console.\n");
|
||||
}
|
||||
printf("//\n");
|
||||
printf("// Command : %s %s\n", $prg, join(" ", @ARGV));
|
||||
printf("// Command: %s %s\n", $prg, join(" ", @ARGV));
|
||||
printf("// version: %2.1f\n", $VERSION);
|
||||
printf("// From cwd : %s\n", cwd);
|
||||
printf("// From cwd: %s\n", cwd);
|
||||
printf("// Generated: %s\n", scalar localtime());
|
||||
printf("// Run script in command shell, not PowerShell\n");
|
||||
printf("// NOTE: Run script in command shell, not PowerShell\n");
|
||||
printf("//\n");
|
||||
|
||||
if ($ESP) {
|
||||
print <<EOM;
|
||||
// PROGMEM is not recognized by Win32 tools...
|
||||
#ifdef WIN32
|
||||
#define PROGMEM
|
||||
#endif
|
||||
EOM
|
||||
}
|
||||
|
||||
my @summary;
|
||||
foreach my $file (@files) {
|
||||
push @summary, Process($file);
|
||||
last if ($ctrlC);
|
||||
}
|
||||
|
||||
print "\n// Prototypes:\n// " . join("\n// ", @summary) . "\n";
|
||||
|
||||
if ($DIR) {
|
||||
my $type = "char "; #($UINT8) ? "uint8_t" : "char ";
|
||||
print <<EOM;
|
||||
|
||||
// Directory of Files
|
||||
@@ -135,10 +159,10 @@ if ($DIR) {
|
||||
// an empty "" Filename is reached.
|
||||
//
|
||||
typedef struct {
|
||||
const char * Filename;
|
||||
const char * Filedata;
|
||||
const char * Filetype;
|
||||
uint16_t Filesize;
|
||||
const char * Filename;
|
||||
const $type * Filedata;
|
||||
const char * Filetype;
|
||||
uint16_t Filesize;
|
||||
} DirEntry;
|
||||
|
||||
EOM
|
||||
@@ -147,14 +171,14 @@ EOM
|
||||
foreach my $file (sort keys %DirInfo) {
|
||||
#printf(STDERR "file %s, title %s, size %d\n", $file, $DirInfo{$file}{'reference'}, $DirInfo{$file}{'size'});
|
||||
my $title = $DirInfo{$file}{'reference'};
|
||||
my $fn = sprintf("\"%s\"", $file);
|
||||
my $fn = sprintf("\"%s%s\"", $ROOT ? "/" : "", $file);
|
||||
my $ext = "";
|
||||
$ext = $1 if ($file =~ /.*\.(.*)/);
|
||||
my $ftype = sprintf("\"%s\"", $FileType{$ext});
|
||||
#printf(STDERR "ext: '%s' => '%s'\n", $ext, $FileType{lc($ext)});
|
||||
printf("\t{ %-20s, %-20s, %24s, %6d },\n", $fn, $title, $ftype, $DirInfo{$file}{'size'});
|
||||
}
|
||||
printf("\t{ %-20s, %-20s, %24s, %6d }\n", "\"\"", "NULL", "NULL", 0);
|
||||
printf("\t{ %-20s, %-20s, %24s, %6d }\n", "NULL", "NULL", "NULL", 0);
|
||||
printf("};\n\n");
|
||||
}
|
||||
|
||||
@@ -185,7 +209,7 @@ sub Process {
|
||||
printf("\n");
|
||||
printf("// File: %s\n", $file);
|
||||
printf("//\n");
|
||||
$prototype = sprintf("const char %s[]%s", $title, ($ESP) ? " PROGMEM" : "");
|
||||
$prototype = sprintf("const %s %s[]%s", ($UINT8) ? "uint8_t" : "char", $title, ($ESP) ? " PROGMEM" : "");
|
||||
printf("%s = {\n", $prototype);
|
||||
|
||||
my $size = 0;
|
||||
@@ -198,7 +222,7 @@ sub Process {
|
||||
$line =~ s/\r//g;
|
||||
$line =~ s/"/\\"/g;
|
||||
printf("\t\"%s\\n\"\n", $line);
|
||||
$size += length($line);
|
||||
$size += length($line) + 1; # +1 for the \n line termination.
|
||||
}
|
||||
} else {
|
||||
printf("\t");
|
||||
|
||||
Reference in New Issue
Block a user