build/mklar.pl:
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 14 Apr 2009 22:32:57 +0000 (22:32 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 14 Apr 2009 22:32:57 +0000 (22:32 +0000)
- fix heisenbug with file list padding
- call luac if available
- include non-lua files
- include cbi models and controllers

build/mklar.pl

index 2eb2e313863ac86c30446f9c67511c1db3293d7f..d91eaebef7b659c9ede2196fd24234fbd8361b1c 100755 (executable)
@@ -39,16 +39,7 @@ find( sub {
        ( $File::Find::name =~ m{/luasrc/} ) || return;
 
        # Skip .svn foo
-       ( $File::Find::name !~ m{/\.svn\z} ) || return;
-
-       # Skip non-lua files
-       ( $File::Find::name =~ m{\.lua\z} ) || return;
-
-       # Skip i18n files
-       ( $File::Find::name !~ m{/i18n/} ) || return;
-       
-       # Exclude cbi models and controllers for now
-       ( $File::Find::name !~ m{/controller/} && $File::Find::name !~ m{/model/cbi/} ) || return;
+       ( $File::Find::name !~ m{/\.svn\b} ) || return;
 
        # Exclude luci-statistics and lucittpd for now
        ( $File::Find::name !~ m{/luci-statistics/} && $File::Find::name !~ m{/lucittpd/} ) || return;
@@ -57,7 +48,10 @@ find( sub {
        my $file = $File::Find::name;
        $file =~ s{^.+/luasrc/}{luci/};
 
-       if( open F, "< $_" )
+       my $command = ( $File::Find::name =~ m{\.lua\z} && $ENV{LUAC} )
+               ? "$ENV{LUAC} -o - $_ |" : "< $_";
+
+       if( open F, $command )
        {
                warn sprintf "Member at 0x%08X: %s\n", $offset, $file;
                push @index, [ ];
@@ -66,7 +60,7 @@ find( sub {
                my $pad  = 0;
 
                $index[-1][0] = $offset;
-               
+
                while( read F, my $buffer, 4096 ) {
                        $size += length $buffer;
                        print $buffer;
@@ -97,17 +91,18 @@ find( sub {
 my $filelist = join("\0", map $_->[4], @index) . "\0";
 my $listsize = length $filelist;
 push @index, [ $offset, $listsize, "", 0xFFFF, undef ];
-warn sprintf "Filelist at 0x%08X\n", $offset;
 
-if( $listsize % 4 )
-{
-       $listsize += ( 4 - ($listsize % 4) );
-       $filelist .= "\0" x ( 4 - ($listsize % 4) );
-}
+warn sprintf "Filelist at 0x%08X, length 0x%08X\n", $offset, $listsize;
 
 print $filelist;
 $offset += $listsize;
 
+if( $listsize % 4 )
+{
+       $offset += ( 4 - ($listsize % 4) );
+       print "\0" x ( 4 - ($listsize % 4) );
+}
+
 
 my $count = 1;
 foreach my $file ( @index )