openssl==1.1.1k, sqlite3==3.36.0
This commit is contained in:
parent
c84abccbfa
commit
e72071fc3f
8 changed files with 961 additions and 40 deletions
|
@ -22,6 +22,9 @@ build arm64 aar:
|
|||
- ln -s ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9
|
||||
- cp -f $CI_PROJECT_DIR/scripts/build-target-python.sh ~/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh
|
||||
- cp -f $CI_PROJECT_DIR/scripts/mangled-glibc-syscalls__arm64.h ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21/arch-arm64/usr/include/crystax/bionic/libc/include/sys/mangled-glibc-syscalls.h
|
||||
- cp -f $CI_PROJECT_DIR/scripts/build-binary.mk ~/.buildozer/android/crystax-ndk-10.3.2/build/core/build-binary.mk
|
||||
- rm -rf ~/.buildozer/android/crystax-ndk-10.3.2/sources/sqlite
|
||||
- cp -Rf $CI_PROJECT_DIR/scripts/crystax-sources/sqlite ~/.buildozer/android/crystax-ndk-10.3.2/sources/sqlite
|
||||
- rm ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz
|
||||
- mv buildozer.spec.arm64.ci buildozer.spec
|
||||
- chmod u+x ./build-release.sh
|
||||
|
@ -47,6 +50,9 @@ build arm aar:
|
|||
- cp -f $CI_PROJECT_DIR/p4a/pythonforandroid/bootstraps/lbry/build/templates/build.tmpl.gradle.arm $CI_PROJECT_DIR/p4a/pythonforandroid/bootstraps/lbry/build/templates/build.tmpl.gradle
|
||||
- cp -f $CI_PROJECT_DIR/scripts/build-target-python.sh ~/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh
|
||||
- cp -f $CI_PROJECT_DIR/scripts/mangled-glibc-syscalls.h ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21/arch-arm/usr/include/crystax/bionic/libc/include/sys/mangled-glibc-syscalls.h
|
||||
- cp -f $CI_PROJECT_DIR/scripts/build-binary.mk ~/.buildozer/android/crystax-ndk-10.3.2/build/core/build-binary.mk
|
||||
- rm -rf ~/.buildozer/android/crystax-ndk-10.3.2/sources/sqlite
|
||||
- cp -Rf $CI_PROJECT_DIR/scripts/crystax-sources/sqlite ~/.buildozer/android/crystax-ndk-10.3.2/sources/sqlite
|
||||
- rm ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz
|
||||
- mv buildozer.spec.arm.ci buildozer.spec
|
||||
- chmod u+x ./build-release.sh
|
||||
|
|
|
@ -8,7 +8,7 @@ import sh
|
|||
|
||||
class OpenSSLRecipe(Recipe):
|
||||
version = '1.1'
|
||||
url_version = '1.1.1b'
|
||||
url_version = '1.1.1k'
|
||||
url = 'https://www.openssl.org/source/openssl-{url_version}.tar.gz'
|
||||
|
||||
@property
|
||||
|
|
|
@ -66,7 +66,7 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
url = ''
|
||||
name = 'python3crystax'
|
||||
|
||||
depends = ['hostpython3crystax']
|
||||
depends = ['hostpython3crystax', 'sqlite3', 'openssl']
|
||||
conflicts = ['python2', 'python3']
|
||||
|
||||
from_crystax = True
|
||||
|
@ -123,6 +123,36 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
return join(self.ctx.ndk_dir, 'sources', 'python', self.major_minor_version_string,
|
||||
'libs', arch_name)
|
||||
|
||||
def check_for_sqlite3so(self, sqlite_recipe, arch):
|
||||
dynlib_dir = join(self.ctx.ndk_dir, 'sources', 'python', self.version,
|
||||
'libs', arch.arch, 'modules')
|
||||
|
||||
if os.path.exists(join(dynlib_dir, 'libsqlite3.so')):
|
||||
return 10, 'Shared object exists in ndk'
|
||||
|
||||
major_version = sqlite_recipe.version.split('.')[0]
|
||||
# find out why _ssl.so is missin
|
||||
source_dir = join(self.ctx.ndk_dir, 'sources', 'sqlite', major_version)
|
||||
if not os.path.exists(source_dir):
|
||||
return 0, 'sqlite3 version not present'
|
||||
|
||||
# these two path checks are lifted straight from:
|
||||
# crystax-ndk/build/tools/build-target-python.sh
|
||||
if not os.path.exists(join(source_dir, 'Android.mk')):
|
||||
return 1.1, 'Android.mk is missing in sqlite3 source'
|
||||
|
||||
include_dir = join(source_dir, 'include')
|
||||
if not os.path.exists(join(include_dir, 'sqlite3.h')):
|
||||
return 1.2, 'sqlite3 include dir missing'
|
||||
|
||||
# lastly a check to see whether shared objects for the correct arch
|
||||
# is present in the ndk
|
||||
if not os.path.exists(join(source_dir, 'libs', arch.arch, 'libsqlite3.a')):
|
||||
return 2, 'sqlite3 libs for this arch is missing in ndk'
|
||||
|
||||
return 5, 'Ready to recompile python'
|
||||
|
||||
|
||||
def check_for_sslso(self, ssl_recipe, arch):
|
||||
# type: (Recipe, str)
|
||||
dynlib_dir = join(self.ctx.ndk_dir, 'sources', 'python', self.version,
|
||||
|
@ -132,7 +162,6 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
return 10, 'Shared object exists in ndk'
|
||||
|
||||
# find out why _ssl.so is missing
|
||||
|
||||
source_dir = join(self.ctx.ndk_dir, 'sources', 'openssl', ssl_recipe.version)
|
||||
if not os.path.exists(source_dir):
|
||||
return 0, 'Openssl version not present'
|
||||
|
@ -151,8 +180,6 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
'opensslconf_{}.h'.format(under_scored_arch))):
|
||||
return 1.3, 'Opensslconf arch header missing from include'
|
||||
|
||||
|
||||
|
||||
# lastly a check to see whether shared objects for the correct arch
|
||||
# is present in the ndk
|
||||
if not os.path.exists(join(source_dir, 'libs', arch.arch)):
|
||||
|
@ -167,6 +194,13 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
if os.path.exists(mk_path):
|
||||
return mk_path
|
||||
|
||||
def find_sqlite3_Android_mk(self):
|
||||
sqlite_dir = join(self.ctx.ndk_dir, 'sources', 'sqlite')
|
||||
for version in os.listdir(sqlite_dir):
|
||||
mk_path = join(sqlite_dir, version, 'Android.mk')
|
||||
if os.path.exists(mk_path):
|
||||
return mk_path
|
||||
|
||||
def prebuild_arch(self, arch):
|
||||
super(Python3Recipe, self).prebuild_arch(arch)
|
||||
if self.version in ('3.6', '3.7', '3.9'):
|
||||
|
@ -198,7 +232,6 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
sh.cp("-r", join(self.get_recipe_dir(), 'libffi'), join(build_dir, 'Modules', '_ctypes'))
|
||||
print #####Copied bundle####'
|
||||
|
||||
|
||||
shprint(sh.ln, '-sf',
|
||||
realpath(join(build_dir, 'Lib/site-packages/README.txt')),
|
||||
join(build_dir, 'Lib/site-packages/README'))
|
||||
|
@ -219,18 +252,60 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
shprint(sh.rm, '-f', join(ndk_sources_python_dir, '{}/Android.mk.tmp'.format(self.version)))
|
||||
|
||||
def build_arch(self, arch):
|
||||
# If openssl is needed we may have to recompile cPython to get the
|
||||
rebuild = False
|
||||
|
||||
if self.from_crystax and 'sqlite3' in self.ctx.recipe_build_order:
|
||||
info('checking sqlite3 in crystax-python')
|
||||
sqlite_recipe = self.get_recipe('sqlite3', self.ctx)
|
||||
stage, msg = self.check_for_sqlite3so(sqlite_recipe, arch)
|
||||
major_version = sqlite_recipe.version.split('.')[0]
|
||||
info(msg)
|
||||
sqlite3_build_dir = sqlite_recipe.get_build_dir(arch.arch)
|
||||
sqlite3_ndk_dir = join(self.ctx.ndk_dir, 'sources', 'sqlite', major_version)
|
||||
|
||||
if stage < 2:
|
||||
info('copying sqlite3 Android.mk to ndk')
|
||||
ensure_dir(sqlite3_ndk_dir)
|
||||
if stage < 1.2:
|
||||
# copy include folder and Android.mk to ndk
|
||||
mk_path = self.find_sqlite3_Android_mk()
|
||||
if mk_path is None:
|
||||
raise IOError('Android.mk file could not be found in '
|
||||
'any versions in ndk->sources->sqlite')
|
||||
shprint(sh.cp, '-f', mk_path, sqlite3_ndk_dir)
|
||||
|
||||
include_dir = join(sqlite3_build_dir, 'include')
|
||||
if stage < 1.3:
|
||||
ndk_include_dir = join(sqlite3_ndk_dir, 'include')
|
||||
ensure_dir(sqlite3_ndk_dir)
|
||||
shprint(sh.cp, '-f', join(sqlite3_build_dir, 'sqlite3.h'), join(ndk_include_dir, 'sqlite3.h'))
|
||||
shprint(sh.cp, '-f', join(sqlite3_build_dir, 'sqlite3ext.h'), join(ndk_include_dir, 'sqlite3ext.h'))
|
||||
|
||||
if stage < 3:
|
||||
info('copying sqlite3 libs to ndk')
|
||||
arch_ndk_lib = join(sqlite3_ndk_dir, 'libs', arch.arch)
|
||||
ensure_dir(arch_ndk_lib)
|
||||
shprint(sh.ln, '-sf',
|
||||
realpath(join(sqlite3_build_dir, 'libsqlite3')),
|
||||
join(sqlite3_build_dir, 'libsqlite3.a'))
|
||||
libs = ['libs/{}/libsqlite3.a'.format(arch.arch)]
|
||||
cmd = [join(sqlite3_build_dir, lib) for lib in libs] + [arch_ndk_lib]
|
||||
shprint(sh.cp, '-f', *cmd)
|
||||
|
||||
if stage < 10:
|
||||
rebuild = True
|
||||
|
||||
# If openssl is needed we may have to recompile cPython to get the
|
||||
# ssl.py module working properly
|
||||
if self.from_crystax and 'openssl' in self.ctx.recipe_build_order:
|
||||
info('Openssl and crystax-python combination may require '
|
||||
info('openssl and crystax-python combination may require '
|
||||
'recompilation of python...')
|
||||
ssl_recipe = self.get_recipe('openssl', self.ctx)
|
||||
stage, msg = self.check_for_sslso(ssl_recipe, arch)
|
||||
stage = 0 if stage < 5 else stage
|
||||
info(msg)
|
||||
openssl_build_dir = ssl_recipe.get_build_dir(arch.arch)
|
||||
openssl_ndk_dir = join(self.ctx.ndk_dir, 'sources', 'openssl',
|
||||
ssl_recipe.version)
|
||||
openssl_ndk_dir = join(self.ctx.ndk_dir, 'sources', 'openssl', ssl_recipe.version)
|
||||
|
||||
if stage < 2:
|
||||
info('Copying openssl headers and Android.mk to ndk')
|
||||
|
@ -279,16 +354,19 @@ class Python3Recipe(TargetPythonRecipe):
|
|||
shprint(sh.cp, '-f', *cmd)
|
||||
|
||||
if stage < 10:
|
||||
info('Recompiling python-crystax')
|
||||
self.patch_dev_defaults(ssl_recipe)
|
||||
build_script = join(self.ctx.ndk_dir, 'build', 'tools',
|
||||
'build-target-python.sh')
|
||||
rebuild = True
|
||||
|
||||
shprint(Command(build_script),
|
||||
'--ndk-dir={}'.format(self.ctx.ndk_dir),
|
||||
'--abis={}'.format(arch.arch),
|
||||
'-j5', '--verbose',
|
||||
self.get_build_dir(arch.arch))
|
||||
if rebuild:
|
||||
info('Recompiling python-crystax')
|
||||
self.patch_dev_defaults(ssl_recipe)
|
||||
build_script = join(self.ctx.ndk_dir, 'build', 'tools',
|
||||
'build-target-python.sh')
|
||||
|
||||
shprint(Command(build_script),
|
||||
'--ndk-dir={}'.format(self.ctx.ndk_dir),
|
||||
'--abis={}'.format(arch.arch),
|
||||
'-j5', '--verbose',
|
||||
self.get_build_dir(arch.arch))
|
||||
|
||||
info('Extracting CrystaX python3 from NDK package')
|
||||
dirn = self.ctx.get_python_install_dir()
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
LOCAL_PATH := $(call my-dir)/..
|
||||
TOP_PATH := $(call my-dir)/..
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_PATH := $(TOP_PATH)
|
||||
LOCAL_SRC_FILES := sqlite3.c
|
||||
LOCAL_MODULE := sqlite3_static
|
||||
LOCAL_MODULE_FILENAME := libsqlite3
|
||||
LOCAL_CFLAGS := -DSQLITE_ENABLE_FTS4 -D_FILE_OFFSET_BITS=64
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
LOCAL_MODULE := sqlite3
|
||||
|
||||
LOCAL_CFLAGS := -DSQLITE_ENABLE_FTS4
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
|
|
@ -4,31 +4,35 @@ from os.path import join, exists
|
|||
import sh
|
||||
|
||||
class Sqlite3Recipe(NDKRecipe):
|
||||
version = '3.24.0'
|
||||
version = '3.36.0'
|
||||
# Don't forget to change the URL when changing the version
|
||||
url = 'https://www.sqlite.org/2018/sqlite-amalgamation-3240000.zip'
|
||||
url = 'https://www.sqlite.org/2021/sqlite-amalgamation-3360000.zip'
|
||||
generated_libraries = ['sqlite3']
|
||||
|
||||
def should_build(self, arch):
|
||||
return not self.has_libs(arch, 'libsqlite3.so')
|
||||
return not self.has_libs(arch, 'libsqlite3.a')
|
||||
|
||||
def prebuild_arch(self, arch):
|
||||
super(Sqlite3Recipe, self).prebuild_arch(arch)
|
||||
super().prebuild_arch(arch)
|
||||
# Copy the Android make file
|
||||
|
||||
sh.mkdir('-p', join(self.get_build_dir(arch.arch), 'jni'))
|
||||
shutil.copyfile(join(self.get_recipe_dir(), 'Android.mk'),
|
||||
join(self.get_build_dir(arch.arch), 'jni/Android.mk'))
|
||||
|
||||
def build_arch(self, arch, *extra_args):
|
||||
super(Sqlite3Recipe, self).build_arch(arch)
|
||||
# Copy the shared library
|
||||
shutil.copyfile(join(self.get_build_dir(arch.arch), 'libs', arch.arch, 'libsqlite3.so'),
|
||||
join(self.ctx.get_libs_dir(arch.arch), 'libsqlite3.so'))
|
||||
super().build_arch(arch)
|
||||
# Copy the static library
|
||||
# (which doesn't get placed in the libs folder for some reason so we force that to happen)
|
||||
sh.mkdir('-p', join(self.get_build_dir(arch.arch), 'libs', arch.arch))
|
||||
shutil.copyfile(join(self.get_build_dir(arch.arch), 'obj', 'local', arch.arch, 'libsqlite3.a'),
|
||||
join(self.get_build_dir(arch.arch), 'libs', arch.arch, 'libsqlite3.a'))
|
||||
shutil.copyfile(join(self.get_build_dir(arch.arch), 'libs', arch.arch, 'libsqlite3.a'),
|
||||
join(self.ctx.get_libs_dir(arch.arch), 'libsqlite3.a'))
|
||||
|
||||
def get_recipe_env(self, arch):
|
||||
env = super(Sqlite3Recipe, self).get_recipe_env(arch)
|
||||
env = super().get_recipe_env(arch)
|
||||
env['NDK_PROJECT_PATH'] = self.get_build_dir(arch.arch)
|
||||
return env
|
||||
|
||||
|
||||
recipe = Sqlite3Recipe()
|
831
scripts/build-binary.mk
Normal file
831
scripts/build-binary.mk
Normal file
|
@ -0,0 +1,831 @@
|
|||
# Copyright (C) 2008, 2014, 2015 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# Check that LOCAL_MODULE is defined, then restore its LOCAL_XXXX values
|
||||
$(call assert-defined,LOCAL_MODULE)
|
||||
$(call module-restore-locals,$(LOCAL_MODULE))
|
||||
|
||||
# For now, only support target (device-specific modules).
|
||||
# We may want to introduce support for host modules in the future
|
||||
# but that is too experimental for now.
|
||||
#
|
||||
my := TARGET_
|
||||
|
||||
# LOCAL_MAKEFILE must also exist and name the Android.mk that
|
||||
# included the module build script.
|
||||
#
|
||||
$(call assert-defined,LOCAL_MAKEFILE LOCAL_BUILD_SCRIPT LOCAL_BUILT_MODULE)
|
||||
|
||||
# A list of LOCAL_XXX variables that are ignored for static libraries.
|
||||
# Print a warning if they are present inside a module definition to let
|
||||
# the user know this won't do what he/she expects.
|
||||
not_in_static_libs := \
|
||||
LOCAL_LDFLAGS \
|
||||
LOCAL_LDLIBS \
|
||||
LOCAL_ALLOW_UNDEFINED_SYMBOLS
|
||||
|
||||
ifeq ($(call module-get-class,$(LOCAL_MODULE)),STATIC_LIBRARY)
|
||||
$(foreach _notvar,$(not_in_static_libs),\
|
||||
$(if $(strip $($(_notvar))),\
|
||||
$(call __ndk_info,WARNING:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): $(_notvar) is always ignored for static libraries)\
|
||||
)\
|
||||
)
|
||||
endif
|
||||
|
||||
# Some developers like to add library names (e.g. -lfoo) to LOCAL_LDLIBS
|
||||
# and LOCAL_LDFLAGS directly. This is very fragile and can lead to broken
|
||||
# builds and other nasty surprises, because it doesn't tell ndk-build
|
||||
# that the corresponding module depends on these files. Emit a warning
|
||||
# when we detect this case.
|
||||
libs_in_ldflags := $(filter -l% %.so %.a,$(LOCAL_LDLIBS) $(LOCAL_LDFLAGS))
|
||||
|
||||
# Remove the system libraries we know about from the warning, it's ok
|
||||
# (and actually expected) to link them with -l<name>.
|
||||
system_libs := \
|
||||
android \
|
||||
c \
|
||||
dl \
|
||||
jnigraphics \
|
||||
log \
|
||||
m \
|
||||
m_hard \
|
||||
stdc++ \
|
||||
z \
|
||||
EGL \
|
||||
GLESv1_CM \
|
||||
GLESv2 \
|
||||
GLESv3 \
|
||||
OpenSLES \
|
||||
OpenMAXAL \
|
||||
mediandk \
|
||||
atomic
|
||||
|
||||
libs_in_ldflags := $(filter-out $(addprefix -l,$(system_libs)), $(libs_in_ldflags))
|
||||
|
||||
ifneq (,$(strip $(libs_in_ldflags)))
|
||||
$(call __ndk_info,WARNING:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): non-system libraries in linker flags: $(libs_in_ldflags))
|
||||
$(call __ndk_info, This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES)
|
||||
$(call __ndk_info, or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the)
|
||||
$(call __ndk_info, current module)
|
||||
endif
|
||||
|
||||
include $(BUILD_SYSTEM)/import-locals.mk
|
||||
|
||||
# Check for LOCAL_THIN_ARCHIVE / APP_THIN_ARCHIVE and print a warning if
|
||||
# it is defined for non-static library modules.
|
||||
thin_archive := $(strip $(LOCAL_THIN_ARCHIVE))
|
||||
ifdef thin_archive
|
||||
ifneq (STATIC_LIBRARY,$(call module-get-class,$(LOCAL_MODULE)))
|
||||
$(call __ndk_info,WARNING:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_THIN_ARCHIVE is for building static libraries)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef thin_archive
|
||||
thin_archive := $(strip $(NDK_APP_THIN_ARCHIVE))
|
||||
endif
|
||||
# Print a warning if the value is not 'true', 'false' or empty.
|
||||
ifneq (,$(filter-out true false,$(thin_archive)))
|
||||
$(call __ndk_info,WARNING:$(LOCAL_MAKEFILE):$(LOCAL_MODULE): Invalid LOCAL_THIN_ARCHIVE value '$(thin_archive)' ignored!)
|
||||
thin_archive :=
|
||||
endif
|
||||
|
||||
#
|
||||
# Ensure that 'make <module>' and 'make clean-<module>' work
|
||||
#
|
||||
.PHONY: $(LOCAL_MODULE)
|
||||
$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE)
|
||||
|
||||
cleantarget := clean-$(LOCAL_MODULE)-$(TARGET_ARCH_ABI)
|
||||
.PHONY: $(cleantarget)
|
||||
clean: $(cleantarget)
|
||||
|
||||
$(cleantarget): PRIVATE_ABI := $(TARGET_ARCH_ABI)
|
||||
$(cleantarget): PRIVATE_MODULE := $(LOCAL_MODULE)
|
||||
ifneq ($(LOCAL_BUILT_MODULE_NOT_COPIED),true)
|
||||
$(cleantarget): PRIVATE_CLEAN_FILES := $(LOCAL_BUILT_MODULE) \
|
||||
$($(my)OBJS)
|
||||
else
|
||||
$(cleantarget): PRIVATE_CLEAN_FILES := $($(my)OBJS)
|
||||
endif
|
||||
$(cleantarget)::
|
||||
$(call host-echo-build-step,$(PRIVATE_ABI),Clean) "$(PRIVATE_MODULE) [$(PRIVATE_ABI)]"
|
||||
$(hide) $(call host-rmdir,$(PRIVATE_CLEAN_FILES))
|
||||
|
||||
ifeq ($(NDK_APP_DEBUGGABLE),true)
|
||||
$(NDK_APP_GDBSETUP): PRIVATE_SRC_DIRS += $(LOCAL_C_INCLUDES) $(LOCAL_PATH)
|
||||
endif
|
||||
|
||||
# list of generated object files
|
||||
LOCAL_OBJECTS :=
|
||||
|
||||
# list of generated object files from RS files, subset of LOCAL_OBJECTS
|
||||
LOCAL_RS_OBJECTS :=
|
||||
|
||||
# always define ANDROID when building binaries
|
||||
#
|
||||
LOCAL_CFLAGS := -DANDROID $(LOCAL_CFLAGS)
|
||||
|
||||
#
|
||||
# Add the default system shared libraries to the build
|
||||
#
|
||||
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
|
||||
LOCAL_SHARED_LIBRARIES += $(TARGET_DEFAULT_SYSTEM_SHARED_LIBRARIES)
|
||||
else
|
||||
LOCAL_SHARED_LIBRARIES += $(LOCAL_SYSTEM_SHARED_LIBRARIES)
|
||||
endif
|
||||
|
||||
#
|
||||
# Check LOCAL_CPP_EXTENSION
|
||||
#
|
||||
bad_cpp_extensions := $(strip $(filter-out .%,$(LOCAL_CPP_EXTENSION)))
|
||||
ifdef bad_cpp_extensions
|
||||
$(call __ndk_info,WARNING: Invalid LOCAL_CPP_EXTENSION values: $(bad_cpp_extensions))
|
||||
LOCAL_CPP_EXTENSION := $(filter $(bad_cpp_extensions),$(LOCAL_CPP_EXTENSIONS))
|
||||
endif
|
||||
LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
|
||||
ifeq ($(LOCAL_CPP_EXTENSION),)
|
||||
# Match the default GCC C++ extensions.
|
||||
LOCAL_CPP_EXTENSION := $(default-c++-extensions)
|
||||
endif
|
||||
LOCAL_RS_EXTENSION := $(default-rs-extensions)
|
||||
|
||||
#
|
||||
# Check LOCAL_OBJC_EXTENSION, use '.m' by default
|
||||
#
|
||||
bad_objc_extensions := $(strip $(filter-out .%,$(LOCAL_OBJC_EXTENSION)))
|
||||
ifdef bad_objc_extensions
|
||||
$(call __ndk_info,WARNING: Invalid LOCAL_OBJC_EXTENSION values: $(bad_objc_extensions))
|
||||
LOCAL_OBJC_EXTENSION := $(filter $(bad_objc_extensions),$(LOCAL_OBJC_EXTENSION))
|
||||
endif
|
||||
LOCAL_OBJC_EXTENSION := $(strip $(LOCAL_OBJC_EXTENSION))
|
||||
ifeq ($(LOCAL_OBJC_EXTENSION),)
|
||||
LOCAL_OBJC_EXTENSION := .m
|
||||
endif
|
||||
|
||||
#
|
||||
# Check LOCAL_OBJCPP_EXTENSION, use '.mm' by default
|
||||
#
|
||||
bad_objcpp_extensions := $(strip $(filter-out .%,$(LOCAL_OBJCPP_EXTENSION)))
|
||||
ifdef bad_objcpp_extensions
|
||||
$(call __ndk_info,WARNING: Invalid LOCAL_OBJCPP_EXTENSION values: $(bad_objcpp_extensions))
|
||||
LOCAL_OBJCPP_EXTENSION := $(filter $(bad_objcpp_extensions),$(LOCAL_OBJCPP_EXTENSION))
|
||||
endif
|
||||
LOCAL_OBJCPP_EXTENSION := $(strip $(LOCAL_OBJCPP_EXTENSION))
|
||||
ifeq ($(LOCAL_OBJCPP_EXTENSION),)
|
||||
LOCAL_OBJCPP_EXTENSION := .mm
|
||||
endif
|
||||
|
||||
#
|
||||
# If LOCAL_ALLOW_UNDEFINED_SYMBOLS is not true, the linker will allow the generation
|
||||
# of a binary that uses undefined symbols.
|
||||
#
|
||||
ifneq ($(LOCAL_ALLOW_UNDEFINED_SYMBOLS),true)
|
||||
LOCAL_LDFLAGS += $($(my)NO_UNDEFINED_LDFLAGS)
|
||||
endif
|
||||
|
||||
# Toolchain by default disallows generated code running from the heap and stack.
|
||||
# If LOCAL_DISABLE_NO_EXECUTE is true, we allow that
|
||||
#
|
||||
ifeq ($(LOCAL_DISABLE_NO_EXECUTE),true)
|
||||
LOCAL_CFLAGS += $($(my)DISABLE_NO_EXECUTE_CFLAGS)
|
||||
LOCAL_LDFLAGS += $($(my)DISABLE_NO_EXECUTE_LDFLAGS)
|
||||
else
|
||||
LOCAL_CFLAGS += $($(my)NO_EXECUTE_CFLAGS)
|
||||
LOCAL_LDFLAGS += $($(my)NO_EXECUTE_LDFLAGS)
|
||||
endif
|
||||
|
||||
# Toolchain by default provides relro and GOT protections.
|
||||
# If LOCAL_DISABLE_RELRO is true, we disable the protections.
|
||||
#
|
||||
ifeq ($(LOCAL_DISABLE_RELRO),true)
|
||||
LOCAL_LDFLAGS += $($(my)DISABLE_RELRO_LDFLAGS)
|
||||
else
|
||||
LOCAL_LDFLAGS += $($(my)RELRO_LDFLAGS)
|
||||
endif
|
||||
|
||||
# By default, we protect against format string vulnerabilities
|
||||
# If LOCAL_DISABLE_FORMAT_STRING_CHECKS is true, we disable the protections.
|
||||
ifeq ($(LOCAL_DISABLE_FORMAT_STRING_CHECKS),true)
|
||||
LOCAL_CFLAGS += $($(my)DISABLE_FORMAT_STRING_CFLAGS)
|
||||
else
|
||||
LOCAL_CFLAGS += $($(my)FORMAT_STRING_CFLAGS)
|
||||
endif
|
||||
|
||||
# enable PIE for executable beyond certain API level, unless "-static"
|
||||
ifneq (,$(filter true,$(NDK_APP_PIE) $(TARGET_PIE)))
|
||||
ifeq ($(call module-get-class,$(LOCAL_MODULE)),EXECUTABLE)
|
||||
ifeq (,$(filter -static,$(TARGET_LDFLAGS) $(LOCAL_LDFLAGS) $(NDK_APP_LDFLAGS)))
|
||||
LOCAL_CFLAGS += -fPIE
|
||||
LOCAL_LDFLAGS += -fPIE -pie
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# The original Android build system allows you to use the .arm prefix
|
||||
# to a source file name to indicate that it should be defined in either
|
||||
# 'thumb' or 'arm' mode, depending on the value of LOCAL_ARM_MODE
|
||||
#
|
||||
# First, check LOCAL_ARM_MODE, it should be empty, 'thumb' or 'arm'
|
||||
# We make the default 'thumb'
|
||||
#
|
||||
LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
|
||||
ifdef LOCAL_ARM_MODE
|
||||
ifneq ($(words $(LOCAL_ARM_MODE)),1)
|
||||
$(call __ndk_info, LOCAL_ARM_MODE in $(LOCAL_MAKEFILE) must be one word, not '$(LOCAL_ARM_MODE)')
|
||||
$(call __ndk_error, Aborting)
|
||||
endif
|
||||
# check that LOCAL_ARM_MODE is defined to either 'arm' or 'thumb'
|
||||
$(if $(filter-out thumb arm, $(LOCAL_ARM_MODE)),\
|
||||
$(call __ndk_info, LOCAL_ARM_MODE must be defined to either 'arm' or 'thumb' in $(LOCAL_MAKEFILE) not '$(LOCAL_ARM_MODE)')\
|
||||
$(call __ndk_error, Aborting)\
|
||||
)
|
||||
endif
|
||||
|
||||
# As a special case, the original Android build system
|
||||
# allows one to specify that certain source files can be
|
||||
# forced to build in ARM mode by using a '.arm' suffix
|
||||
# after the extension, e.g.
|
||||
#
|
||||
# LOCAL_SRC_FILES := foo.c.arm
|
||||
#
|
||||
# to build source file $(LOCAL_PATH)/foo.c as ARM
|
||||
#
|
||||
|
||||
$(call clear-all-src-tags)
|
||||
|
||||
# As a special extension, the NDK also supports the .neon extension suffix
|
||||
# to indicate that a single file can be compiled with ARM NEON support
|
||||
# We must support both foo.c.neon and foo.c.arm.neon here
|
||||
#
|
||||
# Also, if LOCAL_ARM_NEON is set to 'true', force Neon mode for all source
|
||||
# files
|
||||
#
|
||||
|
||||
neon_sources := $(filter %.neon,$(LOCAL_SRC_FILES))
|
||||
neon_sources := $(neon_sources:%.neon=%)
|
||||
|
||||
LOCAL_ARM_NEON := $(strip $(LOCAL_ARM_NEON))
|
||||
ifdef LOCAL_ARM_NEON
|
||||
$(if $(filter-out true false,$(LOCAL_ARM_NEON)),\
|
||||
$(call __ndk_info,LOCAL_ARM_NEON must be defined either to 'true' or 'false' in $(LOCAL_MAKEFILE), not '$(LOCAL_ARM_NEON)')\
|
||||
$(call __ndk_error,Aborting) \
|
||||
)
|
||||
endif
|
||||
ifeq ($(LOCAL_ARM_NEON),true)
|
||||
neon_sources += $(LOCAL_SRC_FILES:%.neon=%)
|
||||
# tag the precompiled header with 'neon' tag if it exists
|
||||
ifneq (,$(LOCAL_PCH))
|
||||
$(call tag-src-files,$(LOCAL_PCH),neon)
|
||||
endif
|
||||
endif
|
||||
|
||||
neon_sources := $(strip $(neon_sources))
|
||||
ifdef neon_sources
|
||||
ifeq ($(filter $(TARGET_ARCH_ABI), armeabi-v7a armeabi-v7a-hard arm64-v8a x86 x86_64),)
|
||||
$(call __ndk_info,NEON support is only possible for armeabi-v7a ABI, its variant armeabi-v7a-hard, and arm64-v8a, x86 and x86_64 ABIs)
|
||||
$(call __ndk_info,Please add checks against TARGET_ARCH_ABI in $(LOCAL_MAKEFILE))
|
||||
$(call __ndk_error,Aborting)
|
||||
endif
|
||||
$(call tag-src-files,$(neon_sources:%.arm=%),neon)
|
||||
endif
|
||||
|
||||
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES:%.neon=%)
|
||||
|
||||
# strip the .arm suffix from LOCAL_SRC_FILES
|
||||
# and tag the relevant sources with the 'arm' tag
|
||||
#
|
||||
arm_sources := $(filter %.arm,$(LOCAL_SRC_FILES))
|
||||
arm_sources := $(arm_sources:%.arm=%)
|
||||
thumb_sources := $(filter-out %.arm,$(LOCAL_SRC_FILES))
|
||||
LOCAL_SRC_FILES := $(LOCAL_SRC_FILES:%.arm=%)
|
||||
|
||||
ifeq ($(LOCAL_ARM_MODE),arm)
|
||||
arm_sources := $(LOCAL_SRC_FILES)
|
||||
# tag the precompiled header with 'arm' tag if it exists
|
||||
ifneq (,$(LOCAL_PCH))
|
||||
$(call tag-src-files,$(LOCAL_PCH),arm)
|
||||
endif
|
||||
else
|
||||
# For arm, all sources are compiled in thumb mode by default in release mode.
|
||||
# Linker should behave similarly
|
||||
ifneq ($(filter armeabi%, $(TARGET_ARCH_ABI)),)
|
||||
ifneq ($(APP_OPTIM),debug)
|
||||
LOCAL_LDFLAGS += -mthumb
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq ($(LOCAL_ARM_MODE),thumb)
|
||||
arm_sources := $(empty)
|
||||
endif
|
||||
$(call tag-src-files,$(arm_sources),arm)
|
||||
|
||||
# tag debug if APP_OPTIM is 'debug'
|
||||
#
|
||||
ifeq ($(APP_OPTIM),debug)
|
||||
$(call tag-src-files,$(LOCAL_SRC_FILES),debug)
|
||||
ifneq (,$(LOCAL_PCH))
|
||||
$(call tag-src-files,$(LOCAL_PCH),debug)
|
||||
endif
|
||||
endif
|
||||
|
||||
# add PCH to LOCAL_SRC_FILES so that TARGET-process-src-files-tags could process it
|
||||
ifneq (,$(LOCAL_PCH))
|
||||
LOCAL_SRC_FILES += $(LOCAL_PCH)
|
||||
endif
|
||||
|
||||
# Process all source file tags to determine toolchain-specific
|
||||
# target compiler flags, and text.
|
||||
#
|
||||
$(call TARGET-process-src-files-tags)
|
||||
|
||||
# now remove PCH from LOCAL_SRC_FILES to prevent getting NDK warning about
|
||||
# unsupported source file extensions
|
||||
ifneq (,$(LOCAL_PCH))
|
||||
LOCAL_SRC_FILES := $(filter-out $(LOCAL_PCH),$(LOCAL_SRC_FILES))
|
||||
endif
|
||||
|
||||
# only call dump-src-file-tags during debugging
|
||||
#$(dump-src-file-tags)
|
||||
|
||||
LOCAL_DEPENDENCY_DIRS :=
|
||||
|
||||
# all_source_patterns contains the list of filename patterns that correspond
|
||||
# to source files recognized by our build system
|
||||
ifneq ($(filter x86 x86_64, $(TARGET_ARCH_ABI)),)
|
||||
all_source_extensions := .c .s .S .asm $(LOCAL_CPP_EXTENSION) $(LOCAL_RS_EXTENSION) $(LOCAL_OBJC_EXTENSION) $(LOCAL_OBJCPP_EXTENSION)
|
||||
else
|
||||
all_source_extensions := .c .s .S $(LOCAL_CPP_EXTENSION) $(LOCAL_RS_EXTENSION) $(LOCAL_OBJC_EXTENSION) $(LOCAL_OBJCPP_EXTENSION)
|
||||
endif
|
||||
all_source_patterns := $(foreach _ext,$(all_source_extensions),%$(_ext))
|
||||
all_cpp_patterns := $(foreach _ext,$(LOCAL_CPP_EXTENSION),%$(_ext))
|
||||
all_rs_patterns := $(foreach _ext,$(LOCAL_RS_EXTENSION),%$(_ext))
|
||||
all_objc_patterns := $(foreach _ext,$(LOCAL_OBJC_EXTENSION),%$(_ext))
|
||||
all_objcpp_patterns := $(foreach _ext,$(LOCAL_OBJCPP_EXTENSION),%$(_ext))
|
||||
|
||||
unknown_sources := $(strip $(filter-out $(all_source_patterns),$(LOCAL_SRC_FILES)))
|
||||
ifdef unknown_sources
|
||||
$(call __ndk_info,WARNING: Unsupported source file extensions in $(LOCAL_MAKEFILE) for module $(LOCAL_MODULE))
|
||||
$(call __ndk_info, $(unknown_sources))
|
||||
endif
|
||||
|
||||
# LOCAL_OBJECTS will list all object files corresponding to the sources
|
||||
# listed in LOCAL_SRC_FILES, in the *same* order.
|
||||
#
|
||||
LOCAL_OBJECTS := $(LOCAL_SRC_FILES)
|
||||
$(foreach _ext,$(all_source_extensions),\
|
||||
$(eval LOCAL_OBJECTS := $$(LOCAL_OBJECTS:%$(_ext)=%$$(TARGET_OBJ_EXTENSION)))\
|
||||
)
|
||||
LOCAL_OBJECTS := $(filter %$(TARGET_OBJ_EXTENSION),$(LOCAL_OBJECTS))
|
||||
LOCAL_OBJECTS := $(subst ../,__/,$(LOCAL_OBJECTS))
|
||||
LOCAL_OBJECTS := $(subst :,_,$(LOCAL_OBJECTS))
|
||||
LOCAL_OBJECTS := $(foreach _obj,$(LOCAL_OBJECTS),$(LOCAL_OBJS_DIR)/$(_obj))
|
||||
|
||||
LOCAL_RS_OBJECTS := $(filter $(all_rs_patterns),$(LOCAL_SRC_FILES))
|
||||
$(foreach _ext,$(LOCAL_RS_EXTENSION),\
|
||||
$(eval LOCAL_RS_OBJECTS := $$(LOCAL_RS_OBJECTS:%$(_ext)=%$$(TARGET_OBJ_EXTENSION)))\
|
||||
)
|
||||
LOCAL_RS_OBJECTS := $(filter %$(TARGET_OBJ_EXTENSION),$(LOCAL_RS_OBJECTS))
|
||||
LOCAL_RS_OBJECTS := $(subst ../,__/,$(LOCAL_RS_OBJECTS))
|
||||
LOCAL_RS_OBJECTS := $(subst :,_,$(LOCAL_RS_OBJECTS))
|
||||
LOCAL_RS_OBJECTS := $(foreach _obj,$(LOCAL_RS_OBJECTS),$(LOCAL_OBJS_DIR)/$(_obj))
|
||||
|
||||
ifneq (,$(call module-has-objc-sources,$(LOCAL_MODULE)))
|
||||
objc_cflags :=
|
||||
objc_ldflags :=
|
||||
#objc_cflags += objc-exception
|
||||
ifneq (,$(filter clang%,$(NDK_TOOLCHAIN_VERSION)))
|
||||
objc_cflags += objc-arc
|
||||
objc_ldflags += objc-arc
|
||||
endif
|
||||
$(foreach __f,$(objc_cflags),\
|
||||
$(eval LOCAL_OBJCFLAGS += $(if $(filter -f$(__f) -fno-$(__f),$(foreach __t,TARGET LOCAL NDK_APP,$(foreach __l,C OBJC,$($(__t)_$(__l)FLAGS)))),,-f$(__f)))\
|
||||
)
|
||||
$(foreach __f,$(objc_ldflags),\
|
||||
$(eval LOCAL_LDFLAGS += $(if $(filter -f$(__f) -fno-$(__f),$(foreach __t,TARGET LOCAL NDK_APP,$($(__t)_LDFLAGS))),,-f$(__f)))\
|
||||
)
|
||||
endif
|
||||
|
||||
# If the module has any kind of C++ features, enable them in LOCAL_CPPFLAGS
|
||||
#
|
||||
ifneq (,$(call module-has-c++-features,$(LOCAL_MODULE),rtti))
|
||||
LOCAL_CPPFLAGS += -frtti
|
||||
endif
|
||||
ifneq (,$(call module-has-c++-features,$(LOCAL_MODULE),exceptions))
|
||||
LOCAL_CPPFLAGS += -fexceptions
|
||||
endif
|
||||
|
||||
ifeq ($(filter -std=%,$(LOCAL_CFLAGS) $(LOCAL_CPPFLAGS)),)
|
||||
ifneq ($(TARGET_CXX_STANDARD),)
|
||||
LOCAL_CPPFLAGS += -std=$(TARGET_CXX_STANDARD)
|
||||
endif
|
||||
endif
|
||||
|
||||
# If we're using the 'system' STL and use rtti or exceptions, then
|
||||
# automatically link against the GNU libsupc++ for now.
|
||||
#
|
||||
ifneq (,$(call module-has-c++-features,$(LOCAL_MODULE),rtti exceptions))
|
||||
ifeq (system,$(NDK_APP_STL))
|
||||
LOCAL_LDLIBS := $(LOCAL_LDLIBS) $(call host-path,$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libsupc++$(TARGET_LIB_EXTENSION))
|
||||
endif
|
||||
endif
|
||||
|
||||
# Set include patch for renderscript
|
||||
|
||||
|
||||
ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
|
||||
LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
|
||||
else
|
||||
LOCAL_RENDERSCRIPT_INCLUDES := \
|
||||
$(RENDERSCRIPT_TOOLCHAIN_HEADER) \
|
||||
$(TARGET_C_INCLUDES)/rs/scriptc \
|
||||
$(LOCAL_RENDERSCRIPT_INCLUDES)
|
||||
endif
|
||||
|
||||
RS_COMPAT :=
|
||||
ifneq ($(call module-is-shared-library,$(LOCAL_MODULE)),)
|
||||
RS_COMPAT := true
|
||||
endif
|
||||
|
||||
|
||||
# Build PCH
|
||||
|
||||
get-pch-name = $(strip \
|
||||
$(subst ../,__/,\
|
||||
$(eval __pch := $1)\
|
||||
$(eval __pch := $(__pch:%.h=%.precompiled.h))\
|
||||
$(__pch)\
|
||||
))
|
||||
|
||||
ifneq (,$(LOCAL_PCH))
|
||||
# Build PCH into obj directory
|
||||
LOCAL_BUILT_PCH := $(call get-pch-name,$(LOCAL_PCH))
|
||||
|
||||
# Build PCH
|
||||
$(call compile-cpp-source,$(LOCAL_PCH),$(LOCAL_BUILT_PCH).gch)
|
||||
|
||||
# All obj files are dependent on the PCH
|
||||
$(foreach src,$(filter $(all_cpp_patterns),$(LOCAL_SRC_FILES)),\
|
||||
$(eval $(LOCAL_OBJS_DIR)/$(call get-object-name,$(src)) : $(LOCAL_OBJS_DIR)/$(LOCAL_BUILT_PCH).gch)\
|
||||
)
|
||||
|
||||
# Files from now on build with PCH
|
||||
LOCAL_CPPFLAGS += -Winvalid-pch -include $(LOCAL_OBJS_DIR)/$(LOCAL_BUILT_PCH)
|
||||
|
||||
# Insert PCH dir at beginning of include search path
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_OBJS_DIR) \
|
||||
$(LOCAL_C_INCLUDES)
|
||||
endif
|
||||
|
||||
# Build the sources to object files
|
||||
#
|
||||
|
||||
$(foreach src,$(filter %.c,$(LOCAL_SRC_FILES)), $(call compile-c-source,$(src),$(call get-object-name,$(src))))
|
||||
$(foreach src,$(filter %.S %.s,$(LOCAL_SRC_FILES)), $(call compile-s-source,$(src),$(call get-object-name,$(src))))
|
||||
$(foreach src,$(filter $(all_objc_patterns),$(LOCAL_SRC_FILES)),\
|
||||
$(call compile-objc-source,$(src),$(call get-object-name,$(src)))\
|
||||
)
|
||||
$(foreach src,$(filter $(all_objcpp_patterns),$(LOCAL_SRC_FILES)),\
|
||||
$(call compile-objc++-source,$(src),$(call get-object-name,$(src)))\
|
||||
)
|
||||
$(foreach src,$(filter $(all_cpp_patterns),$(LOCAL_SRC_FILES)),\
|
||||
$(call compile-cpp-source,$(src),$(call get-object-name,$(src)))\
|
||||
)
|
||||
|
||||
$(foreach src,$(filter $(all_rs_patterns),$(LOCAL_SRC_FILES)),\
|
||||
$(call compile-rs-source,$(src),$(call get-rs-scriptc-name,$(src)),$(call get-rs-bc-name,$(src)),$(call get-rs-so-name,$(src)),$(call get-object-name,$(src)),$(RS_COMPAT))\
|
||||
)
|
||||
|
||||
ifneq ($(filter x86 x86_64, $(TARGET_ARCH_ABI)),)
|
||||
$(foreach src,$(filter %.asm,$(LOCAL_SRC_FILES)), $(call compile-asm-source,$(src),$(call get-object-name,$(src))))
|
||||
endif
|
||||
|
||||
#
|
||||
# The compile-xxx-source calls updated LOCAL_OBJECTS and LOCAL_DEPENDENCY_DIRS
|
||||
#
|
||||
ALL_DEPENDENCY_DIRS += $(sort $(LOCAL_DEPENDENCY_DIRS))
|
||||
CLEAN_OBJS_DIRS += $(LOCAL_OBJS_DIR)
|
||||
|
||||
#
|
||||
# Handle the static and shared libraries this module depends on
|
||||
#
|
||||
|
||||
# If LOCAL_LDLIBS contains anything like -l<library> then
|
||||
# prepend a -L$(SYSROOT_LINK)/usr/lib to it to ensure that the linker
|
||||
# looks in the right location
|
||||
#
|
||||
ifneq ($(filter -l%,$(LOCAL_LDLIBS)),)
|
||||
LOCAL_LDLIBS := -L$(call host-path,$(SYSROOT_LINK)/usr/lib) $(LOCAL_LDLIBS)
|
||||
ifneq ($(filter x86_64 mips64,$(TARGET_ARCH_ABI)),)
|
||||
LOCAL_LDLIBS := -L$(call host-path,$(SYSROOT_LINK)/usr/lib64) $(LOCAL_LDLIBS)
|
||||
endif
|
||||
endif
|
||||
|
||||
# When LOCAL_SHORT_COMMANDS is defined to 'true' we are going to write the
|
||||
# list of all object files and/or static/shared libraries that appear on the
|
||||
# command line to a file, then use the @<listfile> syntax to invoke it.
|
||||
#
|
||||
# This allows us to link or archive a huge number of stuff even on Windows
|
||||
# with its puny 8192 max character limit on its command-line.
|
||||
#
|
||||
LOCAL_SHORT_COMMANDS := $(strip $(LOCAL_SHORT_COMMANDS))
|
||||
ifndef LOCAL_SHORT_COMMANDS
|
||||
LOCAL_SHORT_COMMANDS := $(strip $(NDK_APP_SHORT_COMMANDS))
|
||||
endif
|
||||
|
||||
define libcrystax-link-type
|
||||
$(strip \
|
||||
$(call assert-defined,LOCAL_LDFLAGS NDK_APP_LIBCRYSTAX)\
|
||||
$(if \
|
||||
$(or \
|
||||
$(filter -static,$(LOCAL_LDFLAGS)),\
|
||||
$(filter static,$(NDK_APP_LIBCRYSTAX))\
|
||||
),\
|
||||
static,\
|
||||
dynamic\
|
||||
)\
|
||||
)
|
||||
endef
|
||||
|
||||
# $1: Target ABI
|
||||
define libcrystax-libpath
|
||||
$(strip \
|
||||
$(eval __libcrystax_libpath := $(crystax-dir)/libs/$(1)$(if $(filter armeabi%,$(1)),/thumb))\
|
||||
$(if $(wildcard $(__libcrystax_libpath)),\
|
||||
$(__libcrystax_libpath),\
|
||||
$(call __ndk_info,Could not find libcrystax libraries: $(call pretty-dir,$(__libcrystax_libpath)) (broken NDK?))\
|
||||
$(call __ndk_error,Aborting)\
|
||||
)\
|
||||
)
|
||||
endef
|
||||
|
||||
# - Ensure -lcrystax is _always_ before -lc
|
||||
# - Properly detect how to link libcrystax - statically or dynamically
|
||||
# - Specify path to empty libcrystax.a stub to make linker happy when it
|
||||
# use -lcrystax (according to built-in linker spec)
|
||||
# - Specify proper path to libcrystax binary
|
||||
# - Force __crystax_on_load/__crystax_on_unload to be undefined in case of static
|
||||
# libcrystax linking. This way we ensure they will not be thrown away by linker.
|
||||
# - Enable 'muldefs' option when statically linking.
|
||||
# This way app will use functions from libcrystax and link successfully
|
||||
# even if there are symbols with the same name in subsequent static libraries (libc etc)
|
||||
# - Force -Wl,--eh-frame-hdr for static executables if not yet specified
|
||||
# Parameters:
|
||||
# $1: List of linker '-lxxx' options to adjust
|
||||
define interpose-libcrystax
|
||||
$(strip \
|
||||
$(call assert-defined,TARGET_ARCH_ABI LOCAL_LDFLAGS)\
|
||||
$(filter-out -lc -lm,$(1)) \
|
||||
$(if $(filter static,$(libcrystax-link-type)),\
|
||||
-u __crystax_on_load \
|
||||
-u __crystax_on_unload \
|
||||
) \
|
||||
$(if $(filter -static,$(LOCAL_LDFLAGS)),\
|
||||
$(eval __libcrystax_muldefs := -Wl,-z,muldefs) \
|
||||
$(__libcrystax_muldefs) \
|
||||
) \
|
||||
$(if $(filter -static,$(LOCAL_LDFLAGS)),\
|
||||
$(eval __libcrystax_static_eh_frame_hdr := -Wl,--eh-frame-hdr) \
|
||||
$(if $(filter $(__libcrystax_static_eh_frame_hdr),$(LOCAL_LDFLAGS)),,$(__libcrystax_static_eh_frame_hdr)) \
|
||||
) \
|
||||
-L$(crystax-dir)/empty \
|
||||
$(call libcrystax-libpath,$(TARGET_ARCH_ABI))/libcrystax.$(if $(filter static,$(libcrystax-link-type)),a,so) \
|
||||
-lc \
|
||||
)
|
||||
endef
|
||||
|
||||
$(call generate-file-dir,$(LOCAL_BUILT_MODULE))
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_OBJECTS := $(LOCAL_OBJECTS)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LIBGCC := $(TARGET_LIBGCC)
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LD := $(TARGET_LD)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS := $(TARGET_LDFLAGS) $(LOCAL_LDFLAGS) $(NDK_APP_LDFLAGS)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LDLIBS := $(call interpose-libcrystax,$(LOCAL_LDLIBS) $(TARGET_LDLIBS))
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_NAME := $(notdir $(LOCAL_BUILT_MODULE))
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_CXX := $(TARGET_CXX)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_CC := $(TARGET_CC)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_SYSROOT_LINK := $(SYSROOT_LINK)
|
||||
|
||||
ifeq ($(call module-get-class,$(LOCAL_MODULE)),STATIC_LIBRARY)
|
||||
|
||||
#
|
||||
# This is a static library module, things are very easy. We only need
|
||||
# to build the object files and archive them with 'ar'. Note that module
|
||||
# dependencies can be ignored here, i.e. if the module depends on other
|
||||
# static or shared libraries, there is no need to actually build them
|
||||
# before, so don't add Make dependencies to them.
|
||||
#
|
||||
# In other words, consider the following graph:
|
||||
#
|
||||
# libfoo.so -> libA.a ->libB.a
|
||||
#
|
||||
# then libA.a and libB.a can be built in parallel, only linking libfoo.so
|
||||
# depends on their completion.
|
||||
#
|
||||
|
||||
ar_objects := $(call host-path,$(LOCAL_OBJECTS))
|
||||
|
||||
ifeq ($(LOCAL_SHORT_COMMANDS),true)
|
||||
$(call ndk_log,Building static library module '$(LOCAL_MODULE)' with linker list file)
|
||||
ar_list_file := $(LOCAL_OBJS_DIR)/archiver.list
|
||||
$(call generate-list-file,$(ar_objects),$(ar_list_file))
|
||||
ar_objects := @$(call host-path,$(ar_list_file))
|
||||
$(LOCAL_BUILT_MODULE): $(ar_list_file)
|
||||
endif
|
||||
|
||||
# Compute 'ar' flags. Thin archives simply require 'T' here.
|
||||
ar_flags := $(TARGET_ARFLAGS)
|
||||
ifeq (true,$(thin_archive))
|
||||
$(call ndk_log,$(TARGET_ARCH_ABI):Building static library '$(LOCAL_MODULE)' as thin archive)
|
||||
ar_flags := $(ar_flags)T
|
||||
endif
|
||||
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_ABI := $(TARGET_ARCH_ABI)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_AR := $(TARGET_AR) $(ar_flags)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_AR_OBJECTS := $(ar_objects)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_BUILD_STATIC_LIB := $(cmd-build-static-library)
|
||||
|
||||
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
|
||||
$(call host-echo-build-step,$(PRIVATE_ABI),StaticLibrary) "$(PRIVATE_NAME)"
|
||||
# $(hide) $(call host-rm,$@)
|
||||
$(hide) $(PRIVATE_BUILD_STATIC_LIB)
|
||||
|
||||
ALL_STATIC_LIBRARIES += $(LOCAL_BUILT_MODULE)
|
||||
|
||||
endif
|
||||
|
||||
ifneq (,$(filter SHARED_LIBRARY EXECUTABLE,$(call module-get-class,$(LOCAL_MODULE))))
|
||||
|
||||
#
|
||||
# This is a shared library or an executable, so computing dependencies properly is
|
||||
# crucial. The general rule to apply is the following:
|
||||
#
|
||||
# - collect the list of all static libraries that need to be part
|
||||
# of the link, and in the right order. To do so, get the transitive
|
||||
# closure of LOCAL_STATIC_LIBRARIES and LOCAL_WHOLE_STATIC_LIBRARIES
|
||||
# and ensure they are ordered topologically.
|
||||
#
|
||||
# - collect the list of all shared libraries that need to be part of
|
||||
# the link. This is the transitive closure of the list of
|
||||
# LOCAL_SHARED_LIBRARIES for the module and all its dependent static
|
||||
# libraries identified in the step above. Of course, need to be
|
||||
# ordered topologically too.
|
||||
#
|
||||
# - add Make dependencies to ensure that all these libs are built
|
||||
# before the module itself too.
|
||||
#
|
||||
# A few quick examples:
|
||||
#
|
||||
# main.exe -> libA.a -> libB.a -> libfoo.so -> libC.a
|
||||
#
|
||||
# static_libs(main.exe) = libA.a libB.a (i.e. no libC.a)
|
||||
# shared_libs(main.exe) = libfoo.so
|
||||
# static_libs(libfoo.so) = libC.a
|
||||
#
|
||||
# main.exe -> libA.a ---> libB.a
|
||||
# | ^
|
||||
# v |
|
||||
# libC.a ------
|
||||
#
|
||||
# static_libs(main.exe) = libA.a libC.a libB.a
|
||||
# (i.e. libB.a must appear after all libraries that depend on it).
|
||||
#
|
||||
all_libs := $(call module-get-link-libs,$(LOCAL_MODULE))
|
||||
shared_libs := $(call module-filter-shared-libraries,$(all_libs))
|
||||
static_libs := $(call module-filter-static-libraries,$(all_libs))
|
||||
whole_static_libs := $(call module-extract-whole-static-libs,$(LOCAL_MODULE),$(static_libs))
|
||||
static_libs := $(filter-out $(whole_static_libs),$(static_libs))
|
||||
|
||||
$(call -ndk-mod-debug,module $(LOCAL_MODULE) [$(LOCAL_BUILT_MODULE)])
|
||||
$(call -ndk-mod-debug,. all_libs='$(all_libs)')
|
||||
$(call -ndk-mod-debug,. shared_libs='$(shared_libs)')
|
||||
$(call -ndk-mod-debug,. static_libs='$(static_libs)')
|
||||
$(call -ndk-mod-debug,. whole_static_libs='$(whole_static_libs)')
|
||||
|
||||
shared_libs := $(call map,module-get-built,$(shared_libs))\
|
||||
$(TARGET_PREBUILT_SHARED_LIBRARIES)
|
||||
static_libs := $(call map,module-get-built,$(static_libs))
|
||||
whole_static_libs := $(call map,module-get-built,$(whole_static_libs))
|
||||
|
||||
$(call -ndk-mod-debug,. built_shared_libs='$(shared_libs)')
|
||||
$(call -ndk-mod-debug,. built_static_libs='$(static_libs)')
|
||||
$(call -ndk-mod-debug,. built_whole_static_libs='$(whole_static_libs)')
|
||||
|
||||
# The list of object/static/shared libraries passed to the linker when
|
||||
# building shared libraries and executables. order is important.
|
||||
#
|
||||
# Cannot use immediate evaluation because PRIVATE_LIBGCC may not be defined at this point.
|
||||
linker_objects_and_libraries = $(strip $(call TARGET-get-linker-objects-and-libraries,\
|
||||
$(LOCAL_OBJECTS), \
|
||||
$(static_libs), \
|
||||
$(whole_static_libs), \
|
||||
$(shared_libs)))
|
||||
|
||||
ifeq ($(LOCAL_SHORT_COMMANDS),true)
|
||||
$(call ndk_log,Building ELF binary module '$(LOCAL_MODULE)' with linker list file)
|
||||
linker_options := $(linker_objects_and_libraries)
|
||||
linker_list_file := $(LOCAL_OBJS_DIR)/linker.list
|
||||
linker_objects_and_libraries := @$(call host-path,$(linker_list_file))
|
||||
$(call generate-list-file,$(linker_options),$(linker_list_file))
|
||||
$(LOCAL_BUILT_MODULE): $(linker_list_file)
|
||||
endif
|
||||
|
||||
$(LOCAL_BUILT_MODULE): $(shared_libs) $(static_libs) $(whole_static_libs)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_ABI := $(TARGET_ARCH_ABI)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_LINKER_OBJECTS_AND_LIBRARIES := $(linker_objects_and_libraries)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_STATIC_LIBRARIES := $(static_libs)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_WHOLE_STATIC_LIBRARIES := $(whole_static_libs)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBRARIES := $(shared_libs)
|
||||
|
||||
endif
|
||||
|
||||
#
|
||||
# If this is a shared library module
|
||||
#
|
||||
ifeq ($(call module-get-class,$(LOCAL_MODULE)),SHARED_LIBRARY)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_BUILD_SHARED_LIB := $(cmd-build-shared-library)
|
||||
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
|
||||
$(call host-echo-build-step,$(PRIVATE_ABI),SharedLibrary) "$(PRIVATE_NAME)"
|
||||
$(hide) $(PRIVATE_BUILD_SHARED_LIB)
|
||||
|
||||
ALL_SHARED_LIBRARIES += $(LOCAL_BUILT_MODULE)
|
||||
endif
|
||||
|
||||
#
|
||||
# If this is an executable module
|
||||
#
|
||||
ifeq ($(call module-get-class,$(LOCAL_MODULE)),EXECUTABLE)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_ABI := $(TARGET_ARCH_ABI)
|
||||
$(LOCAL_BUILT_MODULE): PRIVATE_BUILD_EXECUTABLE := $(cmd-build-executable)
|
||||
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
|
||||
$(call host-echo-build-step,$(PRIVATE_ABI),Executable) "$(PRIVATE_NAME)"
|
||||
$(hide) $(PRIVATE_BUILD_EXECUTABLE)
|
||||
|
||||
ALL_EXECUTABLES += $(LOCAL_BUILT_MODULE)
|
||||
endif
|
||||
|
||||
#
|
||||
# If this is a copyable prebuilt module
|
||||
#
|
||||
ifeq ($(call module-is-copyable,$(LOCAL_MODULE)),$(true))
|
||||
$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS)
|
||||
$(call host-echo-build-step,$(PRIVATE_ABI),Prebuilt) "$(PRIVATE_NAME) <= $(call pretty-dir,$(dir $<))"
|
||||
$(hide) $(call host-cp,$<,$@)
|
||||
endif
|
||||
|
||||
#
|
||||
# If this is an installable module
|
||||
#
|
||||
ifeq ($(call module-is-installable,$(LOCAL_MODULE)),$(true))
|
||||
$(LOCAL_INSTALLED): PRIVATE_ABI := $(TARGET_ARCH_ABI)
|
||||
$(LOCAL_INSTALLED): PRIVATE_NAME := $(notdir $(LOCAL_BUILT_MODULE))
|
||||
$(LOCAL_INSTALLED): PRIVATE_SRC := $(LOCAL_BUILT_MODULE)
|
||||
$(LOCAL_INSTALLED): PRIVATE_DST_DIR := $(NDK_APP_DST_DIR)
|
||||
$(LOCAL_INSTALLED): PRIVATE_DST := $(LOCAL_INSTALLED)
|
||||
$(LOCAL_INSTALLED): PRIVATE_STRIP := $(TARGET_STRIP)
|
||||
$(LOCAL_INSTALLED): PRIVATE_STRIP_CMD := $(call cmd-strip, $(PRIVATE_DST))
|
||||
$(LOCAL_INSTALLED): PRIVATE_OBJCOPY := $(TARGET_OBJCOPY)
|
||||
$(LOCAL_INSTALLED): PRIVATE_OBJCOPY_CMD := $(call cmd-add-gnu-debuglink, $(PRIVATE_DST), $(PRIVATE_SRC))
|
||||
|
||||
LIBCRYSTAX_INSTALLED := $(subst //,/,$(call parent-dir,$(LOCAL_INSTALLED))/libcrystax.so)
|
||||
|
||||
$(LOCAL_INSTALLED): $(LOCAL_BUILT_MODULE) clean-installed-binaries $(if $(filter dynamic,$(libcrystax-link-type)),$(LIBCRYSTAX_INSTALLED))
|
||||
$(call host-echo-build-step,$(PRIVATE_ABI),Install) "$(PRIVATE_NAME) => $(call pretty-dir,$(PRIVATE_DST))"
|
||||
$(hide) $(call host-install,$(PRIVATE_SRC),$(PRIVATE_DST))
|
||||
$(hide) $(PRIVATE_STRIP_CMD)
|
||||
|
||||
#$(hide) $(PRIVATE_OBJCOPY_CMD)
|
||||
|
||||
$(call generate-file-dir,$(LOCAL_INSTALLED))
|
||||
|
||||
ifeq (,$(GLOBAL_LIBCRYSTAX_INSTALL_RULE_DEFINED.$(TARGET_ARCH_ABI)))
|
||||
|
||||
$(LIBCRYSTAX_INSTALLED): PRIVATE_LIBCRYSTAX_ABI := $(TARGET_ARCH_ABI)
|
||||
|
||||
$(LIBCRYSTAX_INSTALLED): $(LOCAL_BUILT_MODULE) clean-installed-binaries
|
||||
$(call host-echo-build-step,$(PRIVATE_LIBCRYSTAX_ABI),Install) "$(notdir $@) => $(call pretty-dir,$@)"
|
||||
$(hide) $(call host-install,$(call libcrystax-libpath,$(PRIVATE_LIBCRYSTAX_ABI))/libcrystax.so,$@)
|
||||
$(hide) $(call cmd-strip,$@)
|
||||
|
||||
$(call generate-file-dir,$(LIBCRYSTAX_INSTALLED))
|
||||
|
||||
GLOBAL_LIBCRYSTAX_INSTALL_RULE_DEFINED.$(TARGET_ARCH_ABI) := true
|
||||
|
||||
endif
|
||||
|
||||
endif
|
0
scripts/crystax-sources/sqlite/3/Android.mk
Normal file
0
scripts/crystax-sources/sqlite/3/Android.mk
Normal file
|
@ -21,6 +21,9 @@ from lbry.conf import Config
|
|||
from lbry.extras.daemon.components import DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT
|
||||
from lbry.extras.daemon.daemon import Daemon
|
||||
|
||||
import sqlite3
|
||||
import ssl
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
log.setLevel(logging.DEBUG)
|
||||
|
||||
|
@ -122,7 +125,7 @@ def start():
|
|||
|
||||
configure_logging(conf)
|
||||
log.info('Starting lbry sdk {}'.format(lbrynet_version));
|
||||
|
||||
log.info('openssl: {}, sqlite3: {}'.format(ssl.OPENSSL_VERSION, sqlite3.sqlite_version))
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.set_debug(lbrynet_android_utils.isDebug())
|
||||
|
||||
|
|
Loading…
Reference in a new issue