-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv-mingw.sh
executable file
·56 lines (47 loc) · 2.33 KB
/
env-mingw.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
#!/usr/bin/env bash
set -e
TARGET_ARCH=${1}
export TARGET_TRIPLE="${TARGET_ARCH}-w64-mingw32"
export PARALLEL_JOBS="$(nproc)"
export PLATFORM_WIN32="1"
if command -v ccache >/dev/null 2>&1 ; then
export CCACHE_SRC="$(command -v ccache)"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_C_COMPILER_LAUNCHER=ccache"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi
CROSS_TOOLCHAIN_ROOT=${CROSS_TOOLCHAIN_ROOT:-""}
if [ -z "${CROSS_TOOLCHAIN_ROOT}" ]; then
printf "\e[1m\e[31m%s\e[0m\n" "Blank CROSS_TOOLCHAIN_ROOT: '${CROSS_TOOLCHAIN_ROOT}'."
exit 1
fi
export SYSROOT="${CROSS_TOOLCHAIN_ROOT}/${TARGET_TRIPLE}"
# cmake toolchain file
if [ -z "${CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE}" ]; then
CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE="${CROSS_TOOLCHAIN_ROOT}/toolchain-cmake-template"
fi
CROSS_TOOLCHAIN_FILE_CMAKE="${CROSS_TOOLCHAIN_FILE_PREFIX_CMAKE}.${TARGET_ARCH}"
export CMAKE_EXTRA="${CMAKE_EXTRA} -D CMAKE_TOOLCHAIN_FILE=${CROSS_TOOLCHAIN_FILE_CMAKE}"
# meson toolchain file
if [ -z "${CROSS_TOOLCHAIN_FILE_PREFIX_MESON}" ]; then
CROSS_TOOLCHAIN_FILE_PREFIX_MESON="${CROSS_TOOLCHAIN_ROOT}/toolchain-meson-template"
fi
CROSS_TOOLCHAIN_FILE_MESON="${CROSS_TOOLCHAIN_FILE_PREFIX_MESON}.${TARGET_ARCH}"
export MESON_EXTRA="${MESON_EXTRA} --cross-file ${CROSS_TOOLCHAIN_FILE_MESON}"
# pkgconf bin
if [ -z "${CROSS_TOOLCHAIN_PKGCONF_PREFIX}" ]; then
CROSS_TOOLCHAIN_PKGCONF_PREFIX="${CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper"
fi
export CROSS_TOOLCHAIN_PKGCONF="${CROSS_TOOLCHAIN_PKGCONF_PREFIX}.${TARGET_ARCH}"
# for cross-compiling, cmake sets compiler vars by toolchain file, so keep CC/CXX.
export HOSTCC="${CROSS_TOOLCHAIN_ROOT}/bin/clang"
export HOSTCXX="${CROSS_TOOLCHAIN_ROOT}/bin/clang++"
export HOSTCPP="${CROSS_TOOLCHAIN_ROOT}/bin/clang-cpp"
export CC=" ${CCACHE_SRC} ${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-clang"
export CXX="${CCACHE_SRC} ${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-clang++"
export WINDRES="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-windres"
export LD="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-ld"
export NM="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-nm"
export AR="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-ar"
export AS="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-as"
export RANLIB="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-ranlib"
export STRIP="${CROSS_TOOLCHAIN_ROOT}/bin/${TARGET_TRIPLE}-strip"