mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 13:52:37 +00:00
Bug 297923 - Make the standalone glue work on mac, and write GRE-finding code which looks for our new XUL framework, and make our new XUL framework. r=jhpedemonte+darin a=chofmann
This commit is contained in:
parent
966ac14026
commit
fab45591e2
@ -1068,7 +1068,7 @@ case "$host" in
|
||||
HOST_NSPR_MDCPUCFG='\"md/_darwin.cfg\"'
|
||||
HOST_OPTIMIZE_FLAGS="${HOST_OPTIMIZE_FLAGS=-O3}"
|
||||
MOZ_FIX_LINK_PATHS='-Wl,-executable_path,$(DIST)/bin'
|
||||
LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) -lxul -lobjc'
|
||||
LIBXUL_LIBS='$(XPCOM_FROZEN_LDOPTS) $(DIST)/bin/XUL -lobjc'
|
||||
;;
|
||||
|
||||
*-linux*)
|
||||
|
@ -49,6 +49,14 @@ FORCE_USE_PIC = 1
|
||||
FORCE_SHARED_LIB = 1
|
||||
MOZILLA_INTERNAL_API = 1
|
||||
|
||||
ifeq ($(OS_ARCH),Darwin)
|
||||
# This is going to be a framework named "XUL", not an ordinary library named
|
||||
# "libxul.dylib"
|
||||
LIBRARY_NAME=XUL
|
||||
DLL_PREFIX=
|
||||
DLL_SUFFIX=
|
||||
endif
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
|
@ -212,6 +212,7 @@ NS_GetFrozenFunctions(XPCOMFunctions *entryPoints, const char* libraryPath);
|
||||
// you have to love apple..
|
||||
#ifdef XP_MACOSX
|
||||
#define XPCOM_SEARCH_KEY "DYLD_LIBRARY_PATH"
|
||||
#define GRE_FRAMEWORK_NAME "XUL"
|
||||
#else
|
||||
#define XPCOM_SEARCH_KEY "LD_LIBRARY_PATH"
|
||||
#endif
|
||||
|
@ -58,8 +58,8 @@
|
||||
# define INCL_DOS
|
||||
# include <os2.h>
|
||||
#elif defined(XP_MACOSX)
|
||||
# include <Processes.h>
|
||||
# include <CFBundle.h>
|
||||
# include <unistd.h>
|
||||
#elif defined(XP_UNIX)
|
||||
# include <unistd.h>
|
||||
# include <sys/param.h>
|
||||
@ -74,6 +74,15 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
#if defined(XP_MACOSX)
|
||||
|
||||
static PRBool
|
||||
GRE_FindGREFramework(const char* version, const char* rootPath,
|
||||
char* buffer, PRUint32 buflen);
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
|
||||
static PRBool
|
||||
GRE_GetPathFromConfigDir(const char* version, const char* dirname,
|
||||
char* buffer, PRUint32 buflen);
|
||||
@ -81,10 +90,12 @@ static PRBool
|
||||
GRE_GetPathFromConfigFile(const char* version, const char* dirname,
|
||||
char* buffer, PRUint32 buflen);
|
||||
|
||||
#ifdef XP_WIN
|
||||
#elif defined(XP_WIN)
|
||||
|
||||
static PRBool
|
||||
GRE_GetPathFromRegKey(const char* version, HKEY aRegKey,
|
||||
char* buffer, PRUint32 buflen);
|
||||
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
@ -97,7 +108,7 @@ GRE_GetGREPathForVersion(const char *aVersion,
|
||||
#if XP_UNIX
|
||||
if (realpath(env, aBuffer))
|
||||
return NS_OK;
|
||||
#elif XP_WIN32
|
||||
#elif XP_WIN
|
||||
if (_fullpath(aBuffer, env, aBufLen))
|
||||
return NS_OK;
|
||||
#else
|
||||
@ -120,12 +131,58 @@ GRE_GetGREPathForVersion(const char *aVersion,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
aBuffer[0] = '\0';
|
||||
|
||||
// Check the bundle first, for <bundle>/Contents/Frameworks/XUL/libxpcom.dylib
|
||||
CFBundleRef appBundle = CFBundleGetMainBundle();
|
||||
if (appBundle) {
|
||||
CFURLRef fwurl = CFBundleCopyPrivateFrameworksURL(appBundle);
|
||||
if (fwurl) {
|
||||
CFURLRef xulurl =
|
||||
CFURLCreateCopyAppendingPathComponent(NULL, fwurl,
|
||||
CFSTR("XUL"), PR_TRUE);
|
||||
|
||||
if (xulurl) {
|
||||
CFURLRef xpcomurl =
|
||||
CFURLCreateCopyAppendingPathComponent(NULL, xulurl,
|
||||
CFSTR("libxpcom.dylib"),
|
||||
PR_FALSE);
|
||||
|
||||
if (xpcomurl) {
|
||||
if (!CFURLGetFileSystemRepresentation(xpcomurl, PR_TRUE,
|
||||
(UInt8*) aBuffer, aBufLen) ||
|
||||
access(aBuffer, R_OK | X_OK) != 0)
|
||||
aBuffer[0] = '\0';
|
||||
}
|
||||
|
||||
CFRelease(xulurl);
|
||||
}
|
||||
|
||||
CFRelease(fwurl);
|
||||
}
|
||||
}
|
||||
|
||||
if (aBuffer[0])
|
||||
return NS_OK;
|
||||
|
||||
// Check ~/Library/Frameworks/XUL/Versions/<version>/libxpcom.dylib
|
||||
const char *home = PR_GetEnv("HOME");
|
||||
if (home && *home && GRE_FindGREFramework(aVersion, home, aBuffer, aBufLen)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check /Library/Frameworks/XUL/Versions/<version>/libxpcom.dylib
|
||||
if (GRE_FindGREFramework(aVersion, "", aBuffer, aBufLen)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
env = PR_GetEnv("MOZ_GRE_CONF");
|
||||
if (env && GRE_GetPathFromConfigFile(aVersion, env, aBuffer, aBufLen)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if XP_UNIX
|
||||
env = PR_GetEnv("HOME");
|
||||
if (env && *env) {
|
||||
char buffer[MAXPATHLEN];
|
||||
@ -158,9 +215,8 @@ GRE_GetGREPathForVersion(const char *aVersion,
|
||||
if (GRE_GetPathFromConfigDir(aVersion, GRE_CONF_DIR, aBuffer, aBufLen)) {
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if XP_WIN32
|
||||
#elif defined(XP_WIN)
|
||||
HKEY hRegKey = NULL;
|
||||
|
||||
// A couple of key points here:
|
||||
@ -196,6 +252,24 @@ GRE_GetGREPathForVersion(const char *aVersion,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
PRBool
|
||||
GRE_FindGREFramework(const char* version, const char* rootPath,
|
||||
char* buffer, PRUint32 buflen)
|
||||
{
|
||||
snprintf(buffer, buflen,
|
||||
"%s/Library/Frameworks/" GRE_FRAMEWORK_NAME "/Versions/%s/" XPCOM_DLL,
|
||||
rootPath, version);
|
||||
|
||||
if (access(buffer, R_OK | X_OK) == 0)
|
||||
return PR_TRUE;
|
||||
|
||||
buffer[0] = '\0';
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#elif defined(XP_UNIX)
|
||||
|
||||
PRBool
|
||||
GRE_GetPathFromConfigDir(const char* version, const char* dirname,
|
||||
char* buffer, PRUint32 buflen)
|
||||
@ -282,7 +356,8 @@ GRE_GetPathFromConfigFile(const char* version, const char* filename,
|
||||
return (*pathBuffer != '\0');
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
#elif defined(XP_WIN)
|
||||
|
||||
static PRBool
|
||||
CopyWithEnvExpansion(char* aDest, const char* aSource, PRUint32 aBufLen,
|
||||
DWORD aType)
|
||||
|
@ -123,7 +123,7 @@ nsGREDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile *
|
||||
|
||||
//*****************************************************************************
|
||||
// Implementations from nsXPCOMGlue.h and helper functions.
|
||||
//*****************************************************************************
|
||||
//*****************************************************************************
|
||||
|
||||
PRBool
|
||||
GRE_GetCurrentProcessDirectory(char* buffer)
|
||||
@ -162,7 +162,6 @@ GRE_GetCurrentProcessDirectory(char* buffer)
|
||||
}
|
||||
CFRelease(bundleURL);
|
||||
}
|
||||
CFRelease(appBundle);
|
||||
}
|
||||
if (*buffer) return PR_TRUE;
|
||||
|
||||
|
@ -46,7 +46,11 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#if XP_WIN32
|
||||
#ifdef XP_MACOSX
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <windows.h>
|
||||
#include <mbstring.h>
|
||||
#endif
|
||||
@ -57,21 +61,59 @@ void GRE_AddGREToEnvironment();
|
||||
nsresult GlueStartupDebug();
|
||||
void GlueShutdownDebug();
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
// You cannot unload a .dylib on Mac OS X, so we don't bother saving the
|
||||
// mach_header*
|
||||
|
||||
static PRLibrary *xpcomLib;
|
||||
#endif
|
||||
|
||||
static XPCOMFunctions xpcomFunctions;
|
||||
|
||||
extern "C"
|
||||
nsresult XPCOMGlueStartup(const char* xpcomFile)
|
||||
{
|
||||
#ifdef XPCOM_GLUE_NO_DYNAMIC_LOADING
|
||||
return NS_OK;
|
||||
#else
|
||||
nsresult rv = NS_OK;
|
||||
GetFrozenFunctionsFunc function = nsnull;
|
||||
|
||||
xpcomFunctions.version = XPCOM_GLUE_VERSION;
|
||||
xpcomFunctions.size = sizeof(XPCOMFunctions);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (!xpcomFile)
|
||||
xpcomFile = XPCOM_DLL;
|
||||
|
||||
if ((xpcomFile[0] != '.' || xpcomFile[1] != '\0')) {
|
||||
(void) NSAddImage(xpcomFile,
|
||||
NSADDIMAGE_OPTION_RETURN_ON_ERROR |
|
||||
NSADDIMAGE_OPTION_WITH_SEARCHING |
|
||||
NSADDIMAGE_OPTION_MATCH_FILENAME_BY_INSTALLNAME);
|
||||
// We don't really care if this fails, as long as we can get
|
||||
// NS_GetFrozenFunctions below.
|
||||
}
|
||||
|
||||
if (!NSIsSymbolNameDefined("_NS_GetFrozenFunctions"))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
NSSymbol sym = NSLookupAndBindSymbol("_NS_GetFrozenFunctions");
|
||||
function = (GetFrozenFunctionsFunc) NSAddressOfSymbol(sym);
|
||||
|
||||
if (!function)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = (*function)(&xpcomFunctions, nsnull);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = GlueStartupDebug();
|
||||
if (NS_FAILED(rv)) {
|
||||
memset(&xpcomFunctions, 0, sizeof(xpcomFunctions));
|
||||
return rv;
|
||||
}
|
||||
|
||||
GRE_AddGREToEnvironment();
|
||||
return NS_OK;
|
||||
#else
|
||||
//
|
||||
// if xpcomFile == ".", then we assume xpcom is already loaded, and we'll
|
||||
// use NSPR to find NS_GetFrozenFunctions from the list of already loaded
|
||||
@ -164,23 +206,19 @@ bail:
|
||||
extern "C"
|
||||
nsresult XPCOMGlueShutdown()
|
||||
{
|
||||
#ifdef XPCOM_GLUE_NO_DYNAMIC_LOADING
|
||||
return NS_OK;
|
||||
#else
|
||||
|
||||
GlueShutdownDebug();
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
if (xpcomLib) {
|
||||
PR_UnloadLibrary(xpcomLib);
|
||||
xpcomLib = nsnull;
|
||||
}
|
||||
#endif
|
||||
|
||||
memset(&xpcomFunctions, 0, sizeof(xpcomFunctions));
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef XPCOM_GLUE_NO_DYNAMIC_LOADING
|
||||
extern "C" NS_COM nsresult
|
||||
NS_InitXPCOM2(nsIServiceManager* *result,
|
||||
nsIFile* binDirectory,
|
||||
@ -480,8 +518,6 @@ NS_Free(void* ptr)
|
||||
xpcomFunctions.freeFunc(ptr);
|
||||
}
|
||||
|
||||
#endif // #ifndef XPCOM_GLUE_NO_DYNAMIC_LOADING
|
||||
|
||||
static char* spEnvString = 0;
|
||||
|
||||
void
|
||||
|
@ -81,15 +81,26 @@ FORCE_USE_PIC = 1
|
||||
|
||||
FORCE_SHARED_LIB = 1
|
||||
|
||||
EXTRA_DSO_LDOPTS = $(LIBS_DIR) $(MOZ_FIX_LINK_PATHS)
|
||||
|
||||
ifdef MOZ_ENABLE_LIBXUL
|
||||
EXTRA_DSO_LIBS = xul
|
||||
|
||||
ifeq (Darwin,$(OS_ARCH))
|
||||
EXTRA_DSO_LDOPTS += $(DIST)/bin/XUL
|
||||
else
|
||||
EXTRA_DSL_LIBS = xul
|
||||
endif
|
||||
|
||||
else #!MOZ_ENABLE_LIBXUL
|
||||
|
||||
ifeq ($(OS_TARGET),OS2)
|
||||
EXTRA_DSO_LIBS = xpcomcor
|
||||
else
|
||||
EXTRA_DSO_LIBS = xpcom_core
|
||||
endif
|
||||
|
||||
endif
|
||||
EXTRA_DSO_LDOPTS = $(LIBS_DIR) $(MOZ_FIX_LINK_PATHS) $(EXTRA_DSO_LIBS) $(NSPR_LIBS)
|
||||
|
||||
EXTRA_DSO_LDOPTS += $(EXTRA_DSO_LIBS) $(NSPR_LIBS)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -24,6 +24,7 @@
|
||||
# Jonathan Wilson <jonwil@tpgi.com.au>
|
||||
# Dan Mosedale <dmose@mozilla.org>
|
||||
# Darin Fisher <darin@meer.net>
|
||||
# Benjamin Smedberg <benjamin@smedbergs.us>
|
||||
#
|
||||
# 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
|
||||
@ -51,9 +52,7 @@ MOZILLA_INTERNAL_API = 1
|
||||
DIRS = profile
|
||||
|
||||
PREF_JS_EXPORTS = $(srcdir)/xulrunner.js
|
||||
|
||||
# hardcode en-US for the moment
|
||||
AB_CD = en-US
|
||||
GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/,xulrunner.js)
|
||||
|
||||
DEFINES += -DAB_CD=$(AB_CD)
|
||||
|
||||
@ -237,7 +236,7 @@ LDFLAGS += -Zlinker /NOE
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
|
||||
ifneq (,$(filter-out OS2 WINNT Darwin,$(OS_ARCH)))
|
||||
|
||||
xulrunner:: mozilla.in Makefile.in Makefile $(DEPTH)/config/autoconf.mk
|
||||
cat $< | sed -e "s|%MOZAPPDIR%|$(mozappdir)|" \
|
||||
@ -252,8 +251,6 @@ install:: xulrunner
|
||||
$(SYSINSTALL) $< $(DESTDIR)$(bindir)
|
||||
|
||||
GARBAGE += xulrunner
|
||||
GARBAGE += $(addprefix $(DIST)/bin/defaults/pref/, xulrunner.js)
|
||||
|
||||
endif
|
||||
|
||||
ifneq (,$(filter gtk gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
@ -291,9 +288,6 @@ ifeq ($(OS_ARCH),WINNT)
|
||||
cp $(srcdir)/xulrunner.ico $(DIST)/branding/app.ico
|
||||
cp $(srcdir)/document.ico $(DIST)/branding/document.ico
|
||||
endif
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
cp $(srcdir)/macbuild/xulrunner.icns $(DIST)/branding/xulrunner.icns
|
||||
endif
|
||||
ifneq (,$(filter gtk gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
cp $(srcdir)/mozicon16.xpm $(DIST)/branding/mozicon16.xpm
|
||||
cp $(srcdir)/mozicon50.xpm $(DIST)/branding/mozicon50.xpm
|
||||
@ -314,24 +308,25 @@ libs::
|
||||
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
|
||||
APP_NAME = XULRunner
|
||||
APP_VERSION = $(MOZILLA_VERSION)
|
||||
FRAMEWORK_NAME = XUL
|
||||
FRAMEWORK_VERSION = $(MOZILLA_VERSION)
|
||||
|
||||
libs:: $(PROGRAM)
|
||||
mkdir -p $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||
rsync -a --exclude CVS --exclude "*.in" $(srcdir)/macbuild/Contents $(DIST)/$(APP_NAME).app
|
||||
sed -e "s/APP_VERSION/$(APP_VERSION)/" $(srcdir)/macbuild/Contents/Info.plist.in > $(DIST)/$(APP_NAME).app/Contents/Info.plist
|
||||
rsync -a $(DIST)/bin/ $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||
rm -f $(DIST)/$(APP_NAME).app/Contents/MacOS/$(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS/mangle $(DIST)/$(APP_NAME).app/Contents/MacOS/shlibsign
|
||||
rsync -aL $(PROGRAM) $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||
-cp -L $(DIST)/bin/mangle $(DIST)/bin/shlibsign $(DIST)/$(APP_NAME).app/Contents/MacOS
|
||||
cp -RL $(DIST)/branding/xulrunner.icns $(DIST)/$(APP_NAME).app/Contents/Resources/xulrunner.icns
|
||||
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 {} \;
|
||||
mkdir -p $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION)/Resources
|
||||
$(NSINSTALL) $(srcdir)/macbuild/InfoPlist.strings $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION)/Resources
|
||||
sed -e "s/APP_VERSION/$(APP_VERSION)/" $(srcdir)/macbuild/Info.plist.in > $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION)/Info.plist
|
||||
rsync -a $(DIST)/bin/ $(DIST)/$(FRAMEWORK_NAME).framework/Versions/$(FRAMEWORK_VERSION) --exclude mangle --exclude shlibsign
|
||||
rm -f $(DIST)/$(FRAMEWORK_NAME).framework/Versions/Current \
|
||||
$(DIST)/$(FRAMEWORK_NAME).framework/libxpcom.dylib \
|
||||
$(DIST)/$(FRAMEWORK_NAME).framework/XUL \
|
||||
$(DIST)/$(FRAMEWORK_NAME).framework/xulrunner-bin
|
||||
ln -s $(FRAMEWORK_VERSION) $(DIST)/$(FRAMEWORK_NAME).framework/Versions/Current
|
||||
ln -s Versions/Current/libxpcom.dylib $(DIST)/$(FRAMEWORK_NAME).framework/libxpcom.dylib
|
||||
ln -s Versions/Current/XUL $(DIST)/$(FRAMEWORK_NAME).framework/XUL
|
||||
ln -s Versions/Current/xulrunner-bin $(DIST)/$(FRAMEWORK_NAME).framework/xulrunner-bin
|
||||
|
||||
clean clobber::
|
||||
rm -rf $(DIST)/$(APP_NAME).app
|
||||
rm -rf $(DIST)/$(FRAMEWORK_NAME).framework
|
||||
endif
|
||||
|
||||
README_FILE = $(topsrcdir)/README.txt
|
||||
|
@ -6,10 +6,6 @@
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>xulrunner-bin</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>XULRunner APP_VERSION, © 1998-2005 Contributors</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>xulrunner</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.mozilla.xulrunner</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
@ -17,14 +13,10 @@
|
||||
<key>CFBundleName</key>
|
||||
<string>XULRunner</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>APP_VERSION</string>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>MOZB</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>APP_VERSION</string>
|
||||
<key>NSAppleScriptEnabled</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user