Repository navigation
Expand file tree
/
Copy pathconfigure_quesa.sh
More file actions
executable file
·220 lines (184 loc) · 5.77 KB
/
Copy pathconfigure_quesa.sh
File metadata and controls
executable file
·220 lines (184 loc) · 5.77 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/bash
#
# Configure ControllerCoreUnitTest to use a specific Quesa framework build
#
# Usage:
# ./configure_quesa.sh /path/to/Quesa.framework
# ./configure_quesa.sh --find-release
# ./configure_quesa.sh --find-debug
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
# Function to find Quesa framework
find_quesa_framework() {
local BUILD_CONFIG=$1 # "Release" or "Debug"
print_info "Searching for Quesa.framework ($BUILD_CONFIG)..."
# Search paths in order of preference
local SEARCH_PATHS=(
# Relative to this project
"${SCRIPT_DIR}/../build/${BUILD_CONFIG}/Quesa.framework"
"${SCRIPT_DIR}/../Build/${BUILD_CONFIG}/Quesa.framework"
# DerivedData (Xcode's default build location)
"${HOME}/Library/Developer/Xcode/DerivedData/Quesa-"*"/Build/Products/${BUILD_CONFIG}/Quesa.framework"
# Standard locations
"/Library/Frameworks/Quesa.framework"
"${HOME}/Library/Frameworks/Quesa.framework"
)
for path in "${SEARCH_PATHS[@]}"; do
# Expand glob patterns
for expanded_path in $path; do
if [ -d "$expanded_path" ]; then
echo "$expanded_path"
return 0
fi
done
done
return 1
}
# Function to validate framework
validate_framework() {
local FRAMEWORK_PATH=$1
if [ ! -d "$FRAMEWORK_PATH" ]; then
print_error "Not a directory: $FRAMEWORK_PATH"
return 1
fi
if [ ! -d "$FRAMEWORK_PATH/Headers" ]; then
print_error "No Headers directory in framework: $FRAMEWORK_PATH"
return 1
fi
if [ ! -f "$FRAMEWORK_PATH/Headers/Quesa.h" ]; then
print_error "Missing Quesa.h in framework headers"
return 1
fi
if [ ! -f "$FRAMEWORK_PATH/Headers/QuesaController.h" ]; then
print_error "Missing QuesaController.h in framework headers"
return 1
fi
# Check for the actual framework binary
local FRAMEWORK_NAME=$(basename "$FRAMEWORK_PATH" .framework)
if [ ! -f "$FRAMEWORK_PATH/$FRAMEWORK_NAME" ] && [ ! -f "$FRAMEWORK_PATH/Versions/A/$FRAMEWORK_NAME" ]; then
print_error "Missing framework binary: $FRAMEWORK_NAME"
return 1
fi
return 0
}
# Parse arguments
FRAMEWORK_PATH=""
if [ $# -eq 0 ]; then
print_error "No arguments provided"
echo ""
echo "Usage:"
echo " $0 /path/to/Quesa.framework"
echo " $0 --find-release (search for Release build)"
echo " $0 --find-debug (search for Debug build)"
echo " $0 --help"
exit 1
fi
case "$1" in
--find-release)
FRAMEWORK_PATH=$(find_quesa_framework "Release")
if [ -z "$FRAMEWORK_PATH" ]; then
print_error "Could not find Release build of Quesa.framework"
exit 1
fi
;;
--find-debug)
FRAMEWORK_PATH=$(find_quesa_framework "Debug")
if [ -z "$FRAMEWORK_PATH" ]; then
print_error "Could not find Debug build of Quesa.framework"
exit 1
fi
;;
--help)
echo "Configure ControllerCoreUnitTest to use a specific Quesa framework"
echo ""
echo "Usage:"
echo " $0 /path/to/Quesa.framework Use specific framework path"
echo " $0 --find-release Auto-find Release build"
echo " $0 --find-debug Auto-find Debug build"
echo " $0 --help Show this help"
echo ""
echo "Examples:"
echo " $0 --find-release"
echo " $0 ~/Library/Developer/Xcode/DerivedData/.../Quesa.framework"
echo ""
exit 0
;;
*)
FRAMEWORK_PATH="$1"
;;
esac
# Validate the framework
print_info "Validating framework: $FRAMEWORK_PATH"
if ! validate_framework "$FRAMEWORK_PATH"; then
print_error "Framework validation failed"
exit 1
fi
print_success "Framework validated successfully"
# Get absolute path
FRAMEWORK_PATH=$(cd "$(dirname "$FRAMEWORK_PATH")" && pwd)/$(basename "$FRAMEWORK_PATH")
echo ""
print_info "Framework path: $FRAMEWORK_PATH"
print_info "Headers: $FRAMEWORK_PATH/Headers"
# Export environment variable
export QUESA_FRAMEWORK_PATH="$FRAMEWORK_PATH"
# Save to a file that can be sourced
cat > "${SCRIPT_DIR}/.quesa_config" << EOF
# Auto-generated by configure_quesa.sh
# Source this file to set up Quesa framework path
export QUESA_FRAMEWORK_PATH="$FRAMEWORK_PATH"
EOF
print_success "Saved configuration to .quesa_config"
# Create/update build directory with CMake
echo ""
print_info "Configuring CMake build..."
mkdir -p "${SCRIPT_DIR}/build"
cd "${SCRIPT_DIR}/build"
if cmake -DQUESA_LIBRARY="$FRAMEWORK_PATH" \
-DQUESA_INCLUDE_DIR="$FRAMEWORK_PATH/Headers" \
..; then
print_success "CMake configuration successful"
else
print_error "CMake configuration failed"
exit 1
fi
# Print next steps
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}Configuration Complete!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Using Quesa framework:"
echo " $FRAMEWORK_PATH"
echo ""
echo "To build and run tests:"
echo " cd build"
echo " cmake --build ."
echo " ./controller_gtest"
echo ""
echo "Or use the quick build script:"
echo " source .quesa_config"
echo " ./build.sh"
echo ""
echo "To use this configuration in another terminal:"
echo " source .quesa_config"
echo ""
print_success "Ready to build!"