Clean up build script

Remove loading of thread modules. Not core module, and we don't use
them.

Return value of system command.

Add --force-qmake option, and by default avoid running qmake when a
Makefile already exists.

Do not pass '-j 1' unless explicit on the command line, and pick up
'MAKE' environment variable. (Thiago)

Remove usage of File::Which, as it's not a core module, and often not
present on host machines. (Peppe)

Remove '-s' or '/s' optin to make/nmake, as we cannot see how far we
have compiled, and we only get warnings/errors.

Change the qtwebkit build command, and add separate command for
installing qtwebkit. Also add the required build tools for WebKit
on Windows.

Change-Id: I79bffa39a13ece78fa401f39a38a1ccaf0f389b0
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
Marius Storm-Olsen
2012-03-27 09:50:27 -05:00
committed by Qt by Nokia
parent 712875dc29
commit 2e119465a5
2 changed files with 67 additions and 31 deletions

80
build
View File

@@ -51,9 +51,8 @@ use English qw( -no_match_vars );
use Getopt::Long qw( GetOptionsFromArray ); use Getopt::Long qw( GetOptionsFromArray );
use Pod::Usage qw( pod2usage ); use Pod::Usage qw( pod2usage );
use Cwd qw( getcwd ); use Cwd qw( getcwd );
use File::Spec qw( path catfile );
use Config; use Config;
use thread;
use threads::shared;
# Like `system', but possibly log the command, and die on non-zero exit code # Like `system', but possibly log the command, and die on non-zero exit code
sub exe sub exe
@@ -66,7 +65,7 @@ sub exe
confess "@cmd exited with status $CHILD_ERROR"; confess "@cmd exited with status $CHILD_ERROR";
} }
return; return 0;
} }
sub dropPrivileges() sub dropPrivileges()
@@ -112,8 +111,8 @@ sub exeLowPriv()
die "Couldn't fork" unless defined $pid; die "Couldn't fork" unless defined $pid;
if ($pid == 0) { if ($pid == 0) {
$self->dropPrivileges; $self->dropPrivileges;
$ret = $self->exe(@cmd); $self->exe(@cmd);
exit $ret; exit 0;
} else { } else {
waitpid($pid, 0); waitpid($pid, 0);
return $?; return $?;
@@ -133,7 +132,7 @@ sub new
my $depfile = "build.dependencies"; my $depfile = "build.dependencies";
my $result; my $result;
our (%build_dependencies, %build_commands); our (%build_dependencies, %build_commands, %install_commands);
# following variables may be expanded in the evaluation below # following variables may be expanded in the evaluation below
my $MAKEOPTS = $self->{'MAKEOPTS'}; my $MAKEOPTS = $self->{'MAKEOPTS'};
@@ -145,7 +144,8 @@ sub new
} }
$self->{'deps'} = \%build_dependencies; $self->{'deps'} = \%build_dependencies;
$self->{'cmds'} = \%build_commands; $self->{'buildcmds'} = \%build_commands;
$self->{'instcmds'} = \%install_commands;
return $self; return $self;
} }
@@ -157,7 +157,8 @@ sub parse_arguments
%{$self} = (%{$self}, %{$self} = (%{$self},
'verbose' => 0, 'verbose' => 0,
'continue' => 0, 'continue' => 0,
'jobs' => 1, 'jobs' => -1,
'force_qmake' => 0,
'build-submodules' => [], 'build-submodules' => [],
); );
@@ -165,6 +166,7 @@ sub parse_arguments
'verbose|v:1' => \$self->{'verbose'}, 'verbose|v:1' => \$self->{'verbose'},
'continue' => \$self->{'continue'}, 'continue' => \$self->{'continue'},
'jobs|j:1' => \$self->{'jobs'}, 'jobs|j:1' => \$self->{'jobs'},
'force-qmake' => \$self->{'force_qmake'},
'help|?' => sub { pod2usage(1); }, 'help|?' => sub { pod2usage(1); },
) || pod2usage(2); ) || pod2usage(2);
@@ -173,20 +175,39 @@ sub parse_arguments
return; return;
} }
sub which {
my ($self, $exe) = @_;
foreach my $path (File::Spec->path()) {
my $file = File::Spec->catfile($path, $exe);
return $file if -x $file;
}
return;
}
sub detect_configuration sub detect_configuration
{ {
my ($self) = @_; my ($self) = @_;
die "You need to configure Qt before you try to build it, aborting." if (!-e 'qtbase/.qmake.cache'); die "You need to configure Qt before you try to build it, aborting." if (!-e 'qtbase/.qmake.cache');
$self->{'MAKEOPTS'} = "-s -j $self->{'jobs'}"; use Cwd qw(abs_path);
$self->{'MAKE'} = "make"; use Env qw(@PATH);
if ("$Config{osname}" =~ /(ms|cyg)win/i) { my $abs_path = abs_path('qtbase/bin');
use File::Which; unshift @PATH, $abs_path;
my $exe = which("nmake.exe");
$exe = which("jom.exe") if (defined $exe && which("jom.exe")); if ($self->{'jobs'} >= 0) {
$exe = which("mingw32-make") if (!defined $exe); $self->{'MAKEOPTS'} = "-j $self->{'jobs'}";
} else {
$self->{'MAKEOPTS'} = "";
}
$self->{'MAKE'} = $ENV{MAKE} || "make";
if ("$Config{osname}" =~ /mswin/i) {
my $exe = $self->which("nmake.exe");
$exe = $self->which("jom.exe") if (defined $exe && $self->which("jom.exe"));
$exe = $self->which("mingw32-make.exe") if (!defined $exe);
# Use the /MP compiler option, if using nmake, to use all CPU threads when compiling # Use the /MP compiler option, if using nmake, to use all CPU threads when compiling
if ($exe =~ 'nmake') { if ($exe =~ 'nmake') {
@@ -194,14 +215,11 @@ sub detect_configuration
unshift @CL, '/MP'; unshift @CL, '/MP';
} }
$self->{'MAKE'} = $exe if (defined $exe); $self->{'MAKE'} = "\"$exe\"" if (defined $exe);
$self->{'MAKEOPTS'} = "/s" if (defined $exe && $exe =~ /nmake/); $self->{'MAKEOPTS'} = "" if (defined $exe && $exe =~ /nmake/);
}
if (-e 'qtbase/bin') { # Tools needed for building QtWebKit/Windows (Bison, Flex, gperf, iconv)
use Cwd qw(abs_path); my $abs_path = abs_path('gnuwin32/bin');
use Env qw(@PATH);
my $abs_path = abs_path('qtbase/bin');
unshift @PATH, "$abs_path"; unshift @PATH, "$abs_path";
} }
} }
@@ -342,10 +360,17 @@ sub get_all_next_modules
sub build_project sub build_project
{ {
my ($self, $module) = @_; my ($self, $module) = @_;
my $build_command = $self->{'cmds'}->{$module}; my $build_command = $self->{'buildcmds'}->{$module};
$build_command = "qmake -r && $self->{MAKE} $self->{MAKEOPTS}" if (!defined $build_command); my $install_command = $self->{'instcmds'}->{$module};
exeLowPriv("cd $module && $build_command") && die "'cd $module && $build_command' failed: $?"; if (!defined $build_command) {
exeHighPriv("cd $module && $self->{MAKE} install") && die "'cd $module && $self->{MAKE} install failed: $?"; if (!-e "$module/Makefile") {
$self->exeLowPriv("cd $module && qmake -r") && die "'cd $module && $build_command' failed: $?";
}
$build_command = "$self->{MAKE} $self->{MAKEOPTS}" if (!defined $build_command);
}
$self->exeLowPriv("cd $module && $build_command") && die "'cd $module && $build_command' failed: $?";
$install_command = "$self->{MAKE} install" if (!defined $install_command);
$self->exeHighPriv("cd $module && $install_command") && die "'cd $module && $install_command failed: $?";
$self->mark_as_finished($module); $self->mark_as_finished($module);
return 0; return 0;
} }
@@ -357,7 +382,8 @@ sub build_qt
printf "OS Name ........ %s\n", $Config{osname}; printf "OS Name ........ %s\n", $Config{osname};
printf "Verbose ........ %s\n", ($self->{'verbose'} ? $self->{'verbose'} : "no"); printf "Verbose ........ %s\n", ($self->{'verbose'} ? $self->{'verbose'} : "no");
printf "Continue ....... %s\n", ($self->{'continue'} ? "yes" : "no"); printf "Continue ....... %s\n", ($self->{'continue'} ? "yes" : "no");
printf "Jobs ........... %d\n", $self->{'jobs'}; printf "Force qmake..... %s\n", ($self->{'force_qmake'} ? "yes" : "no");
printf "Jobs ........... %s\n", ($self->{'jobs'} >= 0 ? $self->{'jobs'} : "unset");
my $path = $ENV{'PATH'}; my $path = $ENV{'PATH'};
print "PATH $path\n"; print "PATH $path\n";

