-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_wsl_windows.sh
More file actions
executable file
·48 lines (41 loc) · 1.86 KB
/
build_wsl_windows.sh
File metadata and controls
executable file
·48 lines (41 loc) · 1.86 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
#!/bin/bash
# 1. Update and install all required development libraries
sudo apt update && sudo apt upgrade -y
sudo apt install -y \
build-essential cmake pkg-config python3-dev python-is-python3 \
zlib1g-dev libjpeg-dev libtiff-dev libpng-dev libssl-dev libbz2-dev \
liblzma-dev libzstd-dev liblz4-dev libzip-dev \
libhdf5-dev libblosc-dev libblosc2-dev libnlopt-dev libfftw3-dev
# 2. Fix WSL clock sync (prevents "Clock skew detected" errors)
sudo hwclock -s
# 3. Navigate to project directory (the repo that contains this script)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
git pull # Ensure we have the latest code
# 4. Neutralize "Custom" build scripts that force x86/Intel optimizations
# This forces the project to use the ARM-compatible system libraries instead
mkdir -p cmake/deps/backup
mv cmake/deps/*_custom.cmake cmake/deps/backup/ 2>/dev/null || true
# 5. Clean and Configure Build
rm -rf build && mkdir build && cd build
# We use CMAKE_C_STANDARD_LIBRARIES and CMAKE_CXX_STANDARD_LIBRARIES
# to ensure the linker order is correct (libraries at the end of the command)
HDF5_INC="/usr/include/hdf5/serial"
# Auto-detect architecture (x86_64-linux-gnu or aarch64-linux-gnu)
MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null || echo "x86_64-linux-gnu")
HDF5_LIB_DIR="/usr/lib/${MULTIARCH}/hdf5/serial"
LIBS="-L${HDF5_LIB_DIR} -lhdf5_hl -lhdf5 -ltiff -lblosc2 -lblosc -lfftw3 -lnlopt -lz -lm -ldl"
cmake .. \
-DUSE_SYSTEM_DEPS=ON \
-DDOWNLOAD_DEPENDENCIES=OFF \
-DINSTALL_PYTHON_DEPENDENCIES=OFF \
-DPYTHON_EXECUTABLE=/usr/bin/python3 \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_CUDA=OFF \
-DCMAKE_C_FLAGS="-I${HDF5_INC}" \
-DCMAKE_CXX_FLAGS="-I${HDF5_INC}" \
-DCMAKE_C_STANDARD_LIBRARIES="${LIBS}" \
-DCMAKE_CXX_STANDARD_LIBRARIES="${LIBS}" \
-Wno-dev
# 6. Build using all available CPU cores
make -j$(nproc)