-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild_release.sh
More file actions
executable file
·152 lines (109 loc) · 4.14 KB
/
build_release.sh
File metadata and controls
executable file
·152 lines (109 loc) · 4.14 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
148
149
150
151
152
#!/bin/bash
# Build script for creating a standalone release binary
# This binary will work without requiring environment variables
set -e
echo "Building standalone release binary..."
# Detect OS
OS=$(uname -s)
ARCH=$(uname -m)
# Set up environment for build
export Z3_SYS_Z3_HEADER=/opt/homebrew/include/z3.h
export DYLD_LIBRARY_PATH=/opt/homebrew/Cellar/llvm/19.1.7/lib:$DYLD_LIBRARY_PATH
# Build release version
echo "Compiling release build..."
cargo build --release
# Create distribution directory
DIST_DIR="dist/cpp-borrow-checker-${OS}-${ARCH}"
mkdir -p "$DIST_DIR"
# Copy the binary
cp target/release/cpp-borrow-checker "$DIST_DIR/"
if [ "$OS" = "Darwin" ]; then
echo "Configuring for macOS..."
# Create a wrapper script for macOS that sets library paths
cat > "$DIST_DIR/cpp-borrow-checker-standalone" << 'EOF'
#!/bin/bash
# Standalone wrapper for cpp-borrow-checker
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set library paths
export DYLD_LIBRARY_PATH="/opt/homebrew/Cellar/llvm/19.1.7/lib:/opt/homebrew/lib:/usr/local/lib:$DYLD_LIBRARY_PATH"
# Run the actual binary
exec "$SCRIPT_DIR/cpp-borrow-checker" "$@"
EOF
chmod +x "$DIST_DIR/cpp-borrow-checker-standalone"
# Use install_name_tool to fix library paths
echo "Fixing library dependencies..."
# Find all dylib dependencies
LIBS=$(otool -L "$DIST_DIR/cpp-borrow-checker" | grep -E '^\s+/' | awk '{print $1}' | grep -v '/usr/lib\|/System')
# Copy required libraries locally (optional - for truly standalone)
# mkdir -p "$DIST_DIR/lib"
# for lib in $LIBS; do
# if [ -f "$lib" ]; then
# cp "$lib" "$DIST_DIR/lib/" 2>/dev/null || true
# base=$(basename "$lib")
# install_name_tool -change "$lib" "@loader_path/lib/$base" "$DIST_DIR/cpp-borrow-checker" 2>/dev/null || true
# fi
# done
echo "Creating installer package..."
cat > "$DIST_DIR/install.sh" << 'EOF'
#!/bin/bash
# Installer for cpp-borrow-checker
INSTALL_DIR="/usr/local/bin"
echo "Installing cpp-borrow-checker to $INSTALL_DIR..."
# Check for required dependencies
if ! command -v clang &> /dev/null; then
echo "Warning: clang not found. Please install LLVM/Clang:"
echo " brew install llvm"
fi
# Copy the binary
sudo cp cpp-borrow-checker-standalone "$INSTALL_DIR/cpp-borrow-checker"
sudo chmod +x "$INSTALL_DIR/cpp-borrow-checker"
echo "Installation complete!"
echo "You can now run: cpp-borrow-checker <file.cpp>"
EOF
elif [ "$OS" = "Linux" ]; then
echo "Configuring for Linux..."
# Create wrapper script for Linux
cat > "$DIST_DIR/cpp-borrow-checker-standalone" << 'EOF'
#!/bin/bash
# Standalone wrapper for cpp-borrow-checker
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set library paths for common LLVM installations
export LD_LIBRARY_PATH="/usr/lib/llvm-14/lib:/usr/lib/llvm-13/lib:/usr/local/lib:$LD_LIBRARY_PATH"
exec "$SCRIPT_DIR/cpp-borrow-checker" "$@"
EOF
chmod +x "$DIST_DIR/cpp-borrow-checker-standalone"
fi
chmod +x "$DIST_DIR/install.sh" 2>/dev/null || true
# Create README for distribution
cat > "$DIST_DIR/README.md" << EOF
# C++ Borrow Checker - Standalone Release
This is a standalone release of the C++ Borrow Checker.
## Installation
### Quick Install
Run: \`./install.sh\`
### Manual Install
Copy \`cpp-borrow-checker-standalone\` to your PATH:
\`\`\`bash
cp cpp-borrow-checker-standalone /usr/local/bin/cpp-borrow-checker
\`\`\`
## Requirements
- LLVM/Clang libraries (usually already installed)
- For macOS: \`brew install llvm\`
- For Linux: \`apt-get install llvm\` or \`yum install llvm\`
## Usage
\`\`\`bash
cpp-borrow-checker <file.cpp>
\`\`\`
## Troubleshooting
If you get library not found errors:
1. Install LLVM: \`brew install llvm\` (macOS) or \`apt-get install llvm\` (Linux)
2. Use the wrapper script: \`cpp-borrow-checker-standalone\` instead of the raw binary
EOF
echo "Build complete!"
echo "Distribution created in: $DIST_DIR"
echo ""
echo "To install locally, run:"
echo " cd $DIST_DIR && ./install.sh"
echo ""
echo "Or copy cpp-borrow-checker-standalone to your PATH"