Bug 136388 - [iOS] Configure Xcode to build a command line tool for the iOS Simulator
Summary: [iOS] Configure Xcode to build a command line tool for the iOS Simulator
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: iPhone / iPad Unspecified
: P2 Normal
Assignee: Daniel Bates
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-29 14:12 PDT by Daniel Bates
Modified: 2014-08-29 16:34 PDT (History)
6 users (show)

See Also:


Attachments
Patch (10.34 KB, patch)
2014-08-29 14:30 PDT, Daniel Bates
no flags Details | Formatted Diff | Diff
Patch (10.43 KB, patch)
2014-08-29 14:40 PDT, 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 2014-08-29 14:12:15 PDT
Towards building iOS WebKit using the public iOS SDK we need to configure Xcode to support building a command line tool for the iOS Simulator (e.g. JSCLLIntOffsetsExtractor).
Comment 1 Daniel Bates 2014-08-29 14:30:59 PDT
Created attachment 237379 [details]
Patch
Comment 2 Daniel Bates 2014-08-29 14:40:46 PDT
Created attachment 237380 [details]
Patch

Renamed updateXcodeSpecification() to createXcodeSpecificationFromSpecificationAndId() to better describe what it does. I am open to name suggestions.
Comment 3 Daniel Bates 2014-08-29 15:02:51 PDT
Comment on attachment 237380 [details]
Patch

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

> Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:142
> +    if ($foundSpecification) {

The conditional expression of this if-statement should be "$foundSpecification && $position >= 0".
Comment 4 David Kilzer (:ddkilzer) 2014-08-29 15:08:52 PDT
Comment on attachment 237380 [details]
Patch

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

r=me

> Tools/ChangeLog:9
> +        Add a script, called configure-Xcode-to-build-iOS-Simulator-command-line-tool, to
> +        configure Xcode to support building a command line tool for the iOS Simulator.

We could be a little less specific about the script name so it could be shorter:  configure-Xcode-for-iOS-Simulator-builds

Not required if there are no other objections.

> Tools/ChangeLog:16
> +        Additionally, teach build-{jsc, webkit} to call the script when building for
> +        iOS Simulator.

How much does this slow down build-webkit?

While it's great that we can make this transparent to the user, don't they need to be root to run the script?  I always envisioned this as a one-time script (after installing Xcode) that each developer would have to run, although there is value in making builds "just work".  :)

> Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:52
> +    if ($file =~ /^\../) {

Won't this ignore "."?  Maybe that doesn't matter because it gets filtered out below.

> Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:57
> +    return if -d $file || $file !~ /\.xcspec$/;

Do we care about operating on symlinks?  An alternative approach that only operates on real files is:

    return if ! -f $file || $file !~ /\.xcspec$/;

> Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:94
> +

Please add an 'exit 0;' here to show when the main part of the script ends.
Comment 5 Andy Estes 2014-08-29 15:27:03 PDT
Comment on attachment 237380 [details]
Patch

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

>> Tools/ChangeLog:9
>> +        configure Xcode to support building a command line tool for the iOS Simulator.
> 
> We could be a little less specific about the script name so it could be shorter:  configure-Xcode-for-iOS-Simulator-builds
> 
> Not required if there are no other objections.

I also object to this. Given that we'll want to eventually support device builds, I don't like having "Simulator" as part of the script name. I suggested "configure-xcode-for-ios-development" to Dan over IRC.
Comment 6 Daniel Bates 2014-08-29 16:24:57 PDT
(In reply to comment #4)
> > Tools/ChangeLog:9
> > +        Add a script, called configure-Xcode-to-build-iOS-Simulator-command-line-tool, to
> > +        configure Xcode to support building a command line tool for the iOS Simulator.
> 
> We could be a little less specific about the script name so it could be shorter:  configure-Xcode-for-iOS-Simulator-builds
> 
> Not required if there are no other objections.
> 

As per our IRC conversation today with Andy Estes, will rename the script to configure-xcode-for-ios-development, which is a generic name and allows us to expand the functionality of this script without having to rename it in a subsequent commit.

> > Tools/ChangeLog:16
> > +        Additionally, teach build-{jsc, webkit} to call the script when building for
> > +        iOS Simulator.
> 
> How much does this slow down build-webkit?
> 

For now, I'm going to remove the call to the script from build-{webkit, jsc} since the script may need to be run as root (see my response to your next question for more details). So, there will be no performance impact to build-{webkit, jsc}.

For completeness, running "time Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool” three times on my MacBook Pro shows that it takes on average about .111 seconds (real time) to complete.

> While it's great that we can make this transparent to the user, don't they need to be root to run the script? I always envisioned this as a one-time script (after installing Xcode) that each developer would have to run, although there is value in making builds "just work".  :)

You will need to run this script as root if Xcode was installed via the App Store (which it is the majority of the time). I'll go with the approach you envisioned and will modify the script to error out with the following message when it's not with an effective UID of 0 (root): "configure-xcode-for-ios-development must be run as root."

Moreover, I will revert the changes to build-{webkit, jsc} that call this script. We may want to consider teaching build-webkit to error out and inform a person to run the script configure-xcode-for-ios-development if applicable. We can do such an enhancement in another bug.

> 
> > Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:52
> > +    if ($file =~ /^\../) {
> 
> Won't this ignore "."?  Maybe that doesn't matter because it gets filtered out below.
> 

Notice that the regular expression only matches a path with at least two characters (a period and some other character). So, we don't ignore "." here. As you noticed, we disregard "." below since it's a directory.

> > Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:57
> > +    return if -d $file || $file !~ /\.xcspec$/;
> 
> Do we care about operating on symlinks?  An alternative approach that only operates on real files is:
> 
>     return if ! -f $file || $file !~ /\.xcspec$/;
> 

Will use this approach.

> > Tools/Scripts/configure-Xcode-to-build-iOS-Simulator-command-line-tool:94
> > +
> 
> Please add an 'exit 0;' here to show when the main part of the script ends.

Will add "exit 0;".
Comment 7 Daniel Bates 2014-08-29 16:34:52 PDT
Committed r173129: <http://trac.webkit.org/changeset/173129>