bug 543060 - remove fennec's dependency on xulrunner r=mfinkle
authorBrad Lassey <blassey@mozilla.com>
Fri, 29 Jan 2010 11:15:37 -0500
changeset 66026 d6254957586563480c01d18c45809e4439f5d14e
parent 66025 e26e505de76c18584de3525e2512f12ae6d5567b
child 66027 8c0546dcdf245f72c04c060b8fb6a67f72239c24
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs543060
bug 543060 - remove fennec's dependency on xulrunner r=mfinkle
mobile/Makefile.in
mobile/app/Makefile.in
mobile/app/nsBrowserApp.cpp
mobile/build.mk
mobile/confvars.sh
mobile/installer/Makefile.in
--- a/mobile/Makefile.in
+++ b/mobile/Makefile.in
@@ -40,16 +40,20 @@ DEPTH      = ..
 topsrcdir  = @top_srcdir@
 srcdir     = @srcdir@
 VPATH      = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 DIRS       = chrome locales components themes app
 
+ifndef LIBXUL_SDK
+PARALLEL_DIRS += $(DEPTH)/xulrunner/tools/redit
+endif
+
 ifdef WINCE
 DIRS += installer/wince
 endif
 
 include $(topsrcdir)/config/rules.mk
 include $(topsrcdir)/testing/testsuite-targets.mk
 
 package-mobile-tests:
--- a/mobile/app/Makefile.in
+++ b/mobile/app/Makefile.in
@@ -40,16 +40,53 @@ topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 PREF_JS_EXPORTS = $(srcdir)/mobile.js
 DIST_FILES = application.ini
 
+ifndef LIBXUL_SDK
+PROGRAM=$(MOZ_APP_NAME)$(BIN_SUFFIX)
+
+CPPSRCS = nsBrowserApp.cpp
+
+LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
+
+ifdef MOZ_ENABLE_LIBXUL
+APP_XPCOM_LIBS = $(XPCOM_GLUE_LDOPTS)
+else
+MOZILLA_INTERNAL_API = 1
+APP_XPCOM_LIBS = $(XPCOM_LIBS)
+endif
+
+LIBS += $(APP_XPCOM_LIBS) \
+	$(NSPR_LIBS) \
+	$(NULL)
+
+ifdef BUILD_STATIC_LIBS
+LIBS += $(DEPTH)/toolkit/xre/$(LIB_PREFIX)xulapp_s.$(LIB_SUFFIX)
+else
+ifneq (,$(filter OS2 WINCE WINNT,$(OS_ARCH)))
+LIBS += $(LIB_PREFIX)xul.$(LIB_SUFFIX)
+endif
+endif
+
+ifdef _MSC_VER
+# Always enter a Windows program through wmain, whether or not we're
+# a console application.
+ifdef WINCE
+WIN32_EXE_LDFLAGS += -ENTRY:mainWCRTStartup
+else
+WIN32_EXE_LDFLAGS += -ENTRY:wmainCRTStartup
+endif
+endif
+endif #LIBXUL_SDK
+
 include $(topsrcdir)/config/rules.mk
 
 GRE_MILESTONE = $(shell $(PYTHON) $(topsrcdir)/config/printconfigsetting.py $(LIBXUL_DIST)/bin/platform.ini Build Milestone)
 GRE_BUILDID = $(shell $(PYTHON) $(topsrcdir)/config/printconfigsetting.py $(LIBXUL_DIST)/bin/platform.ini Build BuildID)
 APP_BUILDID = $(shell $(PYTHON) $(topsrcdir)/toolkit/xre/make-platformini.py --print-buildid)
 APP_ICON = mobile
 APP_SPLASH = splash
 
@@ -123,28 +160,33 @@ libs repackage:: application.ini
 	cp $(LIBXUL_DIST)/bin/xulrunner$(BIN_SUFFIX) $(DIST)/$(APP_NAME).app/Contents/MacOS/$(APP_BINARY)
 	rsync -a --exclude nsinstall --copy-unsafe-links $(LIBXUL_DIST)/XUL.framework $(DIST)/$(APP_NAME).app/Contents/Frameworks
 	echo -n APPLMOZB > $(DIST)/$(APP_NAME).app/Contents/PkgInfo
 #	remove CVS dirs from packaged app
 	find $(DIST)/$(APP_NAME).app -type d -name "CVS" -prune -exec rm -rf {} \;
 
 else
 
+
 libs::
