forked from Mcrich23/Container-Compose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-release.sh
More file actions
executable file
·92 lines (78 loc) · 2.9 KB
/
build-release.sh
File metadata and controls
executable file
·92 lines (78 loc) · 2.9 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
#!/bin/bash
# Build script for container-compose that ensures clean environment
# This script clears conda-injected compiler flags that conflict with Xcode SDK
#
# Usage: ./build-release.sh [swift-build-args]
# Example: ./build-release.sh
# ./build-release.sh -c release
# ./build-release.sh -c debug --target ContainerCompose
set -e
echo "=========================================="
echo "Container-Compose Release Build"
echo "=========================================="
echo ""
# Detect if conda flags are present
if [[ -n "$CPPFLAGS" ]] || [[ -n "$CXXFLAGS" ]] || [[ -n "$CMAKE_ARGS" ]]; then
echo "⚠️ Detected conda-injected compiler flags"
echo " Clearing them to ensure compatibility with Xcode SDK..."
echo ""
fi
# Clear ALL conda-injected compiler flags and variables
unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS DEBUG_CFLAGS DEBUG_CXXFLAGS CMAKE_ARGS 2>/dev/null || true
unset CONDA_TOOLCHAIN_BUILD CONDA_TOOLCHAIN_HOST CONDA_DEFAULT_ENV 2>/dev/null || true
unset CC CXX CC_FOR_BUILD CXX_FOR_BUILD OBJC_FOR_BUILD 2>/dev/null || true
unset _CE_CONDA _CE_M CONDA_PREFIX CONDA_PROMPT_MODIFIER 2>/dev/null || true
# Remove miniconda from PATH to prevent using its clang
export PATH="$(echo "$PATH" | tr ':' '\n' | grep -v 'miniconda' | tr '\n' ':')"
export PATH="${PATH%:}" # Remove trailing colon if any
echo "Environment after cleanup:"
echo " CPPFLAGS: ${CPPFLAGS:-<not set>}"
echo " CXXFLAGS: ${CXXFLAGS:-<not set>}"
echo " CFLAGS: ${CFLAGS:-<not set>}"
echo " LDFLAGS: ${LDFLAGS:-<not set>}"
echo " CC: ${CC:-<not set>}"
echo " CXX: ${CXX:-<not set>}"
echo " PATH: $(echo "$PATH" | tr ':' '\n' | head -5 | tr '\n' ':')..."
echo ""
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
# Default to release build if no configuration specified
if [[ "$*" == *"-c"* ]] || [[ "$*" == *"--configuration"* ]]; then
BUILD_ARGS="$@"
else
BUILD_ARGS="-c release $@"
fi
echo "Building with: swift build $BUILD_ARGS"
echo ""
# Build
swift build $BUILD_ARGS
BUILD_STATUS=$?
if [ $BUILD_STATUS -eq 0 ]; then
echo ""
echo "=========================================="
echo "✅ Build successful!"
echo "=========================================="
echo ""
echo "Binary location:"
BINARY_PATH=".build/release/container-compose"
if [ ! -f "$BINARY_PATH" ]; then
BINARY_PATH=".build/debug/container-compose"
fi
ls -lh "$BINARY_PATH" 2>/dev/null
# Remove macOS provenance attributes that can cause runtime traps
if command -v xattr &>/dev/null; then
echo ""
echo "Clearing macOS extended attributes..."
xattr -c "$BINARY_PATH" 2>/dev/null || true
fi
echo ""
echo "To install system-wide:"
echo " sudo ./install.sh"
else
echo ""
echo "=========================================="
echo "❌ Build failed with exit code $BUILD_STATUS"
echo "=========================================="
exit $BUILD_STATUS
fi