From a794294985647a4a31ca9d62bc37cfb869ac636c Mon Sep 17 00:00:00 2001 From: Ilya Mizus Date: Sun, 23 Nov 2014 12:55:09 +0300 Subject: [PATCH 1/2] Makefile improvement to support okhttp, and Bouncy Castle for Android version --- makefile | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/makefile b/makefile index dc2b9dc717..c429698294 100755 --- a/makefile +++ b/makefile @@ -343,13 +343,35 @@ ifneq ($(android),) xml-java = $(android)/libcore/xml/src/main/java xml-javas := $(shell find $(xml-java) -name '*.java') + + okhttp-android-java = $(android)/external/okhttp/android/main/java + okhttp-android-javas := $(shell find $(okhttp-android-java) -name '*.java') + + okhttp-java = $(android)/external/okhttp/okhttp/src/main/java + okhttp-javas := $(shell find $(okhttp-java) -name '*.java') + + okio-java = $(android)/external/okhttp/okio/src/main/java + okio-javas := $(shell find $(okio-java) -name '*.java') + + bcpkix-java = $(android)/external/bouncycastle/bcpkix/src/main/java + bcpkix-javas := $(shell find $(bcpkix-java) -name '*.java') + + bcprov-java = $(android)/external/bouncycastle/bcprov/src/main/java + bcprov-javas := $(shell find $(bcprov-java) -name '*.java') + android-classes = \ $(call java-classes,$(luni-javas),$(luni-java),$(build)/android) \ $(call java-classes,$(crypto-javas),$(crypto-java),$(build)/android) \ $(call java-classes,$(crypto-platform-javas),$(crypto-platform-java),$(build)/android) \ $(call java-classes,$(dalvik-javas),$(dalvik-java),$(build)/android) \ $(call java-classes,$(libart-javas),$(libart-java),$(build)/android) \ - $(call java-classes,$(xml-javas),$(xml-java),$(build)/android) + $(call java-classes,$(xml-javas),$(xml-java),$(build)/android) \ + $(call java-classes,$(okhttp-javas),$(okhttp-java),$(build)/android) \ + $(call java-classes,$(okhttp-android-javas),$(okhttp-android-java),$(build)/android) \ + $(call java-classes,$(okio-javas),$(okio-java),$(build)/android) \ + $(call java-classes,$(bcpkix-javas),$(bcpkix-java),$(build)/android) \ + $(call java-classes,$(bcprov-javas),$(bcprov-java),$(build)/android) + classpath = android javahome-files = tzdata @@ -1665,7 +1687,8 @@ $(build)/%.o: $(build)/android-src/%.cpp $(build)/android.dep $$($(windows-path) $(<)) $(call output,$(@)) $(build)/android.dep: $(luni-javas) $(dalvik-javas) $(libart-javas) \ - $(xml-javas) $(luni-nonjavas) $(crypto-javas) $(crypto-platform-javas) + $(xml-javas) $(okhttp-android-javas) $(okhttp-javas) $(okio-javas) \ + $(bcpkix-javas) $(bcprov-javas) $(luni-nonjavas) $(crypto-javas) $(crypto-platform-javas) @echo "compiling luni classes" @mkdir -p $(classpath-build) @mkdir -p $(build)/android @@ -1673,7 +1696,7 @@ $(build)/android.dep: $(luni-javas) $(dalvik-javas) $(libart-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)/* $(xml-java)/* $(build)/android-src/ + cp -a $(luni-java)/* $(xml-java)/* $(okhttp-android-java)/* $(okhttp-java)/* $(okio-java)/* $(bcpkix-java)/* $(bcprov-java)/* $(build)/android-src/ rm $(call noop-files,$(luni-blacklist),$(luni-java),$(build)/android-src) (cd $(dalvik-java) && \ $(jar) c $(call noop-files,$(dalvik-javas),$(dalvik-java),.)) \ From aeb87ffd126eca7cfe082b6accd856f033701fc5 Mon Sep 17 00:00:00 2001 From: Ilya Mizus Date: Sat, 17 Jan 2015 18:54:24 +0300 Subject: [PATCH 2/2] Instructions for Building with Android classpath --- README.md | 92 +++---------------------------------------------------- 1 file changed, 4 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 9277db18db..8051aaaf84 100644 --- a/README.md +++ b/README.md @@ -353,93 +353,14 @@ but have not yet been tested. Building with the Android Class Library --------------------------------------- - As an alternative to both the Avian and OpenJDK class libaries, you -can also build with the Android class library on some platforms -(currently Linux works and OS X mostly works). To build this way, do -the following, starting from the Avian directory: +can also build with the Android class library. Now it should work on Linux, OS X and Windows. - cd .. - mkdir -p android/system android/external - cd android +The simpliest way to build Avian with Android classpath is to use `avian-pack` project: https://github.com/bigfatbrowncat/avian-pack - git clone https://android.googlesource.com/platform/bionic - (cd bionic && \ - git checkout 84983592ade3ec7d72d082262fb6646849979bfc) +Avian-pack consists of Avian itself with some Android components (such as libcore and icu4c). - git clone https://android.googlesource.com/platform/system/core \ - system/core - (cd system/core && \ - git checkout 373c77583f9d8eab88e4321d1a2e2af8f5ae8ea7) - - 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 e5311394ca22b280da41cd17059288dab3fb1ea6) - - git clone https://android.googlesource.com/platform/libnativehelper - (cd libnativehelper && \ - git checkout b14825c7c75420049e03849994265be651cc4a4e) - - git clone https://android.googlesource.com/platform/external/openssl \ - external/openssl - (cd external/openssl && \ - git checkout 1417357d893849c4b6afdd98c32b6ca1b4b19a8b) - - git clone https://android.googlesource.com/platform/external/zlib \ - external/zlib - (cd external/zlib && \ - git checkout 15b6223aa57a347ce113729253802cb2fdeb4ad0) - - git clone https://github.com/dicej/android-conscrypt external/conscrypt - (cd external/conscrypt && \ - git checkout a96719f834232634e9160873bd4c44834b84eb15) - - git clone git://git.openssl.org/openssl.git openssl-upstream - (cd openssl-upstream && git checkout OpenSSL_1_0_1h) - - git clone https://github.com/dicej/android-libcore64 libcore - (cd libcore && \ - git checkout 69a1fd8623b85f978ead36dcf1c6c78c5ff79932) - - curl -Of http://oss.readytalk.com/avian-web/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 \ - && (for x in ../external/openssl/patches/*.patch; \ - do patch -p1 < $x; done) \ - && CC="gcc -fPIC" ./config && make) - - cd ../avian - make android=$(pwd)/../android test - -Note that we use https://github.com/dicej/android-libcore64 above -instead of the upstream -https://android.googlesource.com/platform/libcore repository, since -the former has patches to provide better support for non-Linux -platforms. We have also forked -https://android.googlesource.com/platform/external/conscrypt as -https://github.com/dicej/android-conscrypt to patch that project as -well. - -Also note that we use the upstream OpenSSL repository and apply the +Note that we use the upstream OpenSSL repository and apply the Android patches to it. This is because it is not clear how to build the Android fork of OpenSSL directly without checking out and building the entire platform. As of this writing, the patches apply cleanly @@ -447,11 +368,6 @@ against OpenSSL 1.0.1h, 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 ----------