# -*- 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           cmake 1.1
PortGroup           boost 1.0

github.setup        ethereum solidity 0.8.28 v
revision            0

categories          lang
license             GPL-3+
maintainers         {@kaimingguo kaiming.io:me} \
                    openmaintainer

description         Solidity, the Smart Contract Programming Language

long_description    Solidity is a statically typed, contract-oriented, \
                    high-level language for implementing smart contracts \
                    on the Ethereum platform.

homepage            https://soliditylang.org
github.tarball_from releases
distname            ${github.project}_${github.version}

checksums           rmd160  67927b1fb9f042deb6d71790b5c51543e571c69e \
                    sha256  ec756e30f26a5a38d028fd6f401ef0a7f5cfbf4a1ce71f76c2e3e1ffb8730672 \
                    size    12640527

set port_libfmt     libfmt9

compiler.cxx_standard 2017

depends_build-append \
                    port:${port_libfmt} \
                    port:range-v3 \
                    port:nlohmann-json

cmake.prefix_path-append \
                    ${prefix}/lib/${port_libfmt}/cmake

configure.cxxflags-append \
                    -std=c++17

configure.args      -DBoost_USE_STATIC_LIBS=OFF \
                    -DTESTS=OFF \
                    -DIGNORE_VENDORED_DEPENDENCIES=ON \
                    -DRANGE_V3_INCLUDE_DIR=${prefix}/include \
                    -DSTRICT_NLOHMANN_JSON_VERSION=OFF \
                    -DWITH_Z3=OFF \
                    -DWITH_CVC4=OFF

patchfiles-append   patch-CMakeLists.txt.diff \
                    patch-libyul_ObjectOptimizer.cpp.diff

default_variants    +z3

variant z3 description {SMT Checker via Z3} {
    depends_lib-append \
        port:z3
    configure.args-append \
        -DSTRICT_Z3_VERSION=OFF
    configure.args-replace \
        -DWITH_Z3=OFF \
        -DWITH_Z3=ON
}

variant cvc4 description {SMT Checker via CVC4} {
    depends_lib-append \
        port:cvc4
    configure.args-replace \
        -DWITH_CVC4=OFF \
        -DWITH_CVC4=ON
}

variant tests description {Enable testing} {
    configure.args-replace \
        -DTESTS=OFF \
        -DTESTS=ON
}

test.run            yes
test.cmd            ${destroot}${prefix}/bin/solc
test.target
test.args           --bin ${filespath}/test.sol
