aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2021-07-29 19:11:32 +0200
committerGeorgy Yakovlev <gyakovlev@gentoo.org>2021-08-25 08:11:29 -0700
commit455448fa078437b2a411550f7189461aaaeb8580 (patch)
tree5094a3e5555d01e0bd9d6c7f3fcb268e239e7f20
parentMove the bulk of the template to base.tera (diff)
downloadcargo-ebuild-455448fa078437b2a411550f7189461aaaeb8580.tar.gz
cargo-ebuild-455448fa078437b2a411550f7189461aaaeb8580.tar.bz2
cargo-ebuild-455448fa078437b2a411550f7189461aaaeb8580.zip
Document the templating support
Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
-rw-r--r--README.md85
1 files changed, 85 insertions, 0 deletions
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 -%}
+```