template

2.1 KB · 77 lines
GITHUB
# Template file for 'vlang'
pkgname=vlang
version=0.5.0
revision=1
# Commit hashes for the latest release in the v & vc repositories (they have to match)
_v_commit="e3616f2db89dc76a37297963840c26f87a24a249"
_vc_commit="e2b49597de33cddd9aba1cb0ec98b6ce66ff17c7"
archs="x86_64"
create_wrksrc=yes
hostmakedepends="git clang"
makedepends="libX11-devel"
short_desc="Simple, fast, safe, compiled language for developing maintainable software"
maintainer="AmarBego <[email protected]>"
license="MIT"
homepage="https://vlang.io"
distfiles="https://github.com/vlang/v/archive/${_v_commit}.zip
 https://github.com/vlang/vc/archive/${_vc_commit}.zip"
checksum="368c6202c8f7850ba162f79fc5fca515befd498dfc6aba1424df99699998f2aa
 c727fa4eeeb9c0c5aa5d760ed3b0ed94e2f3b4022122776bf7adfe00e137212b"
nopie=yes

post_extract() {
	rm -rf "v-${_v_commit}/vc"
	mv "vc-${_vc_commit}" "v-${_v_commit}/vc"

	# we have to set a local=1 because we manually download a specific vc
    # version. this flag also disables downloading tcc automatically.
	make -C "v-${_v_commit}" fresh_tcc
}

do_build() {
	cd "v-${_v_commit}"

    local tmpdir="/tmp/${pkgname}-${_v_commit}"
    mkdir -p "$tmpdir" || { echo "Can't create temporary directory!"; exit 1; }

    # Delete directory when exiting function (even if there is an error)
    trap 'rm -rf "$tmpdir"' RETURN

    # Redefining HOME and TMPDIR for Isolation
    export HOME="$tmpdir"
    export TMPDIR="$tmpdir"

	# Build v with clang for performance 
	# 20minutes CI with everything else 6 minutes with clang
	# CFLAGS and LDFLAGS are emptied for speed as well
	CFLAGS="" LDFLAGS="" make CC=clang prod=1 local=1 -j${XBPS_MAKEJOBS}

	# Compile v using tcc
    LDFLAGS="" ./v build-tools
}

do_install() {
	cd "v-${_v_commit}"
	
	vmkdir usr/lib/vlang
	for d in cmd thirdparty vlib v.mod; do
		vcopy "$d" usr/lib/vlang
	done

	vinstall v 755 usr/lib/vlang

	# Create wrapper script
	cat > v-wrapper.sh <<EOF
#!/bin/sh
exec /usr/lib/vlang/v "\$@"
EOF
	vbin v-wrapper.sh v

	vlicense LICENSE

	vmkdir usr/share/vlang
	vcopy examples usr/share/vlang

	touch ${DESTDIR}/usr/lib/vlang/cmd/tools/.disable_autorecompilation
}

Part of vlang