-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdependency-setup.sh
More file actions
executable file
·120 lines (99 loc) · 3.59 KB
/
dependency-setup.sh
File metadata and controls
executable file
·120 lines (99 loc) · 3.59 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
#!/bin/bash
set -e # Exit immediately if any command fails
set -o pipefail # Fail piped commands
# Updated help function
function display_help() {
echo "
Description:
This script manages dependencies including installation and cleanup
Usage:
./dependency-setup.sh [options]
Options:
-h, --help Show this help
-x Enable verbose mode
--clean Remove all built artifacts
--force Force rebuild all dependencies
"
exit
}
# Improved clean function
clean_artifacts() {
echo "Cleaning all artifacts..."
# Clean drat-trim
if [ -d "drat-trim" ]; then
echo "Cleaning drat-trim..."
(cd drat-trim && make clean -f Makefile 2>/dev/null || true)
fi
# Clean cadical-ks
if [ -d "cadical-ks" ]; then
echo "Cleaning cadical-ks..."
(cd cadical-ks && make clean 2>/dev/null || true)
fi
# Clean maplesat-ks
if [ -d "maplesat-ks" ]; then
echo "Cleaning maplesat-ks..."
(cd maplesat-ks && make clean 2>/dev/null || true)
fi
# Clean march_cu
if [ -d "gen_cubes/march_cu" ]; then
echo "Cleaning march_cu..."
(cd gen_cubes/march_cu && make clean 2>/dev/null || true)
fi
# Clean nauty
if [ -d "nauty2_8_8" ]; then
echo "Cleaning nauty..."
(cd nauty2_8_8 && make clean 2>/dev/null || true)
fi
echo "Cleanup completed"
}
# Check for help and clean flags first
[ "$1" = "-h" -o "$1" = "--help" ] && display_help
[ "$1" = "--clean" ] && { clean_artifacts; exit; }
# Add -x flag for verbose output if needed
[ "$1" = "-x" ] && set -x
# Check if force rebuild is requested
force_rebuild=false
[ "$1" = "--force" ] && force_rebuild=true
echo "Prerequisite: Checking for pip and make..."
command -v pip3 >/dev/null 2>&1 || { echo "pip3 not found. Aborting."; exit 1; }
command -v make >/dev/null 2>&1 || { echo "make not found. Aborting."; exit 1; }
# Networkx version check with better python parsing
required_version="2.5"
if ! python3 -c "import networkx as nx; exit(not (tuple(map(int, nx.__version__.split('.'))) >= (2,5)))" 2>/dev/null; then
echo "Upgrading networkx to >=${required_version}..."
pip3 install --upgrade "networkx>=${required_version}"
else
echo "Networkx >=${required_version} already installed"
fi
# Check if z3-solver is installed
if pip3 list | grep z3-solver
then
echo "Z3-solver package installed"
else
pip3 install z3-solver
fi
# Modified build_dependency function with better target existence check
build_dependency() {
local dir="$1"
local target="$2"
local build_cmd="${3:-make}"
if [ ! -f "$dir/$target" ] || [ "$force_rebuild" = true ]; then
echo "Building ${dir}..."
(cd "$dir" || exit 1
# Add -f flag to make clean to ignore missing files
make clean -f Makefile 2>/dev/null || true
eval "$build_cmd" && echo "Build successful")
else
echo "Target $dir/$target already exists, skipping build"
fi
}
# Build dependencies only if targets don't exist or force rebuild is requested
# Build nauty first as it's required by cadical and maplesat
build_dependency nauty2_8_8 "dreadnaut" "./configure && make" # Changed target to actual binary
build_dependency drat-trim drat-trim "make -f Makefile"
build_dependency cadical-ks build/cadical-ks "./configure && make"
build_dependency maplesat-ks simp/maplesat_static "make clean && make"
# More robust submodule handling
echo "Updating git submodules..."
git submodule update --init --recursive
echo "Dependency setup completed successfully"