Repository navigation
Expand file tree
/
Copy pathdev.sh
More file actions
executable file
·147 lines (132 loc) · 3.49 KB
/
Copy pathdev.sh
File metadata and controls
executable file
·147 lines (132 loc) · 3.49 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# Development script for RSV
# Usage: ./dev.sh [clean|configure|build|run|test|demo|all|help]
set -e
ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
BUILD_DIR="$ROOT_DIR/build"
FAKE_BIN="$ROOT_DIR/tests/fake-slurm/bin"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_step() {
echo -e "${BLUE}━━━ $1 ━━━${NC}"
}
print_success() {
echo -e "${GREEN}✓ $1${NC}"
}
print_error() {
echo -e "${RED}✗ $1${NC}"
}
# cmake isn't installed on ROMEO outside Spack: found the same way as in install.sh
find_cmake() {
command -v cmake >/dev/null 2>&1 && return
type romeo_load_x64cpu_env >/dev/null 2>&1 || source /etc/profile.d/spack_bash_functions.sh 2>/dev/null || true
if type romeo_load_x64cpu_env >/dev/null 2>&1; then
romeo_load_x64cpu_env >/dev/null 2>&1 || true
local prefix
prefix=$(spack find --format '{prefix}' cmake 2>/dev/null | tail -n 1 || true)
[ -n "$prefix" ] && export PATH="$prefix/bin:$PATH"
fi
command -v cmake >/dev/null 2>&1 || { print_error "cmake not found"; exit 1; }
}
do_clean() {
print_step "Removing the build"
rm -rf "$BUILD_DIR"
print_success "Build removed"
}
do_configure() {
print_step "Configuring CMake"
find_cmake
cmake -S "$ROOT_DIR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DRSV_TESTS=ON
print_success "Configured"
}
do_build() {
print_step "Building"
find_cmake
if [ ! -f "$BUILD_DIR/CMakeCache.txt" ]; then
do_configure
fi
cmake --build "$BUILD_DIR" -j "$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)"
print_success "Built"
}
do_test() {
do_build
print_step "Slurm parsing tests"
"$BUILD_DIR/parse_test"
}
do_run() {
if [ ! -f "$BUILD_DIR/rsv" ]; then
print_error "No binary yet: run ./dev.sh build first"
exit 1
fi
"$BUILD_DIR/rsv" "$@"
}
# With a fake Slurm (made-up jobs): anywhere, even without a cluster
do_demo() {
do_build
local state="${TMPDIR:-/tmp}/rsv-demo-$USER"
rm -rf "$state"
PATH="$FAKE_BIN:$PATH" FAKE_SLURM_STATE="$state" FAKE_SLURM_HOME="$state/home" HOME="$state/home" \
USER=demo "$BUILD_DIR/rsv" "$@"
}
show_help() {
echo -e "${YELLOW}RSV - development script${NC}"
echo ""
echo "Usage: ./dev.sh [command]"
echo ""
echo "Commands:"
echo " clean Remove the build folder"
echo " configure Configure CMake (downloads FTXUI if needed)"
echo " build Build (configures if needed)"
echo " run Run RSV"
echo " test Build and run the parsing tests"
echo " demo Run RSV on a fake Slurm (made-up jobs)"
echo " all Clean, build and test"
echo " help Show this help"
echo ""
echo "No argument: build. To install in ~/.local/bin: ./install.sh"
}
case "${1:-}" in
clean)
do_clean
;;
configure)
do_configure
;;
build)
do_build
;;
run)
shift
do_run "$@"
;;
test)
do_test
;;
demo)
shift
do_demo "$@"
;;
all)
do_clean
do_test
echo ""
print_success "Clean build tested"
;;
help|--help|-h)
show_help
;;
"")
do_build
echo ""
echo -e "${YELLOW}To run it:${NC} ./dev.sh run ${BLUE}or${NC} ./dev.sh demo"
;;
*)
print_error "Unknown command: $1"
show_help
exit 1
;;
esac