mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
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:
parent
a9d9bc5d20
commit
82577d742f
52
README.md
52
README.md
@ -357,36 +357,74 @@ the following, starting from the Avian directory:
|
||||
cd ..
|
||||
mkdir -p android/system android/external
|
||||
cd android
|
||||
|
||||
git clone https://android.googlesource.com/platform/bionic
|
||||
(cd bionic && \
|
||||
git checkout 84983592ade3ec7d72d082262fb6646849979bfc)
|
||||
|
||||
git clone https://android.googlesource.com/platform/system/core \
|
||||
system/core
|
||||
git clone https://android.googlesource.com/platform/external/expat \
|
||||
external/expat
|
||||
(cd system/core && \
|
||||
git checkout fafcabd0dd4432de3c7f5956edec23f6ed241b56)
|
||||
|
||||
git clone https://android.googlesource.com/platform/external/fdlibm \
|
||||
external/fdlibm
|
||||
(cd external/fdlibm && \
|
||||
git checkout 0da5f683c9ddc9442af3b389b4220e91ccffb320)
|
||||
|
||||
git clone https://android.googlesource.com/platform/external/icu4c \
|
||||
external/icu4c
|
||||
(cd external/icu4c && \
|
||||
git checkout 8fd45e08f1054d80a356ef8aa05659a2ba84707c)
|
||||
|
||||
git clone https://android.googlesource.com/platform/libnativehelper
|
||||
(cd libnativehelper && \
|
||||
git checkout cf5ac0ec696fce7fac6b324ec7d4d6da217e501c)
|
||||
|
||||
git clone https://android.googlesource.com/platform/external/openssl \
|
||||
external/openssl
|
||||
(cd external/openssl && \
|
||||
git checkout 7b972f1aa23172c4430ada7f3236fa1fd9b31756)
|
||||
|
||||
git clone https://android.googlesource.com/platform/external/zlib \
|
||||
external/zlib
|
||||
(cd external/zlib && \
|
||||
git checkout 15b6223aa57a347ce113729253802cb2fdeb4ad0)
|
||||
|
||||
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
|
||||
|
||||
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 \
|
||||
--enable-static && make)
|
||||
|
||||
(cd external/fdlibm && (mv makefile.in Makefile.in || true) \
|
||||
&& CFLAGS=-fPIC bash configure && make)
|
||||
|
||||
(cd external/icu4c && CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure \
|
||||
--enable-static && make)
|
||||
|
||||
NB: use 'CC="gcc -fPIC" ./Configure darwin64-x86_64-cc' when building
|
||||
for x86_64 OS X instead of 'CC="gcc -fPIC" ./config':
|
||||
|
||||
(cd openssl-upstream && git checkout OpenSSL_1_0_1e \
|
||||
&& (for x in ../external/openssl/patches/*.patch; \
|
||||
do patch -p1 < $x; done) \
|
||||
(cd openssl-upstream \
|
||||
&& (for x in \
|
||||
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)
|
||||
|
||||
cd ../avian
|
||||
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
|
||||
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
|
||||
----------
|
||||
|
34
makefile
34
makefile
@ -168,10 +168,19 @@ ifneq ($(android),)
|
||||
-I$(build)/android-src \
|
||||
-fno-exceptions \
|
||||
-D_FILE_OFFSET_BITS=64 \
|
||||
-DOS_SHARED_LIB_FORMAT_STR="\"$(so-prefix)%s$(so-suffix)\"" \
|
||||
-DJNI_JARJAR_PREFIX= \
|
||||
-g3 \
|
||||
-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)
|
||||
android-cflags += -D__STDC_CONSTANT_MACROS
|
||||
@ -206,18 +215,27 @@ ifneq ($(android),)
|
||||
$(android)/openssl-upstream/libssl.a \
|
||||
$(android)/openssl-upstream/libcrypto.a \
|
||||
$(platform-lflags) \
|
||||
-lrt \
|
||||
-lstdc++
|
||||
|
||||
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-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-javas := $(shell find $(dalvik-java) -name '*.java')
|
||||
xml-java = $(android)/libcore/xml/src/main/java
|
||||
xml-javas := $(shell find $(xml-java) -name '*.java')
|
||||
android-classes = \
|
||||
$(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,$(xml-javas),$(xml-java),$(build)/android)
|
||||
classpath = android
|
||||
@ -1466,13 +1484,20 @@ $(classpath-dep): $(classpath-sources) $(classpath-jar-dep)
|
||||
$(build)/android-src/%.cpp: $(luni-native)/%.cpp
|
||||
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
|
||||
@echo "compiling $(@)"
|
||||
@mkdir -p $(dir $(@))
|
||||
$(cxx) $(android-cflags) $(classpath-extra-cflags) -c \
|
||||
$$($(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"
|
||||
@mkdir -p $(classpath-build)
|
||||
@mkdir -p $(build)/android
|
||||
@ -1480,7 +1505,8 @@ $(build)/android.dep: $(luni-javas) $(dalvik-javas) $(xml-javas)
|
||||
@mkdir -p $(build)/android-src/libexpat
|
||||
cp $(android)/external/fdlibm/fdlibm.h $(build)/android-src/external/fdlibm/
|
||||
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();/' \
|
||||
$(build)/android-src/java/lang/Enum.java
|
||||
find $(build)/android-src -name '*.java' > $(build)/android.txt
|
||||
|
@ -4,3 +4,15 @@ extern "C" int JNI_OnLoad(JavaVM*, void*)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct _JNIEnv;
|
||||
|
||||
struct JniConstants {
|
||||
static void init(_JNIEnv* env);
|
||||
};
|
||||
|
||||
void
|
||||
JniConstants::init(_JNIEnv*)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
@ -9,6 +9,11 @@
|
||||
details. */
|
||||
|
||||
struct JavaVM;
|
||||
struct _JNIEnv;
|
||||
|
||||
struct JniConstants {
|
||||
static void init(_JNIEnv* env);
|
||||
};
|
||||
|
||||
extern "C" int JNI_OnLoad(JavaVM*, void*);
|
||||
|
||||
@ -20,6 +25,10 @@ extern "C" int JNI_OnLoad(JavaVM*, void*);
|
||||
|
||||
using namespace vm;
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_avian_Classes_defineVMClass
|
||||
(Thread*, object, uintptr_t*);
|
||||
|
||||
namespace {
|
||||
|
||||
namespace local {
|
||||
@ -60,6 +69,22 @@ appLoader(Thread* t, object, uintptr_t*)
|
||||
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
|
||||
mapData(Thread*, object, uintptr_t*);
|
||||
|
||||
@ -383,6 +408,10 @@ class MyClasspath : public Classpath {
|
||||
|
||||
intercept(t, c, "createSystemClassLoader", "()Ljava/lang/ClassLoader;",
|
||||
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);
|
||||
|
||||
JniConstants::init(reinterpret_cast<_JNIEnv*>(t));
|
||||
|
||||
JNI_OnLoad(reinterpret_cast< ::JavaVM*>(t->m), 0);
|
||||
}
|
||||
|
||||
@ -714,8 +745,6 @@ jniCreateFileDescriptor(JNIEnv* e, int fd)
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
struct _JNIEnv;
|
||||
|
||||
int
|
||||
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
|
||||
Avian_java_lang_VMClassLoader_defineClass__Ljava_lang_ClassLoader_2Ljava_lang_String_2_3BII
|
||||
(Thread* t, object method, uintptr_t* arguments)
|
||||
|
Loading…
Reference in New Issue
Block a user