From 455448fa078437b2a411550f7189461aaaeb8580 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Thu, 29 Jul 2021 19:11:32 +0200 Subject: Document the templating support Signed-off-by: Luca Barbato Signed-off-by: Georgy Yakovlev --- README.md | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/README.md b/README.md index 77f66f0..d3ee183 100644 --- a/README.md +++ b/README.md @@ -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 -%} +``` -- cgit v1.2.3-65-gdbad