fix Android classpath build

Hopefully it will stay fixed this time, since we now specify commit
hashes for each dependency which are known to work.
This commit is contained in:
Joel Dice 2013-07-05 14:34:16 -06:00
parent a9d9bc5d20
commit 82577d742f
4 changed files with 120 additions and 15 deletions

View File

@ -357,36 +357,74 @@ the following, starting from the Avian directory:
cd .. cd ..
mkdir -p android/system android/external mkdir -p android/system android/external
cd android cd android
git clone https://android.googlesource.com/platform/bionic git clone https://android.googlesource.com/platform/bionic
(cd bionic && \
git checkout 84983592ade3ec7d72d082262fb6646849979bfc)
git clone https://android.googlesource.com/platform/system/core \ git clone https://android.googlesource.com/platform/system/core \
system/core system/core
git clone https://android.googlesource.com/platform/external/expat \ (cd system/core && \
external/expat git checkout fafcabd0dd4432de3c7f5956edec23f6ed241b56)
git clone https://android.googlesource.com/platform/external/fdlibm \ git clone https://android.googlesource.com/platform/external/fdlibm \
external/fdlibm external/fdlibm
(cd external/fdlibm && \
git checkout 0da5f683c9ddc9442af3b389b4220e91ccffb320)
git clone https://android.googlesource.com/platform/external/icu4c \ git clone https://android.googlesource.com/platform/external/icu4c \
external/icu4c external/icu4c
(cd external/icu4c && \
git checkout 8fd45e08f1054d80a356ef8aa05659a2ba84707c)
git clone https://android.googlesource.com/platform/libnativehelper git clone https://android.googlesource.com/platform/libnativehelper
(cd libnativehelper && \
git checkout cf5ac0ec696fce7fac6b324ec7d4d6da217e501c)
git clone https://android.googlesource.com/platform/external/openssl \ git clone https://android.googlesource.com/platform/external/openssl \
external/openssl external/openssl
(cd external/openssl && \
git checkout 7b972f1aa23172c4430ada7f3236fa1fd9b31756)
git clone https://android.googlesource.com/platform/external/zlib \ git clone https://android.googlesource.com/platform/external/zlib \
external/zlib external/zlib
(cd external/zlib && \
git checkout 15b6223aa57a347ce113729253802cb2fdeb4ad0)
git clone git://git.openssl.org/openssl.git openssl-upstream git clone git://git.openssl.org/openssl.git openssl-upstream
(cd openssl-upstream && \
git checkout OpenSSL_1_0_1e)
git clone https://github.com/dicej/android-libcore64 libcore git clone https://github.com/dicej/android-libcore64 libcore
curl -Of http://readytalk.github.io/avian/expat-2.1.0.tar.gz
(cd external && tar xzf ../expat-2.1.0.tar.gz && mv expat-2.1.0 expat)
(cd external/expat && CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure \ (cd external/expat && CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure \
--enable-static && make) --enable-static && make)
(cd external/fdlibm && (mv makefile.in Makefile.in || true) \ (cd external/fdlibm && (mv makefile.in Makefile.in || true) \
&& CFLAGS=-fPIC bash configure && make) && CFLAGS=-fPIC bash configure && make)
(cd external/icu4c && CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure \ (cd external/icu4c && CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure \
--enable-static && make) --enable-static && make)
NB: use 'CC="gcc -fPIC" ./Configure darwin64-x86_64-cc' when building NB: use 'CC="gcc -fPIC" ./Configure darwin64-x86_64-cc' when building
for x86_64 OS X instead of 'CC="gcc -fPIC" ./config': for x86_64 OS X instead of 'CC="gcc -fPIC" ./config':
(cd openssl-upstream && git checkout OpenSSL_1_0_1e \ (cd openssl-upstream \
&& (for x in ../external/openssl/patches/*.patch; \ && (for x in \
do patch -p1 < $x; done) \ progs \
handshake_cutthrough \
jsse \
channelid \
eng_dyn_dirs \
fix_clang_build \
tls12_digests \
alpn; \
do patch -p1 < ../external/openssl/patches/$x.patch; done) \
&& CC="gcc -fPIC" ./config && make) && CC="gcc -fPIC" ./config && make)
cd ../avian cd ../avian
make android=$(pwd)/../android test make android=$(pwd)/../android test
@ -403,6 +441,10 @@ against OpenSSL 1.0.1e, so that's the tag we check out, but this may
change in the future when the Android fork rebases against a new change in the future when the Android fork rebases against a new
OpenSSL version. OpenSSL version.
Finally, we specify specific commit hashes for each repository which
are known to work. Later versions may also work, but have not been
tested.
Installing Installing
---------- ----------

View File

@ -168,11 +168,20 @@ ifneq ($(android),)
-I$(build)/android-src \ -I$(build)/android-src \
-fno-exceptions \ -fno-exceptions \
-D_FILE_OFFSET_BITS=64 \ -D_FILE_OFFSET_BITS=64 \
-DOS_SHARED_LIB_FORMAT_STR="\"$(so-prefix)%s$(so-suffix)\"" \
-DJNI_JARJAR_PREFIX= \
-g3 \ -g3 \
-Werror -Werror
luni-cpps := $(shell find $(luni-native) -name '*.cpp') luni-cpps := $(shell find $(luni-native) -name '*.cpp')
libnativehelper-native := $(android)/libnativehelper
libnativehelper-cpps := $(libnativehelper-native)/JniConstants.cpp \
$(libnativehelper-native)/toStringArray.cpp
crypto-native := $(android)/libcore/crypto/src/main/native
crypto-cpps := $(crypto-native)/org_conscrypt_NativeCrypto.cpp
ifeq ($(platform),windows) ifeq ($(platform),windows)
android-cflags += -D__STDC_CONSTANT_MACROS android-cflags += -D__STDC_CONSTANT_MACROS
ifneq ($(arch),i386) ifneq ($(arch),i386)
@ -206,18 +215,27 @@ ifneq ($(android),)
$(android)/openssl-upstream/libssl.a \ $(android)/openssl-upstream/libssl.a \
$(android)/openssl-upstream/libcrypto.a \ $(android)/openssl-upstream/libcrypto.a \
$(platform-lflags) \ $(platform-lflags) \
-lrt \
-lstdc++ -lstdc++
classpath-objects = \ classpath-objects = \
$(call cpp-objects,$(luni-cpps),$(luni-native),$(build)) $(call cpp-objects,$(luni-cpps),$(luni-native),$(build)) \
$(call cpp-objects,$(crypto-cpps),$(crypto-native),$(build)) \
$(call cpp-objects,$(libnativehelper-cpps),$(libnativehelper-native),$(build))
luni-java = $(android)/libcore/luni/src/main/java luni-java = $(android)/libcore/luni/src/main/java
luni-javas := $(shell find $(luni-java) -name '*.java') luni-javas := $(shell find $(luni-java) -name '*.java')
libdvm-java = $(android)/libcore/libdvm/src/main/java
libdvm-javas := $(shell find $(libdvm-java) -name '*.java')
crypto-java = $(android)/libcore/crypto/src/main/java
crypto-javas := $(shell find $(crypto-java) -name '*.java')
dalvik-java = $(android)/libcore/dalvik/src/main/java dalvik-java = $(android)/libcore/dalvik/src/main/java
dalvik-javas := $(shell find $(dalvik-java) -name '*.java') dalvik-javas := $(shell find $(dalvik-java) -name '*.java')
xml-java = $(android)/libcore/xml/src/main/java xml-java = $(android)/libcore/xml/src/main/java
xml-javas := $(shell find $(xml-java) -name '*.java') xml-javas := $(shell find $(xml-java) -name '*.java')
android-classes = \ android-classes = \
$(call java-classes,$(luni-javas),$(luni-java),$(build)/android) \ $(call java-classes,$(luni-javas),$(luni-java),$(build)/android) \
$(call java-classes,$(libdvm-javas),$(libdvm-java),$(build)/android) \
$(call java-classes,$(crypto-javas),$(crypto-java),$(build)/android) \
$(call java-classes,$(dalvik-javas),$(dalvik-java),$(build)/android) \ $(call java-classes,$(dalvik-javas),$(dalvik-java),$(build)/android) \
$(call java-classes,$(xml-javas),$(xml-java),$(build)/android) $(call java-classes,$(xml-javas),$(xml-java),$(build)/android)
classpath = android classpath = android
@ -1466,13 +1484,20 @@ $(classpath-dep): $(classpath-sources) $(classpath-jar-dep)
$(build)/android-src/%.cpp: $(luni-native)/%.cpp $(build)/android-src/%.cpp: $(luni-native)/%.cpp
cp $(<) $(@) cp $(<) $(@)
$(build)/android-src/%.cpp: $(libnativehelper-native)/%.cpp
cp $(<) $(@)
$(build)/android-src/%.cpp: $(crypto-native)/%.cpp
cp $(<) $(@)
$(build)/%.o: $(build)/android-src/%.cpp $(build)/android.dep $(build)/%.o: $(build)/android-src/%.cpp $(build)/android.dep
@echo "compiling $(@)" @echo "compiling $(@)"
@mkdir -p $(dir $(@)) @mkdir -p $(dir $(@))
$(cxx) $(android-cflags) $(classpath-extra-cflags) -c \ $(cxx) $(android-cflags) $(classpath-extra-cflags) -c \
$$($(windows-path) $(<)) $(call output,$(@)) $$($(windows-path) $(<)) $(call output,$(@))
$(build)/android.dep: $(luni-javas) $(dalvik-javas) $(xml-javas) $(build)/android.dep: $(luni-javas) $(libdvm-javas) $(crypto-javas) \
$(dalvik-javas) $(xml-javas)
@echo "compiling luni classes" @echo "compiling luni classes"
@mkdir -p $(classpath-build) @mkdir -p $(classpath-build)
@mkdir -p $(build)/android @mkdir -p $(build)/android
@ -1480,7 +1505,8 @@ $(build)/android.dep: $(luni-javas) $(dalvik-javas) $(xml-javas)
@mkdir -p $(build)/android-src/libexpat @mkdir -p $(build)/android-src/libexpat
cp $(android)/external/fdlibm/fdlibm.h $(build)/android-src/external/fdlibm/ cp $(android)/external/fdlibm/fdlibm.h $(build)/android-src/external/fdlibm/
cp $(android)/external/expat/lib/expat*.h $(build)/android-src/libexpat/ cp $(android)/external/expat/lib/expat*.h $(build)/android-src/libexpat/
cp -a $(luni-java)/* $(dalvik-java)/* $(xml-java)/* $(build)/android-src/ cp -a $(luni-java)/* $(libdvm-java)/* $(crypto-java)/* $(dalvik-java)/* \
$(xml-java)/* $(build)/android-src/
sed -i -e 's/return ordinal - o.ordinal;/return ordinal - o.ordinal();/' \ sed -i -e 's/return ordinal - o.ordinal;/return ordinal - o.ordinal();/' \
$(build)/android-src/java/lang/Enum.java $(build)/android-src/java/lang/Enum.java
find $(build)/android-src -name '*.java' > $(build)/android.txt find $(build)/android-src -name '*.java' > $(build)/android.txt

View File

@ -4,3 +4,15 @@ extern "C" int JNI_OnLoad(JavaVM*, void*)
{ {
return 0; return 0;
} }
struct _JNIEnv;
struct JniConstants {
static void init(_JNIEnv* env);
};
void
JniConstants::init(_JNIEnv*)
{
// ignore
}

View File

@ -9,6 +9,11 @@
details. */ details. */
struct JavaVM; struct JavaVM;
struct _JNIEnv;
struct JniConstants {
static void init(_JNIEnv* env);
};
extern "C" int JNI_OnLoad(JavaVM*, void*); extern "C" int JNI_OnLoad(JavaVM*, void*);
@ -20,6 +25,10 @@ extern "C" int JNI_OnLoad(JavaVM*, void*);
using namespace vm; using namespace vm;
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_Classes_defineVMClass
(Thread*, object, uintptr_t*);
namespace { namespace {
namespace local { namespace local {
@ -60,6 +69,22 @@ appLoader(Thread* t, object, uintptr_t*)
return reinterpret_cast<uintptr_t>(root(t, Machine::AppLoader)); return reinterpret_cast<uintptr_t>(root(t, Machine::AppLoader));
} }
int64_t JNICALL
defineClass(Thread* t, object method, uintptr_t* arguments)
{
uintptr_t args[]
= { arguments[0], arguments[2], arguments[3], arguments[4] };
int64_t v = Avian_avian_Classes_defineVMClass(t, method, args);
if (v) {
return reinterpret_cast<uintptr_t>
(getJClass(t, reinterpret_cast<object>(v)));
} else {
return 0;
}
}
int64_t JNICALL int64_t JNICALL
mapData(Thread*, object, uintptr_t*); mapData(Thread*, object, uintptr_t*);
@ -383,6 +408,10 @@ class MyClasspath : public Classpath {
intercept(t, c, "createSystemClassLoader", "()Ljava/lang/ClassLoader;", intercept(t, c, "createSystemClassLoader", "()Ljava/lang/ClassLoader;",
voidPointer(appLoader), updateRuntimeData); voidPointer(appLoader), updateRuntimeData);
intercept(t, c, "defineClass",
"(Ljava/lang/String;[BII)Ljava/lang/Class;",
voidPointer(defineClass), updateRuntimeData);
} }
} }
@ -429,6 +458,8 @@ class MyClasspath : public Classpath {
interceptMethods(t, true); interceptMethods(t, true);
JniConstants::init(reinterpret_cast<_JNIEnv*>(t));
JNI_OnLoad(reinterpret_cast< ::JavaVM*>(t->m), 0); JNI_OnLoad(reinterpret_cast< ::JavaVM*>(t->m), 0);
} }
@ -714,8 +745,6 @@ jniCreateFileDescriptor(JNIEnv* e, int fd)
return descriptor; return descriptor;
} }
struct _JNIEnv;
int int
register_org_apache_harmony_dalvik_NativeTestTarget(_JNIEnv*) register_org_apache_harmony_dalvik_NativeTestTarget(_JNIEnv*)
{ {
@ -949,10 +978,6 @@ Avian_java_lang_VMClassLoader_findLoadedClass
} }
} }
extern "C" JNIEXPORT int64_t JNICALL
Avian_avian_Classes_defineVMClass
(Thread*, object, uintptr_t*);
extern "C" JNIEXPORT int64_t JNICALL extern "C" JNIEXPORT int64_t JNICALL
Avian_java_lang_VMClassLoader_defineClass__Ljava_lang_ClassLoader_2Ljava_lang_String_2_3BII Avian_java_lang_VMClassLoader_defineClass__Ljava_lang_ClassLoader_2Ljava_lang_String_2_3BII
(Thread* t, object method, uintptr_t* arguments) (Thread* t, object method, uintptr_t* arguments)