Bug 55438 - Cleanup: Separate port-specific implementation details from webkitdirs::buildCMakeProject()
Summary: Cleanup: Separate port-specific implementation details from webkitdirs::build...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-28 19:00 PST by Daniel Bates
Modified: 2011-03-15 14:26 PDT (History)
7 users (show)

See Also:


Attachments
Patch (8.92 KB, patch)
2011-02-28 19:45 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (9.20 KB, patch)
2011-02-28 19:48 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (9.22 KB, patch)
2011-02-28 19:52 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (9.06 KB, patch)
2011-03-01 10:25 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (9.25 KB, patch)
2011-03-01 13:33 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (11.06 KB, patch)
2011-03-09 14:10 PST, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (11.04 KB, patch)
2011-03-09 14:13 PST, Daniel Bates
ddkilzer: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2011-02-28 19:00:52 PST
webkitdirs::buildCMakeProject() should be a port-independent function for building a port that uses a CMake build system. Currently, this function also includes logic that is specific to the WinCE and EFL ports. We should extract these details so as to make this function port-independent.
Comment 1 Daniel Bates 2011-02-28 19:45:28 PST
Created attachment 84177 [details]
Patch

I am not very familiar with CMake or the EFL and WinCE ports. So, I would appreciate if this patch is scrutinized for correctness. 

I implemented the functionality for cleaning a CMake project (i.e. build-webkit --clean) using cmake --build ... --target clean. Currently, the code "cleans" a project by removing the build directory (why?).
Comment 2 Daniel Bates 2011-02-28 19:48:53 PST
Created attachment 84178 [details]
Patch
Comment 3 WebKit Review Bot 2011-02-28 19:49:02 PST
Attachment 84177 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/8070579
Comment 4 WebKit Review Bot 2011-02-28 19:50:32 PST
Attachment 84178 [details] did not build on chromium:
Build output: http://queues.webkit.org/results/8075473
Comment 5 Daniel Bates 2011-02-28 19:52:20 PST
Created attachment 84180 [details]
Patch
Comment 6 Gyuyoung Kim 2011-02-28 22:48:12 PST
There is build break on EFL port. Please do not land this patch by fixing this error.


Failed to run "['Tools/Scripts/build-webkit', '--release', '--efl', '--makeargs="-j8"']" exit_code: 1

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LANG = "en_US.US-ASCII"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
CMake Error at CMakeLists.txt:97 (INCLUDE):
  include could not find load file:

    OptionsEFL


-- Platform-specific CMakeLists not found: /mnt/eflews/git/webkit/Source/JavaScriptCore/CMakeListsEFL.txt
-- Platform-specific CMakeLists not found: /mnt/eflews/git/webkit/Source/JavaScriptCore/wtf/CMakeListsEFL.txt
-- Platform-specific CMakeLists not found: /mnt/eflews/git/webkit/Source/JavaScriptCore/shell/CMakeListsEFL.txt
-- Platform-specific CMakeLists not found: /mnt/eflews/git/webkit/Source/WebCore/CMakeListsEFL.txt
-- Platform-specific CMakeLists not found: /mnt/eflews/git/webkit/Source/WebKit/efl/CMakeListsEFL.txt
You have called ADD_LIBRARY for library WebKit without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Platform-specific CMakeLists not found: /mnt/eflews/git/webkit/Source/../Tools/CMakeListsEFL.txt
-- Enabled features:
-- Configuring incomplete, errors occurred
Comment 7 Daniel Bates 2011-02-28 23:01:00 PST
Comment on attachment 84180 [details]
Patch

Clearing review flag while I look into this some more.
Comment 8 Daniel Bates 2011-03-01 10:25:53 PST
Created attachment 84248 [details]
Patch
Comment 9 Daniel Bates 2011-03-01 13:33:13 PST
Created attachment 84287 [details]
Patch
Comment 10 Patrick R. Gansterer 2011-03-07 12:04:17 PST
Comment on attachment 84287 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=84287&action=review