+ifdef LIBXUL_SDK
 	cp $(LIBXUL_DIST)/bin/xulrunner-stub$(BIN_SUFFIX) $(DIST)/bin/$(APP_BINARY)
+endif
 ifdef MOZ_FASTSTART
 ifdef _MSC_VER
 ifdef WINCE
 	cp $(LIBXUL_DIST)/bin/faststartstub$(BIN_SUFFIX) $(DIST)/bin/$(APP_BINARY_FASTSTART)
 endif
 endif
 endif
 ifndef SKIP_COPY_XULRUNNER
+ifdef LIBXUL_SDK
 	$(NSINSTALL) -D $(DIST)/bin/xulrunner
 	(cd $(LIBXUL_SDK)/bin && tar $(TAR_CREATE_FLAGS) - .) | (cd $(DIST)/bin/xulrunner && tar -xf -)
+endif
 endif # SKIP_COPY_XULRUNNER
 
 	$(NSINSTALL) -D $(DIST)/bin/chrome/icons/default
 
 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
 	cp $(srcdir)/$(APP_ICON).ico $(DIST)/bin/chrome/icons/default/$(APP_ICON).ico
 	cp $(srcdir)/$(APP_SPLASH).bmp $(DIST)/bin/$(APP_SPLASH).bmp
 	$(REDIT_PATH)/redit $(DIST)/bin/$(APP_BINARY) $(srcdir)/$(APP_ICON).ico
new file mode 100644
--- /dev/null
+++ b/mobile/app/nsBrowserApp.cpp
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2002
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *  Brian Ryner <bryner@brianryner.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsXULAppAPI.h"
+#ifdef XP_WIN
+#include <windows.h>
+#include <stdlib.h>
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "plstr.h"
+#include "prprf.h"
+#include "prenv.h"
+
+#include "nsCOMPtr.h"
+#include "nsILocalFile.h"
+#include "nsStringGlue.h"
+
+#ifdef XP_WIN
+// we want to use the DLL blocklist if possible
+#define XRE_WANT_DLL_BLOCKLIST
+// we want a wmain entry point
+#include "nsWindowsWMain.cpp"
+#endif
+
+static void Output(const char *fmt, ... )
+{
+  va_list ap;
+  va_start(ap, fmt);
+
+#if defined(XP_WIN) && !MOZ_WINCONSOLE
+  PRUnichar msg[2048];
+  _vsnwprintf(msg, sizeof(msg)/sizeof(msg[0]), NS_ConvertUTF8toUTF16(fmt).get(), ap);
+  MessageBoxW(NULL, msg, L"XULRunner", MB_OK | MB_ICONERROR);
+#else
+  vfprintf(stderr, fmt, ap);
+#endif
+
+  va_end(ap);
+}
+
+/**
+ * Return true if |arg| matches the given argument name.
+ */
+static PRBool IsArg(const char* arg, const char* s)
+{
+  if (*arg == '-')
+  {
+    if (*++arg == '-')
+      ++arg;
+    return !PL_strcasecmp(arg, s);
+  }
+
+#if defined(XP_WIN) || defined(XP_OS2)
+  if (*arg == '/')
+    return !PL_strcasecmp(++arg, s);
+#endif
+
+  return PR_FALSE;
+}
+
+int main(int argc, char* argv[])
+{
+  nsCOMPtr<nsILocalFile> appini;
+  nsresult rv = XRE_GetBinaryPath(argv[0], getter_AddRefs(appini));
+  if (NS_FAILED(rv)) {
+    Output("Couldn't calculate the application directory.");
+    return 255;
+  }
+  appini->SetNativeLeafName(NS_LITERAL_CSTRING("application.ini"));
+
+  // Allow firefox.exe to launch XULRunner apps via -app <application.ini>
+  // Note that -app must be the *first* argument.
+  char *appEnv = nsnull;
+  const char *appDataFile = PR_GetEnv("XUL_APP_FILE");
+  if (appDataFile && *appDataFile) {
+    rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
+    if (NS_FAILED(rv)) {
+      Output("Invalid path found: '%s'", appDataFile);
+      return 255;
+    }
+  }
+  else if (argc > 1 && IsArg(argv[1], "app")) {
+    if (argc == 2) {
+      Output("Incorrect number of arguments passed to -app");
+      return 255;
+    }
+
+    rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(appini));
+    if (NS_FAILED(rv)) {
+      Output("application.ini path not recognized: '%s'", argv[2]);
+      return 255;
+    }
+
+    appEnv = PR_smprintf("XUL_APP_FILE=%s", argv[2]);
+    PR_SetEnv(appEnv);
+    argv[2] = argv[0];
+    argv += 2;
+    argc -= 2;
+  }
+
+  nsXREAppData *appData;
+  rv = XRE_CreateAppData(appini, &appData);
+  if (NS_FAILED(rv)) {
+    Output("Couldn't read application.ini");
+    return 255;
+  }
+
+  int result = XRE_main(argc, argv, appData);
+  XRE_FreeAppData(appData);
+  if (appEnv)
+    PR_smprintf_free(appEnv);
+  return result;
+}
--- a/mobile/build.mk
+++ b/mobile/build.mk
@@ -30,16 +30,20 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
+ifndef LIBXUL_SDK
+include $(topsrcdir)/toolkit/toolkit-tiers.mk
+endif
+
 TIERS += app
 
 ifdef MOZ_EXTENSIONS
 tier_app_dirs += extensions
 endif
 
 tier_app_dirs += \
   $(MOZ_BRANDING_DIRECTORY) \
