I just added a patch to move key Android configuration to ./configure --enable-android so that it is shared across all the builds. There is more stuff that can be moved there, that is not yet:
Android NDK version detection and enforcement (e.g. >= r19 or only exactly r20)
CFLAGS and LDFLAGS to find parity with Android NDK builds done with ndk-build, which automatically sets things there.
Perhaps the state of --disable-linker-hardening and --disable-gcc-hardening could also be maintained there, since we're all building with the Android NDK's clang.
The patch is attached, here's the diff:
diff --git a/configure.ac b/configure.acindex a639ffaf3..afee6940c 100644--- a/configure.ac+++ b/configure.ac@@ -88,6 +88,27 @@ else [Defined if we're building with OpenSSL or LibreSSL]) fi+dnl Enable Android only features.+AC_ARG_ENABLE(android,+ AS_HELP_STRING(--enable-android, [build with Android features enabled]))+AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])++if test "x$enable_android" = "xyes"; then+ AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])++ dnl Check if the Android log library is available.+ AC_CHECK_HEADERS([android/log.h])+ AC_SEARCH_LIBS(__android_log_write, [log])++ asciidoc=false+ enable_html_manual=no+ enable_manpage=no+ enable_pic=yes+ enable_system_torrc=no+ enable_tool_name_check=no+ have_systemd=no+fi+ if test "$enable_static_tor" = "yes"; then enable_static_libevent="yes"; enable_static_openssl="yes";@@ -117,7 +138,7 @@ AC_ARG_ENABLE(asciidoc, "yes") asciidoc=true ;; "no") asciidoc=false ;; *) AC_MSG_ERROR(bad value for --disable-asciidoc) ;;- esac], [asciidoc=true])+ esac], [test "x$asciidoc" = "xtrue" && asciidoc=true]) # systemd notify support AC_ARG_ENABLE(systemd,@@ -227,20 +248,6 @@ if test x$enable_event_tracing_debug = xyes; then AC_DEFINE([TOR_EVENT_TRACING_ENABLED], [1], [Compile the event tracing instrumentation]) fi-dnl Enable Android only features.-AC_ARG_ENABLE(android,- AS_HELP_STRING(--enable-android, [build with Android features enabled]))-AM_CONDITIONAL([USE_ANDROID], [test "x$enable_android" = "xyes"])--if test "x$enable_android" = "xyes"; then- AC_DEFINE([USE_ANDROID], [1], [Compile with Android specific features enabled])-- dnl Check if the Android log library is available.- AC_CHECK_HEADERS([android/log.h])- AC_SEARCH_LIBS(__android_log_write, [log])--fi- dnl --- dnl Tor modules options. These options are namespaced with --disable-module-XXX dnl ----- 2.20.1
I just got the gitlab-ci job for r17b working, so I can confirm that tor with my changes builds with NDK r17b, but this job does not include lzma or zstd.
I just got the gitlab-ci job for r17b working, so I can confirm that tor with my changes builds with NDK r17b, but this job does not include lzma or zstd.
I'm assuming we need to open new tickets for building these libraries? Or is this something we can live without for now?
-cp $distdir/share/tor/geoip $TORCONFIGDIR-cp $distdir/share/tor/geoip6 $TORCONFIGDIR-+[% IF !c("var/android") -%]+ cp $distdir/share/tor/geoip $TORCONFIGDIR+ cp $distdir/share/tor/geoip6 $TORCONFIGDIR+[% END -%]
Can you set TORCONFIGDIR=assets/common and use the original code instead?
In the build script, please use install instead of cp (see how files are copied within the other platform blocks).
+[% IF c("var/android") %]+ libsdir=jniLibs/[% c("var/abi") %]+ mkdir -p $libsdir assets/common+ # Copy tor using naming convention that Android will recognize + cp bin/tor $libsdir/libTor.so
There's a trailing space after 'recognize'
Can you move the tar command into the general platform-specific tar/zip block that immediately follows the android block?