Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
98e82ddf
Unverified
Commit
98e82ddf
authored
Feb 12, 2020
by
Luca Boccassi
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3828 from sappo/master
Android build helper improvement + fix for prefix dir
parents
91792109
67e6a8c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
55 deletions
+45
-55
README.md
builds/android/README.md
+4
-0
android_build_helper.sh
builds/android/android_build_helper.sh
+38
-18
build.sh
builds/android/build.sh
+3
-37
No files found.
builds/android/README.md
View file @
98e82ddf
...
@@ -22,6 +22,10 @@ To specify the minimum sdk version set the environment variable below:
...
@@ -22,6 +22,10 @@ To specify the minimum sdk version set the environment variable below:
export MIN_SDK_VERSION=21 # Default value if unset
export MIN_SDK_VERSION=21 # Default value if unset
To specify the prefix directory set the environment variable below:
export ANDROID_BUILD_DIR=./builds/android/prefix/<android_arch> # Default value if unset
## Build
## Build
In the android directory, run:
In the android directory, run:
...
...
builds/android/android_build_helper.sh
View file @
98e82ddf
...
@@ -2,21 +2,21 @@
...
@@ -2,21 +2,21 @@
#
#
# Copyright (c) 2014, Joe Eli McIlvain
# Copyright (c) 2014, Joe Eli McIlvain
# All rights reserved.
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# modification, are permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice,
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# this list of conditions and the following disclaimer.
#
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# and/or other materials provided with the distribution.
#
#
# 3. Neither the name of the copyright holder nor the names of its
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
# this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
...
@@ -69,12 +69,36 @@ function android_build_check_fail {
...
@@ -69,12 +69,36 @@ function android_build_check_fail {
fi
fi
}
}
function
android_build_arch
{
function
android_build_set_env
{
BUILD_ARCH
=
$1
export
TOOLCHAIN_PATH
=
"
${
ANDROID_NDK_ROOT
}
/toolchains/llvm/prebuilt/
${
HOST_PLATFORM
}
/bin"
export
TOOLCHAIN_PATH
=
"
${
ANDROID_NDK_ROOT
}
/toolchains/llvm/prebuilt/
${
HOST_PLATFORM
}
/bin"
export
TOOLCHAIN_HOST
=
$1
export
TOOLCHAIN_COMP
=
$2
# Set variables for each architecture
export
TOOLCHAIN_CXXSTL
=
$3
if
[
$BUILD_ARCH
==
"arm"
]
;
then
export
TOOLCHAIN_ARCH
=
$4
export
TOOLCHAIN_HOST
=
"arm-linux-androideabi"
export
TOOLCHAIN_COMP
=
"armv7a-linux-androideabi
${
MIN_SDK_VERSION
}
"
export
TOOLCHAIN_ABI
=
"armeabi-v7a"
export
TOOLCHAIN_ARCH
=
"arm"
elif
[
$BUILD_ARCH
==
"x86"
]
;
then
export
TOOLCHAIN_HOST
=
"i686-linux-android"
export
TOOLCHAIN_COMP
=
"i686-linux-android
${
MIN_SDK_VERSION
}
"
export
TOOLCHAIN_ABI
=
"x86"
export
TOOLCHAIN_ARCH
=
"x86"
elif
[
$BUILD_ARCH
==
"arm64"
]
;
then
export
TOOLCHAIN_HOST
=
"aarch64-linux-android"
export
TOOLCHAIN_COMP
=
"aarch64-linux-android
${
MIN_SDK_VERSION
}
"
export
TOOLCHAIN_ABI
=
"arm64-v8a"
export
TOOLCHAIN_ARCH
=
"arm64"
elif
[
$BUILD_ARCH
==
"x86_64"
]
;
then
export
TOOLCHAIN_HOST
=
"x86_64-linux-android"
export
TOOLCHAIN_COMP
=
"x86_64-linux-android
${
MIN_SDK_VERSION
}
"
export
TOOLCHAIN_ABI
=
"x86_64"
export
TOOLCHAIN_ARCH
=
"x86_64"
fi
export
ANDROID_BUILD_SYSROOT
=
"
${
ANDROID_NDK_ROOT
}
/platforms/android-
${
MIN_SDK_VERSION
}
/arch-
${
TOOLCHAIN_ARCH
}
"
export
ANDROID_BUILD_PREFIX
=
"
${
ANDROID_BUILD_DIR
}
/prefix/
${
TOOLCHAIN_ARCH
}
"
}
}
function
android_build_env
{
function
android_build_env
{
...
@@ -101,9 +125,9 @@ function android_build_env {
...
@@ -101,9 +125,9 @@ function android_build_env {
ANDROID_BUILD_FAIL+
=(
" (eg.
\"
armv7a-linux-androideabi
\"
)"
)
ANDROID_BUILD_FAIL+
=(
" (eg.
\"
armv7a-linux-androideabi
\"
)"
)
fi
fi
if
[
-z
"
$TOOLCHAIN_
CXXSTL
"
]
;
then
if
[
-z
"
$TOOLCHAIN_
ABI
"
]
;
then
ANDROID_BUILD_FAIL+
=(
"Please set the TOOLCHAIN_
CXXSTL
environment variable"
)
ANDROID_BUILD_FAIL+
=(
"Please set the TOOLCHAIN_
ABI
environment variable"
)
ANDROID_BUILD_FAIL+
=(
" (eg.
\"
armeabi-v7a
bi
\"
)"
)
ANDROID_BUILD_FAIL+
=(
" (eg.
\"
armeabi-v7a
\"
)"
)
fi
fi
if
[
-z
"
$TOOLCHAIN_ARCH
"
]
;
then
if
[
-z
"
$TOOLCHAIN_ARCH
"
]
;
then
...
@@ -129,15 +153,11 @@ function android_build_env {
...
@@ -129,15 +153,11 @@ function android_build_env {
##
##
# Set up some local variables and check them
# Set up some local variables and check them
ANDROID_BUILD_SYSROOT
=
"
${
ANDROID_NDK_ROOT
}
/platforms/android-
${
MIN_SDK_VERSION
}
/arch-
${
TOOLCHAIN_ARCH
}
"
if
[
!
-d
"
$ANDROID_BUILD_SYSROOT
"
]
;
then
if
[
!
-d
"
$ANDROID_BUILD_SYSROOT
"
]
;
then
ANDROID_BUILD_FAIL+
=(
"The ANDROID_BUILD_SYSROOT directory does not exist"
)
ANDROID_BUILD_FAIL+
=(
"The ANDROID_BUILD_SYSROOT directory does not exist"
)
ANDROID_BUILD_FAIL+
=(
"
${
ANDROID_BUILD_SYSROOT
}
"
)
ANDROID_BUILD_FAIL+
=(
"
${
ANDROID_BUILD_SYSROOT
}
"
)
fi
fi
ANDROID_BUILD_PREFIX
=
"
${
ANDROID_BUILD_DIR
}
/prefix/
${
TOOLCHAIN_ARCH
}
"
mkdir
-p
"
$ANDROID_BUILD_PREFIX
"
||
{
mkdir
-p
"
$ANDROID_BUILD_PREFIX
"
||
{
ANDROID_BUILD_FAIL+
=(
"Failed to make ANDROID_BUILD_PREFIX directory"
)
ANDROID_BUILD_FAIL+
=(
"Failed to make ANDROID_BUILD_PREFIX directory"
)
ANDROID_BUILD_FAIL+
=(
"
${
ANDROID_BUILD_PREFIX
}
"
)
ANDROID_BUILD_FAIL+
=(
"
${
ANDROID_BUILD_PREFIX
}
"
)
...
@@ -211,7 +231,7 @@ function android_build_opts {
...
@@ -211,7 +231,7 @@ function android_build_opts {
local
LIBS
=
"-lc -lgcc -ldl -lm -llog -lc++_shared"
local
LIBS
=
"-lc -lgcc -ldl -lm -llog -lc++_shared"
local
LDFLAGS
=
"-L
${
ANDROID_BUILD_PREFIX
}
/lib"
local
LDFLAGS
=
"-L
${
ANDROID_BUILD_PREFIX
}
/lib"
LDFLAGS+
=
" -L
${
ANDROID_NDK_ROOT
}
/sources/cxx-stl/llvm-libc++/libs/
${
TOOLCHAIN_
CXXSTL
}
"
LDFLAGS+
=
" -L
${
ANDROID_NDK_ROOT
}
/sources/cxx-stl/llvm-libc++/libs/
${
TOOLCHAIN_
ABI
}
"
CFLAGS+
=
" -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE"
CFLAGS+
=
" -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE"
CPPFLAGS+
=
" -I
${
ANDROID_BUILD_PREFIX
}
/include"
CPPFLAGS+
=
" -I
${
ANDROID_BUILD_PREFIX
}
/include"
...
...
builds/android/build.sh
View file @
98e82ddf
...
@@ -6,16 +6,15 @@ function usage {
...
@@ -6,16 +6,15 @@ function usage {
# Use directory of current script as the build directory and working directory
# Use directory of current script as the build directory and working directory
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
ANDROID_BUILD_DIR
=
"
$
(
pwd
)
"
ANDROID_BUILD_DIR
=
"
$
{
ANDROID_BUILD_DIR
:-
`
pwd
`
}
"
# Get access to android_build functions and variables
# Get access to android_build functions and variables
source
${
ANDROID_BUILD_DIR
}
/android_build_helper.sh
source
.
/android_build_helper.sh
# Choose a C++ standard library implementation from the ndk
# Choose a C++ standard library implementation from the ndk
ANDROID_BUILD_CXXSTL
=
"gnustl_shared_49"
ANDROID_BUILD_CXXSTL
=
"gnustl_shared_49"
BUILD_ARCH
=
$1
BUILD_ARCH
=
$1
if
[
-z
$BUILD_ARCH
]
;
then
if
[
-z
$BUILD_ARCH
]
;
then
usage
usage
exit
1
exit
1
...
@@ -41,41 +40,8 @@ export NDK_VERSION=${NDK_VERSION:-android-ndk-r20}
...
@@ -41,41 +40,8 @@ export NDK_VERSION=${NDK_VERSION:-android-ndk-r20}
# SDK version 21 is the minimum version for 64-bit builds.
# SDK version 21 is the minimum version for 64-bit builds.
export
MIN_SDK_VERSION
=
${
MIN_SDK_VERSION
:-
21
}
export
MIN_SDK_VERSION
=
${
MIN_SDK_VERSION
:-
21
}
# Set variables for each architecture
HOST_ARM
=
"arm-linux-androideabi"
HOST_ARM64
=
"aarch64-linux-android"
HOST_X86
=
"i686-linux-android"
HOST_X86_64
=
"x86_64-linux-android"
COMP_ARM
=
"armv7a-linux-androideabi
${
MIN_SDK_VERSION
}
"
COMP_ARM64
=
"aarch64-linux-android
${
MIN_SDK_VERSION
}
"
COMP_X86
=
"i686-linux-android
${
MIN_SDK_VERSION
}
"
COMP_X86_64
=
"x86_64-linux-android
${
MIN_SDK_VERSION
}
"
CXXSTL_ARM
=
"armeabi-v7a"
CXXSTL_ARM64
=
"arm64-v8a"
CXXSTL_X86
=
"x86"
CXXSTL_X86_64
=
"x86_64"
ARCH_ARM
=
"arm"
ARCH_ARM64
=
"arm64"
ARCH_X86
=
"x86"
ARCH_X86_64
=
"x86_64"
if
[
$BUILD_ARCH
==
"arm"
]
;
then
android_build_arch
$HOST_ARM
$COMP_ARM
$CXXSTL_ARM
$ARCH_ARM
elif
[
$BUILD_ARCH
==
"x86"
]
;
then
android_build_arch
$HOST_X86
$COMP_X86
$CXXSTL_X86
$ARCH_X86
elif
[
$BUILD_ARCH
==
"arm64"
]
;
then
android_build_arch
$HOST_ARM64
$COMP_ARM64
$CXXSTL_ARM64
$ARCH_ARM64
elif
[
$BUILD_ARCH
==
"x86_64"
]
;
then
android_build_arch
$HOST_X86_64
$COMP_X86_64
$CXXSTL_X86_64
$ARCH_X86_64
else
usage
exit
1
fi
# Set up android build environment and set ANDROID_BUILD_OPTS array
# Set up android build environment and set ANDROID_BUILD_OPTS array
android_build_set_env
$BUILD_ARCH
android_build_env
android_build_env
android_build_opts
android_build_opts
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment