forked from maidsafe/temp_safe_network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (87 loc) · 3.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
SHELL := /bin/bash
SN_NODE_VERSION := $(shell grep "^version" < Cargo.toml | head -n 1 | awk '{ print $$3 }' | sed 's/\"//g')
UNAME_S := $(shell uname -s)
DEPLOY_PATH := deploy
DEPLOY_PROD_PATH := ${DEPLOY_PATH}/prod
build:
ifeq ($(UNAME_S),Linux)
@echo "This target should not be used for Linux - please use the `musl` target."
@exit 1
endif
rm -rf artifacts
mkdir artifacts
cargo build --release
find target/release -maxdepth 1 -type f -exec cp '{}' artifacts \;
musl:
ifneq ($(UNAME_S),Linux)
@echo "This target only applies to Linux - please use the `build` target."
@exit 1
endif
rm -rf target
rm -rf artifacts
mkdir artifacts
sudo apt update -y && sudo apt install -y musl-tools
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
find target/x86_64-unknown-linux-musl/release \
-maxdepth 1 -type f -exec cp '{}' artifacts \;
arm-unknown-linux-musleabi:
rm -rf target
rm -rf artifacts
mkdir artifacts
cargo install cross
cross build --release --target arm-unknown-linux-musleabi
find target/arm-unknown-linux-musleabi/release -maxdepth 1 -type f -exec cp '{}' artifacts \;
armv7-unknown-linux-musleabihf:
rm -rf target
rm -rf artifacts
mkdir artifacts
cargo install cross
cross build --release --target armv7-unknown-linux-musleabihf
find target/armv7-unknown-linux-musleabihf/release -maxdepth 1 -type f -exec cp '{}' artifacts \;
aarch64-unknown-linux-musl:
rm -rf target
rm -rf artifacts
mkdir artifacts
cargo install cross
cross build --release --target aarch64-unknown-linux-musl
find target/aarch64-unknown-linux-musl/release -maxdepth 1 -type f -exec cp '{}' artifacts \;
.ONESHELL:
build-artifacts-for-deploy:
# This target is just for debugging the packaging process.
# Given the zipped artifacts retrieved from Github, it creates the
# directory structure that's expected by the packaging target.
declare -a architectures=( \
"x86_64-unknown-linux-musl" \
"x86_64-pc-windows-msvc" \
"x86_64-apple-darwin" \
"arm-unknown-linux-musleabi" \
"armv7-unknown-linux-musleabihf" \
"aarch64-unknown-linux-musl")
cd artifacts
for arch in "$${architectures[@]}" ; do \
mkdir -p prod/$$arch/release; \
unzip sn_node-$$arch-prod.zip -d prod/$$arch/release; \
rm sn_node-$$arch-prod.zip
done
.ONESHELL:
package-version-artifacts-for-deploy:
rm -f *.zip *.tar.gz
rm -rf ${DEPLOY_PATH}
mkdir -p ${DEPLOY_PROD_PATH}
declare -a architectures=( \
"x86_64-unknown-linux-musl" \
"x86_64-pc-windows-msvc" \
"x86_64-apple-darwin" \
"arm-unknown-linux-musleabi" \
"armv7-unknown-linux-musleabihf" \
"aarch64-unknown-linux-musl")
for arch in "$${architectures[@]}" ; do \
if [[ $$arch == *"windows"* ]]; then bin_name="sn_node.exe"; else bin_name="sn_node"; fi; \
zip -j sn_node-${SN_NODE_VERSION}-$$arch.zip artifacts/prod/$$arch/release/$$bin_name; \
zip -j sn_node-latest-$$arch.zip artifacts/prod/$$arch/release/$$bin_name; \
tar -C artifacts/prod/$$arch/release -zcvf sn_node-${SN_NODE_VERSION}-$$arch.tar.gz $$bin_name; \
tar -C artifacts/prod/$$arch/release -zcvf sn_node-latest-$$arch.tar.gz $$bin_name; \
done
mv *.tar.gz ${DEPLOY_PROD_PATH}
mv *.zip ${DEPLOY_PROD_PATH}