This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
forked from rave-engine/python3-android
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build against the new unified toolchain in NDK r19
Ref: android/ndk#780
- Loading branch information
Chih-Hsuan Yen
authored and
Chih-Hsuan Yen
committed
Dec 8, 2018
1 parent
4095136
commit c8cc5a5
Showing
6 changed files
with
260 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
diff --git a/Configurations/15-android.conf b/Configurations/15-android.conf | ||
index 10342ed5e3..9c9ceb64df 100644 | ||
--- a/Configurations/15-android.conf | ||
+++ b/Configurations/15-android.conf | ||
@@ -3,147 +3,6 @@ | ||
# See NOTES.ANDROID for details, and don't miss platform-specific | ||
# comments below... | ||
|
||
-{ | ||
- use File::Spec::Functions; | ||
- | ||
- my $android_ndk = {}; | ||
- my %triplet = ( | ||
- arm => "arm-linux-androideabi", | ||
- arm64 => "aarch64-linux-android", | ||
- mips => "mipsel-linux-android", | ||
- mips64 => "mips64el-linux-android", | ||
- x86 => "i686-linux-android", | ||
- x86_64 => "x86_64-linux-android", | ||
- ); | ||
- | ||
- sub android_ndk { | ||
- unless (%$android_ndk) { | ||
- if ($now_printing =~ m|^android|) { | ||
- return $android_ndk = { bn_ops => "BN_AUTO" }; | ||
- } | ||
- | ||
- my $ndk = $ENV{ANDROID_NDK}; | ||
- die "\$ANDROID_NDK is not defined" if (!$ndk); | ||
- if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") { | ||
- # $ndk/platforms is traditional "all-inclusive" NDK, while | ||
- # $ndk/AndroidVersion.txt is so-called standalone toolchain | ||
- # tailored for specific target down to API level. | ||
- die "\$ANDROID_NDK=$ndk is invalid"; | ||
- } | ||
- $ndk = canonpath($ndk); | ||
- | ||
- my $ndkver = undef; | ||
- | ||
- if (open my $fh, "<$ndk/source.properties") { | ||
- local $_; | ||
- while(<$fh>) { | ||
- if (m|Pkg\.Revision\s*=\s*([0-9]+)|) { | ||
- $ndkver = $1; | ||
- last; | ||
- } | ||
- } | ||
- close $fh; | ||
- } | ||
- | ||
- my ($sysroot, $api, $arch); | ||
- | ||
- $config{target} =~ m|[^-]+-([^-]+)$|; # split on dash | ||
- $arch = $1; | ||
- | ||
- if ($sysroot = $ENV{CROSS_SYSROOT}) { | ||
- $sysroot =~ m|/android-([0-9]+)/arch-(\w+)/?$|; | ||
- ($api, $arch) = ($1, $2); | ||
- } elsif (-f "$ndk/AndroidVersion.txt") { | ||
- $sysroot = "$ndk/sysroot"; | ||
- } else { | ||
- $api = "*"; | ||
- | ||
- # see if user passed -D__ANDROID_API__=N | ||
- foreach (@{$useradd{CPPDEFINES}}, @{$user{CPPFLAGS}}) { | ||
- if (m|__ANDROID_API__=([0-9]+)|) { | ||
- $api = $1; | ||
- last; | ||
- } | ||
- } | ||
- | ||
- # list available platforms (numerically) | ||
- my @platforms = sort { $a =~ m/-([0-9]+)$/; my $aa = $1; | ||
- $b =~ m/-([0-9]+)$/; $aa <=> $1; | ||
- } glob("$ndk/platforms/android-$api"); | ||
- die "no $ndk/platforms/android-$api" if ($#platforms < 0); | ||
- | ||
- $sysroot = "@platforms[$#platforms]/arch-$arch"; | ||
- $sysroot =~ m|/android-([0-9]+)/arch-$arch|; | ||
- $api = $1; | ||
- } | ||
- die "no sysroot=$sysroot" if (!-d $sysroot); | ||
- | ||
- my $triarch = $triplet{$arch}; | ||
- my $cflags; | ||
- my $cppflags; | ||
- | ||
- # see if there is NDK clang on $PATH, "universal" or "standalone" | ||
- if (which("clang") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) { | ||
- my $host=$1; | ||
- # harmonize with gcc default | ||
- my $arm = $ndkver > 16 ? "armv7a" : "armv5te"; | ||
- (my $tridefault = $triarch) =~ s/^arm-/$arm-/; | ||
- (my $tritools = $triarch) =~ s/(?:x|i6)86(_64)?-.*/x86$1/; | ||
- $cflags .= " -target $tridefault " | ||
- . "-gcc-toolchain \$(ANDROID_NDK)/toolchains" | ||
- . "/$tritools-4.9/prebuilt/$host"; | ||
- $user{CC} = "clang" if ($user{CC} !~ m|clang|); | ||
- $user{CROSS_COMPILE} = undef; | ||
- if (which("llvm-ar") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) { | ||
- $user{AR} = "llvm-ar"; | ||
- $user{ARFLAGS} = [ "rs" ]; | ||
- $user{RANLIB} = ":"; | ||
- } | ||
- } elsif (-f "$ndk/AndroidVersion.txt") { #"standalone toolchain" | ||
- my $cc = $user{CC} // "clang"; | ||
- # One can probably argue that both clang and gcc should be | ||
- # probed, but support for "standalone toolchain" was added | ||
- # *after* announcement that gcc is being phased out, so | ||
- # favouring clang is considered adequate. Those who insist | ||
- # have option to enforce test for gcc with CC=gcc. | ||
- if (which("$triarch-$cc") !~ m|^$ndk|) { | ||
- die "no NDK $triarch-$cc on \$PATH"; | ||
- } | ||
- $user{CC} = $cc; | ||
- $user{CROSS_COMPILE} = "$triarch-"; | ||
- } elsif ($user{CC} eq "clang") { | ||
- die "no NDK clang on \$PATH"; | ||
- } else { | ||
- if (which("$triarch-gcc") !~ m|^$ndk/.*/prebuilt/([^/]+)/|) { | ||
- die "no NDK $triarch-gcc on \$PATH"; | ||
- } | ||
- $cflags .= " -mandroid"; | ||
- $user{CROSS_COMPILE} = "$triarch-"; | ||
- } | ||
- | ||
- if (!-d "$sysroot/usr/include") { | ||
- my $incroot = "$ndk/sysroot/usr/include"; | ||
- die "no $incroot" if (!-d $incroot); | ||
- die "no $incroot/$triarch" if (!-d "$incroot/$triarch"); | ||
- $incroot =~ s|^$ndk/||; | ||
- $cppflags = "-D__ANDROID_API__=$api"; | ||
- $cppflags .= " -isystem \$(ANDROID_NDK)/$incroot/$triarch"; | ||
- $cppflags .= " -isystem \$(ANDROID_NDK)/$incroot"; | ||
- } | ||
- | ||
- $sysroot =~ s|^$ndk/||; | ||
- $android_ndk = { | ||
- cflags => "$cflags --sysroot=\$(ANDROID_NDK)/$sysroot", | ||
- cppflags => $cppflags, | ||
- bn_ops => $arch =~ m/64$/ ? "SIXTY_FOUR_BIT_LONG" | ||
- : "BN_LLONG", | ||
- }; | ||
- } | ||
- | ||
- return $android_ndk; | ||
- } | ||
-} | ||
- | ||
my %targets = ( | ||
"android" => { | ||
inherit_from => [ "linux-generic32" ], | ||
@@ -158,10 +17,6 @@ my %targets = ( | ||
# systems are perfectly capable of executing binaries targeting | ||
# Froyo. Keep in mind that in the nutshell Android builds are | ||
# about JNI, i.e. shared libraries, not applications. | ||
- cflags => add(sub { android_ndk()->{cflags} }), | ||
- cppflags => add(sub { android_ndk()->{cppflags} }), | ||
- cxxflags => add(sub { android_ndk()->{cflags} }), | ||
- bn_ops => sub { android_ndk()->{bn_ops} }, | ||
bin_cflags => "-pie", | ||
enable => [ ], | ||
}, | ||
@@ -194,62 +49,23 @@ my %targets = ( | ||
# Newer NDK versions reportedly require additional -latomic. | ||
# | ||
inherit_from => [ "android", asm("armv4_asm") ], | ||
- bn_ops => add("RC4_CHAR"), | ||
+ bn_ops => "BN_LLONG RC4_CHAR", | ||
}, | ||
"android-arm64" => { | ||
inherit_from => [ "android", asm("aarch64_asm") ], | ||
- bn_ops => add("RC4_CHAR"), | ||
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", | ||
perlasm_scheme => "linux64", | ||
}, | ||
|
||
- "android-mips" => { | ||
- inherit_from => [ "android", asm("mips32_asm") ], | ||
- bn_ops => add("RC4_CHAR"), | ||
- perlasm_scheme => "o32", | ||
- }, | ||
- "android-mips64" => { | ||
- ################################################################ | ||
- # You are more than likely have to specify target processor | ||
- # on ./Configure command line. Trouble is that toolchain's | ||
- # default is MIPS64r6 (at least in r10d), but there are no | ||
- # such processors around (or they are too rare to spot one). | ||
- # Actual problem is that MIPS64r6 is binary incompatible | ||
- # with previous MIPS ISA versions, in sense that unlike | ||
- # prior versions original MIPS binary code will fail. | ||
- # | ||
- inherit_from => [ "android", asm("mips64_asm") ], | ||
- bn_ops => add("RC4_CHAR"), | ||
- perlasm_scheme => "64", | ||
- }, | ||
- | ||
"android-x86" => { | ||
inherit_from => [ "android", asm("x86_asm") ], | ||
CFLAGS => add(picker(release => "-fomit-frame-pointer")), | ||
- bn_ops => add("RC4_INT"), | ||
+ bn_ops => "BN_LLONG RC4_INT", | ||
perlasm_scheme => "android", | ||
}, | ||
"android-x86_64" => { | ||
inherit_from => [ "android", asm("x86_64_asm") ], | ||
- bn_ops => add("RC4_INT"), | ||
+ bn_ops => "SIXTY_FOUR_BIT_LONG RC4_INT", | ||
perlasm_scheme => "elf", | ||
}, | ||
- | ||
- #################################################################### | ||
- # Backward compatible targets, (might) requre $CROSS_SYSROOT | ||
- # | ||
- "android-armeabi" => { | ||
- inherit_from => [ "android-arm" ], | ||
- }, | ||
- "android64" => { | ||
- inherit_from => [ "android" ], | ||
- }, | ||
- "android64-aarch64" => { | ||
- inherit_from => [ "android-arm64" ], | ||
- }, | ||
- "android64-x86_64" => { | ||
- inherit_from => [ "android-x86_64" ], | ||
- }, | ||
- "android64-mips64" => { | ||
- inherit_from => [ "android-mips64" ], | ||
- }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,26 @@ | ||
class Arch: | ||
ANDROID_COMPILER = '4.9' | ||
ANDROID_TARGET: str | ||
LLVM_TARGET: str | ||
ANDROID_TOOLCHAIN_PREFIX: str | ||
|
||
@property | ||
def ANDROID_TOOLCHAIN(self) -> str: | ||
return self.ANDROID_TOOLCHAIN_PREFIX + self.ANDROID_COMPILER | ||
def binutils_prefix(self): | ||
return self.ANDROID_TARGET | ||
|
||
|
||
class arm(Arch): | ||
ANDROID_TARGET = 'arm-linux-androideabi' | ||
LLVM_TARGET = 'armv7-none-linux-androideabi' | ||
ANDROID_TOOLCHAIN_PREFIX = 'arm-linux-androideabi-' | ||
ANDROID_TARGET = 'armv7a-linux-androideabi' | ||
|
||
@property | ||
def binutils_prefix(self): | ||
return 'arm-linux-androideabi' | ||
|
||
|
||
class arm64(Arch): | ||
ANDROID_TARGET = 'aarch64-linux-android' | ||
LLVM_TARGET = 'aarch64-none-linux-android' | ||
ANDROID_TOOLCHAIN_PREFIX = 'aarch64-linux-android-' | ||
|
||
|
||
class x86(Arch): | ||
ANDROID_TARGET = 'i686-linux-android' | ||
LLVM_TARGET = 'i686-none-linux-android' | ||
ANDROID_TOOLCHAIN_PREFIX = 'x86-' | ||
|
||
|
||
class x86_64(Arch): | ||
ANDROID_TARGET = 'x86_64-linux-android' | ||
LLVM_TARGET = 'x86_64-none-linux-android' | ||
ANDROID_TOOLCHAIN_PREFIX = 'x86_64-' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
target_arch = 'arm64' | ||
target_arch = 'arm' | ||
android_api_level = 21 | ||
|
||
# Python optional modules. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.