--- a/mobile/confvars.sh
+++ b/mobile/confvars.sh
@@ -46,12 +46,17 @@ case "$target" in
     . ${srcdir}/${MOZ_BUILD_APP}/winmo-version.txt
     ;;
 *)
     . ${srcdir}/${MOZ_BUILD_APP}/default-version.txt
     ;;
 esac
 
 MOZ_XUL_APP=1
-MOZ_UPDATER=0
 MOZ_ENABLE_LIBXUL=1
 MOZ_NO_XPCOM_OBSOLETE=1
+if test "$LIBXUL_SDK"; then
 MOZ_XULRUNNER=1
+else
+MOZ_XULRUNNER=
+MOZ_MORK=
+MOZ_PLACES=1
+fi
--- a/mobile/installer/Makefile.in
+++ b/mobile/installer/Makefile.in
@@ -68,25 +68,25 @@ DEFINES += \
 	-DMOZ_DEB_TIMESTAMP=$(MOZ_DEB_TIMESTAMP) \
 	-DDEB_PKG_VERSION=$(DEB_PKG_VERSION) \
 	$(NULL)
 
 NO_PKG_FILES = \
 	$(MOZ_APP_NAME)-config \
 	$(MOZ_APP_NAME)-bin.elf \
 	xulrunner-config \
+	$(MOZ_APP_NAME)-bin$(BIN_SUFFIX) \
 	nspr-config \
 	regchrome* \
 	regxpcom* \
 	xpcshell* \
 	xpidl* \
 	xpt_dump* \
 	xpt_link* \
 	bloaturls.txt \
-	run-mozilla.sh \
 	nsinstall \
 	*Test* \
 	*test* \
 	BadPlugin* \
 	GoodPlugin* \
 	ReadNTLM* \
 	ShowSSEConfig* \
 	SimpleTypeLib* \
@@ -123,26 +123,28 @@ PACKAGE_XULRUNNER = package-xulrunner
 UNPACKAGE = $(LIBXUL_DIST)/xulrunner*$(PKG_SUFFIX)
 endif
 
 include $(topsrcdir)/toolkit/mozapps/installer/packager.mk
 
 DEBDESTDIR=debian/$(MOZ_APP_NAME)
 
 package-xulrunner:
+ifdef LIBXUL_SDK
 ifndef SYSTEM_LIBXUL
 	@echo "Packaging xulrunner..."
 	@rm -rf $(LIBXUL_DIST)/xulrunner*
 	@$(MAKE) -C $(LIBXUL_DIST)/.. package || echo "Perhaps you're trying to package a prebuilt SDK. See 'https://wiki.mozilla.org/Mobile/Build/Fennec#Build' for more information."
 	@cd $(DIST)/$(MOZ_PKG_DIR); $(UNMAKE_PACKAGE)
 	@echo "Removing unpackaged files... (the ones xulrunner/installer keeps)"
 	@cd $(DIST)/$(MOZ_PKG_DIR)/xulrunner; rm -rf $(NO_PKG_FILES)
 else
 	@echo "Using system xulrunner..."
 endif
+endif
 
 ifeq ($(OS_TARGET),Linux)
 PP_DEB_FILES =	debian/control \
 		debian/changelog \
 		debian/$(MOZ_APP_NAME).desktop \
 		debian/$(MOZ_APP_NAME).links \
 		debian/$(MOZ_APP_NAME).service \
 		debian/compat \