|
| 1 | +# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com> |
| 2 | + |
| 3 | +_realname=gram |
| 4 | +pkgbase=mingw-w64-${_realname} |
| 5 | +pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" |
| 6 | +pkgver=2.2.0 |
| 7 | +pkgrel=1 |
| 8 | +pkgdesc="A code editor for humanoid apes and grumpy toads (mingw-w64)" |
| 9 | +arch=('any') |
| 10 | +mingw_arch=('ucrt64' 'clang64' 'clangarm64') |
| 11 | +url='https://gram-editor.com' |
| 12 | +msys2_repository_url='https://codeberg.org/GramEditor/gram' |
| 13 | +msys2_documentation_url='https://gram-editor.com/docs' |
| 14 | +license=('spdx:Apache-2.0 AND GPL-3.0-or-later') |
| 15 | +install=gram-${MSYSTEM}.install |
| 16 | +msys2_references=( |
| 17 | + 'anitya:' |
| 18 | + 'archlinux: gram' |
| 19 | + 'aur:' |
| 20 | +) |
| 21 | +depends=("${MINGW_PACKAGE_PREFIX}-nodejs" |
| 22 | + #"${MINGW_PACKAGE_PREFIX}-libgit2" |
| 23 | + "${MINGW_PACKAGE_PREFIX}-zstd" |
| 24 | + "${MINGW_PACKAGE_PREFIX}-sqlite3") |
| 25 | +makedepends=("${MINGW_PACKAGE_PREFIX}-rust" |
| 26 | + "${MINGW_PACKAGE_PREFIX}-cmake" |
| 27 | + "${MINGW_PACKAGE_PREFIX}-pkgconf" |
| 28 | + "${MINGW_PACKAGE_PREFIX}-protobuf" |
| 29 | + "${MINGW_PACKAGE_PREFIX}-rust-bindgen" |
| 30 | + "${MINGW_PACKAGE_PREFIX}-nasm" |
| 31 | + "${MINGW_PACKAGE_PREFIX}-efxc2" |
| 32 | + 'git') |
| 33 | +optdepends=("${MINGW_PACKAGE_PREFIX}-rustup: to build extensions" |
| 34 | + "${MINGW_PACKAGE_PREFIX}-git: for a better Git integration") |
| 35 | +source=("git+${msys2_repository_url}.git#tag=${pkgver}" |
| 36 | + "rust-protobuf-native.tar.gz::https://codeberg.org/GramEditor/rust-protobuf-native/archive/a70e2d9986e931f2b883b661bf8f4471c5398b7e.tar.gz" |
| 37 | + "zstd-sys.tar.gz::https://static.crates.io/crates/zstd-sys/2.0.16+zstd.1.5.7/download" |
| 38 | + "protobuf-src-abseil-Fix-compiler-warnings.patch" |
| 39 | + "protobuf-src-abseil-fix-linking-abseil_dll.patch" |
| 40 | + "protobuf-src-abseil-Remove-librt-library.patch" |
| 41 | + "protobuf-src-abseil-fix-mingw-build.patch" |
| 42 | + "protobuf-src-fix-clang-build.patch" |
| 43 | + "gram-use-patched-protobuf-src.patch" |
| 44 | + "zstd-sys-remove-statik.patch") |
| 45 | +sha256sums=('f7b6b4a1799e2873132c227a7d1821e2f34798b1ed633677db56ceb207a071ed' |
| 46 | + '8b63253a9b39f388c91af8c9dc1a9a5bc7ffeafc0367f9da3c48ea2dfe11419b' |
| 47 | + '91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748' |
| 48 | + '30fb7526d1c89f722dd0ce0c467e034370140fbf07a1ad4f91df301c7f442551' |
| 49 | + '67ee0328f1aa8e3ad24231b2e6ef6a78963218e087cc6a7230e2d4e61b27a741' |
| 50 | + '8946282db6a225b385729deb345b57e3ee75f4e859dbbc49ab7bc5604d71192f' |
| 51 | + '053d09f18bc3029ece051e59d125f8952ec847b1b8fbc21b605edde86d1c2f63' |
| 52 | + 'e0918deb70ceafa5c8f99a2ffefa98da2b4139fb4b0190f51c06a8fcb86decfb' |
| 53 | + 'b5d138810b3a55491fb2efbb576e4ed7c6627e5a923c0325829dc6b18e80bbe3' |
| 54 | + '48f4900ceb02d3aaf9a1020f33d56629156e96759f456c0e7ca18bfcf910767b') |
| 55 | + |
| 56 | +prepare() { |
| 57 | + cd "${_realname}" |
| 58 | + rm rust-toolchain.toml |
| 59 | + |
| 60 | + # link system deps dynamically |
| 61 | + patch -d ../zstd-sys-2.0.16+zstd.1.5.7 -i ../zstd-sys-remove-statik.patch |
| 62 | + # patch abseil-cpp source (version 20240722.0) in protobuf-src crate |
| 63 | + patch -d ../rust-protobuf-native/protobuf-src/protobuf/third_party/abseil-cpp/ -p1 -i "${srcdir}"/protobuf-src-abseil-Fix-compiler-warnings.patch |
| 64 | + patch -d ../rust-protobuf-native/protobuf-src/protobuf/third_party/abseil-cpp/ -p1 -i "${srcdir}"/protobuf-src-abseil-fix-linking-abseil_dll.patch |
| 65 | + patch -d ../rust-protobuf-native/protobuf-src/protobuf/third_party/abseil-cpp/ -p1 -i "${srcdir}"/protobuf-src-abseil-Remove-librt-library.patch |
| 66 | + patch -d ../rust-protobuf-native/protobuf-src/protobuf/third_party/abseil-cpp/ -p1 -i "${srcdir}"/protobuf-src-abseil-fix-mingw-build.patch |
| 67 | + patch -d ../rust-protobuf-native/protobuf-src/protobuf/ -p1 -i "${srcdir}"/protobuf-src-fix-clang-build.patch |
| 68 | + # use patched *-sys crates |
| 69 | + sed -i '/\[patch\.crates-io\]/a zstd-sys.path = "../zstd-sys-2.0.16+zstd.1.5.7"' Cargo.toml |
| 70 | + patch -p1 -i ../gram-use-patched-protobuf-src.patch |
| 71 | + |
| 72 | + # change git config so `pet*` crates would be fetched without error; requires Windows registry |
| 73 | + # changes, see https://gram-editor.com/docs/development/windows#build-fails-path-too-long for details |
| 74 | + if test true != "$(git config core.longpaths)"; then |
| 75 | + git config --global core.longpaths true |
| 76 | + fi |
| 77 | + |
| 78 | + cargo update -p zstd-sys |
| 79 | + cargo fetch --locked |
| 80 | +} |
| 81 | + |
| 82 | +build() { |
| 83 | + cd "${_realname}" |
| 84 | + |
| 85 | + export PROTOC="${MINGW_PREFIX}/bin/protoc.exe" |
| 86 | + export PROTOC_INCLUDE="${MINGW_PREFIX}/include" |
| 87 | + export OPENSSL_NO_VENDOR=1 |
| 88 | + #export LIBGIT2_NO_VENDOR=1 |
| 89 | + export ZSTD_SYS_USE_PKG_CONFIG=1 |
| 90 | + export WINAPI_NO_BUNDLED_LIBRARIES=1 |
| 91 | + export LIBSQLITE3_SYS_USE_PKG_CONFIG=1 |
| 92 | + export GRAM_UPDATE_EXPLANATION='Updates are handled by pacman' |
| 93 | + export CARGO_PROFILE_RELEASE_DEBUG=0 |
| 94 | + export RELEASE_CHANNEL="stable" |
| 95 | + export RELEASE_VERSION="${pkgver} (Rev${pkgrel}, Built by MSYS2 project)" |
| 96 | + # set path to our fxc compiler |
| 97 | + export GPUI_FXC_PATH="${MINGW_PREFIX}/bin/fxc.exe" |
| 98 | + # should be synced with .cargo/config.toml |
| 99 | + export RUSTFLAGS="${RUSTFLAGS/+crt-static/-crt-static} -C symbol-mangling-version=v0 |
| 100 | + --cfg tokio_unstable --cfg windows_slim_errors" |
| 101 | + |
| 102 | + cargo build --release --frozen -p gram -p cli |
| 103 | +} |
| 104 | + |
| 105 | +check() { |
| 106 | + cd "${_realname}" |
| 107 | + |
| 108 | + cargo test --release --frozen -p gram -p cli |
| 109 | +} |
| 110 | + |
| 111 | +package() { |
| 112 | + install -Dm755 "${_realname}/target/release/cli" "${pkgdir}${MINGW_PREFIX}/bin/gram" |
| 113 | + install -Dm755 "${_realname}/target/release/gram" "${pkgdir}${MINGW_PREFIX}/lib/gram/gram-editor" |
| 114 | + # WSL script |
| 115 | + install -Dm755 "${_realname}/crates/gram/resources/windows/gram.sh" "${pkgdir}${MINGW_PREFIX}/bin/gram-wsl" |
| 116 | + |
| 117 | + install -Dm644 "${_realname}"/LICENSE-{APACHE,GPL} -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/" |
| 118 | +} |
0 commit comments