зеркало из https://github.com/mozilla/pjs.git
Bug 299991 - XULRunner stub executable, r=darin a=shaver
This commit is contained in:
Родитель
0d9f29eddb
Коммит
be61801fba
|
@ -705,8 +705,8 @@ DYNAMIC_XPCOM_LIBS='-L$(DIST)/bin -lxpcom -lxpcom_core'
|
|||
MOZ_FIX_LINK_PATHS='-Wl,-rpath-link,$(DIST)/bin'
|
||||
XPCOM_FROZEN_LDOPTS='-L$(DIST)/bin $(MOZ_FIX_LINK_PATHS) -lxpcom'
|
||||
LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul'
|
||||
XPCOM_GLUE_LDOPTS='-L$(DIST)/lib -lxpcomglue_s $(XPCOM_FROZEN_LDOPTS)'
|
||||
XPCOM_STANDALONE_GLUE_LDOPTS='-L$(DIST)/lib -lxpcomglue'
|
||||
XPCOM_GLUE_LDOPTS='$(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) $(XPCOM_FROZEN_LDOPTS)'
|
||||
XPCOM_STANDALONE_GLUE_LDOPTS='$(DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX)'
|
||||
|
||||
MOZ_COMPONENT_NSPR_LIBS='-L$(DIST)/bin $(NSPR_LIBS)'
|
||||
MOZ_XPCOM_OBSOLETE_LIBS='-L$(DIST)/lib -lxpcom_compat'
|
||||
|
@ -1487,8 +1487,6 @@ case "$target" in
|
|||
UNZIP=unzip
|
||||
XARGS=xargs
|
||||
XPCOM_FROZEN_LDOPTS='$(DIST)/lib/xpcom.lib'
|
||||
XPCOM_GLUE_LDOPTS='$(DIST)/lib/xpcomglue_s.lib $(DIST)/lib/xpcom.lib'
|
||||
XPCOM_STANDALONE_GLUE_LDOPTS='$(DIST)/lib/xpcomglue.lib'
|
||||
ZIP=zip
|
||||
LIBIDL_CFLAGS="-I$MOZ_TOOLS_DIR/include ${GLIB_CFLAGS}"
|
||||
LIBIDL_LIBS="$MOZ_TOOLS_DIR/lib/libidl-0.6.lib $MOZ_TOOLS_DIR/lib/glib-1.2.lib"
|
||||
|
@ -1582,8 +1580,6 @@ case "$target" in
|
|||
DYNAMIC_XPCOM_LIBS='$(DIST)/lib/xpcom.lib $(DIST)/lib/xpcom_core.lib'
|
||||
XPCOM_FROZEN_LDOPTS='$(DIST)/lib/xpcom.lib'
|
||||
LIBXUL_LIBS='$(DIST)/lib/xpcom.lib $(DIST)/lib/xul.lib'
|
||||
XPCOM_GLUE_LDOPTS='$(DIST)/lib/xpcomglue_s.lib $(DIST)/lib/xpcom.lib'
|
||||
XPCOM_STANDALONE_GLUE_LDOPTS='$(DIST)/lib/xpcomglue.lib'
|
||||
MOZ_COMPONENT_NSPR_LIBS='$(NSPR_LIBS)'
|
||||
MOZ_XPCOM_OBSOLETE_LIBS='$(DIST)/lib/xpcom_compat.lib'
|
||||
fi
|
||||
|
|
|
@ -1006,6 +1006,10 @@ RemoteCommandLine()
|
|||
}
|
||||
#endif // MOZ_ENABLE_XREMOTE
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
static char const *gBinaryPath;
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
XRE_GetBinaryPath(const char* argv0, nsILocalFile* *aResult)
|
||||
{
|
||||
|
@ -1028,6 +1032,10 @@ XRE_GetBinaryPath(const char* argv0, nsILocalFile* *aResult)
|
|||
return rv;
|
||||
|
||||
#elif defined(XP_MACOSX)
|
||||
if (gBinaryPath)
|
||||
return NS_NewNativeLocalFile(nsDependentCString(gBinaryPath), PR_FALSE,
|
||||
aResult);
|
||||
|
||||
NS_NewNativeLocalFile(EmptyCString(), PR_TRUE, getter_AddRefs(lf));
|
||||
nsCOMPtr<nsILocalFileMac> lfm (do_QueryInterface(lf));
|
||||
if (!lfm)
|
||||
|
@ -1442,6 +1450,12 @@ SelectProfile(nsIProfileLock* *aResult, nsINativeAppSupport* aNative,
|
|||
localDir = lf;
|
||||
}
|
||||
|
||||
// Clear out flags that we handled (or should have handled!) last startup.
|
||||
char *dummy;
|
||||
CheckArg("p", &dummy);
|
||||
CheckArg("profile", &dummy);
|
||||
CheckArg("profilemanager", &dummy);
|
||||
|
||||
return NS_LockProfilePath(lf, localDir, nsnull, aResult);
|
||||
}
|
||||
|
||||
|
@ -1871,6 +1885,16 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// The xulrunner stub executable tricks CFBundleGetMainBundle on
|
||||
// purpose into lying about the main bundle path. It will set
|
||||
// XRE_BINARY_PATH to inform us of our real location.
|
||||
gBinaryPath = getenv("XRE_BINARY_PATH");
|
||||
|
||||
if (gBinaryPath && !*gBinaryPath)
|
||||
gBinaryPath = nsnull;
|
||||
#endif
|
||||
|
||||
gAppData = aAppData;
|
||||
|
||||
gRestartArgc = argc;
|
||||
|
@ -2233,6 +2257,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
PR_SetEnv("XRE_IMPORT_PROFILES=");
|
||||
PR_SetEnv("NO_EM_RESTART=");
|
||||
PR_SetEnv("XUL_APP_FILE=");
|
||||
PR_SetEnv("XRE_BINARY_PATH=");
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// we re-initialize the command-line service and do appleevents munging
|
||||
|
@ -2355,6 +2380,14 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
PR_SetEnv(kEnvVar1);
|
||||
PR_SetEnv(kEnvVar2);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (gBinaryPath) {
|
||||
static char kEnvVar3[MAXPATHLEN];
|
||||
sprintf(kEnvVar3, "XRE_BINARY_PATH=%s", gBinaryPath);
|
||||
PR_SetEnv(kEnvVar3);
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = LaunchChild(nativeApp, appInitiatedRestart);
|
||||
return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
|
||||
}
|
||||
|
|
|
@ -135,10 +135,16 @@ GRE_GetGREPathForVersion(const char *aVersion,
|
|||
CFBundleRef appBundle = CFBundleGetMainBundle();
|
||||
if (appBundle) {
|
||||
CFURLRef fwurl = CFBundleCopyPrivateFrameworksURL(appBundle);
|
||||
CFURLRef absfwurl = nsnull;
|
||||
if (fwurl) {
|
||||
absfwurl = CFURLCopyAbsoluteURL(fwurl);
|
||||
CFRelease(fwurl);
|
||||
}
|
||||
|
||||
if (absfwurl) {
|
||||
CFURLRef xulurl =
|
||||
CFURLCreateCopyAppendingPathComponent(NULL, fwurl,
|
||||
CFSTR("XUL"), PR_TRUE);
|
||||
CFURLCreateCopyAppendingPathComponent(NULL, absfwurl,
|
||||
CFSTR("XUL.framework"), PR_TRUE);
|
||||
|
||||
if (xulurl) {
|
||||
CFURLRef xpcomurl =
|
||||
|
@ -147,16 +153,25 @@ GRE_GetGREPathForVersion(const char *aVersion,
|
|||
PR_FALSE);
|
||||
|
||||
if (xpcomurl) {
|
||||
if (!CFURLGetFileSystemRepresentation(xpcomurl, PR_TRUE,
|
||||
(UInt8*) aBuffer, aBufLen) ||
|
||||
access(aBuffer, R_OK | X_OK) != 0)
|
||||
aBuffer[0] = '\0';
|
||||
char tbuffer[MAXPATHLEN];
|
||||
|
||||
if (CFURLGetFileSystemRepresentation(xpcomurl, PR_TRUE,
|
||||
(UInt8*) tbuffer,
|
||||
sizeof(tbuffer)) &&
|
||||
access(tbuffer, R_OK | X_OK) == 0 &&
|
||||
realpath(tbuffer, aBuffer)) {
|
||||
char *lastslash = strrchr(aBuffer, '/');
|
||||
if (lastslash)
|
||||
*lastslash = '\0';
|
||||
}
|
||||
|
||||
CFRelease(xpcomurl);
|
||||
}
|
||||
|
||||
CFRelease(xulurl);
|
||||
}
|
||||
|
||||
CFRelease(fwurl);
|
||||
CFRelease(absfwurl);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,8 +348,8 @@ GRE_GetPathFromConfigFile(const char* version, const char* filename,
|
|||
// we found a section heading, check to see if it is the one we
|
||||
// are interested in.
|
||||
if (buffer[0] == '[') {
|
||||
foundHeader == (buffer[versionlen + 1] == ']' &&
|
||||
strncmp(buffer + 1, version, versionlen) == 0);
|
||||
foundHeader = (buffer[versionlen + 1] == ']' &&
|
||||
strncmp(buffer + 1, version, versionlen) == 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = app examples
|
||||
DIRS = stub app examples
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
ifdef MOZ_INSTALLER
|
||||
|
|
|
@ -52,11 +52,11 @@ IS_COMPONENT = 1
|
|||
|
||||
CPPSRCS = SimpleTest.cpp
|
||||
|
||||
# We link against the xpcom glue library to avoid depending on unfrozen
|
||||
# XPCOM symbols.
|
||||
EXTRA_DSO_LIBS = xpcomglue_s
|
||||
EXTRA_DSO_LDOPTS= $(EXTRA_DSO_LIBS) $(MOZ_COMPONENT_LIBS)
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(XPCOM_GLUE_LDOPTS) \
|
||||
$(NSPR_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_COMPONENTS= $(srcdir)/SimpleTest.js
|
||||
EXTRA_COMPONENTS = $(srcdir)/SimpleTest.js
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# ***** 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 XULRunner.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Benjamin Smedberg <benjamin@smedbergs.us>.
|
||||
#
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# 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 *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
|
||||
MODULE = xulrunner
|
||||
PROGRAM = xulrunner$(BIN_SUFFIX)
|
||||
|
||||
CPPSRCS = nsXULStubOSX.cpp
|
||||
|
||||
endif # OS_ARCH
|
||||
|
||||
DEFINES += -DXPCOM_GLUE
|
||||
|
||||
LIBS = \
|
||||
$(XPCOM_STANDALONE_GLUE_LDOPTS) \
|
||||
$(NULL)
|
||||
|
||||
# Need to link with CoreFoundation on Mac
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
LIBS += \
|
||||
$(TK_LIBS) \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,120 @@
|
|||
/* ***** 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 XULRunner.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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 <unistd.h>
|
||||
|
||||
#include <CFBundle.h>
|
||||
#include <Processes.h>
|
||||
|
||||
#include "nsBuildID.h"
|
||||
#include "nsXPCOMGlue.h"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char greDir[PATH_MAX];
|
||||
|
||||
// XXXbsmedberg: read application.ini version information instead of
|
||||
// using compiled-in GRE_BUILD_ID
|
||||
nsresult rv = GRE_GetGREPathForVersion(GRE_BUILD_ID, greDir, sizeof(greDir));
|
||||
if (NS_FAILED(rv)) {
|
||||
// XXXbsmedberg: Do something much smarter here: notify the
|
||||
// user/offer to download/?
|
||||
|
||||
fprintf(stderr,
|
||||
"Could not find compatible GRE, version <" GRE_BUILD_ID ">\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
CFBundleRef appBundle = CFBundleGetMainBundle();
|
||||
if (!appBundle)
|
||||
return 1;
|
||||
|
||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(appBundle);
|
||||
if (!resourcesURL)
|
||||
return 1;
|
||||
|
||||
CFURLRef absResourcesURL = CFURLCopyAbsoluteURL(resourcesURL);
|
||||
CFRelease(resourcesURL);
|
||||
if (!absResourcesURL)
|
||||
return 1;
|
||||
|
||||
CFURLRef iniFileURL =
|
||||
CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault,
|
||||
absResourcesURL,
|
||||
CFSTR("application.ini"),
|
||||
false);
|
||||
CFRelease(resourcesURL);
|
||||
|
||||
if (!iniFileURL)
|
||||
return 1;
|
||||
|
||||
CFStringRef iniPathStr =
|
||||
CFURLCopyFileSystemPath(iniFileURL, kCFURLPOSIXPathStyle);
|
||||
CFRelease(iniFileURL);
|
||||
|
||||
if (!iniPathStr)
|
||||
return 1;
|
||||
|
||||
char iniPath[PATH_MAX];
|
||||
CFStringGetCString(iniPathStr, iniPath, sizeof(iniPath),
|
||||
kCFStringEncodingUTF8);
|
||||
CFRelease(iniPathStr);
|
||||
|
||||
char **argv2 = (char**) malloc(sizeof(char*) * (argc + 2));
|
||||
if (!argv2)
|
||||
return 1;
|
||||
|
||||
char xulBin[PATH_MAX];
|
||||
snprintf(xulBin, sizeof(xulBin), "%s/xulrunner-bin", greDir);
|
||||
|
||||
setenv("DYLD_LIBRARY_PATH", greDir, 1);
|
||||
setenv("XRE_BINARY_PATH", xulBin, 1);
|
||||
|
||||
// IMPORTANT: we lie to argv[0] about what binary is being run, so that it
|
||||
// thinks it's in the current app bundle, not the XUL.framework.
|
||||
argv2[0] = argv[0];
|
||||
argv2[1] = iniPath;
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
argv2[i + 1] = argv[i];
|
||||
|
||||
argv2[argc + 1] = NULL;
|
||||
|
||||
execv(xulBin, argv2);
|
||||
return 1;
|
||||
}
|
Загрузка…
Ссылка в новой задаче