nimbus-build-system/scripts/create_nimble_link.sh

38 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2019-08-20 21:14:45 +00:00
2022-01-19 23:44:30 +00:00
# Copyright (c) 2018-2021 Status Research & Development GmbH. Licensed under
2019-08-20 21:14:45 +00:00
# either of:
# - Apache License, version 2.0
# - MIT license
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
set -u
module_name="${1#*/}"
2022-01-19 23:44:30 +00:00
if [[ $(ls -1 *.nimble 2>/dev/null | wc -l) -gt 0 ]]; then
2019-08-20 21:14:45 +00:00
PKG_DIR="$(${PWD_CMD})"
2022-01-19 23:44:30 +00:00
for EXCLUDED_REL_PATH in ${EXCLUDED_NIM_PACKAGES}; do
if [[ "${PKG_DIR}" =~ ${EXCLUDED_REL_PATH} ]]; then
# skip it
exit
fi
done
if [[ -d src ]]; then
2019-08-20 21:14:45 +00:00
PKG_DIR="${PKG_DIR}/src"
fi
2022-01-19 23:44:30 +00:00
mkdir -p "${NIMBLE_DIR}/pkgs/${module_name}-#head"
NIMBLE_LINK_PATH="${NIMBLE_DIR}/pkgs/${module_name}-#head/${module_name}.nimble-link"
if [[ -e "${NIMBLE_LINK_PATH}" ]]; then
echo -e "\nERROR: Nim package already present in '${NIMBLE_LINK_PATH}': '$(head -n1 "${NIMBLE_LINK_PATH}")'"
echo -e "Will not replace it with '${PKG_DIR}'.\nPick one and put the other's relative path in EXCLUDED_NIM_PACKAGES.\nSee also: https://github.com/status-im/nimbus-build-system#excluded_nim_packages\n"
rm -rf "${NIMBLE_DIR}"
exit 1
fi
echo -e "${PKG_DIR}\n${PKG_DIR}" > "${NIMBLE_LINK_PATH}"
2019-08-20 21:14:45 +00:00
fi