mirror of
https://github.com/openharmony/third_party_rust_mio.git
synced 2026-07-21 01:35:28 -04:00
Fix compile on aarch64-linux-android (#601)
aarch64-linux-android is also added to the CI run.
This commit is contained in:
+12
-1
@@ -64,7 +64,7 @@ matrix:
|
||||
install:
|
||||
- rustup target add $TARGET
|
||||
|
||||
# Android
|
||||
# Android arm-linux-androideabi
|
||||
- os: linux
|
||||
env: TARGET=arm-linux-androideabi
|
||||
rust: stable
|
||||
@@ -75,6 +75,17 @@ matrix:
|
||||
install:
|
||||
- rustup target add $TARGET
|
||||
|
||||
# Android aarch64-linux-android
|
||||
- os: linux
|
||||
env: TARGET=aarch64-linux-android
|
||||
rust: stable
|
||||
script:
|
||||
- cargo build
|
||||
- cargo build --no-default-features
|
||||
- sh ci/run-docker.sh $TARGET;
|
||||
install:
|
||||
- rustup target add $TARGET
|
||||
|
||||
# FreeBSD
|
||||
- os: linux
|
||||
env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ default = ["with-deprecated"]
|
||||
lazycell = "0.4.0"
|
||||
log = "0.3.1"
|
||||
slab = "0.3.0"
|
||||
net2 = "0.2.19"
|
||||
net2 = "0.2.29"
|
||||
iovec = "0.1.0"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
RUN dpkg --add-architecture i386 && \
|
||||
dpkg --add-architecture amd64 && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
file \
|
||||
curl \
|
||||
ca-certificates \
|
||||
python \
|
||||
unzip \
|
||||
expect \
|
||||
openjdk-9-jre \
|
||||
libstdc++6:i386 \
|
||||
gcc \
|
||||
libc6-dev \
|
||||
qt5-default zlib1g:i386 libx11-6:i386 \
|
||||
libpulse0:amd64 libpulse0:i386
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
COPY cargo_config /etc/cargo_config
|
||||
|
||||
WORKDIR /android/
|
||||
|
||||
COPY install-ndk.sh /android/
|
||||
RUN sh /android/install-ndk.sh
|
||||
|
||||
ENV PATH=$PATH:/android/ndk-arm64/bin:/android/sdk/tools:/android/sdk/tools/bin:/android/sdk/platform-tools:/android/sdk/emulator/qemu/linux-x86_64
|
||||
|
||||
COPY install-sdk.sh /android/
|
||||
RUN sh /android/install-sdk.sh
|
||||
|
||||
ENV PATH=$PATH:/rust/bin \
|
||||
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=aarch64-linux-android-gcc \
|
||||
ANDROID_EMULATOR_FORCE_32BIT=0 \
|
||||
HOME=/tmp
|
||||
RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/*
|
||||
|
||||
RUN cp -r /root/.android /tmp
|
||||
RUN chmod 777 -R /tmp/.android
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/expect -f
|
||||
# ignore-license
|
||||
|
||||
set timeout 1800
|
||||
set cmd [lindex $argv 0]
|
||||
set licenses [lindex $argv 1]
|
||||
|
||||
spawn {*}$cmd
|
||||
expect {
|
||||
"Accept? (y/N):*" {
|
||||
exp_send "y\r"
|
||||
exp_continue
|
||||
}
|
||||
eof
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
[target.aarch64-linux-android]
|
||||
ar = "/android/ndk-arm64/bin/aarch64-linux-android-ar"
|
||||
linker = "/android/ndk-arm64/bin/aarch64-linux-android-gcc"
|
||||
|
||||
[target.arm-linux-androideabi]
|
||||
ar = "/android/ndk-arm64/bin/arm-linux-androideabi-ar"
|
||||
linker = "/android/ndk-arm64/bin/arm-linux-androideabi-gcc"
|
||||
|
||||
[target.armv7-linux-androideabi]
|
||||
ar = "/android/ndk-arm64/bin/arm-linux-androideabi-ar"
|
||||
linker = "/android/ndk-arm64/bin/arm-linux-androideabi-gcc"
|
||||
|
||||
[target.i686-linux-android]
|
||||
ar = "/android/ndk-arm64/bin/i686-linux-android-ar"
|
||||
linker = "/android/ndk-arm64/bin/i686-linux-android-gcc"
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
set -ex
|
||||
|
||||
curl -O https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip
|
||||
unzip -q android-ndk-r14b-linux-x86_64.zip
|
||||
android-ndk-r14b/build/tools/make_standalone_toolchain.py \
|
||||
--install-dir /android/ndk-arm64 \
|
||||
--arch arm64 \
|
||||
--api 24
|
||||
|
||||
rm -rf ./android-ndk-r14b-linux-x86_64.zip ./android-ndk-r14b
|
||||
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
set -ex
|
||||
|
||||
# Prep the SDK and emulator
|
||||
#
|
||||
# Note that the update process requires that we accept a bunch of licenses, and
|
||||
# we can't just pipe `yes` into it for some reason, so we take the same strategy
|
||||
# located in https://github.com/appunite/docker by just wrapping it in a script
|
||||
# which apparently magically accepts the licenses.
|
||||
|
||||
mkdir sdk
|
||||
|
||||
curl -o sdk-tools-linux-3859397.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip && \
|
||||
unzip sdk-tools-linux-3859397.zip && \
|
||||
mv tools sdk/
|
||||
|
||||
|
||||
|
||||
yes | sdkmanager --licenses
|
||||
sdkmanager tools platform-tools "build-tools;25.0.2" "platforms;android-24" "system-images;android-24;default;arm64-v8a"
|
||||
|
||||
echo "no" | avdmanager create avd \
|
||||
--force \
|
||||
--name arm64-24 \
|
||||
--package "system-images;android-24;default;arm64-v8a" \
|
||||
--abi arm64-v8a \
|
||||
--sdcard 256M
|
||||
@@ -14,6 +14,9 @@ RUN dpkg --add-architecture i386 && \
|
||||
gcc \
|
||||
libc6-dev
|
||||
|
||||
|
||||
COPY cargo_config /etc/cargo_config
|
||||
|
||||
WORKDIR /android/
|
||||
|
||||
COPY install-ndk.sh /android/
|
||||
@@ -28,7 +31,7 @@ ENV PATH=$PATH:/rust/bin \
|
||||
CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \
|
||||
ANDROID_EMULATOR_FORCE_32BIT=1 \
|
||||
HOME=/tmp
|
||||
RUN chmod 755 /android/sdk/tools/*
|
||||
RUN chmod 755 /android/sdk/tools/* /android/sdk/tools/qemu/linux-x86_64/* /android/sdk/tools/qemu/linux-x86/*
|
||||
|
||||
RUN cp -r /root/.android /tmp
|
||||
RUN chmod 777 -R /tmp/.android
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
[target.aarch64-linux-android]
|
||||
ar = "/android/ndk-arm/bin/aarch64-linux-android-ar"
|
||||
linker = "/android/ndk-arm/bin/aarch64-linux-android-gcc"
|
||||
|
||||
[target.arm-linux-androideabi]
|
||||
ar = "/android/ndk-arm/bin/arm-linux-androideabi-ar"
|
||||
linker = "/android/ndk-arm/bin/arm-linux-androideabi-gcc"
|
||||
|
||||
[target.armv7-linux-androideabi]
|
||||
ar = "/android/ndk-arm/bin/arm-linux-androideabi-ar"
|
||||
linker = "/android/ndk-arm/bin/arm-linux-androideabi-gcc"
|
||||
|
||||
[target.i686-linux-android]
|
||||
ar = "/android/ndk-arm/bin/i686-linux-android-ar"
|
||||
linker = "/android/ndk-arm/bin/i686-linux-android-gcc"
|
||||
@@ -7,10 +7,11 @@ set -ex
|
||||
|
||||
TARGET=$1
|
||||
|
||||
cargo build --test test --target $TARGET
|
||||
if [ -f /etc/cargo_config ] && [ -d /cargo ]; then cp -f /etc/cargo_config /cargo/config; fi
|
||||
cargo build --target=$TARGET --test test --verbose
|
||||
|
||||
# Find the file to run
|
||||
TEST_FILE="$(find target/$TARGET/debug -maxdepth 1 -type f -name test-* | head -1)"
|
||||
TEST_FILE=$(find target/$TARGET/debug -maxdepth 1 -type f -perm -111 -name "test-*" | head -1)
|
||||
|
||||
case "$TARGET" in
|
||||
arm-linux-androideabi)
|
||||
@@ -22,6 +23,19 @@ case "$TARGET" in
|
||||
grep "^test result.* 0 failed" /tmp/out
|
||||
;;
|
||||
|
||||
aarch64-linux-android)
|
||||
# Use the 64bit emulator
|
||||
export LD_LIBRARY_PATH="/android/sdk/emulator/lib64/qt/lib:/usr/lib/x86_64-linux-gnu"
|
||||
qemu-system-aarch64 @arm64-24 -memory 768 -accel off -gpu off -no-skin -no-window -no-audio -no-snapshot-load -no-snapshot-save &
|
||||
adb wait-for-device
|
||||
adb root
|
||||
adb push $TEST_FILE /data/mio-test
|
||||
#adb unroot
|
||||
adb shell chmod 755 /data/mio-test
|
||||
adb shell /data/mio-test 2>&1 | tee /tmp/out
|
||||
grep "^test result.* 0 failed" /tmp/out
|
||||
;;
|
||||
|
||||
*)
|
||||
exit 1;
|
||||
;;
|
||||
|
||||
@@ -122,6 +122,7 @@ impl UnixSocket {
|
||||
}
|
||||
|
||||
/// Bind the socket to the specified address
|
||||
#[cfg(not(all(target_arch = "aarch64",target_os = "android")))]
|
||||
pub fn bind<P: AsRef<Path> + ?Sized>(&self, addr: &P) -> io::Result<()> {
|
||||
unsafe {
|
||||
let (addr, len) = try!(sockaddr_un(addr.as_ref()));
|
||||
@@ -132,6 +133,18 @@ impl UnixSocket {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(target_arch = "aarch64",target_os = "android"))]
|
||||
pub fn bind<P: AsRef<Path> + ?Sized>(&self, addr: &P) -> io::Result<()> {
|
||||
unsafe {
|
||||
let (addr, len) = try!(sockaddr_un(addr.as_ref()));
|
||||
let len_i32 = len as i32;
|
||||
try!(cvt(libc::bind(self.as_raw_fd(),
|
||||
&addr as *const _ as *const _,
|
||||
len_i32)));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_clone(&self) -> io::Result<UnixSocket> {
|
||||
Ok(UnixSocket { io: try!(self.io.try_clone()) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user