Closed Bug 682283 Opened 13 years ago Closed 13 years ago

Define XP_IOS in configure, shuffle some configure checks around

Categories

(Firefox Build System :: General, defect)

ARM
iOS 4
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla9

People

(Reporter: ted, Assigned: ted)

Details

(Whiteboard: [iOS] fixed-in-bs)

Attachments

(1 file, 1 obsolete file)

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.
Attached patch Define XP_IOS in configure (obsolete) — Splinter Review
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.
Attachment #556026 - Flags: review?(khuey)
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.
Attachment #556110 - Flags: review?(khuey)
Attachment #556026 - Attachment is obsolete: true
Attachment #556026 - Flags: review?(khuey)
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
Attachment #556110 - Flags: review?(khuey) → review+
(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.
http://hg.mozilla.org/mozilla-central/rev/4613ef36f288
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: