commit:     455448fa078437b2a411550f7189461aaaeb8580
Author:     Luca Barbato <lu_zero <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 29 17:11:32 2021 +0000
Commit:     Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
CommitDate: Wed Aug 25 15:11:29 2021 +0000
URL:        https://gitweb.gentoo.org/proj/cargo-ebuild.git/commit/?id=455448fa

Document the templating support

Signed-off-by: Luca Barbato <lu_zero <AT> gentoo.org>
Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>

 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 -%}
+```

Reply via email to