Commit d2533be2 authored by dbates@webkit.org's avatar dbates@webkit.org

2011-03-14 Daniel Bates <dbates@rim.com>

        Reviewed by David Kilzer.

        Cleanup: Separate port-specific implementation details from webkitdirs::buildCMakeProject()
        https://bugs.webkit.org/show_bug.cgi?id=55438

        Separate out the EFL- and WinCE-specific logic from the port-independent logic in
        webkitdirs::buildCMakeProject(). Also, remove redundant code for generating the
        CMake arguments for feature defines.

        * Scripts/build-webkit:
          - Added cMakeArgsFromFeatures() to convert the @features array to CMake arguments.
          - Modified EFL and WinCE-specific building logic to call buildCMakeProjectOrExit().
          - Sorted forward declarations.
          - Initialize $makeArgs with the empty string so as to simplify its use in string operations;
            Modified call sites as needed.
        * Scripts/webkitdirs.pm:
          - Added cleanCMakeGeneratedProject() to clean a CMake build.
          - Added buildCMakeGeneratedProject() to build using generated build system.
          - Added buildCMakeProjectOrExit() which is a facade for building a CMake project.
          - Added generateBuildSystemFromCMakeProject() to generate the build system from
            a CMake project.
          - Removed buildCMakeProject(). This functionality is in buildCMakeProjectOrExit().