Sorry for the long delay. LGTM, but one change is required to work (at least on my machine).

> Tools/Scripts/build-webkit:542
> +    buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ('-DCMAKE_WINCE_SDK="STANDARDSDK_500 (ARMV4I)"', cMakeArgsFromFeatures()));

I don't know why, but it only works when chanig the quotes:
buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK='STANDARDSDK_500 (ARMV4I)'", cMakeArgsFromFeatures()));
Comment 11 Daniel Bates 2011-03-09 13:46:01 PST
(In reply to comment #10)
> (From update of attachment 84287 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=84287&action=review
> 
> [...]
> I don't know why, but it only works when chanig the quotes:
> buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK='STANDARDSDK_500 (ARMV4I)'", cMakeArgsFromFeatures()));

Notice, buildCMakeProjectOrExit() passes the argument @cmakeArgs to generateBuildSystemFromCMakeProject().

We don't need the inner quotes around the value of DCMAKE_WINCE_SDK since generateBuildSystemFromCMakeProject() calls system() using the Program, List form of this subroutine. This form of the subroutine passes the argument list directly to Program (instead of calling the system shell first) as per <http://perldoc.perl.org/functions/system.html>. In particular, the CMake argument "DCMAKE_WINCE_SDK='STANDARDSDK_500 (ARMV4I)'" will be passed directly. Hence, we don't need the quotes around the value of DCMAKE_WINCE_SDK.
Comment 12 Daniel Bates 2011-03-09 14:10:17 PST
Created attachment 85228 [details]
Patch

Simplified logic for $makeArgs by initializing it to the empty string.
Comment 13 Daniel Bates 2011-03-09 14:13:00 PST
Created attachment 85230 [details]
Patch
Comment 14 David Kilzer (:ddkilzer) 2011-03-11 11:11:32 PST
Comment on attachment 85230 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=85230&action=review

r=me assuming the other CMake port maintainers are okay with this.

> Tools/Scripts/build-webkit:60
> +my $makeArgs = ""; # We initialize this to the empty string to simplify its use in string operations.

Nit: Comment probably isn't necessary unless someone removes the initialization in the future.

> Tools/Scripts/build-webkit:537
> +    buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK=STANDARDSDK_500 (ARMV4I)", cMakeArgsFromFeatures()));

I don't think the -DCMAKE_WINCE_SDK=STANDARDSDK_500 (ARMV4I) argument be quoted correctly.  This should be (unless calling system() simply does the right thing without quoting):

    buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK=\"STANDARDSDK_500 (ARMV4I)\"", cMakeArgsFromFeatures()));

> Tools/Scripts/webkitdirs.pm:1487
> +    chdir($buildPath);

Nit: Might consider adding back the "or die..." code to the chdir here.

> Tools/Scripts/webkitdirs.pm:1492
> +    push @args, "-DPORT=$port";
> +    push @args, "-DCMAKE_INSTALL_PREFIX=$prefixPath" if $prefixPath;
> +    push @args, "-DCMAKE_BUILD_TYPE=$config";

Nit: To be extra-safe and future-proof, you could double-quote the values.  At least consider doing this for the $prefixPath value since paths can have spaces in them (unless the system() call obviates the need for this):

    push @args, "-DPORT=\"$port\"";
    push @args, "-DCMAKE_INSTALL_PREFIX=\"$prefixPath\"" if $prefixPath;
    push @args, "-DCMAKE_BUILD_TYPE=\"$config\"";

Nit: The old code didn't assume that $config was always "Debug" or "Release".  What happens if someone uses "release" instead?  Will cmake still do the correct thing?

> Tools/Scripts/webkitdirs.pm:1494
> +    push @args, sourceDir() . "/Source";

