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

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

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

    set -x
    ${OS_TRIPLET}-gcc $CFLAGS -w -std=gnu99 -fno-strict-aliasing $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
}
