name=v
version=35f6523e473233b73d76858a6b387050c8c11942
revision=1
tarball_url="https://github.com/vlang/v/archive/${version}.tar.gz"
tarball_blake2b="cca1b0732607bfd1b4c7ad1b245743c3580682e253438a9886a27968a12fef02c3c14f3648a8a075fc9f4add600b6bcb3581558dbccfad4b6d695acd5367dff8"
source_imagedeps="curl"
source_allow_network="yes"
hostdeps="gcc"
deps="core-libs"

regenerate() {
    curl -o v.c https://raw.githubusercontent.com/vlang/vc/859b3a6f31f4fb808a670dfbcde8936a1425c02a/v.c
}

build() {
    cp -r ${source_dir}/. ./

    set -x
    ${OS_TRIPLET}-gcc $CFLAGS -w -std=gnu99 $LDFLAGS v.c -o v
    set +x
}

package() {
    rm -rf "${dest_dir}${prefix}"/v
    mkdir -p "${dest_dir}${prefix}"/v
    cp -r . "${dest_dir}${prefix}"/v/

    mkdir -p "${dest_dir}${prefix}"/bin
    ln -sf ../v/v "${dest_dir}${prefix}"/bin/v

    post_package_strip
}
