Last Comment Bug 682283 - Define XP_IOS in configure, shuffle some configure checks around
: Define XP_IOS in configure, shuffle some configure checks around
Status: RESOLVED FIXED
[iOS] fixed-in-bs
:
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: Trunk
: ARM iOS 4
: -- normal (vote)
: mozilla9
Assigned To: Ted Mielczarek [:ted.mielczarek]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-26 07:19 PDT by Ted Mielczarek [:ted.mielczarek]
Modified: 2011-09-01 18:52 PDT (History)
5 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Define XP_IOS in configure (4.82 KB, patch)
2011-08-26 07:38 PDT, Ted Mielczarek [:ted.mielczarek]
no flags Details | Diff | Review
Define XP_IOS in configure, change XP_MACOSX to only be defined onOS X, and add XP_DARWIN (6.38 KB, patch)
2011-08-26 12:56 PDT, Ted Mielczarek [:ted.mielczarek]
khuey: review+
Details | Diff | Review

Description Ted Mielczarek [:ted.mielczarek] 2011-08-26 07:19:55 PDT
Currently my iOS patch queue has been relying on using MOZ_WIDGET_COCOA to detect OS X builds vs. iOS builds, but that's not ideal, since we do also have someone maintaining Darwin/GTK builds. I'm going to keep XP_MACOSX defined for iOS builds, since otherwise I'd have to make a lot of changes, but I'm also going to define XP_IOS so I can make some of these checks conditional on that. This patch does that, and also cleans up some of the configure logic while I'm there.
Comment 1 Ted Mielczarek [:ted.mielczarek] 2011-08-26 07:38:47 PDT
Created attachment 556026 [details] [diff] [review]
Define XP_IOS in configure

This does what I want, with the nice side effect of cleaning up some configure checks. I tested this on an iOS and an OS X build.
Comment 2 Ted Mielczarek [:ted.mielczarek] 2011-08-26 12:56:01 PDT
Created attachment 556110 [details] [diff] [review]
Define XP_IOS in configure, change XP_MACOSX to only be defined onOS X, and add XP_DARWIN

I changed my mind a bit. I'm changing the defines so that we'll have XP_DARWIN defined on both OS X and iOS, XP_MACOSX only on OS X, and XP_IOS only on iOS. I think that will reuqire the least amount of code churn, but I guess I'll find out.
Comment 3 Kyle Huey [:khuey] (khuey@mozilla.com) (Away until 6/13) 2011-08-29 04:48:47 PDT
Comment on attachment 556110 [details] [diff] [review]
Define XP_IOS in configure, change XP_MACOSX to only be defined onOS X, and add XP_DARWIN

>-    _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'
>+    # Check whether we're targeting OS X or iOS
>+    AC_CACHE_CHECK(for iOS target,
>+                   ac_cv_ios_target,
>+                   [cat > conftest.h <<EOF
>+#include <TargetConditionals.h>
>+
>+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
>+#define XP_IOS 1
>+#else
>+#define XP_IOS 0
>+#endif
>+
>+XP_IOS
>+EOF
>+                    if test `$CPP conftest.h 2>/dev/null | tail -n1` -eq 1; then
>+                        ac_cv_ios_target="yes"
>+                    else
>+                        ac_cv_ios_target="no"
>+                    fi
>+                    rm -f conftest.h
>+                   ])

This test is a little nasty.  Can you change the '#define XP_IOS 0' to '#error not iOS' and just AC_TRY_COMPILE this?

>+    if test "$ac_cv_ios_target" = "yes"; then
>+        AC_DEFINE(XP_IOS)
>+        AC_DEFINE(XP_DARWIN)
>+        _PLATFORM_DEFAULT_TOOLKIT='cairo-uikit'
>+    else
>+        AC_DEFINE(XP_MACOSX)
>+        AC_DEFINE(XP_DARWIN)
>+        _PLATFORM_DEFAULT_TOOLKIT='cairo-cocoa'

I wonder why we need _PLATFORM_DEFAULT_TOOLKIT crap anyways.