View File

@@ -19,7 +19,7 @@ use Config;
"qtimageformats" => "qtbase", "qtimageformats" => "qtbase",
"qtjsbackend" => "qtbase", "qtjsbackend" => "qtbase",
"qtjsondb" => "qtbase,qtdeclarative,qtxmlpatterns", "qtjsondb" => "qtbase,qtdeclarative,qtxmlpatterns",
"qtlocation" => "qtbase,qtdeclarative,qt3d,qtjsondb", "qtlocation" => "qtbase,qtdeclarative,qt3d,qtjsondb:s",
"qtmultimedia" => "qtbase,qtdeclarative", "qtmultimedia" => "qtbase,qtdeclarative",
"qtphonon" => "qtbase", "qtphonon" => "qtbase",
"qtpim" => "qtdeclarative,qtjsondb:s", "qtpim" => "qtdeclarative,qtjsondb:s",
@@ -36,14 +36,24 @@ use Config;
"qtxmlpatterns" => "qtbase", "qtxmlpatterns" => "qtbase",
); );
%build_commands = ( if ("$Config{osname}" =~ /mswin/i) {
"qtwebkit" => "QMAKEPATH=Tools/qmake qmake && make", %build_commands = (
"qtwebkit" => "perl Tools/Scripts/build-webkit --qt --no-netscape-plugin --no-webkit2",
);
} else {
%build_commands = (
"qtwebkit" => "perl Tools/Scripts/build-webkit --qt --release --no-netscape-plugin",
);
}
%install_commands = (
"qtwebkit" => "perl Tools/Scripts/build-webkit --qt --makeargs=\"install\"",
); );
# Platform specific modules # Platform specific modules
if ("$Config{osname}" =~ /linux/i) { if ("$Config{osname}" =~ /linux/i) {
$build_dependencies{"qtwaysland"} = "qtbase"; $build_dependencies{"qtwayland"} = "qtbase";
} }
if ("$Config{osname}" =~ /(ms|cyg)win/i) { if ("$Config{osname}" =~ /(ms|cyg)win/i) {