# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup github 1.0
PortGroup ocaml 1.1

name                ocaml-hacl-star
github.setup        cryspen hacl-packages ocaml-v0.7.2
version             0.7.2
revision            0

# Release tarball is the pre-packaged OCaml distribution from cryspen/hacl-packages.
# It contains pre-verified C sources and bundled karamel headers, so no F*
# verification or separate karamel/fstar ports are required.
github.tarball_from releases
distname            hacl-star.${version}
extract.mkdir       yes

categories          ocaml devel security
maintainers         {landonf @landonf} openmaintainer
license             Apache-2
description         High-assurance cryptographic library.
long_description    Formally verified library of modern cryptographic algorithms, \
                    including Curve25519, Ed25519, AES-GCM, Chacha20, Poly1305, SHA-2, \
                    SHA-3, HMAC, and HKDF. The code for all of these algorithms is \
                    formally verified using the F* verification framework for memory \
                    safety, functional correctness, and secret independence (resistance \
                    to some types of timing side-channels).

checksums           rmd160  d70a4dba52b291f07716dd9e52c9bf05963f1809 \
                    sha256  dbd17b1af7b481179095f03a770e29d4bc8cbec363ec4f1b0a5f793fa71b931b \
                    size    551583

# Required to build the ocaml-hacl-star bindings
subport ocaml-hacl-star-raw {
    ocaml.use_findlib   yes
    use_configure       no

    depends_build-append port:cmake
    depends_lib-append  port:ocaml-ctypes

    build.dir           ${worksrcpath}/hacl-star-raw
    build.target        build-bindings
    build.args

    # build-c (cmake) generates build/Makefile.include which sets
    # TOOLCHAIN_CAN_COMPILE_VEC* variables.  These are read at make parse
    # time, so build-c and build-bindings must be separate invocations.
    pre-build {
        system -W ${worksrcpath}/hacl-star-raw "${build.cmd} build-c"
    }

    destroot.dir        ${worksrcpath}/hacl-star-raw
    destroot.args
}

subport ocaml-hacl-star {
    depends_lib-append      port:ocaml-hacl-star-raw \
                            port:ocaml-zarith

    depends_build-append    port:ocaml-cppo

    ocaml.build_type        dune
}
