forked from ChazDazzle/pypoker-eval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·98 lines (83 loc) · 2.77 KB
/
build.sh
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
#!/bin/bash
# Arrête le script si une commande échoue
set -e
# Fonction pour détecter l'OS
detect_os() {
case "$(uname -s)" in
Linux*) echo "Linux";;
Darwin*) echo "MacOS";;
CYGWIN*|MINGW32*|MSYS*|MINGW*) echo "Windows";;
*) echo "unknown"
esac
}
OS=$(detect_os)
echo "Detected OS: $OS"
WORK_DIR=$(pwd)
echo "Working directory: $WORK_DIR"
BASE_PATH="$WORK_DIR"
echo "Base path: $BASE_PATH"
# path to base for Windows
if [ "$OS" = "Windows" ]; then
BASE_PATH2=$(cygpath -w "$BASE_PATH")
else
BASE_PATH2="$BASE_PATH"
fi
echo "Adjusted BASE_PATH2 for OS: $BASE_PATH2"
# Initialize submodules
echo "Initializing submodules..."
if [ -d "${BASE_PATH}/poker-eval" ]; then
echo "Removing existing poker-eval directory"
rm -rf "${BASE_PATH}/poker-eval"
fi
git submodule update --init --recursive
# Build poker-eval
echo "Building poker-eval..."
cd "${BASE_PATH}/poker-eval"
if [ ! -f "CMakeLists.txt" ]; then
echo "Error: CMakeLists.txt not found in $(pwd)"
exit 1
fi
mkdir -p build
cd build
if [[ "$OS" == "Windows" ]]; then
cmake .. -G "Visual Studio 17 2022"
cmake --build .
elif [[ "$OS" == "Linux" || "$OS" == "MacOS" ]]; then
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON
make
fi
cd "${BASE_PATH}"
# Build pypoker-eval
echo "Building pypoker-eval..."
cd "${BASE_PATH}"
if [ ! -f "CMakeLists.txt" ]; then
echo "Error: CMakeLists.txt not found in $(pwd)"
exit 1
fi
mkdir -p build
cd build
if [[ "$OS" == "Windows" ]]; then
cmake .. -G "Visual Studio 17 2022"
cmake --build .
elif [[ "$OS" == "MacOS" ]]; then
cmake -DPython3_EXECUTABLE=/usr/local/opt/[email protected]/libexec/bin/python3 \
-DPython3_INCLUDE_DIR=/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11 \
-DPython3_LIBRARY=/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib \
..
make
elif [[ "$OS" == "Linux" ]]; then
cmake -DPython3_EXECUTABLE=$(which python3.11) -DPython3_INCLUDE_DIR=$(python3.11 -c "from sysconfig import get_paths as gp; print(gp()['include'])") -DPython3_LIBRARY=$(python3.11 -c "from sysconfig import get_config_var as gcv; print(gcv('LIBDIR') + '/libpython3.11.so')") ..
make
fi
cd "${BASE_PATH}"
if [[ "$OS" == "Windows" ]]; then
echo "Renaming and moving pypokereval.dll..."
mv "${BASE_PATH}/build/Debug/pypokereval.pyd" "${BASE_PATH}/_pokereval_3_11.pyd"
elif [[ "$OS" == "Linux" ]]; then
echo "Copying and renaming pypokereval.so..."
cp "${BASE_PATH}/build/pypokereval.so" "${BASE_PATH}/_pokereval_3_11.so"
elif [[ "$OS" == "MacOS" ]]; then
echo "Copying and renaming pypokereval.so..."
cp "${BASE_PATH}/build/pypokereval.so" "${BASE_PATH}/_pokereval_3_11.so"
fi
echo "Build process completed."