move build_p2pd.sh to nimbus-build-system

This commit is contained in:
Ștefan Talpalaru 2019-08-25 15:44:45 +02:00
parent 5983e83c40
commit 60dfa7081b
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
3 changed files with 2 additions and 76 deletions

View File

@ -56,7 +56,7 @@ P2PD_CACHE :=
p2pd: | go-checks p2pd: | go-checks
BUILD_MSG="$(BUILD_MSG) $@" \ BUILD_MSG="$(BUILD_MSG) $@" \
V=$(V) \ V=$(V) \
$(ENV_SCRIPT) scripts/build_p2pd.sh "$(P2PD_CACHE)" $(ENV_SCRIPT) $(BUILD_SYSTEM_DIR)/scripts/build_p2pd.sh "$(P2PD_CACHE)"
# Windows 10 with WSL enabled, but no distro installed, fails if "../../nimble.sh" is executed directly # Windows 10 with WSL enabled, but no distro installed, fails if "../../nimble.sh" is executed directly
# in a Makefile recipe but works when prefixing it with `bash`. No idea how the PATH is overridden. # in a Makefile recipe but works when prefixing it with `bash`. No idea how the PATH is overridden.

View File

@ -1,74 +0,0 @@
#!/bin/bash
# Copyright (c) 2018-2019 Status Research & Development GmbH. Licensed under
# 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 -e
SUBREPO_DIR="vendor/go/src/github.com/libp2p/go-libp2p-daemon"
CACHE_DIR="$1" # optional parameter pointing to a CI cache dir.
## env vars
# verbosity level
[[ -z "$V" ]] && V=0
[[ -z "$BUILD_MSG" ]] && BUILD_MSG="Building p2pd"
# Windows detection
if uname | grep -qiE "mingw|msys"; then
EXE_SUFFIX=".exe"
else
EXE_SUFFIX=""
fi
# macOS
if uname | grep -qi "darwin"; then
STAT_FORMAT="-f %m"
else
STAT_FORMAT="-c %Y"
fi
TARGET_DIR="vendor/go/bin"
TARGET_BINARY="${TARGET_DIR}/p2pd${EXE_SUFFIX}"
target_needs_rebuilding() {
REBUILD=0
NO_REBUILD=1
if [[ -n "$CACHE_DIR" && -e "${CACHE_DIR}/p2pd${EXE_SUFFIX}" ]]; then
mkdir -p "${TARGET_DIR}"
cp -a "$CACHE_DIR"/* "${TARGET_DIR}/"
fi
# compare binary mtime to the date of the last commit (keep in mind that Git doesn't preserve file timestamps)
if [[ -e "$TARGET_BINARY" && $(stat $STAT_FORMAT "$TARGET_BINARY") -gt $(cd "$SUBREPO_DIR"; git log --pretty=format:%cd -n 1 --date=unix) ]]; then
return $NO_REBUILD
else
return $REBUILD
fi
}
build_target() {
echo -e "$BUILD_MSG"
[[ "$V" == "0" ]] && exec &>/dev/null
pushd "$SUBREPO_DIR"
go get ./...
go install ./...
popd
# update the CI cache
if [[ -n "$CACHE_DIR" ]]; then
rm -rf "$CACHE_DIR"
mkdir "$CACHE_DIR"
cp -a "$TARGET_DIR"/* "$CACHE_DIR"/
fi
}
if target_needs_rebuilding; then
build_target
fi

@ -1 +1 @@
Subproject commit ed16839098d615c977a139e089e4aa354176a94d Subproject commit e359e17445c0fb868620c58d8bab436b45d935ca