android: determinstic build in Android Studio (#6502)

* apps/android: pass and adjust PATH to shell script

* scripts/compress-and-sign: attempt to make determenistic build

* android: strip app-lib from project paths

* scripts/compress-and-sign-apk: compatability with MacOS

* apps/android: remove redundant cmake flag from app-lib

* scripts/compress-and-sign-apk: fix permissions + timestamp normalization

* scripts/compress-and-sign-apk: fix file ordering

some weird mac issues, i dunno

* apps/android: strip comment sections and do not embed build-id in libapp

* scripts/compress-and-sign-apk: disable verbose logging

---------

Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
This commit is contained in:
sh
2025-12-12 17:00:59 +00:00
committed by GitHub
co-authored by Evgeny Poberezkin
parent 13bce0821c
commit afccda1b69
3 changed files with 49 additions and 10 deletions
+4 -1
View File
@@ -192,7 +192,10 @@ tasks {
}
exec {
workingDir("../../scripts/android")
environment = mapOf("JAVA_HOME" to "$javaHome")
environment = mapOf(
"JAVA_HOME" to "$javaHome",
"PATH" to "${System.getenv("PATH")}:$javaHome/bin"
)
commandLine = listOf(
"./compress-and-sign-apk.sh",
"${rootProject.extra["compression.level"]}",
@@ -53,12 +53,19 @@ add_library( support SHARED IMPORTED )
set_target_properties( support PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/libs/${ANDROID_ABI}/libsupport.so)
target_compile_options(app-lib PRIVATE
-g0
)
# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.
# https://developer.android.com/guide/practices/page-sizes#cmake
target_link_options(app-lib PRIVATE "-Wl,-z,max-page-size=16384")
target_link_options(app-lib PRIVATE
"-Wl,-z,max-page-size=16384"
"-Wl,--build-id=none"
)
target_link_libraries( # Specifies the target library.
app-lib
@@ -67,4 +74,10 @@ target_link_libraries( # Specifies the target library.
# Links the target library to the log library
# included in the NDK.
${log-lib})
${log-lib}
)
add_custom_command(TARGET app-lib POST_BUILD
COMMAND ${CMAKE_STRIP} --remove-section=.comment $<TARGET_FILE:app-lib>
COMMENT "Stripping .comment section from app-lib"
)