From e400f9d6a6767538d10026e71d6f90e2513150f6 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Fri, 6 Apr 2012 22:26:03 -0500 Subject: Add --dry-run option to build script The --dry-run option (-n for short) also allows levels of dry-run, where the first level just shows what the build script itself will do. However if you -n 2, then it will recurse the dry-run to the make as well, so you can get a full dry-run of everything. Change-Id: I3a3c8a844411219e7afe6a570bc9ef6718ba472f Reviewed-by: Giuseppe D'Angelo Reviewed-by: Rohan McGovern --- build | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'build') diff --git a/build b/build index 07f60fd3..8154ef0e 100755 --- a/build +++ b/build @@ -64,6 +64,7 @@ sub parse_arguments 'jobs' => -1, 'force_qmake' => 0, 'build-submodules' => [], + 'dry-run' => 0, ); GetOptionsFromArray(\@args, @@ -71,6 +72,7 @@ sub parse_arguments 'continue' => \$self->{'continue'}, 'jobs|j:1' => \$self->{'jobs'}, 'force-qmake' => \$self->{'force_qmake'}, + 'dry-run|n:1' => \$self->{'dry-run'}, 'help|?' => sub { pod2usage(1); }, ) || pod2usage(2); @@ -86,8 +88,8 @@ sub exe print "+ @cmd\n" unless ($self->{quiet}); - if (system(@cmd) != 0) { - confess "@cmd exited with status $CHILD_ERROR"; + if ($self->{'dry-run'} != 1) { + confess "@cmd exited with status $CHILD_ERROR" if (system(@cmd) != 0); } return 0; @@ -179,23 +181,32 @@ sub detect_configuration $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 - if ($exe =~ 'nmake') { - my $cl = $ENV{'CL'}; - if (defined $cl) { - $cl .= ' /MP'; - } else { - $cl = '/MP'; + if (defined $exe) { + $self->{'MAKE'} = "\"$exe\""; + + if ($exe =~ 'nmake') { + # Use the /MP compiler option if using nmake, to use all CPU threads when compiling + my $cl = $ENV{'CL'}; + if (defined $cl) { + $cl .= ' /MP'; + } else { + $cl = '/MP'; + } + $ENV{'CL'} = $cl; + # Remove the -j option, since nmake cannot handle it. + $self->{'MAKEOPTS'} = ""; } - $ENV{'CL'} = $cl; - } - $self->{'MAKE'} = "\"$exe\"" if (defined $exe); - $self->{'MAKEOPTS'} = "" if (defined $exe && $exe =~ /nmake/); + if ($exe =~ 'nmake|jom' && $self->{'dry-run'} > 1) { + $self->{'MAKEOPTS'} = "/N $self->{'MAKEOPTS'}"; + } + } # Tools needed for building QtWebKit/Windows (Bison, Flex, gperf, iconv) my $abs_path = abs_path('gnuwin32/bin'); unshift @PATH, "$abs_path"; + } else { + $self->{'MAKEOPTS'} = "--dry-run $self->{'MAKEOPTS'}" if ($self->{'dry-run'} > 1); } } -- cgit v1.2.3