2020-05-07 10:21:39 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-02-28 17:22:17 +00:00
|
|
|
# This script takes care of generating/updating the maven-sources.nix file
|
|
|
|
# representing the offline Maven repo containing the dependencies
|
|
|
|
# required to build the project
|
|
|
|
|
|
|
|
set -Eeo pipefail
|
2020-05-24 13:44:15 +00:00
|
|
|
|
2020-05-07 10:21:39 +00:00
|
|
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
|
|
|
echo "Remember to call 'make shell'!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
|
|
|
source "${GIT_ROOT}/scripts/colors.sh"
|
|
|
|
|
2022-06-07 11:21:15 +00:00
|
|
|
CUR_DIR=$(cd "${BASH_SOURCE%/*}" && pwd)
|
2020-05-07 10:21:39 +00:00
|
|
|
PROJ_LIST="${CUR_DIR}/proj.list"
|
|
|
|
DEPS_LIST="${CUR_DIR}/deps.list"
|
|
|
|
DEPS_URLS="${CUR_DIR}/deps.urls"
|
2020-05-14 09:13:06 +00:00
|
|
|
DEPS_JSON="${CUR_DIR}/deps.json"
|
2020-05-07 10:21:39 +00:00
|
|
|
|
|
|
|
# Raise limit of file descriptors
|
|
|
|
ulimit -n 16384
|
|
|
|
|
2020-11-27 11:35:21 +00:00
|
|
|
# Generate list of Gradle sub-projects.
|
|
|
|
function gen_proj_list() {
|
2023-02-28 17:22:17 +00:00
|
|
|
"${CUR_DIR}/get_projects.sh" | sort -u -o "${PROJ_LIST}"
|
|
|
|
echo -e "Found ${GRN}$(wc -l < "${PROJ_LIST}")${RST} sub-projects..."
|
2020-11-27 11:35:21 +00:00
|
|
|
}
|
|
|
|
|
2023-06-23 08:43:12 +00:00
|
|
|
# Check each sub-project in parallel, the "" is for local deps.
|
2020-11-27 11:35:21 +00:00
|
|
|
function gen_deps_list() {
|
2023-02-28 17:22:17 +00:00
|
|
|
PROJECTS=$(cat "${PROJ_LIST}")
|
|
|
|
# WARNING: The ${PROJECTS[@]} needs to remain unquoted to expand correctly.
|
|
|
|
# shellcheck disable=SC2068
|
2023-06-23 08:43:12 +00:00
|
|
|
"${CUR_DIR}/get_deps.sh" "" ${PROJECTS[@]} | sort -uV -o "${DEPS_LIST}"
|
2023-02-28 17:22:17 +00:00
|
|
|
echo -e "${CLR}Found ${GRN}$(wc -l < "${DEPS_LIST}")${RST} direct dependencies..."
|
2020-11-27 11:35:21 +00:00
|
|
|
}
|
|
|
|
|
2023-10-19 09:20:32 +00:00
|
|
|
# FIXME: Temporary fix for missing packages.
|
|
|
|
# https://github.com/status-im/status-mobile/issues/15447
|
|
|
|
function add_deps_hack() {
|
|
|
|
echo -n \
|
2023-12-11 15:52:23 +00:00
|
|
|
'com.android.tools.build:gradle:1.3.1
|
|
|
|
com.squareup.okio:okio:1.13.0
|
|
|
|
com.squareup.okio:okio:1.15.0
|
|
|
|
com.squareup.okhttp3:okhttp:3.12.1
|
|
|
|
org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.7.22
|
2024-01-16 15:48:15 +00:00
|
|
|
org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2
|
2024-03-22 14:21:44 +00:00
|
|
|
org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.0
|
|
|
|
org.gradle.toolchains.foojay-resolver-convention:org.gradle.toolchains.foojay-resolver-convention.gradle.plugin:0.5.0
|
|
|
|
org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.8.0
|
|
|
|
com.android.tools.build:gradle:8.1.1
|
|
|
|
com.google.errorprone:error_prone_annotations:2.7.1
|
|
|
|
com.android.tools.lint:lint-gradle:31.1.1
|
2024-04-24 09:55:40 +00:00
|
|
|
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0
|
2024-05-24 15:32:32 +00:00
|
|
|
com.android.tools.build:gradle:3.5.4
|
2024-06-12 08:13:26 +00:00
|
|
|
androidx.annotation:annotation:1.6.0
|
|
|
|
androidx.annotation:annotation-jvm:1.6.0
|
2024-05-24 15:32:32 +00:00
|
|
|
com.facebook.react:hermes-android:0.73.5' \
|
2023-10-19 09:20:32 +00:00
|
|
|
>> "${DEPS_LIST}"
|
|
|
|
}
|
|
|
|
|
2020-11-27 11:35:21 +00:00
|
|
|
# Find download URLs for each dependency.
|
|
|
|
function gen_deps_urls() {
|
2023-02-28 17:22:17 +00:00
|
|
|
go-maven-resolver < "${DEPS_LIST}" | sort -uV -o "${DEPS_URLS}"
|
|
|
|
echo -e "${CLR}Found ${GRN}$(wc -l < "${DEPS_URLS}")${RST} dependency URLs..."
|
2020-11-27 11:35:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Generate the JSON that Nix will consume.
|
|
|
|
function gen_deps_json() {
|
|
|
|
# Open the Nix attribute set.
|
2023-02-28 17:22:17 +00:00
|
|
|
echo -n "[" > "${DEPS_JSON}"
|
2020-11-27 11:35:21 +00:00
|
|
|
|
|
|
|
# Format URLs into a Nix consumable file.
|
2023-02-28 17:22:17 +00:00
|
|
|
URLS=$(cat "${DEPS_URLS}")
|
2022-05-18 08:12:22 +00:00
|
|
|
# Avoid rate limiting by using 4 of the available threads.
|
2023-06-23 08:43:12 +00:00
|
|
|
echo "${URLS}" | parallel --will-cite --keep-order --jobs 4 \
|
2020-11-27 11:35:21 +00:00
|
|
|
"${CUR_DIR}/url2json.sh" \
|
2023-02-28 17:22:17 +00:00
|
|
|
>> "${DEPS_JSON}"
|
2020-11-27 11:35:21 +00:00
|
|
|
|
|
|
|
# Drop tailing comma on last object, stupid JSON
|
2023-02-28 17:22:17 +00:00
|
|
|
sed -i '$ s/},/}/' "${DEPS_JSON}"
|
2020-11-27 11:35:21 +00:00
|
|
|
|
|
|
|
# Close the Nix attribute set
|
2023-02-28 17:22:17 +00:00
|
|
|
echo "]" >> "${DEPS_JSON}"
|
2020-11-27 11:35:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2020-05-07 10:21:39 +00:00
|
|
|
echo "Regenerating Nix files..."
|
|
|
|
|
|
|
|
# Gradle needs to be run in 'android' subfolder
|
2022-07-25 20:38:41 +00:00
|
|
|
cd "${GIT_ROOT}/android"
|
2020-05-07 10:21:39 +00:00
|
|
|
|
|
|
|
# Stop gradle daemons to avoid locking
|
|
|
|
./gradlew --stop >/dev/null
|
|
|
|
|
2020-11-27 11:35:21 +00:00
|
|
|
# A way to run a specific stage of generation
|
2023-02-28 17:22:17 +00:00
|
|
|
if [[ -n "${1}" ]] && type "${1}" > /dev/null; then
|
2020-11-27 11:35:21 +00:00
|
|
|
${1}; exit 0
|
|
|
|
elif [[ -n "${1}" ]]; then
|
|
|
|
echo "No such function: ${1}"; exit 1
|
|
|
|
fi
|
2020-05-07 10:21:39 +00:00
|
|
|
|
2020-11-27 11:35:21 +00:00
|
|
|
# Run each stage in order
|
|
|
|
gen_proj_list
|
|
|
|
gen_deps_list
|
2023-10-19 09:20:32 +00:00
|
|
|
add_deps_hack
|
2020-11-27 11:35:21 +00:00
|
|
|
gen_deps_urls
|
|
|
|
gen_deps_json
|
2020-05-07 10:21:39 +00:00
|
|
|
|
2023-02-28 17:22:17 +00:00
|
|
|
REL_DEPS_JSON=$(realpath --relative-to="${PWD}" "${DEPS_JSON}")
|
2020-05-24 13:44:15 +00:00
|
|
|
echo -e "${CLR}Generated Nix deps file: ${REL_DEPS_JSON#../}"
|
2020-05-07 10:21:39 +00:00
|
|
|
echo -e "${GRN}Done${RST}"
|