Bug 143546 - [GTK] Clean up feature detection and make it hard to accidentally build without optional features
Summary: [GTK] Clean up feature detection and make it hard to accidentally build witho...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on: 143558 144106
Blocks:
  Show dependency treegraph
 
Reported: 2015-04-08 18:28 PDT by Michael Catanzaro
Modified: 2015-04-28 14:25 PDT (History)
5 users (show)

See Also:


Attachments
Patch (4.36 KB, patch)
2015-04-08 19:09 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (4.66 KB, patch)
2015-04-28 10:40 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (12.51 KB, patch)
2015-04-28 12:22 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (12.51 KB, patch)
2015-04-28 12:31 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (11.29 KB, patch)
2015-04-28 12:48 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2015-04-08 18:28:25 PDT
gusrub on IRC noticed that openSUSE accidentally built WebKitGTK+ without support for HTML5 notifications. We did the same in Fedora. This needs to be harder to get wrong; let's hard-fail unless the user builds with -DENABLE_NOTIFICATIONS=OFF.
Comment 1 Michael Catanzaro 2015-04-08 18:48:47 PDT
Let's do the same for geoclue, gnutls, and libsecret, since these are all things that distros really ought to ship: we don't want users to get crippled versions of our software unless distros are actually making an active decision to disable the feature.

We will need to update https://trac.webkit.org/wiki/WebKitGTK/Dependencies
Comment 2 Martin Robinson 2015-04-08 19:03:14 PDT
This seems like a good idea to me.
Comment 3 Michael Catanzaro 2015-04-08 19:09:07 PDT
Created attachment 250402 [details]
Patch
Comment 4 Carlos Garcia Campos 2015-04-08 23:25:06 PDT
Comment on attachment 250402 [details]
Patch

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

I like the idea but I see a problem. What happens if configure fails because an optional dependency was not found? I guess you get an error that libfoo was not found and it's required. How does the user know this is an optional dependency and how to build without it? Is it possible to add a message with all that information when the build fails due to a missing optional dependency?

> Source/cmake/OptionsGTK.cmake:310
> +if (ENABLE_NOTIFICATIONS)
> +    find_package(LibNotify REQUIRED)
> +    add_definitions(-DWTF_USE_LIBNOTIFY=1)
> +else ()
> +    add_definitions(-DWTF_USE_LIBNOTIFY=0)
> +endif ()

