PORTNAME=	lib${GH_PROJECT}
PORTVERSION=	34.0.0
DISTVERSIONPREFIX=	v
PORTREVISION=	1
CATEGORIES=	devel

MAINTAINER=	osa@FreeBSD.org
COMMENT=	Library for fast and secure runtime for WebAssembly
WWW=		https://wasmtime.dev/

LICENSE=	APACHE20
LICENSE_FILE=	${WRKSRC}/LICENSE

NOT_FOR_ARCHS=	armv7 i386
NOT_FOR_ARCHS_REASON=	build currently failing

LIB_DEPENDS=	libzstd.so:archivers/zstd

USES=		cargo cmake:indirect cpe
CPE_VENDOR=	bytecodealliance

USE_LDCONFIG=	yes

USE_GITHUB=	yes
GH_ACCOUNT=	bytecodealliance
GH_PROJECT=	wasmtime

CARGO_BUILD_ARGS=	-p wasmtime-c-api
CMAKE_SOURCE_PATH=	${WRKSRC}/crates/c-api

CARGO_CRATES=	addr2line-0.24.1 \
		adler-1.0.2 \
		adler2-2.0.0 \
		aes-0.8.4 \
		aho-corasick-1.0.2 \
		allocator-api2-0.2.20 \
		ambient-authority-0.0.2 \
		android_system_properties-0.1.5 \
		anes-0.1.6 \
		anstream-0.6.15 \
		anstyle-1.0.8 \
		anstyle-parse-0.2.1 \
		anstyle-query-1.1.2 \
		anstyle-wincon-3.0.4 \
		anyhow-1.0.93 \
		arbitrary-1.4.1 \
		arbtest-0.3.1 \
		arrayvec-0.7.6 \
		async-trait-0.1.71 \
		autocfg-1.1.0 \
		backtrace-0.3.74 \
		base64-0.22.1 \
		base64ct-1.6.0 \
		beef-0.5.2 \
		bindgen-0.70.1 \
		bit-set-0.5.2 \
		bit-vec-0.6.3 \
		bitflags-1.3.2 \
		bitflags-2.6.0 \
		block-buffer-0.10.2 \
		bstr-1.6.0 \
		bumpalo-3.16.0 \
		byteorder-1.4.3 \
		bytes-1.5.0 \
		bytesize-2.0.1 \
		bzip2-0.4.4 \
		bzip2-sys-0.1.11+1.0.8 \
		camino-1.1.4 \
		cap-fs-ext-3.4.4 \
		cap-net-ext-3.4.4 \
		cap-primitives-3.4.4 \
		cap-rand-3.4.4 \
		cap-std-3.4.4 \
		cap-time-ext-3.4.4 \
		capstone-0.13.0 \
		capstone-sys-0.17.0 \
		cargo-platform-0.1.2 \
		cargo_metadata-0.19.2 \
		cast-0.3.0 \
		cc-1.2.22 \
		cexpr-0.6.0 \
		cfg-if-1.0.0 \
		ciborium-0.2.0 \
		ciborium-io-0.2.0 \
		ciborium-ll-0.2.0 \
		cipher-0.4.4 \
		clang-sys-1.8.1 \
		clap-4.5.36 \
		clap_builder-4.5.36 \
		clap_complete-4.5.28 \
		clap_derive-4.5.32 \
		clap_lex-0.7.4 \
		cobs-0.2.3 \
		codespan-reporting-0.11.1 \
		colorchoice-1.0.0 \
		console-0.15.8 \
		constant_time_eq-0.1.5 \
		core-foundation-sys-0.8.6 \
		cpp_demangle-0.4.3 \
		cpufeatures-0.2.7 \
		crc32fast-1.3.2 \
		criterion-0.5.1 \
		criterion-plot-0.5.0 \
		crossbeam-deque-0.8.1 \
		crossbeam-epoch-0.9.18 \
		crossbeam-utils-0.8.20 \
		crunchy-0.2.2 \
		crypto-common-0.1.6 \
		cty-0.2.2 \
		debugid-0.8.0 \
		deranged-0.3.11 \
		derive_arbitrary-1.4.0 \
		digest-0.10.7 \
		directories-next-2.0.0 \
		dirs-sys-next-0.1.2 \
		displaydoc-0.2.5 \
		dlmalloc-0.2.4 \
		downcast-rs-2.0.1 \
		easy-smt-0.2.2 \
		egg-0.6.0 \
		either-1.13.0 \
		embedded-io-0.4.0 \
		encode_unicode-0.3.6 \
		encoding_rs-0.8.31 \
		env_filter-0.1.2 \
		env_logger-0.10.0 \
		env_logger-0.11.5 \
		equivalent-1.0.1 \
		errno-0.3.10 \
		escape8259-0.5.2 \
		fallible-iterator-0.3.0 \
		fastrand-2.3.0 \
		fd-lock-4.0.2 \
		file-per-thread-logger-0.2.0 \
		filecheck-0.5.0 \
		filetime-0.2.16 \
		flagset-0.4.3 \
		flate2-1.1.0 \
		fnv-1.0.7 \
		foldhash-0.1.3 \
		form_urlencoded-1.2.1 \
		fs-set-times-0.20.1 \
		fslock-0.2.1 \
		futures-0.3.31 \
		futures-channel-0.3.31 \
		futures-core-0.3.31 \
		futures-executor-0.3.31 \
		futures-io-0.3.31 \
		futures-macro-0.3.31 \
		futures-sink-0.3.31 \
		futures-task-0.3.31 \
		futures-util-0.3.31 \
		fxhash-0.2.1 \
		fxprof-processed-profile-0.6.0 \
		generic-array-0.14.5 \
		getrandom-0.2.15 \
		getrandom-0.3.1 \
		gimli-0.31.1 \
		glob-0.3.1 \
		gzip-header-1.0.0 \
		h2-0.4.4 \
		half-1.8.2 \
		half-2.4.1 \
		hashbrown-0.12.3 \
		hashbrown-0.15.2 \
		heck-0.4.1 \
		heck-0.5.0 \
		hermit-abi-0.3.9 \
		hmac-0.12.1 \
		home-0.5.9 \
		http-1.0.0 \
		http-body-1.0.0 \
		http-body-util-0.1.0 \
		httparse-1.8.0 \
		httpdate-1.0.2 \
		humantime-2.1.0 \
		hyper-1.0.1 \
		iana-time-zone-0.1.61 \
		iana-time-zone-haiku-0.1.2 \
		icu_collections-1.5.0 \
		icu_locid-1.5.0 \
		icu_locid_transform-1.5.0 \
		icu_locid_transform_data-1.5.0 \
		icu_normalizer-1.5.0 \
		icu_normalizer_data-1.5.0 \
		icu_properties-1.5.1 \
		icu_properties_data-1.5.0 \
		icu_provider-1.5.0 \
		icu_provider_macros-1.5.0 \
		id-arena-2.2.1 \
		idna-1.0.3 \
		idna_adapter-1.2.0 \
		indexmap-1.9.1 \
		indexmap-2.7.0 \
		indicatif-0.13.0 \
		inout-0.1.3 \
		instant-0.1.12 \
		io-extras-0.18.3 \
		io-lifetimes-2.0.3 \
		ipnet-2.5.0 \
		is-terminal-0.4.10 \
		is_terminal_polyfill-1.70.1 \
		itertools-0.10.5 \
		itertools-0.12.1 \
		itertools-0.14.0 \
		itoa-1.0.14 \
		ittapi-0.4.0 \
		ittapi-sys-0.4.0 \
		jobserver-0.1.32 \
		js-sys-0.3.74 \
		lazy_static-1.4.0 \
		leb128-0.2.5 \
		leb128fmt-0.1.0 \
		libc-0.2.171 \
		libfuzzer-sys-0.4.8 \
		libloading-0.8.6 \
		libm-0.2.11 \
		libtest-mimic-0.8.1 \
		linux-raw-sys-0.4.14 \
		linux-raw-sys-0.9.3 \
		listenfd-1.0.0 \
		litemap-0.7.4 \
		log-0.4.22 \
		logos-0.14.2 \
		logos-codegen-0.14.2 \
		logos-derive-0.14.2 \
		mach2-0.4.2 \
		matchers-0.1.0 \
		matrixmultiply-0.3.9 \
		maybe-owned-0.3.4 \
		memchr-2.5.0 \
		memfd-0.6.4 \
		memmap2-0.2.3 \
		minimal-lexical-0.2.1 \
		miniz_oxide-0.7.4 \
		miniz_oxide-0.8.5 \
		mio-1.0.3 \
		multi-stash-0.2.0 \
		ndarray-0.15.6 \
		nom-7.1.3 \
		nu-ansi-term-0.46.0 \
		num-complex-0.4.6 \
		num-conv-0.1.0 \
		num-integer-0.1.46 \
		num-traits-0.2.19 \
		num_cpus-1.16.0 \
		number_prefix-0.3.0 \
		object-0.36.5 \
		ocaml-boxroot-sys-0.2.0 \
		ocaml-interop-0.8.8 \
		ocaml-sys-0.22.3 \
		once_cell-1.19.0 \
		oorandom-11.1.3 \
		openvino-0.8.0 \
		openvino-finder-0.8.0 \
		openvino-sys-0.8.0 \
		ort-2.0.0-rc.2 \
		ort-sys-2.0.0-rc.2 \
		overload-0.1.1 \
		password-hash-0.4.2 \
		paste-1.0.7 \
		pbkdf2-0.11.0 \
		percent-encoding-2.3.1 \
		pin-project-lite-0.2.14 \
		pin-utils-0.1.0 \
		pkg-config-0.3.29 \
		postcard-1.0.8 \
		powerfmt-0.2.0 \
		ppv-lite86-0.2.16 \
		prettyplease-0.2.31 \
		proc-macro2-1.0.92 \
		proptest-1.0.0 \
		psm-0.1.18 \
		quick-error-1.2.3 \
		quick-error-2.0.1 \
		quote-1.0.36 \
		rand-0.8.5 \
		rand_chacha-0.3.1 \
		rand_core-0.6.3 \
		rand_xorshift-0.3.0 \
		rawpointer-0.2.1 \
		rayon-1.5.3 \
		rayon-core-1.12.0 \
		redox_syscall-0.2.13 \
		redox_users-0.4.3 \
		regalloc2-0.12.2 \
		regex-1.9.1 \
		regex-automata-0.1.10 \
		regex-automata-0.3.3 \
		regex-syntax-0.6.25 \
		regex-syntax-0.7.4 \
		regex-syntax-0.8.5 \
		region-3.0.2 \
		ring-0.17.14 \
		rustc-demangle-0.1.24 \
		rustc-hash-1.1.0 \
		rustc-hash-2.1.1 \
		rustix-0.38.43 \
		rustix-1.0.3 \
		rustix-linux-procfs-0.1.1 \
		rustls-0.22.4 \
		rustls-0.23.7 \
		rustls-pki-types-1.3.1 \
		rustls-webpki-0.102.2 \
		rustversion-1.0.14 \
		rusty-fork-0.3.0 \
		ryu-1.0.9 \
		safetensors-0.3.3 \
		same-file-1.0.6 \
		semver-1.0.17 \
		serde-1.0.215 \
		serde_derive-1.0.215 \
		serde_json-1.0.140 \
		serde_spanned-0.6.5 \
		sha1-0.10.6 \
		sha2-0.10.2 \
		sharded-slab-0.1.4 \
		shlex-1.3.0 \
		shuffling-allocator-1.1.2 \
		signal-hook-registry-1.4.1 \
		similar-2.2.0 \
		slab-0.4.7 \
		smallvec-1.13.2 \
		socket2-0.5.7 \
		souper-ir-2.1.0 \
		spin-0.9.8 \
		stable_deref_trait-1.2.0 \
		static_assertions-1.1.0 \
		string-interner-0.19.0 \
		strsim-0.11.1 \
		strum-0.24.1 \
		strum_macros-0.24.3 \
		subtle-2.5.0 \
		symbolic_expressions-5.0.3 \
		syn-1.0.92 \
		syn-2.0.100 \
		synstructure-0.13.1 \
		system-interface-0.27.1 \
		tar-0.4.41 \
		target-lexicon-0.13.0 \
		tch-0.17.0 \
		tempfile-3.19.1 \
		termcolor-1.4.1 \
		terminal_size-0.4.2 \
		test-log-0.2.11 \
		thiserror-1.0.65 \
		thiserror-2.0.12 \
		thiserror-impl-1.0.65 \
		thiserror-impl-2.0.12 \
		thread_local-1.1.4 \
		time-0.3.36 \
		time-core-0.1.2 \
		tinystr-0.7.6 \
		tinytemplate-1.2.1 \
		tokio-1.44.2 \
		tokio-macros-2.5.0 \
		tokio-rustls-0.25.0 \
		tokio-util-0.7.4 \
		toml-0.8.10 \
		toml_datetime-0.6.5 \
		toml_edit-0.22.4 \
		torch-sys-0.17.0 \
		tracing-0.1.37 \
		tracing-attributes-0.1.26 \
		tracing-core-0.1.31 \
		tracing-log-0.1.3 \
		tracing-subscriber-0.3.17 \
		trait-variant-0.1.2 \
		try-lock-0.2.4 \
		typenum-1.15.0 \
		unicode-ident-1.0.8 \
		unicode-segmentation-1.11.0 \
		unicode-width-0.1.9 \
		unicode-width-0.2.0 \
		unicode-xid-0.2.3 \
		untrusted-0.9.0 \
		ureq-2.10.0 \
		url-2.5.4 \
		utf16_iter-1.0.5 \
		utf8_iter-1.0.4 \
		utf8parse-0.2.1 \
		uuid-1.0.0 \
		v8-134.5.0 \
		valuable-0.1.0 \
		version_check-0.9.4 \
		wait-timeout-0.2.0 \
		walkdir-2.3.3 \
		want-0.3.0 \
		wasi-0.11.0+wasi-snapshot-preview1 \
		wasi-0.13.3+wasi-0.2.2 \
		wasi-0.14.0+wasi-0.2.3 \
		wasi-nn-0.6.0 \
		wasm-bindgen-0.2.97 \
		wasm-bindgen-backend-0.2.97 \
		wasm-bindgen-macro-0.2.97 \
		wasm-bindgen-macro-support-0.2.97 \
		wasm-bindgen-shared-0.2.97 \
		wasm-encoder-0.230.0 \
		wasm-encoder-0.233.0 \
		wasm-metadata-0.230.0 \
		wasm-metadata-0.233.0 \
		wasm-mutate-0.233.0 \
		wasm-smith-0.233.0 \
		wasm-wave-0.233.0 \
		wasmi-0.43.1 \
		wasmi_collections-0.43.1 \
		wasmi_core-0.43.1 \
		wasmi_ir-0.43.1 \
		wasmparser-0.227.1 \
		wasmparser-0.230.0 \
		wasmparser-0.233.0 \
		wasmprinter-0.233.0 \
		wast-35.0.2 \
		wast-233.0.0 \
		wat-1.233.0 \
		web-sys-0.3.57 \
		webpki-roots-0.26.1 \
		which-6.0.3 \
		winapi-0.3.9 \
		winapi-i686-pc-windows-gnu-0.4.0 \
		winapi-util-0.1.5 \
		winapi-x86_64-pc-windows-gnu-0.4.0 \
		windows-0.52.0 \
		windows-core-0.52.0 \
		windows-implement-0.52.0 \
		windows-interface-0.52.0 \
		windows-sys-0.52.0 \
		windows-sys-0.59.0 \
		windows-targets-0.52.6 \
		windows_aarch64_gnullvm-0.52.6 \
		windows_aarch64_msvc-0.52.6 \
		windows_i686_gnu-0.52.6 \
		windows_i686_gnullvm-0.52.6 \
		windows_i686_msvc-0.52.6 \
		windows_x86_64_gnu-0.52.6 \
		windows_x86_64_gnullvm-0.52.6 \
		windows_x86_64_msvc-0.52.6 \
		winnow-0.5.39 \
		winsafe-0.0.19 \
		winx-0.36.3 \
		wit-bindgen-0.42.1 \
		wit-bindgen-core-0.42.1 \
		wit-bindgen-rt-0.33.0 \
		wit-bindgen-rt-0.37.0 \
		wit-bindgen-rt-0.42.1 \
		wit-bindgen-rust-0.42.1 \
		wit-bindgen-rust-macro-0.42.1 \
		wit-component-0.230.0 \
		wit-component-0.233.0 \
		wit-parser-0.230.0 \
		wit-parser-0.233.0 \
		witx-0.9.1 \
		write16-1.0.0 \
		writeable-0.5.5 \
		xattr-1.3.1 \
		yoke-0.7.5 \
		yoke-derive-0.7.5 \
		zerofrom-0.1.5 \
		zerofrom-derive-0.1.5 \
		zeroize-1.7.0 \
		zerovec-0.10.4 \
		zerovec-derive-0.10.3 \
		zip-0.6.6 \
		zstd-0.11.2+zstd.1.5.2 \
		zstd-0.13.0 \
		zstd-safe-5.0.2+zstd.1.5.2 \
		zstd-safe-7.0.0 \
		zstd-sys-2.0.9+zstd.1.5.5

GH_TUPLE=	WebAssembly:testsuite:970d36b:testsuite/tests/spec_testsuite \
		WebAssembly:wasi-testsuite:2fec29e:wasi_testsuite/tests/wasi_testsuite/wasi-common \
		WebAssembly:wasi-threads:e1893c0:wasi_threads/tests/wasi_testsuite/wasi-threads

post-configure:
	@cd ${CMAKE_SOURCE_PATH} && ${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS}

post-build:
	@cd ${CMAKE_SOURCE_PATH} && ${SETENV} ${MAKE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH}

do-install:
	${MKDIR} ${STAGEDIR}${PREFIX}/include/wasmtime
	${INSTALL_DATA} ${WRKSRC}/crates/c-api/include/wasm.h ${STAGEDIR}${PREFIX}/include
	(cd ${WRKSRC}/crates/c-api/include && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/include)
	${RM} ${STAGEDIR}${PREFIX}/include/wasmtime/conf.h.in
	${INSTALL_DATA} ${WRKDIR}/target/release/libwasmtime.a ${STAGEDIR}${PREFIX}/lib
	${INSTALL_LIB} ${WRKDIR}/target/release/libwasmtime.so ${STAGEDIR}${PREFIX}/lib

.include <bsd.port.mk>
