diff options
-rw-r--r-- | README.md | 85 |
1 files changed, 85 insertions, 0 deletions
@@ -106,3 +106,88 @@ RDEPEND="" ## API API documentation is available at [docs.rs](https://docs.rs/cargo-ebuild/). + +## Templates + +`cargo-ebuild` allows you to use a custom [tera](https://crates.io/crates/tera) template. + +The built-in `base.tera` provided is the following: + +``` tera +{%- block header -%} +# Copyright 2017-{{ this_year }} Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# Auto-Generated by cargo-ebuild {{ cargo_ebuild_ver }} +{% endblock %} +EAPI={%- block eapi -%}7{%- endblock %} + +{% block crates -%} +CRATES=" +{% for crate in crates -%} +{{ crate }} +{%- endfor -%}" +{%- endblock %} + +inherit {% block inherit -%}cargo{%- endblock %} + +DESCRIPTION={%- block description -%}"{{ description | trim }}"{%- endblock %} +# Double check the homepage as the cargo_metadata crate +# does not provide this value so instead repository is used +HOMEPAGE={%- block homepage -%}"{{ homepage }}"{%- endblock %} +SRC_URI={%- block src_uri -%}{% raw -%}"$(cargo_crate_uris ${CRATES})"{%- endraw %}{%- endblock %} +# License set may be more restrictive as OR is not respected +# use cargo-license for a more accurate license picture +LICENSE={%- block license -%}"{{ license }}"{%- endblock %} +SLOT={%- block slot -%}"0"{%- endblock %} +KEYWORDS={%- block keyword -%}"~amd64"{%- endblock %} +{% block variables -%} +RESTRICT="mirror" +{%- endblock %} + +{%- block phases -%} +{%- endblock -%} +``` + +``` tera +{%- extends "base.tera" -%} + +{% block variables -%} +USE="+capi" + +ASM_DEP=">=dev-lang/nasm-2.14" +BDEPEND=" + amd64? ( ${ASM_DEP} ) + capi? ( dev-util/cargo-c ) +" +{%- endblock %} + +{% block phases -%} +src_compile() { + export CARGO_HOME="${ECARGO_HOME}" + local args=$(usex debug "" --release) + + cargo build ${args} \ + || die "cargo build failed" + + if use capi; then + cargo cbuild ${args} \ + --prefix="/usr" --libdir="/usr/$(get_libdir)" \ + || die "cargo cbuild failed" + fi +} + +src_install() { + export CARGO_HOME="${ECARGO_HOME}" + local args=$(usex debug "" --release) + + if use capi; then + cargo cinstall $args \ + --prefix="/usr" --libdir="/usr/$(get_libdir)" --destdir="${ED}" \ + || die "cargo cinstall failed" + fi + + cargo_src_install +} +{%- endblock -%} +``` |