Bug 144746 - REGRESSION(r183416): [GTK] Checks for DEVELOPMENT_BUILD are all wrong
Summary: REGRESSION(r183416): [GTK] Checks for DEVELOPMENT_BUILD are all wrong
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: Gtk, Regression
Depends on: 144789
Blocks:
  Show dependency treegraph
 
Reported: 2015-05-07 09:07 PDT by Michael Catanzaro
Modified: 2015-05-08 13:31 PDT (History)
6 users (show)

See Also:


Attachments
Patch (7.37 KB, patch)
2015-05-07 09:43 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (7.11 KB, patch)
2015-05-07 09:47 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (6.98 KB, patch)
2015-05-07 10:10 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (9.19 KB, patch)
2015-05-07 13:18 PDT, Michael Catanzaro
no flags Details | Formatted Diff | Diff
Patch (1.51 KB, patch)
2015-05-08 01:13 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (9.61 KB, patch)
2015-05-08 09:45 PDT, Martin Robinson
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-05-07 09:07:37 PDT
/builddir/build/BUILD/webkitgtk-2.9.1/Tools/MiniBrowser/gtk/main.c: In function 'main':
/builddir/build/BUILD/webkitgtk-2.9.1/Tools/MiniBrowser/gtk/main.c:260:45: error: 'WEBKIT_INJECTED_BUNDLE_PATH' undeclared (first use in this function)
     g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
Comment 1 Michael Catanzaro 2015-05-07 09:18:47 PDT
#if defined(DEVELOPMENT_BUILD)
    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
#endif

The problem is that WEBKIT_INJECTED_BUNDLE_PATH is only defined when DEVELOPMENT_BUILD is on. Previously DEVELOPMENT_BUILD was defined only for development builds, but now it is defined to 0 when off (using the new SET_AND_EXPOSE_TO_BUILD macro).

Possible fixes:

#if DEVELOPMENT_BUILD
    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
#endif

or:

#ifdef WEBKIT_INJECTED_BUNDLE_PATH
    g_setenv("WEBKIT_INJECTED_BUNDLE_PATH", WEBKIT_INJECTED_BUNDLE_PATH, FALSE);
#endif

The later seems best to me.
Comment 2 Michael Catanzaro 2015-05-07 09:27:48 PDT
We need to fix all other uses of DEVELOPMENT_BUILD as well, since we always check whether it's defined rather than what it is defined to.

Might as well take the opportunity to remove it, since it's redundant with DEVELOPER_MODE.
Comment 3 Michael Catanzaro 2015-05-07 09:43:28 PDT
Created attachment 252595 [details]
Patch
Comment 4 Michael Catanzaro 2015-05-07 09:44:36 PDT
Patch is speculative since I'm having trouble building locally at the moment (can't install dependencies I'd removed for testing something else, due to some Fedora repository issues); let's see what EWS thinks.
Comment 5 Carlos Garcia Campos 2015-05-07 09:45:07 PDT
Comment on attachment 252595 [details]
Patch

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

Thanks!

> Tools/ChangeLog:22
> +2015-05-07  Michael Catanzaro  <mcatanzaro@igalia.com>
> +
> +        [GTK] 2.9.1 build broken with ENABLE_MINIBROWSER=ON
> +        https://bugs.webkit.org/show_bug.cgi?id=144746
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        * MiniBrowser/gtk/main.c:
> +        (main):
> +

duplicated entry here.
Comment 6 Michael Catanzaro 2015-05-07 09:47:19 PDT
Created attachment 252596 [details]
Patch
Comment 7 Martin Robinson 2015-05-07 09:50:21 PDT
Comment on attachment 252595 [details]
Patch

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

> Source/WebCore/platform/gtk/GtkUtilities.cpp:58
> -#if defined(DEVELOPMENT_BUILD)
> +#if ENABLE(DEVELOPER_MODE)
>  static CString topLevelPath()

