From c06dd28ea0a838575b0764d1238cceaa40923f84 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 31 Jul 2013 15:20:32 -0700 Subject: [PATCH] fix Android classpath build for iOS This mainly involved reworking the makefile to avoid conflating Darwin/ARM builds with iOS, since we may also want to build for the iOS Simulator, which is i386. Note that I was only able to test this on the Simulator, since I don't have a real iOS device to test with. Sorry if I broke something; if so, please fix it :) --- makefile | 77 ++++++++++++++++++++++++--------------- src/classpath-android.cpp | 2 +- 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/makefile b/makefile index 72170bfd35..2f4cea3677 100755 --- a/makefile +++ b/makefile @@ -170,6 +170,7 @@ ifneq ($(android),) -D_FILE_OFFSET_BITS=64 \ -DOS_SHARED_LIB_FORMAT_STR="\"$(so-prefix)%s$(so-suffix)\"" \ -DJNI_JARJAR_PREFIX= \ + -D__DARWIN_UNIX03=1 \ -g3 \ -Werror @@ -445,19 +446,7 @@ ifeq ($(arch),arm) endif ifneq ($(arch),$(build-arch)) - ifeq ($(platform),darwin) - ios-bin = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/usr/bin - ifeq ($(use-clang),true) - cxx = clang -std=c++11 - cc = clang - else - cxx = $(ios-bin)/g++ - cc = $(ios-bin)/gcc - endif - ar = $(ios-bin)/ar - ranlib = $(ios-bin)/ranlib - strip = $(ios-bin)/strip - else + ifneq ($(platform),darwin) cxx = arm-linux-gnueabi-g++ cc = arm-linux-gnueabi-gcc ar = arm-linux-gnueabi-ar @@ -616,24 +605,53 @@ ifeq ($(platform),darwin) shared = -dynamiclib rpath = - sdk-dir = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/SDKs - - ifeq ($(arch),arm) - ios-version := \ - $(shell if test -d $(sdk-dir)/iPhoneOS6.1.sdk; then echo 6.1; \ - elif test -d $(sdk-dir)/iPhoneOS6.0.sdk; then echo 6.0; \ - elif test -d $(sdk-dir)/iPhoneOS5.1.sdk; then echo 5.1; \ - elif test -d $(sdk-dir)/iPhoneOS5.0.sdk; then echo 5.0; \ - elif test -d $(sdk-dir)/iPhoneOS4.3.sdk; then echo 4.3; \ - elif test -d $(sdk-dir)/iPhoneOS4.2.sdk; then echo 4.2; \ - else echo; fi) - - ifeq ($(ios-version),) - x := $(error "couldn't find SDK for iOS version") + ifeq ($(ios),true) + ifeq ($(arch),i386) + target = iPhoneSimulator + sdk = iphonesimulator$(ios-version) + arch = i386 + arch-flag = -arch i386 + release = Release-iphonesimulator + else + target = iPhoneOS + sdk = iphoneos$(ios-version) + arch = arm + arch-flag = -arch armv7 + release = Release-iphoneos endif - flags = -arch armv7 -isysroot \ - $(sdk-dir)/iPhoneOS$(ios-version).sdk/ + platform-dir = $(developer-dir)/Platforms/$(target).platform + sdk-dir = $(platform-dir)/Developer/SDKs + + ios-version := $(shell \ + if test -d $(sdk-dir)/$(target)6.1.sdk; then echo 6.1; \ + elif test -d $(sdk-dir)/$(target)6.0.sdk; then echo 6.0; \ + elif test -d $(sdk-dir)/$(target)5.1.sdk; then echo 5.1; \ + elif test -d $(sdk-dir)/$(target)5.0.sdk; then echo 5.0; \ + elif test -d $(sdk-dir)/$(target)4.3.sdk; then echo 4.3; \ + elif test -d $(sdk-dir)/$(target)4.2.sdk; then echo 4.2; \ + else echo; fi) + + ifeq ($(ios-version),) + x := $(error "couldn't find SDK") + endif + + ios-bin = $(platform-dir)/Developer/usr/bin + + ifeq ($(use-clang),true) + cxx = clang -std=c++11 + cc = clang + else + cxx = $(ios-bin)/g++ + cc = $(ios-bin)/gcc + endif + ar = $(ios-bin)/ar + ranlib = $(ios-bin)/ranlib + strip = $(ios-bin)/strip + + flags = -isysroot $(sdk-dir)/$(target)$(ios-version).sdk \ + $(arch-flag) + classpath-extra-cflags += $(flags) cflags += $(flags) asmflags += $(flags) @@ -1811,6 +1829,7 @@ $(audit-codegen-executable): $(audit-codegen-executable-objects) $(bootimage-generator): $(bootimage-generator-objects) $(vm-objects) echo building $(bootimage-generator) arch=$(build-arch) platform=$(bootimage-platform) $(MAKE) mode=$(mode) \ + ios=false \ build=$(host-build-root) \ arch=$(build-arch) \ aot-only=false \ diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index e669125500..f4b83c324d 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -452,7 +452,7 @@ class MyClasspath : public Classpath { // LD_LIBRARY_PATH is not set as of this writing: #ifdef PLATFORM_WINDOWS _wputenv(L"LD_LIBRARY_PATH=(dummy)"); -#else +#elif (! defined AVIAN_IOS) setenv("LD_LIBRARY_PATH", "", false); #endif