Skip to content

Commit

Permalink
guix: android builds
Browse files Browse the repository at this point in the history
Co-authored-by: Czarek Nakamoto <cyjan@mrcyjanek.net>
  • Loading branch information
tobtoht and MrCyjaneK committed Aug 24, 2024
1 parent f311522 commit 2594e3d
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 160 deletions.
1 change: 1 addition & 0 deletions contrib/depends/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ $(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host)
$(host_arch)_$(host_os)_host=$(host)
host_prefix=$($(host_arch)_$(host_os)_prefix)
build_prefix=$(host_prefix)/native
toolchain_prefix=$(build_prefix)/toolchain

AT_$(V):=
AT_:=@
Expand Down
6 changes: 3 additions & 3 deletions contrib/depends/funcs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ $(1)_stage_env+=$($(1)_stage_env_$(host_arch)_$(host_os)) $($(1)_stage_env_$(hos

$(1)_config_env+=PKG_CONFIG_LIBDIR=$($($(1)_type)_prefix)/lib/pkgconfig
$(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig
$(1)_config_env+=PATH="$(build_prefix)/bin:$(PATH)"
$(1)_build_env+=PATH="$(build_prefix)/bin:$(PATH)"
$(1)_stage_env+=PATH="$(build_prefix)/bin:$(PATH)"
$(1)_config_env+=PATH="$(toolchain_prefix)/bin:$(build_prefix)/bin:$(PATH)"
$(1)_build_env+=PATH="$(toolchain_prefix)/bin:$(build_prefix)/bin:$(PATH)"
$(1)_stage_env+=PATH="$(toolchain_prefix)/bin:$(build_prefix)/bin:$(PATH)"
$(1)_autoconf=./configure --host=$($($(1)_type)_host) --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)"

ifeq ($(filter $(1),libusb unbound),)
Expand Down
24 changes: 18 additions & 6 deletions contrib/depends/hosts/android.mk
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
ANDROID_API=21
android_API=21

ifeq ($(host_arch),arm)
host_toolchain=arm-linux-androideabi-
host_toolchain=armv7a-linux-androideabi$(android_API)-
else ifeq ($(host_arch),aarch64)
host_toolchain=aarch64-linux-android$(android_API)-
endif

android_CC=$(host_toolchain)clang
android_CXX=$(host_toolchain)clang++
android_RANLIB=:
clear_guix_env=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
-u OBJC_INCLUDE_PATH -u OBJCPLUS_INCLUDE_PATH -u CPATH \
-u LIBRARY_PATH

android_CC=$(clear_guix_env) $(host_toolchain)clang
android_CXX=$(clear_guix_env) $(host_toolchain)clang++

android_AR=llvm-ar
android_RANLIB=llvm-ranlib

android_CFLAGS=-pipe
android_CXXFLAGS=$(android_CFLAGS)
Expand All @@ -20,4 +28,8 @@ android_debug_CXXFLAGS=$(android_debug_CFLAGS)

android_native_toolchain=android_ndk

android_cmake_system=Android
# CMake tries to be 'helpful' by manually constructing compiler
# paths when CMAKE_SYSTEM_NAME == "Android". Instead, we want it
# to use the tools and options defined here. It's easier to just
# pretend we're a generic Linux target, than to hack around it.
android_cmake_system=Linux
24 changes: 5 additions & 19 deletions contrib/depends/packages/android_ndk.mk
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
package=android_ndk
$(package)_version=18b
$(package)_version=26d
$(package)_download_path=https://dl.google.com/android/repository/
$(package)_file_name=android-ndk-r$($(package)_version)-linux-x86_64.zip
$(package)_sha256_hash=4f61cbe4bbf6406aa5ef2ae871def78010eed6271af72de83f8bd0b07a9fd3fd
$(package)_patches=api_definition.patch fix_env.patch

define $(package)_set_vars
$(package)_config_opts_arm=--arch arm
$(package)_config_opts_aarch64=--arch arm64
endef
$(package)_file_name=android-ndk-r$($(package)_version)-linux.zip
$(package)_sha256_hash=eefeafe7ccf177de7cc57158da585e7af119bb7504a63604ad719e4b2a328b54

define $(package)_extract_cmds
echo $($(package)_sha256_hash) $($(1)_source_dir)/$($(package)_file_name) | sha256sum -c &&\
unzip -q $($(1)_source_dir)/$($(package)_file_name)
endef

define $(package)_preprocess_cmds
cd android-ndk-r$($(package)_version) && \
patch -p1 < $($(package)_patch_dir)/api_definition.patch && \
patch -p1 < $($(package)_patch_dir)/fix_env.patch
endef

define $(package)_stage_cmds
python3 android-ndk-r$($(package)_version)/build/tools/make_standalone_toolchain.py --api 21 \
--install-dir $(build_prefix) --stl=libc++ $($(package)_config_opts) &&\
mv $(build_prefix) $($(package)_staging_dir)/$(host_prefix)
mkdir -p $($(package)_staging_prefix_dir)/toolchain && \
mv android-ndk-r$($(package)_version)/toolchains/llvm/prebuilt/linux-x86_64/* $($(package)_staging_prefix_dir)/toolchain
endef

22 changes: 9 additions & 13 deletions contrib/depends/packages/boost.mk
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package=boost
$(package)_version=1_64_0
$(package)_download_path=https://downloads.sourceforge.net/project/boost/boost/1.64.0/
$(package)_file_name=$(package)_$($(package)_version).tar.bz2
$(package)_sha256_hash=7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332
$(package)_patches=fix_aroptions.patch fix_arm_arch.patch fix_coalesce.patch
$(package)_version=1.84.0
$(package)_download_path=https://downloads.sourceforge.net/project/boost/boost/$($(package)_version)/
$(package)_file_name=$(package)_$(subst .,_,$($(package)_version)).tar.bz2
$(package)_sha256_hash=cc4b893acf645c9d4b698e9a0f08ca8846aa5d6c68275c14c3e7949c24109454

define $(package)_set_vars
$(package)_config_opts_release=variant=release
$(package)_config_opts_debug=variant=debug
$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam
$(package)_config_opts=variant=release
$(package)_config_opts+=--layout=system --user-config=user-config.jam
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
$(package)_config_opts_android=threadapi=pthread runtime-link=static target-os=android
$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared
$(package)_config_opts_darwin=--toolset=darwin runtime-link=shared target-os=darwin
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
$(package)_config_opts_x86_64_mingw32=address-model=64
$(package)_config_opts_i686_mingw32=address-model=32
Expand All @@ -23,16 +21,14 @@ $(package)_toolset_darwin=darwin
$(package)_archiver_darwin=$($(package)_libtool)
$(package)_config_libraries_$(host_os)="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization"
$(package)_config_libraries_mingw32="chrono,filesystem,program_options,system,thread,test,date_time,regex,serialization,locale"
$(package)_cxxflags+=-std=c++11
$(package)_cxxflags+=-std=c++17
$(package)_cxxflags_linux+=-fPIC
$(package)_cxxflags_android+=-fPIC
$(package)_cxxflags_freebsd+=-fPIC
$(package)_cxxflags_darwin+=-ffile-prefix-map=$($(package)_extract_dir)=/usr
endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/fix_aroptions.patch &&\
patch -p1 < $($(package)_patch_dir)/fix_arm_arch.patch &&\
patch -p1 < $($(package)_patch_dir)/fix_coalesce.patch &&\
echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : <cxxflags>\"$($(package)_cxxflags) $($(package)_cppflags)\" <linkflags>\"$($(package)_ldflags)\" <archiver>\"$(boost_archiver_$(host_os))\" <arflags>\"$($(package)_arflags)\" <striper>\"$(host_STRIP)\" <ranlib>\"$(host_RANLIB)\" <rc>\"$(host_WINDRES)\" : ;" > user-config.jam
endef

Expand Down
6 changes: 4 additions & 2 deletions contrib/depends/packages/openssl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ $(package)_version=3.0.13
$(package)_download_path=https://www.openssl.org/source
$(package)_file_name=$(package)-$($(package)_version).tar.gz
$(package)_sha256_hash=88525753f79d3bec27d2fa7c66aa0b92b3aa9498dafd93d7cfa4b3780cdae313
$(package)_patches=android-fix.patch

# The bundled ranlib in Android NDK 18b inserts timestamps by default.
# To prevent reproducibility issues, we must enable [D]eterministic mode.

define $(package)_set_vars
$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)"
$(package)_config_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native" PATH="$(host_prefix)/native/bin" CC=clang AR=ar RANLIB="ranlib -D"
$(package)_build_env_android=ANDROID_NDK_ROOT="$(host_prefix)/native"
$(package)_config_env_android=ANDROID_NDK_ROOT="$(toolchain_prefix)" PATH="$(toolchain_prefix)/bin"
$(package)_build_env_android=ANDROID_NDK_ROOT="$(toolchain_prefix)"
$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl --libdir=$(host_prefix)/lib
$(package)_config_opts+=no-capieng
$(package)_config_opts+=no-dso
Expand Down Expand Up @@ -52,6 +53,7 @@ $(package)_config_opts_x86_64_freebsd=BSD-x86_64
endef

define $(package)_preprocess_cmds
patch -p1 < $($(package)_patch_dir)/android-fix.patch && \
sed -i.old 's|crypto ssl apps util tools fuzz providers doc|crypto ssl util tools providers|' build.info
endef

Expand Down
5 changes: 5 additions & 0 deletions contrib/depends/packages/rustc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ $(package)_file_name=rustc-$($(package)_version)-src.tar.gz
$(package)_sha256_hash=ee106e4c569f52dba3b5b282b105820f86bd8f6b3d09c06b8dce82fb1bb3a4a1
$(package)_patches=config.toml
$(package)_freebsd_dependencies=freebsd_base native_binutils
$(package)_android_dependencies=android_ndk

define $(package)_set_vars
$(package)_stage_env_freebsd=AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd11-ar
$(package)_stage_env_freebsd+=CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd11-clang
$(package)_stage_env_freebsd+=CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd11-clang++
$(package)_stage_env_aarch64_android=CC_aarch64_linux_android="$(host_toolchain)clang"
$(package)_stage_env_aarch64_android+=CXX_aarch64_linux_android="$(host_toolchain)clang++"
$(package)_stage_env_arm_android=CC_armv7_linux_androideabi="$(host_toolchain)clang"
$(package)_stage_env_arm_android+=CXX_armv7_linux_androideabi="$(host_toolchain)clang++"
endef

define $(package)_config_cmds
Expand Down
15 changes: 0 additions & 15 deletions contrib/depends/patches/android_ndk/api_definition.patch

This file was deleted.

30 changes: 0 additions & 30 deletions contrib/depends/patches/android_ndk/fix_env.patch

This file was deleted.

11 changes: 0 additions & 11 deletions contrib/depends/patches/boost/fix_arm_arch.patch

This file was deleted.

28 changes: 0 additions & 28 deletions contrib/depends/patches/boost/fix_aroptions.patch

This file was deleted.

17 changes: 0 additions & 17 deletions contrib/depends/patches/boost/fix_coalesce.patch

This file was deleted.

Loading

0 comments on commit 2594e3d

Please sign in to comment.