Fix gradle builds for Apple Silicon running arm64 JDKs (#4792)

* add the darwin-aarch64
* fix gradle builds for m1 macs using arm64 JDK
* updated verify desktop scripts to help people migrate
This commit is contained in:
Sammy Khamis 2022-02-03 12:05:46 -10:00 коммит произвёл GitHub
Родитель 0818678c3d
Коммит cbfa39d756
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 36 добавлений и 10 удалений

Просмотреть файл

@ -21,7 +21,7 @@ buildscript {
mockito_core_version = '2.28.2'
roboelectric_core_version = '4.5.1'
robolectric_core_version = '4.5.1'
rust_android_gradle_version = '0.8.3'
rust_android_gradle_version = '0.9.1'
espresso_core_version = '3.3.0'
protobuf_version = '3.11.4'
gradle_protobuf_version = '0.8.14'
@ -61,7 +61,7 @@ buildscript {
// Publish.
classpath "digital.wup:android-maven-publish:$maven_publish_version"
classpath "gradle.plugin.org.mozilla.rust-android-gradle:plugin:$rust_android_gradle_version"
classpath "org.mozilla.rust-android-gradle:plugin:$rust_android_gradle_version"
// Yes, this is unusual. We want to access some host-specific
// computation at build time.
@ -145,8 +145,8 @@ if (useDownloadedLibs) {
task downloadDesktopLibs(type: Download) {
src {
switch (DefaultPlatform.RESOURCE_PREFIX) {
case 'darwin':
case 'darwin-x86-64':
case 'darwin-aarch64':
return "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/project.application-services.application-services.build.libs.desktop.macos.${rootProject.ext.libsGitSha}/artifacts/public/build/macos.tar.gz"
case 'linux-x86-64':
return "https://firefox-ci-tc.services.mozilla.com/api/index/v1/task/project.application-services.application-services.build.libs.desktop.linux.${rootProject.ext.libsGitSha}/artifacts/public/build/linux.tar.gz"
@ -162,8 +162,8 @@ if (useDownloadedLibs) {
dest {
switch (DefaultPlatform.RESOURCE_PREFIX) {
case 'darwin':
case 'darwin-x86-64':
case 'darwin-aarch64':
return new File(buildDir, "libs.desktop.macos.${rootProject.ext.libsGitSha}.tar.gz")
case 'linux-x86-64':
return new File(buildDir, "libs.desktop.linux.${rootProject.ext.libsGitSha}.tar.gz")
@ -229,9 +229,11 @@ ext.rustTargets = [
// Generate libs for our current platform so we can run unit tests.
switch (DefaultPlatform.RESOURCE_PREFIX) {
case 'darwin':
case 'darwin-x86-64':
ext.nativeRustTarget = 'darwin'
ext.nativeRustTarget = 'darwin-x86-64'
break
case 'darwin-aarch64':
ext.nativeRustTarget = 'darwin-aarch64'
break
case 'linux-x86-64':
ext.nativeRustTarget = 'linux-x86-64'

Просмотреть файл

@ -34,12 +34,13 @@ elif [[ -n "${CROSS_COMPILE_TARGET}" ]]; then
echo "Cannot build NSS for unrecognized target OS ${CROSS_COMPILE_TARGET}"
exit 1
elif [[ "$(uname -s)" == "Darwin" ]]; then
DIST_DIR=$(abspath "desktop/darwin/nss")
TARGET_OS="macos"
# We need to set this variable for switching libs based on different macos archs (M1 vs Intel)
if [[ "$(uname -m)" == "arm64" ]]; then
DIST_DIR=$(abspath "desktop/darwin-aarch64/nss")
TARGET_ARCH="aarch64"
else
DIST_DIR=$(abspath "desktop/darwin-x86-64/nss")
TARGET_ARCH="x86_64"
fi
elif [[ "$(uname -s)" == "Linux" ]]; then

Просмотреть файл

@ -34,14 +34,16 @@ elif [[ -n "${CROSS_COMPILE_TARGET}" ]]; then
echo "Cannot build SQLCipher for unrecognized target OS ${CROSS_COMPILE_TARGET}"
exit 1
elif [[ "$(uname -s)" == "Darwin" ]]; then
DIST_DIR=$(abspath "desktop/darwin/sqlcipher")
NSS_DIR=$(abspath "desktop/darwin/nss")
TARGET_OS="macos"
# We need to set this variable for switching libs based on different macos archs (M1 vs Intel)
if [[ "$(uname -m)" == "arm64" ]]; then
TARGET_ARCH="aarch64"
DIST_DIR=$(abspath "desktop/darwin-aarch64/sqlcipher")
NSS_DIR=$(abspath "desktop/darwin-aarch64/nss")
else
TARGET_ARCH="x86_64"
DIST_DIR=$(abspath "desktop/darwin-x86-64/sqlcipher")
NSS_DIR=$(abspath "desktop/darwin-x86-64/nss")
fi
elif [[ "$(uname -s)" == "Linux" ]]; then
# This is a JNA weirdness: "x86-64" rather than "x86_64".

Просмотреть файл

@ -6,6 +6,9 @@
set -e
YELLOW=$"\033[1;33m"
NC=$"\033[0m" # No Color
if [[ ! -f "$(pwd)/libs/build-all.sh" ]]; then
echo "ERROR: bootstrap-desktop.sh should be run from the root directory of the repo"
exit 1
@ -14,7 +17,11 @@ fi
"$(pwd)/libs/verify-common.sh"
if [[ "$(uname -s)" == "Darwin" ]]; then
APPSERVICES_PLATFORM_DIR="$(pwd)/libs/desktop/darwin"
if [[ "$(uname -m)" == "arm64" ]]; then
APPSERVICES_PLATFORM_DIR="$(pwd)/libs/desktop/darwin-aarch64"
else
APPSERVICES_PLATFORM_DIR="$(pwd)/libs/desktop/darwin-x86-64"
fi
else
APPSERVICES_PLATFORM_DIR="$(pwd)/libs/desktop/linux-x86-64"
fi
@ -30,6 +37,20 @@ if [[ -z "${SQLCIPHER_LIB_DIR}" ]] || [[ -z "${SQLCIPHER_INCLUDE_DIR}" ]] || [[
exit 1
fi
# If users previously have built NSS their env vars will still be pointing to darwin
# we need to tell them to update their env with the new arch-specific style
if [[ -z "${CI}" ]] && [[ "$(uname -s)" == "Darwin" ]] && [[ "${NSS_DIR}" != *"desktop/darwin-"* ]]; then
echo ""
echo -e "${YELLOW}!! Your environment variables are outdated! Please use the updated values below !!"
echo -e "Please export or add to your shell initialization file (.zshenv, .bashrc etc.) the following ${NC}"
echo ""
echo "export SQLCIPHER_LIB_DIR=${APPSERVICES_PLATFORM_DIR}/sqlcipher/lib"
echo "export SQLCIPHER_INCLUDE_DIR=${APPSERVICES_PLATFORM_DIR}/sqlcipher/include"
echo "export NSS_DIR=${APPSERVICES_PLATFORM_DIR}/nss"
echo "export NSS_STATIC=1"
exit 1
fi
if [[ ! -d "${SQLCIPHER_LIB_DIR}" ]] || [[ ! -d "${NSS_DIR}" ]]; then
pushd libs
./build-all.sh desktop