I don't think this is correct in this particular case. ENABLE_NOTIFICATIONS should never be disabled, because it's exposed in the public API. Libnotify is only used as default implementation of the notifications, you should be able to build with ENABLE_NOTIFICATIONS and without libnotify, because the API allows you to provide your own implementation.
Comment 5 Carlos Garcia Campos 2015-04-08 23:28:32 PDT
(In reply to comment #0)
> gusrub on IRC noticed that openSUSE accidentally built WebKitGTK+ without
> support for HTML5 notifications. We did the same in Fedora. This needs to be
> harder to get wrong; let's hard-fail unless the user builds with
> -DENABLE_NOTIFICATIONS=OFF.

ENABLE_NOTIFICATIONS is ON unconditionally, if openSUSE is building with DENABLE_NOTIFICATIONS=OFF is because they explicitly added that option in command line. There's another issue here, all options are public, and I don't know how to avoid that in cmake, but some of the options (and ENABLE_NOTIFICATIONS is one of them) should not be exposed to the user.
Comment 6 Martin Robinson 2015-04-08 23:32:25 PDT
(In reply to comment #5)
 
> ENABLE_NOTIFICATIONS is ON unconditionally, if openSUSE is building with
> DENABLE_NOTIFICATIONS=OFF is because they explicitly added that option in
> command line. There's another issue here, all options are public, and I
> don't know how to avoid that in cmake, but some of the options (and
> ENABLE_NOTIFICATIONS is one of them) should not be exposed to the user.

CMake has the concept of "advanced" options, which are hidden unless you explicitly show them. Things that we do not want people to turn on and off should at least be marked as advanced. You can see this in action by searching for 'mark_as_advanced' in Source/cmake.
Comment 7 Carlos Garcia Campos 2015-04-08 23:37:55 PDT
(In reply to comment #6)
> (In reply to comment #5)
>  
> > ENABLE_NOTIFICATIONS is ON unconditionally, if openSUSE is building with
> > DENABLE_NOTIFICATIONS=OFF is because they explicitly added that option in
> > command line. There's another issue here, all options are public, and I
> > don't know how to avoid that in cmake, but some of the options (and
> > ENABLE_NOTIFICATIONS is one of them) should not be exposed to the user.
> 
> CMake has the concept of "advanced" options, which are hidden unless you
> explicitly show them. Things that we do not want people to turn on and off
> should at least be marked as advanced. You can see this in action by
> searching for 'mark_as_advanced' in Source/cmake.

Hidden means you could still use them if you know they actually exist?
Comment 8 Martin Robinson 2015-04-08 23:39:24 PDT
(In reply to comment #7)
 
> Hidden means you could still use them if you know they actually exist?

That's correct, though I imagine very few people would try to modify the advanced options. We can likely also find a way to make them impossible to change.
Comment 9 Carlos Garcia Campos 2015-04-08 23:46:09 PDT
(In reply to comment #8)
> (In reply to comment #7)
>  
> > Hidden means you could still use them if you know they actually exist?
> 
> That's correct, though I imagine very few people would try to modify the
> advanced options. We can likely also find a way to make them impossible to
> change.

Nah, I guess hiding them is enough so that if people keep using them is at their own risk. See https://bugs.webkit.org/show_bug.cgi?id=143558.

Thanks!
Comment 10 Michael Catanzaro 2015-04-09 07:07:46 PDT
(In reply to comment #5) 
> ENABLE_NOTIFICATIONS is ON unconditionally, if openSUSE is building with
> DENABLE_NOTIFICATIONS=OFF is because they explicitly added that option in
> command line.

No, they just build without libnotify in the buildroot (i.e. they do exactly what we would expect them to do) which is enough for the feature to be silently disabled.
Comment 11 Carlos Garcia Campos 2015-04-09 11:25:01 PDT
(In reply to comment #10)
> (In reply to comment #5) 
> > ENABLE_NOTIFICATIONS is ON unconditionally, if openSUSE is building with
> > DENABLE_NOTIFICATIONS=OFF is because they explicitly added that option in
> > command line.
> 
> No, they just build without libnotify in the buildroot (i.e. they do exactly
> what we would expect them to do) which is enough for the feature to be
> silently disabled.

Then the feature is not disabled, but the default implementation.
Comment 12 Michael Catanzaro 2015-04-28 10:40:18 PDT
Created attachment 251859 [details]
Patch
Comment 13 Michael Catanzaro 2015-04-28 11:36:10 PDT
Comment on attachment 251859 [details]
Patch

Nope I missed libnotify
Comment 14 Michael Catanzaro 2015-04-28 12:22:24 PDT
Created attachment 251875 [details]
Patch
Comment 15 Michael Catanzaro 2015-04-28 12:31:52 PDT
Created attachment 251876 [details]
Patch
Comment 16 Martin Robinson 2015-04-28 12:40:12 PDT
Comment on attachment 251876 [details]
Patch

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

Very nice. Still a couple small issues:

> Source/cmake/OptionsGTK.cmake:129
> +WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SUBTLE_CRYPTO PUBLIC OFF)

This should probably be private until the feature is complete enough to ship.

> Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:120
> +find_package(ATSPI 2.5.3)

I'm more comfortable with this in OptionsGTK.cmake.
Comment 17 Michael Catanzaro 2015-04-28 12:48:33 PDT
Created attachment 251878 [details]
Patch
Comment 18 WebKit Commit Bot 2015-04-28 13:40:37 PDT
Comment on attachment 251878 [details]
Patch

Clearing flags on attachment: 251878

Committed r183505: <http://trac.webkit.org/changeset/183505>
Comment 19 WebKit Commit Bot 2015-04-28 13:40:43 PDT
All reviewed patches have been landed.  Closing bug.
Comment 20 Csaba Osztrogonác 2015-04-28 14:12:06 PDT
(In reply to comment #18)
> Comment on attachment 251878 [details]
> Patch
> 
> Clearing flags on attachment: 251878
> 
> Committed r183505: <http://trac.webkit.org/changeset/183505>

It broke the build on the GTK buildbots and EWS too.
Comment 21 Martin Robinson 2015-04-28 14:25:13 PDT
(In reply to comment #20)
> (In reply to comment #18)
> > Comment on attachment 251878 [details]
> > Patch
> > 
> > Clearing flags on attachment: 251878
> > 
> > Committed r183505: <http://trac.webkit.org/changeset/183505>
> 
> It broke the build on the GTK buildbots and EWS too.

The bot was missing libnotify, so it looks like this patch is already benefiting us by catching hidden problems!