PORTNAME=	gitlab-code-parser
DISTVERSIONPREFIX=	v
DISTVERSION=	0.22.0
PORTREVISION=	4
CATEGORIES=	textproc

MAINTAINER=	mfechner@FreeBSD.org
COMMENT=	Rust-based code parser used by GitLab
WWW=		https://gitlab.com/gitlab-org/rust/gitlab-code-parser

LICENSE=	MIT
LICENSE_FILE=	${WRKSRC}/LICENSE.md

BROKEN_i386=	compilation fails: error: undefined symbol: __atomic_load

BUILD_DEPENDS=	${LOCALBASE}/llvm${LLVM_DEFAULT}/lib/libclang.so:devel/llvm${LLVM_DEFAULT} \
		oniguruma>=0:devel/oniguruma \
		zstd>=0:archivers/zstd

USES=		cargo ssl

USE_GITLAB=	yes
GL_ACCOUNT=	gitlab-org/rust
USE_LDCONFIG=	yes

PLIST_FILES=	bin/parser-cli \
		include/parser-c-bindings.h \
		lib/libchunker.rlib \
		lib/libparser_c_bindings.a \
		lib/libparser_c_bindings.so \
		lib/libparser_core.rlib \
		lib/libtesting.rlib \
		lib/libtreesitter_visit.rlib

# update the crates file with: make cargo-crates > Makefile.crates

do-install:
	${INSTALL_DATA} ${CARGO_TARGET_DIR}/include/*.h ${STAGEDIR}${PREFIX}/include
	${INSTALL_LIB} ${CARGO_TARGET_DIR}/release/*.so ${STAGEDIR}${PREFIX}/lib
	${INSTALL_DATA} ${CARGO_TARGET_DIR}/release/*.a ${STAGEDIR}${PREFIX}/lib
	${INSTALL_DATA} ${CARGO_TARGET_DIR}/release/*.rlib ${STAGEDIR}${PREFIX}/lib
	${INSTALL_PROGRAM} ${CARGO_TARGET_DIR}/release/parser-cli ${STAGEDIR}${PREFIX}/bin

.include <bsd.port.mk>
