Bug 695843 part 10 - Allow nested omni.jar and build one for Android. r=bsmedberg

This commit is contained in:
Mike Hommey 2011-12-08 11:03:36 +01:00
parent 9b0673934e
commit ce0123f5fb
2 changed files with 17 additions and 6 deletions

View File

@ -260,9 +260,6 @@ endif #Create an RPM file
ifeq ($(MOZ_PKG_FORMAT),APK)
# we have custom stuff for Android
MOZ_OMNIJAR =
JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
include $(topsrcdir)/config/android-common.mk
@ -346,7 +343,8 @@ INNER_MAKE_PACKAGE = \
done && \
unzip -o $(_ABS_DIST)/gecko.ap_ && \
rm $(_ABS_DIST)/gecko.ap_ && \
$(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) ) && \
$(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) && \
$(ZIP) -0 $(_ABS_DIST)/gecko.ap_ $(OMNIJAR_NAME)) && \
rm -f $(_ABS_DIST)/gecko.apk && \
$(APKBUILDER) $(_ABS_DIST)/gecko.apk -v $(APKBUILDER_FLAGS) -z $(_ABS_DIST)/gecko.ap_ -f $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \
cp $(_ABS_DIST)/gecko.apk $(_ABS_DIST)/gecko-unsigned-unaligned.apk && \

View File

@ -51,6 +51,7 @@ nsIFile *Omnijar::sPath[2] = { nsnull, nsnull };
nsZipArchive *Omnijar::sReader[2] = { nsnull, nsnull };
bool Omnijar::sInitialized = false;
static bool sIsUnified = false;
static bool sIsNested[2] = { false, false };
static const char *sProp[2] =
{ NS_GRE_DIR, NS_XPCOM_CURRENT_PROCESS_DIR };
@ -111,6 +112,14 @@ Omnijar::InitOne(nsIFile *aPath, Type aType)
return;
}
nsRefPtr<nsZipHandle> handle;
if (NS_SUCCEEDED(nsZipHandle::Init(zipReader, NS_STRINGIFY(OMNIJAR_NAME), getter_AddRefs(handle)))) {
zipReader = new nsZipArchive();
if (NS_FAILED(zipReader->OpenArchive(handle)))
return;
sIsNested[aType] = true;
}
CleanUpOne(aType);
sReader[aType] = zipReader;
NS_IF_ADDREF(sReader[aType]);
@ -142,12 +151,12 @@ Omnijar::GetReader(nsIFile *aPath)
bool equals;
nsresult rv;
if (sPath[GRE]) {
if (sPath[GRE] && !sIsNested[GRE]) {
rv = sPath[GRE]->Equals(aPath, &equals);
if (NS_SUCCEEDED(rv) && equals)
return GetReader(GRE);
}
if (sPath[APP]) {
if (sPath[APP] && !sIsNested[APP]) {
rv = sPath[APP]->Equals(aPath, &equals);
if (NS_SUCCEEDED(rv) && equals)
return GetReader(APP);
@ -173,8 +182,12 @@ Omnijar::GetURIString(Type aType, nsACString &result)
NS_ENSURE_SUCCESS(rv, rv);
result = "jar:";
if (sIsNested[aType])
result += "jar:";
result += omniJarSpec;
result += "!";
if (sIsNested[aType])
result += "/" NS_STRINGIFY(OMNIJAR_NAME) "!";
} else {
nsCOMPtr<nsIFile> dir;
nsDirectoryService::gService->Get(SPROP(aType), NS_GET_IID(nsIFile), getter_AddRefs(dir));