>+        # The ExceptionHandling framework is needed for Objective-C exception
>+        # logging code in nsObjCExceptions.h. Currently we only use that in debug
>+        # builds.
>+        MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
>+    fi
>     TARGET_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
>-    # The ExceptionHandling framework is needed for Objective-C exception
>-    # logging code in nsObjCExceptions.h. Currently we only use that in debug
>-    # builds.
>-    _SAVE_LDFLAGS=$LDFLAGS
>-     AC_MSG_CHECKING([for -framework ExceptionHandling])
>-    LDFLAGS="$LDFLAGS -framework ExceptionHandling"
>-    AC_TRY_LINK(,[return 0;],
>-                ac_cv_have_framework_exceptionhandling="yes",
>-                ac_cv_have_framework_exceptionhandling="no")
>-    AC_MSG_RESULT([$ac_cv_have_framework_exceptionhandling])
>-    if test "$ac_cv_have_framework_exceptionhandling" = "yes"; then
>-      MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling";
>-    fi
>-    LDFLAGS=$_SAVE_LDFLAGS
>+
>     # Debug builds should always have frame pointers
>     MOZ_DEBUG_FLAGS="-g -fno-omit-frame-pointer"
> 
>     if test "x$lto_is_enabled" = "xyes"; then
>         echo "Skipping -dead_strip because lto is enabled."
>     dnl DTrace and -dead_strip don't interact well. See bug 403132.
>     dnl ===================================================================
>     elif test "x$enable_dtrace" = "xyes"; then
>         echo "Skipping -dead_strip because DTrace is enabled. See bug 403132."
>     else
>@@ -4914,20 +4934,21 @@
>     [ _DEFAULT_TOOLKIT=$enableval ],
>     [ _DEFAULT_TOOLKIT=$_PLATFORM_DEFAULT_TOOLKIT])
> 
>     if test "$_DEFAULT_TOOLKIT" = "cairo-windows" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-dfb" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-gtk2-x11" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-qt" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-os2" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-cocoa" \
>+        -o "$_DEFAULT_TOOLKIT" = "cairo-uikit" \
>         -o "$_DEFAULT_TOOLKIT" = "cairo-android"
>     then
>         dnl nglayout only supports building with one toolkit,
>         dnl so ignore everything after the first comma (",").
>         MOZ_WIDGET_TOOLKIT=`echo "$_DEFAULT_TOOLKIT" | sed -e "s/,.*$//"`
>     else
>         AC_MSG_ERROR([You must specify a default toolkit (perhaps $_PLATFORM_DEFAULT_TOOLKIT).])
>     fi
> 
> dnl ========================================================
>@@ -5000,49 +5021,47 @@
> 
> cairo-os2)
>     MOZ_WIDGET_TOOLKIT=os2
>     USE_FC_FREETYPE=1
>     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
>     TK_LIBS='$(MOZ_CAIRO_LIBS)'
>     MOZ_PDF_PRINTING=1
>     ;;
> 
> cairo-cocoa)
>-    # Check if we have the Cocoa framework, or if we're targeting Cocoa Touch
>-    _SAVE_LDFLAGS=$LDFLAGS
>-    LDFLAGS="$LDFLAGS -framework Cocoa"
>-    AC_TRY_LINK(,[return 0;],_HAVE_FRAMEWORK_COCOA=1,_HAVE_FRAMEWORK_COCOA=)
>-    if test -z "$_HAVE_FRAMEWORK_COCOA"; then
>-        LDFLAGS="$_SAVE_LDFLAGS -framework UIKit";
>-        AC_TRY_LINK(,[return 0;],_HAVE_FRAMEWORK_UIKIT=1,
>-                    AC_MSG_ERROR([Neither Cocoa nor UIKit frameworks were found. Are you using the correct SDK?]))
>-        MOZ_WIDGET_TOOLKIT=uikit
>-      AC_DEFINE(MOZ_WIDGET_UIKIT)
>-      TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
>-    else
>-      MOZ_WIDGET_TOOLKIT=cocoa
>-      AC_DEFINE(MOZ_WIDGET_COCOA)
>-      TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
>-    fi
>-    MOZ_USER_DIR="Mozilla"
>-    AC_DEFINE(XP_MACOSX)
>-
>+    MOZ_WIDGET_TOOLKIT=cocoa
>+    AC_DEFINE(MOZ_WIDGET_COCOA)
>+    LDFLAGS="$LDFLAGS -framework Cocoa -lobjc"
>+    TK_LIBS='-framework QuartzCore -framework Carbon -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework AddressBook -framework OpenGL'
>     TK_CFLAGS="-DNO_X11"
>-    LDFLAGS="$LDFLAGS -lobjc"
>     CFLAGS="$CFLAGS $TK_CFLAGS"
>     CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
>     LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
>+    MOZ_USER_DIR="Mozilla"
>     MOZ_FS_LAYOUT=bundle
>     MOZ_WEBGL=1
>     MOZ_INSTRUMENT_EVENT_LOOP=1
>     ;;
> 
>+cairo-uikit)
>+    MOZ_WIDGET_TOOLKIT=uikit
>+    AC_DEFINE(MOZ_WIDGET_UIKIT)
>+    LDFLAGS="$LDFLAGS -framework UIKit -lobjc"
>+    TK_CFLAGS="-DNO_X11"
>+    TK_LIBS='-framework Foundation -framework CoreFoundation -framework CoreGraphics -framework CoreText'
>+    CFLAGS="$CFLAGS $TK_CFLAGS"
>+    CXXFLAGS="$CXXFLAGS $TK_CFLAGS"
>+    LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(LIBXUL_DIST)/bin/XUL'
>+    MOZ_USER_DIR="Mozilla"
>+    MOZ_FS_LAYOUT=bundle
>+    ;;
>+
> cairo-android)
>     AC_DEFINE(MOZ_WIDGET_ANDROID)
>     MOZ_WIDGET_TOOLKIT=android
>     TK_CFLAGS='$(MOZ_CAIRO_CFLAGS)'
>     TK_LIBS='$(MOZ_CAIRO_LIBS)'
>     MOZ_WEBGL=1
>     MOZ_PDF_PRINTING=1
>     ;;
> 
> esac
Comment 4 Ted Mielczarek [:ted.mielczarek] 2011-08-29 04:53:13 PDT
(In reply to Kyle Huey [:khuey] (khuey@mozilla.com) from comment #3)
> This test is a little nasty.  Can you change the '#define XP_IOS 0' to
> '#error not iOS' and just AC_TRY_COMPILE this?

Yeah, I considered that, I wasn't sure if it would be readable. I'll change it.

> I wonder why we need _PLATFORM_DEFAULT_TOOLKIT crap anyways.

Because you can --enable-default-toolkit=something else, like for Linux/Qt builds.
Comment 5 Ted Mielczarek [:ted.mielczarek] 2011-08-29 08:19:49 PDT
http://hg.mozilla.org/projects/build-system/rev/4613ef36f288
Comment 6 Kyle Huey [:khuey] (khuey@mozilla.com) (Away until 6/13) 2011-08-31 08:06:33 PDT
http://hg.mozilla.org/mozilla-central/rev/4613ef36f288

Note You need to log in before you can comment on or make changes to this bug.