Skip to content

Commit

Permalink
zig: enable mingw64 and ucrt64
Browse files Browse the repository at this point in the history
- build a standalone zig
- linked with static llvm
  • Loading branch information
raedrizqie committed Dec 22, 2024
1 parent baee831 commit 48e94a6
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions mingw-w64-zig/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,32 @@
_realname=zig
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.13.0
_pkgver=0.14.0-dev.2487+af89bb05d
pkgver=${_pkgver/-/}
pkgrel=1
pkgdesc='A general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software (mingw-w64)'
arch=('any')
mingw_arch=('clang64')
mingw_arch=('mingw64' 'ucrt64' 'clang64')
url='https://ziglang.org'
msys2_repository_url='https://github.com/ziglang/zig/'
msys2_documentation_url='https://github.com/ziglang/zig?tab=readme-ov-file#readme'
msys2_references=(
'archlinux: zig'
)
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
makedepends=("${MINGW_PACKAGE_PREFIX}-clang-bootstrap"
"${MINGW_PACKAGE_PREFIX}-llvm-bootstrap"
"${MINGW_PACKAGE_PREFIX}-lld-bootstrap"
"${MINGW_PACKAGE_PREFIX}-libc++-bootstrap"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${MINGW_PACKAGE_PREFIX}-lld")
depends=("${MINGW_PACKAGE_PREFIX}-clang-libs"
"${MINGW_PACKAGE_PREFIX}-llvm-libs"
"${MINGW_PACKAGE_PREFIX}-zstd")
source=("https://ziglang.org/download/${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('06c73596beeccb71cc073805bdb9c0e05764128f16478fa53bf17dfabc1d4318')
"${MINGW_PACKAGE_PREFIX}-zlib"
"${MINGW_PACKAGE_PREFIX}-zstd"
"git")
depends=("${MINGW_PACKAGE_PREFIX}-crt"
"${MINGW_PACKAGE_PREFIX}-headers")
source=("https://ziglang.org/builds/${_realname}-${_pkgver}.tar.xz")
sha256sums=('3f5143efa587a4146a428d9efaf729f0883241be5719c80c2665e502ea151040')

build() {
declare -a _extra_config
Expand All @@ -33,28 +38,34 @@ build() {
_extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
fi

MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
${MINGW_PREFIX}/bin/cmake \
export PATH="${MINGW_PREFIX}/bootstrap/bin:${PATH}"

MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=;-DCMAKE_EXE_LINKER_FLAGS=" \
cmake -Wno-dev \
-GNinja \
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
-DZIG_PIE=ON \
-DZIG_SHARED_LLVM=ON \
-DZIG_STATIC_ZLIB=OFF \
-DZIG_STATIC_ZSTD=OFF \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_EXE_LINKER_FLAGS="-L${MINGW_PREFIX}/bootstrap/lib -L${MINGW_PREFIX}/lib" \
-DZIG_HOST_TARGET_TRIPLE=x86_64-windows-gnu \
-DZIG_TARGET_TRIPLE=x86_64-windows-gnu \
-DZIG_STATIC=ON \
-DZIG_STATIC_LLVM=ON \
-DZIG_STATIC_ZLIB=ON \
-DZIG_STATIC_ZSTD=ON \
-DZIG_SYSTEM_LIBCXX=c++ \
-DZIG_TARGET_MCPU=baseline \
-DZIG_USE_LLVM_CONFIG=ON \
"${_extra_config[@]}" \
-S ${_realname}-${pkgver} \
-S ${_realname}-${_pkgver} \
-B build-${MSYSTEM}

${MINGW_PREFIX}/bin/cmake --build build-${MSYSTEM}
cmake --build build-${MSYSTEM}
}

package() {
cd build-${MSYSTEM}

DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .
DESTDIR="${pkgdir}" cmake --install build-${MSYSTEM}

install -Dm644 "${srcdir}"/${_realname}-${pkgver}/LICENSE \
install -Dm644 "${srcdir}"/${_realname}-${_pkgver}/LICENSE \
"${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

0 comments on commit 48e94a6

Please sign in to comment.