| 14 | | # |
| 15 | | # Copyright (C) 2006, Bradley Morrison <bradley.morrison@nokia.com> |
| 16 | | # Copyright (C) 2006, Nokia Corporation, Inc. |
| 17 | | # |
| 18 | | # This library is free software; you can redistribute it and/or |
| 19 | | # modify it under the terms of the GNU Library General Public |
| 20 | | # License as published by the Free Software Foundation; either |
| 21 | | # version 2 of the License, or (at your option) any later version. |
| 22 | | # |
| 23 | | # This library is distributed in the hope that it will be useful, |
| 24 | | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 26 | | # Library General Public License for more details. |
| 27 | | # |
| 28 | | # You should have received a copy of the GNU Library General Public License |
| 29 | | # along with this library; see the file COPYING.LIB. If not, write to |
| 30 | | # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 31 | | # Boston, MA 02111-1307, USA. |
| | 14 | #line 15 |
| 38 | | use Win32::TieRegistry ( Delimiter => '/'); |
| 39 | | |
| 40 | | sub usage { |
| 41 | | die "Usage:\n".basename $0."\t[OPTS] [COMPONENT] |
| 42 | | -c Include clean in compile |
| 43 | | -d Turn on debugging |
| 44 | | -r Delete S60Internal files and exit |
| 45 | | -h View this message |
| 46 | | \n"; |
| 47 | | } |
| 48 | | getopts('hdcr', \my %opts) or usage(); |
| 49 | | $opts{h} and usage(); |
| 50 | | |
| 51 | | my $component = shift; |
| 52 | | |
| 53 | | my $sdkhome = $Registry -> { |
| | 23 | use IO::Tee; |
| | 24 | use Win32::TieRegistry ( Delimiter => '/' ); |
| | 25 | |
| | 26 | getopts( 'gethdfcrowns:', \my %opts ); |
| | 27 | die basename $0. "\t[OPTS] [COMPONENT] |
| | 28 | -n Do not include clean in compile |
| | 29 | -f run freeze phase and exit |
| | 30 | -g GCCE compiler for hardware build |
| | 31 | -w Code Warrior compiler for emulator build |
| | 32 | -t Target build |
| | 33 | -d Turn on debugging, forces udeb flavour |
| | 34 | -e Export generated environment and exit |
| | 35 | -r Remove S60Internal dependencies and exit |
| | 36 | -s X Map drive to this letter (default: x) |
| | 37 | -h View this message |
| | 38 | " if $opts{h}; |
| | 39 | |
| | 40 | my $outfile = "build.log"; |
| | 41 | my $tee = new IO::Tee( \*STDOUT, new IO::File(">$outfile") ); |
| | 42 | |
| | 43 | my $verbose = do { $opts{d} ? '-v' : '' }; |
| | 44 | my $redirect = do { $opts{d} ? '2>&1' : '' }; |
| | 45 | my $component = shift || ''; |
| | 46 | |
| | 47 | my $epocroot = dirname $Bin; |
| | 48 | my $toplevel = basename $Bin; |
| | 49 | |
| | 50 | build_platform() if $opts{o}; |
| | 51 | |
| | 52 | $opts{s} ||= 'x:'; |
| | 53 | $opts{s} .= ':' unless $opts{s} =~ /:$/; |
| | 54 | unless ( -d "\\$toplevel" ) { |
| | 55 | `subst $opts{s} /d $redirect`; |
| | 56 | systemtee ("subst $opts{s} $epocroot") |
| | 57 | and die "Failed to subst $opts{s} to $epocroot: $!\n"; |
| | 58 | chdir $opts{s} |
| | 59 | or die "Failed to chdir to $opts{s} (subst: $epocroot): $!\n"; |
| | 60 | } |
| | 61 | |
| | 62 | chdir '\\'; |
| | 63 | print "Building under $opts{s} drive\n"; |
| | 64 | |
| | 65 | my $sdkhome = |
| | 66 | $Registry->{ |
| 60 | | $cbdhome = "c:\\Carbide" unless -d $cbdhome; |
| 61 | | $cbdhome = "c:\\apps\\Carbide" unless -d $cbdhome; |
| 62 | | unless (defined $cbdhome and -d $cbdhome) { |
| 63 | | die "ERROR: cannot find Carbide installation path\n". |
| 64 | | "Set CARBIDE_HOME to Carbide installation path and try again\n"; |
| 65 | | } |
| 66 | | |
| 67 | | $ENV{'CWFolder'} = $cbdhome; |
| | 74 | $cbdhome = "c:\\Carbide" unless -d $cbdhome; |
| | 75 | $cbdhome = "c:\\apps\\Carbide" unless -d $cbdhome; |
| | 76 | |
| | 77 | unless ( defined $cbdhome and -d $cbdhome ) { |
| | 78 | die "ERROR: cannot find Carbide installation path\n" |
| | 79 | . "Set CARBIDE_HOME to Carbide installation path and try again\n"; |
| | 80 | } |
| | 81 | |
| | 82 | $ENV{'CWFolder'} = $cbdhome; |
| 69 | | $ENV{'EPOCROOT'}='\\'; |
| 70 | | $ENV{'MWCSym2Includes'}='1'; |
| 71 | | $ENV{'MWLibraries'}= "$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\Win32-x86 Support\\Libraries\\Win32 SDK;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\MSL\\MSL_C\\MSL_Common\\Include;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\MSL\\MSL_C\\MSL_Win32\\Include;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\MSL\\MSL_C++\\MSL_Common\\Include;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\Runtime\\Runtime_x86\\Runtime_Win32\\Libs"; |
| 72 | | $ENV{'MWSym2LibraryFiles'}= 'gdi32.lib;user32.lib;kernel32.lib;MSL_All_MSE.lib;MSL_All_MSE_Symbian.lib;MSL_All_x86.lib;MSL_All_x86_Symbian.lib'; |
| 73 | | $ENV{'PATH'}= "$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Tools\\Command_Line_Tools;$sdkhome\\epoc32\\tools;$sdkhome\\epoc32\\gcc\\bin;".$ENV{PATH}; |
| 74 | | |
| 75 | | if ($opts{d}) { |
| 76 | | print "ENV: $_\n\n$ENV{$_}\n\n" for keys %ENV; |
| 77 | | } |
| 78 | | my $epocroot = dirname $Bin; |
| 79 | | my $toplevel = basename $Bin; |
| 80 | | |
| 81 | | # only subst if current drive ne subst dir |
| 82 | | unless ( -d "\\$toplevel" ) { |
| 83 | | `subst x: /d 2>&1`; # discards STDERR & STDOUT |
| 84 | | system "subst x: $epocroot" and warn "Failed to subst x: to $epocroot: $!\n"; |
| 85 | | } |
| 86 | | chdir 'x:' or die "Failed to chdir to x: (subst: $epocroot): $!\n"; |
| 87 | | chdir '\\'; |
| | 84 | $ENV{'EPOCROOT'} = '\\'; |
| | 85 | $ENV{'MWCSym2Includes'} = '1'; |
| | 86 | $ENV{'MWLibraries'} = |
| | 87 | "$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\Win32-x86 Support\\Libraries\\Win32 SDK;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\MSL\\MSL_C\\MSL_Common\\Include;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\MSL\\MSL_C\\MSL_Win32\\Include;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\MSL\\MSL_C++\\MSL_Common\\Include;$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Support\\Runtime\\Runtime_x86\\Runtime_Win32\\Libs"; |
| | 88 | $ENV{'MWSym2LibraryFiles'} = |
| | 89 | 'gdi32.lib;user32.lib;kernel32.lib;MSL_All_MSE.lib;MSL_All_MSE_Symbian.lib;MSL_All_x86.lib;MSL_All_x86_Symbian.lib'; |
| | 90 | $ENV{'PATH'} = |
| | 91 | "$cbdhome\\plugins\\com.nokia.carbide.cpp.support_1.0.0\\Symbian_Tools\\Command_Line_Tools;$sdkhome\\epoc32\\tools;$sdkhome\\epoc32\\gcc\\bin;" |
| | 92 | . $ENV{PATH}; |
| | 93 | delete $ENV{'MWSYM2LIBRARIES'}; |
| | 94 | $ENV{'ARCHIVER'} = 'arm-none-symbianelf-ar'; |
| | 95 | |
| | 96 | if ( $opts{e} ) { |
| | 97 | for ( |
| | 98 | qw /CWFolder LM_LICENSE_FILE EPOCROOT MWCSym2Includes MWLibraries MWSym2LibraryFiles PATH ARCHIVER/ |
| | 99 | ) |
| | 100 | { |
| | 101 | print "set $_=$ENV{$_}\n"; |
| | 102 | } |
| | 103 | exit; |
| | 104 | } |
| | 105 | |
| | 106 | if ( $opts{d} ) { |
| | 107 | print "$_=$ENV{$_}\n\n" for sort keys %ENV; |
| | 108 | } |
| 90 | | foreach (`unzip -l $toplevel\\S60Internals\\*.zip`) { |
| 91 | | if ( /\d\d:\d\d\s*(.*)/ ) { |
| 92 | | next unless -f $1; |
| 93 | | print "Removing $1\n"; |
| 94 | | unlink $1; |
| 95 | | } |
| 96 | | } |
| 97 | | exit; |
| 98 | | } |
| 99 | | |
| 100 | | system "unzip -od \\ $toplevel\\S60Internals\\*.zip" |
| 101 | | if glob <$toplevel/S60Internals/*.zip>; |
| 102 | | |
| 103 | | chdir $toplevel or die "Cannot cd to $toplevel: $!\n"; |
| 104 | | if ( $component ) { |
| 105 | | chdir "$component\\group" or die "Cannot cd to $component: $!\n"; |
| 106 | | } |
| 107 | | |
| 108 | | my $verbose = do {$opts{d} ? '-v' : ''}; |
| 109 | | system "bldmake $verbose bldfiles winscw"; |
| 110 | | system "abld $verbose reallyclean winscw udeb" if $opts{c}; |
| 111 | | system "abld $verbose build winscw udeb"; |
| 112 | | |
| | 111 | foreach (`unzip -l $toplevel\\S60Internals\\*.zip $redirect`) { |
| | 112 | if (/\d\d:\d\d\s*(.*)/) { |
| | 113 | next unless -f $1; |
| | 114 | print "Removing $1\n"; |
| | 115 | unlink $1; |
| | 116 | } |
| | 117 | } |
| | 118 | exit; |
| | 119 | } |
| | 120 | |
| | 121 | `unzip -od \\ $toplevel\\S60Internals\\*.zip $redirect` |
| | 122 | if glob <$toplevel/S60Internals/*.zip>; |
| | 123 | |
| | 124 | print |
| | 125 | "Synching \\$toplevel\\LayoutTests with \\epoc32\\winscw\\c\\LayoutTests\n"; |
| | 126 | |
| | 127 | my $dirsync = new File::DirSync { |
| | 128 | verbose => $opts{d}, |
| | 129 | src => "$Bin/LayoutTests", |
| | 130 | dst => "\\epoc32\\winscw\\c\\LayoutTests", |
| | 131 | nocache => 1, |
| | 132 | }; |
| | 133 | $dirsync->ignore('.svn'); |
| | 134 | $dirsync->dirsync(); |
| | 135 | print $dirsync ->entries_updated() . " LayoutTests files updated\n"; |
| | 136 | print $dirsync ->entries_removed() . " LayoutTests files removed\n"; |
| | 137 | |
| | 138 | chdir $toplevel or die "Cannot cd to $toplevel: $!\n"; |
| | 139 | |
| | 140 | if ( $opts{w} ) { |
| | 141 | build( 'udeb', 'winscw' ); |
| | 142 | } |
| | 143 | elsif ( $opts{g} ) { |
| | 144 | build( 'urel', 'gcce' ); |
| | 145 | } |
| | 146 | else { |
| | 147 | build( 'udeb', 'winscw' ); |
| | 148 | |
| | 149 | # build ('urel','gcce'); |
| | 150 | } |
| | 151 | |
| | 152 | if ( $opts{g} ) { |
| | 153 | chdir '\\s60\\s60webui\\webui\\install'; |
| | 154 | systemtee('buildsis'); |
| | 155 | chdir '\\s60'; |
| | 156 | } |
| | 157 | |
| | 158 | finish(); |
| | 159 | |
| | 160 | sub build { |
| | 161 | my ( $flavour, $platform ) = @_; |
| | 162 | do { systemtee("abld $verbose freeze $platform"); exit $? } |
| | 163 | if $opts{f}; |
| | 164 | if ( $opts{t} ) { |
| | 165 | systemtee("abld $verbose target $platform $flavour $component"); |
| | 166 | return; |
| | 167 | } |
| | 168 | $flavour = 'udeb' if $opts{d}; # debugging forces udeb flavour |
| | 169 | systemtee("bldmake $verbose bldfiles $platform"); |
| | 170 | |
| | 171 | # disable logging |
| | 172 | system("abld $verbose reallyclean $platform $flavour $component") |
| | 173 | unless $opts{n}; |
| | 174 | systemtee("abld $verbose build $platform $flavour $component"); |
| | 175 | } |
| | 176 | |
| | 177 | sub build_platform { |
| | 178 | $ENV{EPOCROOT} = '\\'; |
| | 179 | chdir 'S60Internals'; |
| | 180 | `unzip -o S60Libs.zip $redirect`; |
| | 181 | `unzip -o S60Headers.zip $redirect`; |
| | 182 | chdir '../S60Tools'; |
| | 183 | systemtee("perl \\epoc32\\tools\\genbuild.pl WebEngine.txt"); |
| | 184 | for (qw/bldfiles export makefile clean what/) { |
| | 185 | system "WebEngine_${_}.cmd"; |
| | 186 | } |
| | 187 | for (qw/resource library target/) { |
| | 188 | system("WebEngine_${_}.cmd"); |
| | 189 | } |
| | 190 | finish(); |
| | 191 | } |
| | 192 | |
| | 193 | sub systemtee { |
| | 194 | my ($cmd) = @_; |
| | 195 | return unless $cmd; |
| | 196 | open( my $STATUS, "$cmd 2>&1 |" ) |
| | 197 | || die "can't fork: $!"; |
| | 198 | while (<$STATUS>) { |
| | 199 | print $tee $_; |
| | 200 | } |
| | 201 | close $STATUS || warn "Bad cmd $! exit value: $?\n"; |
| | 202 | return $?; |
| | 203 | } |
| | 204 | |
| | 205 | sub finish { |
| | 206 | my ( $sec, $min, $hour, @trash ) = gmtime( time - $^T ); |
| | 207 | printf "\n\tCompleted in: %02d:%02d:%02d\n", $hour, $min, $sec; |
| | 208 | print "\n\tScanning build output for errors: "; |
| | 209 | my $summary = `perl \\epoc32\\tools\\scanlog.pl $outfile`; |
| | 210 | unless ( $summary =~ /Total\s*\d\d:\d\d\:\d\d\s*(\d+)/ ) { |
| | 211 | warn("\nFailed to parse build summary:\n$summary"); |
| | 212 | } |
| | 213 | else { |
| | 214 | print "$1 found\n"; |
| | 215 | } |
| | 216 | exit $1; |
| | 217 | } |