Nit: I know the original code didn't do this, but this should probably use File::Spec->catdir(sourceDir(), "Source").
Comment 15 Daniel Bates 2011-03-14 09:56:16 PDT
(In reply to comment #14)
> (From update of attachment 85230 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=85230&action=review
> [...]
> > Tools/Scripts/build-webkit:60
> > +my $makeArgs = ""; # We initialize this to the empty string to simplify its use in string operations.
> 
> Nit: Comment probably isn't necessary unless someone removes the initialization in the future.

Will remove.

> 
> > Tools/Scripts/build-webkit:537
> > +    buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK=STANDARDSDK_500 (ARMV4I)", cMakeArgsFromFeatures()));
> 
> I don't think the -DCMAKE_WINCE_SDK=STANDARDSDK_500 (ARMV4I) argument be quoted correctly.  This should be (unless calling system() simply does the right thing without quoting):

I'll add quotes around this value and change the call to system() (in generateBuildSystemFromCMakeProject()) so that it passes through the shell for processing (similar to what is done in buildCMakeGeneratedProject()). 

Currently, quotes are unnecessary since I'm using the PROGRAM-LIST form of system() with a LIST that consists of more than one argument in generateBuildSystemFromCMakeProject(): <http://perldoc.perl.org/functions/system.html>.

> 
>     buildCMakeProjectOrExit($clean, "WinCE", $prefixPath, $makeArgs, ("-DCMAKE_WINCE_SDK=\"STANDARDSDK_500 (ARMV4I)\"", cMakeArgsFromFeatures()));
> 
> > Tools/Scripts/webkitdirs.pm:1487
> > +    chdir($buildPath);
> 
> Nit: Might consider adding back the "or die..." code to the chdir here.

Will add.

> 
> > Tools/Scripts/webkitdirs.pm:1492
> > +    push @args, "-DPORT=$port";
> > +    push @args, "-DCMAKE_INSTALL_PREFIX=$prefixPath" if $prefixPath;
> > +    push @args, "-DCMAKE_BUILD_TYPE=$config";
> 
> Nit: To be extra-safe and future-proof, you could double-quote the values.  At least consider doing this for the $prefixPath value since paths can have spaces in them (unless the system() call obviates the need for this):
> 
>     push @args, "-DPORT=\"$port\"";
>     push @args, "-DCMAKE_INSTALL_PREFIX=\"$prefixPath\"" if $prefixPath;
>     push @args, "-DCMAKE_BUILD_TYPE=\"$config\"";
> 

Will change.

Currently, the form of system() used obviates the need for quotes as explained above.

> Nit: The old code didn't assume that $config was always "Debug" or "Release".  What happens if someone uses "release" instead?  Will cmake still do the correct thing?

Will change this to read:

if ($config =~ /release/i) {
    push @args, "-DCMAKE_BUILD_TYPE=Release";
} elsif ($config =~ /debug/i) {
    push @args, "-DCMAKE_BUILD_TYPE=Debug";
}

> 
> > Tools/Scripts/webkitdirs.pm:1494
> > +    push @args, sourceDir() . "/Source";
> 
> Nit: I know the original code didn't do this, but this should probably use File::Spec->catdir(sourceDir(), "Source").

Will change.
Comment 16 Daniel Bates 2011-03-14 11:14:04 PDT
(In reply to comment #14)
> (From update of attachment 85230 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=85230&action=review
> 
> r=me assuming the other CMake port maintainers are okay with this.

Patrick Gansterer said the patch "LGTM" with a remark to use quotes (which I have corrected) in comment 10. Also, the patch builds on EFL according the EFL EWS bot. I don't foresee issues with the changes you suggested. I will land this patch shortly and watch the build bots.
Comment 17 Daniel Bates 2011-03-14 11:24:46 PDT
Committed r81041: <http://trac.webkit.org/changeset/81041>
Comment 18 David Kilzer (:ddkilzer) 2011-03-15 14:26:41 PDT
(In reply to comment #17)
> Committed r81041: <http://trac.webkit.org/changeset/81041>

Follow-up fix in r81042: <http://trac.webkit.org/changeset/81042>