How will this work if ENABLE_DEVELOPER_MODE is not defined? I think that build-webkit just defines DEVELOPER_MODE and not ENABLE_DEVELOPER_MODE.
Comment 8 Michael Catanzaro 2015-05-07 10:01:53 PDT
It won't work, good catch.
Comment 9 Carlos Garcia Campos 2015-05-07 10:06:43 PDT
(In reply to comment #7)
> Comment on attachment 252595 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=252595&action=review
> 
> > Source/WebCore/platform/gtk/GtkUtilities.cpp:58
> > -#if defined(DEVELOPMENT_BUILD)
> > +#if ENABLE(DEVELOPER_MODE)
> >  static CString topLevelPath()
> 
> How will this work if ENABLE_DEVELOPER_MODE is not defined? I think that
> build-webkit just defines DEVELOPER_MODE and not ENABLE_DEVELOPER_MODE.

Oops, I assumed it was :-P
Comment 10 Michael Catanzaro 2015-05-07 10:10:19 PDT
Another speculative patch for EWS. To be clear, this one should work because DEVELOPER_MODE is not defined at all when it is off (whereas DEVELOPMENT_BUILD was defined to 0).
Comment 11 Michael Catanzaro 2015-05-07 10:10:34 PDT
Created attachment 252598 [details]
Patch
Comment 12 Carlos Garcia Campos 2015-05-07 10:33:56 PDT
Comment on attachment 252598 [details]
Patch

why changing all #if defined with #ifdef? why not just s/DEVELOPMENT_BUILD/DEVELOPER_MODE/s Or is it always defined but set to 0 now for non devel builds? then it should be just #if, no?
Comment 13 Martin Robinson 2015-05-07 11:37:18 PDT
I'd also like to include in this patch the new use of the broken idiom from my spellchecking patch. I'm happy to update the patch for that.
Comment 14 Michael Catanzaro 2015-05-07 13:00:28 PDT
(In reply to comment #12)
> Comment on attachment 252598 [details]
> Patch
> 
> why changing all #if defined with #ifdef? why not just
> s/DEVELOPMENT_BUILD/DEVELOPER_MODE/s

It doesn't matter; I'll switch it back to #if defined() to make the patch easier to read. But we use #ifdef usually.

>Or is it always defined but set to 0
> now for non devel builds? then it should be just #if, no?

No, that's why this patch works: DEVELOPER_MODE is not always defined, unlike DEVELOPMENT_BUILD.
Comment 15 Michael Catanzaro 2015-05-07 13:18:35 PDT
Created attachment 252608 [details]
Patch
Comment 16 WebKit Commit Bot 2015-05-07 14:10:25 PDT
Comment on attachment 252608 [details]
Patch

Clearing flags on attachment: 252608

Committed r183945: <http://trac.webkit.org/changeset/183945>
Comment 17 WebKit Commit Bot 2015-05-07 14:10:30 PDT
All reviewed patches have been landed.  Closing bug.
Comment 18 Carlos Garcia Campos 2015-05-08 00:40:48 PDT
This broke the world. DEVELOPER_MODE is not exposed to the build, that's what DEVELOPMENT_BUILD was for.
Comment 19 WebKit Commit Bot 2015-05-08 00:52:16 PDT
Re-opened since this is blocked by bug 144789
Comment 20 Carlos Garcia Campos 2015-05-08 01:11:51 PDT
The actual problem is that r183416 removed the -DDEVELOPMENT_BUILD=1 definition.
Comment 21 Carlos Garcia Campos 2015-05-08 01:13:51 PDT
Created attachment 252699 [details]
Patch
Comment 22 Michael Catanzaro 2015-05-08 05:46:57 PDT
I assumed CMake would pass the DEVELOPER_MODE option through to the compiler, but that was a terrible assumption (how would it tell the difference from a real option?). And trying to trust EWS to sanity-check this patch was also a bad idea, because evidently only clean builds broke.

Let's commit Carlos's patch as-is first, since it is the minimal patch that fixes the build. The rest is just a matter of style: we can follow-up with /s/DEVELOPMENT_BUILD/DEVELOPER_MODE later on, use SET_AND_EXPOSE_TO_BUILD to get DEVELOPER_MODE, and replace the #if defined() with plain #if.
Comment 23 Carlos Garcia Campos 2015-05-08 06:10:02 PDT
(In reply to comment #22)
> I assumed CMake would pass the DEVELOPER_MODE option through to the
> compiler, but that was a terrible assumption (how would it tell the
> difference from a real option?). And trying to trust EWS to sanity-check
> this patch was also a bad idea, because evidently only clean builds broke.

The build was not broken, but the tests, because the test infrastructure relies on some things that are only done for development builds (like search for binaries in the ui process binary dir). That's what caused all test to fail, it failed to find all secondary processes.

> Let's commit Carlos's patch as-is first, since it is the minimal patch that
> fixes the build. The rest is just a matter of style: we can follow-up with
> /s/DEVELOPMENT_BUILD/DEVELOPER_MODE later on, use SET_AND_EXPOSE_TO_BUILD to
> get DEVELOPER_MODE, and replace the #if defined() with plain #if.

I don't think we should use SET_AND_EXPOSE_TO_BUILD, because that only adds a define to cmakeconfig.h, and not all sources files include that header, some "external" tools (at least the MiniBrowser) don't include that header (at least not automatically). So for global compile options it's safer to use add_definitions(-DFOO=Bar). 

Also I don't see why we need to rename it. For me a development build is just another thing done by the developer mode, but the developer mode is more than that, it also enables tests and minibrowser, for example.
Comment 24 Michael Catanzaro 2015-05-08 07:48:42 PDT
OK, I have no strong preference about the rest.
Comment 25 Martin Robinson 2015-05-08 08:08:35 PDT
(In reply to comment #23)

> I don't think we should use SET_AND_EXPOSE_TO_BUILD, because that only adds
> a define to cmakeconfig.h, and not all sources files include that header,
> some "external" tools (at least the MiniBrowser) don't include that header
> (at least not automatically). So for global compile options it's safer to
> use add_definitions(-DFOO=Bar). 

No. We just removed most of the definitions. If the tools need to include cmakeconfig.h they should. Please don't undo my work.
Comment 26 Martin Robinson 2015-05-08 08:10:13 PDT
(In reply to comment #23)

> Also I don't see why we need to rename it. For me a development build is
> just another thing done by the developer mode, but the developer mode is
> more than that, it also enables tests and minibrowser, for example.

This is also inaccurate:

martin@dillardmcburdle:~/WebKit/Tools/MiniBrowser/gtk$ git grep cmakeconfig.h
BrowserDownloadsBar.c:#include "cmakeconfig.h"
BrowserSearchBar.c:#include "cmakeconfig.h"
BrowserWindow.c:#include "cmakeconfig.h"
main.c:#include "cmakeconfig.h"
Comment 27 Martin Robinson 2015-05-08 08:16:28 PDT
(In reply to comment #26)
> (In reply to comment #23)
> 
> > Also I don't see why we need to rename it. For me a development build is
> > just another thing done by the developer mode, but the developer mode is
> > more than that, it also enables tests and minibrowser, for example.
> 
> This is also inaccurate:
> 
> martin@dillardmcburdle:~/WebKit/Tools/MiniBrowser/gtk$ git grep cmakeconfig.h
> BrowserDownloadsBar.c:#include "cmakeconfig.h"
> BrowserSearchBar.c:#include "cmakeconfig.h"
> BrowserWindow.c:#include "cmakeconfig.h"
> main.c:#include "cmakeconfig.h"

I'm rewriting this patch to use the ENABLE macro. I files that don't include the WTF Platform.h file, this will give an error signalling that the cmakeconfig.h file isn't included. There are few places that do include cmakeconfig.h and not the WTF Platform.h file, so they can just use ENABLE_DEVELOPER_MODE.
Comment 28 Martin Robinson 2015-05-08 08:29:37 PDT
(In reply to comment #27)
> (In reply to comment #26)
> > (In reply to comment #23)
> > 
> > > Also I don't see why we need to rename it. For me a development build is
> > > just another thing done by the developer mode, but the developer mode is
> > > more than that, it also enables tests and minibrowser, for example.
> > 
> > This is also inaccurate:
> > 
> > martin@dillardmcburdle:~/WebKit/Tools/MiniBrowser/gtk$ git grep cmakeconfig.h
> > BrowserDownloadsBar.c:#include "cmakeconfig.h"
> > BrowserSearchBar.c:#include "cmakeconfig.h"
> > BrowserWindow.c:#include "cmakeconfig.h"
> > main.c:#include "cmakeconfig.h"
> 
> I'm rewriting this patch to use the ENABLE macro. I files that don't include
> the WTF Platform.h file, this will give an error signalling that the
> cmakeconfig.h file isn't included. There are few places that do include
> cmakeconfig.h and not the WTF Platform.h file, so they can just use
> ENABLE_DEVELOPER_MODE.

Building and testing this now, so please everyone hang tight. We can solve this issue somehow.
Comment 29 Martin Robinson 2015-05-08 08:35:40 PDT
(In reply to comment #26)
> (In reply to comment #23)
> 
> > Also I don't see why we need to rename it. For me a development build is
> > just another thing done by the developer mode, but the developer mode is
> > more than that, it also enables tests and minibrowser, for example.

Sorry, I misread your statement. It isn't inaccurate. This is a philosophical point to be sure. I added DEVELOPER_MODE, but I never considered the two to be separate things. If it's okay with you, I think we can just continue down this path. I prefer that the code files reflect the option that is passed to the build system to avoid confusion.
Comment 30 Carlos Garcia Campos 2015-05-08 08:58:27 PDT
(In reply to comment #29)
> (In reply to comment #26)
> > (In reply to comment #23)
> > 
> > > Also I don't see why we need to rename it. For me a development build is
> > > just another thing done by the developer mode, but the developer mode is
> > > more than that, it also enables tests and minibrowser, for example.
> 
> Sorry, I misread your statement. It isn't inaccurate. This is a
> philosophical point to be sure. I added DEVELOPER_MODE, but I never
> considered the two to be separate things. If it's okay with you, I think we
> can just continue down this path. I prefer that the code files reflect the
> option that is passed to the build system to avoid confusion.

I've always considered developer mode as a build-webkit feature rather than a build option. I'm fine with using ENABLE(DEVELOPER_MODE) in any case. I don't see a reason to r- my patch, though, it's perfectly valid and fixes a regression.
Comment 31 Martin Robinson 2015-05-08 09:45:42 PDT
Created attachment 252724 [details]
Patch
Comment 32 Carlos Garcia Campos 2015-05-08 09:54:44 PDT
Comment on attachment 252724 [details]
Patch

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

> Source/cmake/OptionsGTK.cmake:79
> -# FIXME: There is no reason these should be different.
> -SET_AND_EXPOSE_TO_BUILD(DEVELOPMENT_BUILD ${DEVELOPER_MODE})
> +SET_AND_EXPOSE_TO_BUILD(ENABLE_DEVELOPER_MODE ${DEVELOPER_MODE})

Maybe renaming this to SET_AND_EXPOSE_TO_CONFIG would be less confusing, unless we enforce somehow that all files include cmakeconfig.h

> Tools/MiniBrowser/gtk/main.c:259
> -#if defined(DEVELOPMENT_BUILD)
> +#if ENABLE_DEVELOPER_MODE

Hopefully MB is the only exception, I guess the build will fail anyway if you try to use ENABLE(FOO) in a file not including Platform.h no? What happens in a file doesn't include cmakeconfig.h? wasn't there a way to include config.h from the build system?
Comment 33 Martin Robinson 2015-05-08 09:59:52 PDT
(In reply to comment #32)
> Comment on attachment 252724 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=252724&action=review
> 
> > Source/cmake/OptionsGTK.cmake:79
> > -# FIXME: There is no reason these should be different.
> > -SET_AND_EXPOSE_TO_BUILD(DEVELOPMENT_BUILD ${DEVELOPER_MODE})
> > +SET_AND_EXPOSE_TO_BUILD(ENABLE_DEVELOPER_MODE ${DEVELOPER_MODE})
> 
> Maybe renaming this to SET_AND_EXPOSE_TO_CONFIG would be less confusing,
> unless we enforce somehow that all files include cmakeconfig.h

How about SET_AND_ADD_TO_CONFIG_HEADER?

> > Tools/MiniBrowser/gtk/main.c:259
> > -#if defined(DEVELOPMENT_BUILD)
> > +#if ENABLE_DEVELOPER_MODE
> 
> Hopefully MB is the only exception, I guess the build will fail anyway if
> you try to use ENABLE(FOO) in a file not including Platform.h no? What
> happens in a file doesn't include cmakeconfig.h? wasn't there a way to
> include config.h from the build system?

That's a great idea actually. We should make cmakeconfig.h a global compiler header. I think that should be possible.
Comment 34 Michael Catanzaro 2015-05-08 11:07:12 PDT
(In reply to comment #33)
> How about SET_AND_ADD_TO_CONFIG_HEADER?

Sounds good to me.

> That's a great idea actually. We should make cmakeconfig.h a global compiler
> header. I think that should be possible.

See http://stackoverflow.com/questions/3387453/include-header-files-from-command-line-gcc
Comment 35 Martin Robinson 2015-05-08 13:31:07 PDT
Comment on attachment 252724 [details]
Patch

Clearing flags on attachment: 252724

Committed r184010: <http://trac.webkit.org/changeset/184010>
Comment 36 Martin Robinson 2015-05-08 13:31:13 PDT
All reviewed patches have been landed.  Closing bug.