bug 578493 - Set env vars before loading libraries r=mwu

This commit is contained in:
Brad Lassey 2010-07-16 11:52:01 -04:00
parent 5e5cb36122
commit 58eb93aeac
6 changed files with 140 additions and 43 deletions

@ -67,24 +67,6 @@ abstract public class GeckoApp
// and then fire us up
Intent i = getIntent();
String env = i.getStringExtra("env0");
Log.i("GeckoApp", "env0: "+ env);
for (int c = 1; env != null; c++) {
GeckoAppShell.putenv(env);
env = i.getStringExtra("env" + c);
Log.i("GeckoApp", "env"+ c +": "+ env);
}
String tmpdir = System.getProperty("java.io.tmpdir");
if (tmpdir == null) {
try {
File f = Environment.getDownloadCacheDirectory();
dalvik.system.TemporaryDirectory.setUpDirectory(f);
tmpdir = f.getPath();
} catch (Exception e) {
Log.e("GeckoApp", "error setting up tmp dir" + e);
}
}
GeckoAppShell.putenv("TMPDIR=" + tmpdir);
GeckoAppShell.runGecko(getApplication().getPackageResourcePath(),
i.getStringExtra("args"),
i.getDataString());

@ -94,7 +94,28 @@ class GeckoAppShell
// MozAlloc
System.loadLibrary("mozalloc");
System.loadLibrary("mozutils");
Intent i = GeckoApp.mAppContext.getIntent();
String env = i.getStringExtra("env0");
Log.i("GeckoApp", "env0: "+ env);
for (int c = 1; env != null; c++) {
GeckoAppShell.putenv(env);
env = i.getStringExtra("env" + c);
Log.i("GeckoApp", "env"+ c +": "+ env);
}
String tmpdir = System.getProperty("java.io.tmpdir");
if (tmpdir == null) {
try {
File f = Environment.getDownloadCacheDirectory();
dalvik.system.TemporaryDirectory.setUpDirectory(f);
tmpdir = f.getPath();
} catch (Exception e) {
Log.e("GeckoApp", "error setting up tmp dir" + e);
}
}
GeckoAppShell.putenv("TMPDIR=" + tmpdir);
// NSPR
System.loadLibrary("nspr4");
System.loadLibrary("plc4");

@ -69,6 +69,8 @@ GARBAGE += \
GARBAGE_DIRS += res libs dist classes
DIRS = utils
# Bug 567884 - Need a way to find appropriate icons during packaging
ifeq ($(MOZ_APP_NAME),fennec)
ICON_PATH = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/fennec_48x48.png
@ -78,7 +80,7 @@ ICON_PATH = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/icon48.png
ICON_PATH_HI = $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/content/icon64.png
endif
NATIVE_LIBS = $(shell cat $(DIST)/bin/dependentlibs.list) libxpcom.so libnssckbi.so libfreebl3.so
NATIVE_LIBS = $(shell cat $(DIST)/bin/dependentlibs.list) libxpcom.so libnssckbi.so libfreebl3.so libmozutils.so
FULL_LIBS = $(addprefix libs/armeabi/,$(NATIVE_LIBS))
# We'll strip all the libs by default, due to size, but we might
@ -145,16 +147,16 @@ libs/armeabi/%: $(DIST)/lib/%
# Bug 567873 - Android packaging should use standard packaging code
dist: FORCE
$(NSINSTALL) -D dist/components
rm -f dist/components/*
@(for f in $(DIST)/bin/components/* ; do ln -sf ../../$$f dist/components ; done)
rm -rf dist/components/*
@(for f in $(DIST)/bin/components/* ; do $(NSINSTALL) $$f dist/components ; done)
$(NSINSTALL) -D dist/chrome
rm -f dist/chrome/*
@(for f in $(DIST)/bin/chrome/* ; do ln -sf ../../$$f dist/chrome ; done)
rm -rf dist/chrome/*
@(for f in $(DIST)/bin/chrome/* ; do $(NSINSTALL) $$f dist/chrome ; done)
$(NSINSTALL) -D dist/defaults
rm -f dist/defaults/*
@(for f in $(DIST)/bin/defaults/* ; do ln -sf ../../$$f dist/defaults ; done )
rm -rf dist/defaults/*
@(for f in $(DIST)/bin/defaults/* ; do $(NSINSTALL) $$f dist/defaults ; done )
@(for PREF in $(DIST)/bin/defaults/pref/*.js ; do cat "$$PREF" >> dist/defaults/prefs.js ; echo >> dist/defaults/prefs.js ; done )
rm dist/defaults/pref
rm -rf dist/defaults/pref
@(for f in $(DIST_LINK_FILES) ; do if [ -e $(DIST)/bin/$$f ] ; then echo $$f ; ln -sf ../$(DIST)/bin/$$f dist ; fi ; done)
gecko-unsigned-unaligned.apk: gecko.ap_ classes.dex dist $(FULL_LIBS)

@ -0,0 +1,50 @@
# ***** 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 the Mozilla browser.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Brad Lassey <blassey@mozilla.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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = mozutils
LIBRARY_NAME = mozutils
FORCE_SHARED_LIB = 1
CPPSRCS = nsGeckoUtils.cpp
include $(topsrcdir)/config/rules.mk

@ -0,0 +1,58 @@
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* ***** 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 Android code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brad Lassey <blassey@mozilla.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 <jni.h>
#include <stdlib.h>
extern "C" {
void JNICALL Java_org_mozilla_gecko_GeckoAppShell_putenv(JNIEnv *jenv, jclass, jstring map);
}
__attribute__ ((visibility("default")))
void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_putenv(JNIEnv *jenv, jclass, jstring map)
{
const char* str;
// XXX: java doesn't give us true UTF8, we should figure out something
// better to do here
str = jenv->GetStringUTFChars(map, NULL);
if (str == NULL)
return;
putenv(strdup(str));
jenv->ReleaseStringUTFChars(map, str);
}

@ -56,7 +56,6 @@ extern "C" {
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv *, jclass, jobject event);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_setSurfaceView(JNIEnv *jenv, jclass, jobject sv);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_setInitialSize(JNIEnv *jenv, jclass, int width, int height);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_putenv(JNIEnv *jenv, jclass, jstring map);
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_onResume(JNIEnv *, jclass);
}
@ -93,21 +92,6 @@ Java_org_mozilla_gecko_GeckoAppShell_setInitialSize(JNIEnv *jenv, jclass, int wi
nsWindow::SetInitialAndroidBounds(gfxIntSize(width, height));
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_putenv(JNIEnv *jenv, jclass, jstring map)
{
const char* str;
str = jenv->GetStringUTFChars(map, NULL);
if (str == NULL)
return;
#ifdef DEBUG
__android_log_print(ANDROID_LOG_INFO, "GeckoJNI", "putenv(%s)", str);
#endif
putenv(strdup(str));
jenv->ReleaseStringUTFChars(map, str);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_onResume(JNIEnv *jenv, jclass jc)
{