git-svn-id: svn://svn.chromium.org/blink/trunk@81041 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b520e081
2011-03-14 Daniel Bates <dbates@rim.com>
Reviewed by David Kilzer.
Cleanup: Separate port-specific implementation details from webkitdirs::buildCMakeProject()
https://bugs.webkit.org/show_bug.cgi?id=55438
Separate out the EFL- and WinCE-specific logic from the port-independent logic in
webkitdirs::buildCMakeProject(). Also, remove redundant code for generating the
CMake arguments for feature defines.
* Scripts/build-webkit:
- Added cMakeArgsFromFeatures() to convert the @features array to CMake arguments.
- Modified EFL and WinCE-specific building logic to call buildCMakeProjectOrExit().
- Sorted forward declarations.
- Initialize $makeArgs with the empty string so as to simplify its use in string operations;
Modified call sites as needed.
* Scripts/webkitdirs.pm:
- Added cleanCMakeGeneratedProject() to clean a CMake build.
- Added buildCMakeGeneratedProject() to build using generated build system.
- Added buildCMakeProjectOrExit() which is a facade for building a CMake project.
- Added generateBuildSystemFromCMakeProject() to generate the build system from
a CMake project.
- Removed buildCMakeProject(). This functionality is in buildCMakeProjectOrExit().
2011-03-14 John Knottenbelt <jknotten@chromium.org> 2011-03-14 John Knottenbelt <jknotten@chromium.org>
Reviewed by Steve Block. Reviewed by Steve Block.
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. # Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
# Copyright (C) 2009 Google Inc. All rights reserved. # Copyright (C) 2009 Google Inc. All rights reserved.
# Copyright (C) 2010 moiji-mobile.com All rights reserved. # Copyright (C) 2010 moiji-mobile.com All rights reserved.
# Copyright (C) 2011 Research In Motion Limited. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -41,6 +42,7 @@ use webkitdirs; ...@@ -41,6 +42,7 @@ use webkitdirs;
use webkitperl::features; use webkitperl::features;
use POSIX; use POSIX;
sub cMakeArgsFromFeatures();
sub checkForJavaSDK(); sub checkForJavaSDK();
sub formatBuildTime($); sub formatBuildTime($);
sub writeCongrats(); sub writeCongrats();
...@@ -55,7 +57,7 @@ my $v8 = 0; ...@@ -55,7 +57,7 @@ my $v8 = 0;
my $installHeaders; my $installHeaders;
my $installLibs; my $installLibs;
my $prefixPath; my $prefixPath;
my $makeArgs; my $makeArgs = "";
my $noWebKit2 = 0; my $noWebKit2 = 0;
my $startTime = time(); my $startTime = time();
...@@ -419,7 +421,7 @@ if (isGtk()) { ...@@ -419,7 +421,7 @@ if (isGtk()) {
} }
push @options, "--prefix=" . $prefixPath if defined($prefixPath); push @options, "--prefix=" . $prefixPath if defined($prefixPath);
push @options, "--makeargs=" . $makeArgs if defined($makeArgs); push @options, "--makeargs=" . $makeArgs if $makeArgs;
} elsif (isAppleMacWebKit()) { } elsif (isAppleMacWebKit()) {
checkForJavaSDK(); checkForJavaSDK();
push @options, XcodeOptions(); push @options, XcodeOptions();
...@@ -487,7 +489,7 @@ if (isGtk()) { ...@@ -487,7 +489,7 @@ if (isGtk()) {
@options = @ARGV; @options = @ARGV;
push @options, "--install-headers=" . $installHeaders if defined($installHeaders); push @options, "--install-headers=" . $installHeaders if defined($installHeaders);
push @options, "--install-libs=" . $installLibs if defined($installLibs); push @options, "--install-libs=" . $installLibs if defined($installLibs);
push @options, "--makeargs=" . $makeArgs if defined($makeArgs); push @options, "--makeargs=" . $makeArgs if $makeArgs;
foreach (@features) { foreach (@features) {
push @options, "DEFINES+=$_->{define}=${$_->{value}}" if ${$_->{value}} != $_->{default}; push @options, "DEFINES+=$_->{define}=${$_->{value}}" if ${$_->{value}} != $_->{default};
...@@ -511,10 +513,7 @@ if (isInspectorFrontend()) { ...@@ -511,10 +513,7 @@ if (isInspectorFrontend()) {
if (isWx()) { if (isWx()) {
downloadWafIfNeeded(); downloadWafIfNeeded();
@options = (); @options = split(/ /, $makeArgs);
if (defined($makeArgs)) {
@options = split(/ /, $makeArgs);
}
@projects = (); @projects = ();
my $result = buildWafProject('.', $clean, @options); my $result = buildWafProject('.', $clean, @options);
exit exitStatus($result) if exitStatus($result); exit exitStatus($result) if exitStatus($result);
...@@ -529,34 +528,13 @@ if (isChromium()) { ...@@ -529,34 +528,13 @@ if (isChromium()) {
} }
if (isEfl()) { if (isEfl()) {
@options = (); # By default we build using all of the available CPUs.
@projects = (); $makeArgs .= ($makeArgs ? " " : "") . "-j" . numberOfCPUs() if $makeArgs !~ /-j\s*\d+/;
foreach (@features) { buildCMakeProjectOrExit($clean, "Efl", $prefixPath, $makeArgs, cMakeArgsFromFeatures());
my $featureName = $_->{define};
if ($featureName) {
my $featureEnabled = ${$_->{value}} ? "ON" : "OFF";
push @options, "-D$featureName=$featureEnabled";
}
}
push @options, "--makeargs=" . $makeArgs if defined($makeArgs);
push @options, "--prefix=" . $prefixPath if defined($prefixPath);
my $result = buildCMakeEflProject($clean, @options);
exit exitStatus($result) if exitStatus($result);
} }
if (isWinCE()) { if (isWinCE()) {
@options = (); buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK=STANDARDSDK_500 (ARMV4I)", cMakeArgsFromFeatures()));
@projects = ();
foreach (@features) {
my $featureName = $_->{define};
if ($featureName) {
my $featureEnabled = ${$_->{value}} ? "ON" : "OFF";
push @options, "-D$featureName=$featureEnabled";
}
}
push @options, "--makeargs=" . $makeArgs if defined($makeArgs);
my $result = buildCMakeWinCEProject("STANDARDSDK_500 (ARMV4I)", $clean, @options);
exit exitStatus($result) if exitStatus($result);
} }
# Build, and abort if the build fails. # Build, and abort if the build fails.
...@@ -613,6 +591,19 @@ writeCongrats(); ...@@ -613,6 +591,19 @@ writeCongrats();
exit 0; exit 0;
sub cMakeArgsFromFeatures()
{
my @args;
foreach (@features) {
my $featureName = $_->{define};
if ($featureName) {
my $featureEnabled = ${$_->{value}} ? "ON" : "OFF";
push @args, "-D$featureName=$featureEnabled";
}
}
return @args;
}
sub checkForJavaSDK() sub checkForJavaSDK()
{ {
my $jniHeader = "/System/Library/Frameworks/JavaVM.framework/Headers/jni.h"; my $jniHeader = "/System/Library/Frameworks/JavaVM.framework/Headers/jni.h";
......
# Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved. # Copyright (C) 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
# Copyright (C) 2009 Google Inc. All rights reserved. # Copyright (C) 2009 Google Inc. All rights reserved.
# Copyright (C) 2011 Research In Motion Limited. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
...@@ -1476,90 +1477,72 @@ sub buildAutotoolsProject($@) ...@@ -1476,90 +1477,72 @@ sub buildAutotoolsProject($@)
return $result; return $result;
} }
sub buildCMakeProject($@) sub generateBuildSystemFromCMakeProject
{ {
my ($port, $clean, @buildParams) = @_; my ($port, $prefixPath, @cmakeArgs) = @_;
my $dir = File::Spec->canonpath(baseProductDir());
my $config = configuration(); my $config = configuration();
my $result; my $buildPath = File::Spec->catdir(baseProductDir(), $config);
my $cmakeBuildArgs = ""; File::Path::mkpath($buildPath) unless -d $buildPath;
my $makeArgs = ""; my $originalWorkingDirectory = getcwd();
my @buildArgs; chdir($buildPath) or die;
if ($port =~ m/wince/i) {
if ($config =~ m/debug/i) {
$cmakeBuildArgs .= " --config Debug";
} elsif ($config =~ m/release/i) {
$cmakeBuildArgs .= " --config Release";
}
} else {
$makeArgs .= " -j" . numberOfCPUs() if ($makeArgs !~ m/-j\s*\d+/);
}
if ($clean) {
print "Cleaning the build directory '$dir'\n";
$dir = File::Spec->catfile($dir, $config);
File::Path::remove_tree($dir, {keep_root => 1});
$result = 0;
} else {
my $cmakebin = "cmake";
my $cmakeBuildCommand = $cmakebin . " --build .";
push @buildArgs, "-DPORT=$port";
for my $i (0 .. $#buildParams) {
my $opt = $buildParams[$i];
if ($opt =~ /^--makeargs=(.*)/i ) {
$makeArgs = $1;
} elsif ($opt =~ /^--prefix=(.*)/i ) {
push @buildArgs, "-DCMAKE_INSTALL_PREFIX=$1";
} else {
push @buildArgs, $opt;
}
}
if ($config =~ m/debug/i) {
push @buildArgs, "-DCMAKE_BUILD_TYPE=Debug";
} elsif ($config =~ m/release/i) {
push @buildArgs, "-DCMAKE_BUILD_TYPE=Release";
}
push @buildArgs, sourceDir() . "/Source"; my @args;
push @args, "-DPORT=\"$port\"";
$dir = File::Spec->catfile($dir, $config); push @args, "-DCMAKE_INSTALL_PREFIX=\"$prefixPath\"" if $prefixPath;
File::Path::mkpath($dir); if ($config =~ /release/i) {
chdir $dir or die "Failed to cd into " . $dir . "\n"; push @args, "-DCMAKE_BUILD_TYPE=Release";
} elsif ($config =~ /debug/i) {
print "Calling '$cmakebin @buildArgs' in " . $dir . "\n\n"; push @args, "-DCMAKE_BUILD_TYPE=Debug";
my $result = system "$cmakebin @buildArgs"; }
if ($result ne 0) { push @args, @cmakeArgs if @cmakeArgs;
die "Failed while running $cmakebin to generate makefiles!\n"; push @args, '"' . File::Spec->catdir(sourceDir(), "Source") . '"';
}
$cmakeBuildArgs .= " -- " . $makeArgs; # We call system("cmake @args") instead of system("cmake", @args) so that @args is
# parsed for shell metacharacters.
my $returnCode = system("cmake @args");
print "Calling '$cmakeBuildCommand $cmakeBuildArgs' in " . $dir . "\n\n"; chdir($originalWorkingDirectory);
$result = system "$cmakeBuildCommand $cmakeBuildArgs"; return $returnCode;
if ($result ne 0) { }
die "Failed to build $port port\n";
}
chdir ".." or die; sub buildCMakeGeneratedProject($)
{
my ($makeArgs) = @_;
my $config = configuration();
my $buildPath = File::Spec->catdir(baseProductDir(), $config);
if (! -d $buildPath) {
die "Must call generateBuildSystemFromCMakeProject() before building CMake project.";
} }
my @args = ("--build", $buildPath, "--config", $config);
push @args, ("--", $makeArgs) if $makeArgs;
return $result; # We call system("cmake @args") instead of system("cmake", @args) so that @args is
# parsed for shell metacharacters. In particular, $makeArgs may contain such metacharacters.
return system("cmake @args");
} }
sub buildCMakeEflProject($@) sub cleanCMakeGeneratedProject()
{ {
my ($clean, @buildArgs) = @_; my $config = configuration();
return buildCMakeProject("Efl", $clean, @buildArgs); my $buildPath = File::Spec->catdir(baseProductDir(), $config);
if (-d $buildPath) {
return system("cmake", "--build", $buildPath, "--config", $config, "--target", "clean");
}
return 0;
} }
sub buildCMakeWinCEProject($@) sub buildCMakeProjectOrExit($$$$@)
{ {
my ($sdk, $clean, @buildArgs) = @_; my ($clean, $port, $prefixPath, $makeArgs, @cmakeArgs) = @_;
return buildCMakeProject("WinCE -DCMAKE_WINCE_SDK=\"" . $sdk . "\"", $clean, @buildArgs); my $returnCode;
if ($clean) {
$returnCode = exitStatus(cleanCMakeGeneratedProject());
exit($returnCode) if $returnCode;
}
$returnCode = exitStatus(generateBuildSystemFromCMakeProject($port, $prefixPath, @cmakeArgs));
exit($returnCode) if $returnCode;
$returnCode = exitStatus(buildCMakeGeneratedProject($makeArgs));
exit($returnCode) if $returnCode;
} }
sub buildQMakeProject($@) sub buildQMakeProject($@)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment