From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6025C1580B9 for ; Wed, 25 Aug 2021 15:35:09 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 94EC9E0878; Wed, 25 Aug 2021 15:35:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 77B1FE0878 for ; Wed, 25 Aug 2021 15:35:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ED9B033BE3A for ; Wed, 25 Aug 2021 15:35:06 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 863888D7 for ; Wed, 25 Aug 2021 15:35:05 +0000 (UTC) From: "Georgy Yakovlev" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Georgy Yakovlev" Message-ID: <1629904289.455448fa078437b2a411550f7189461aaaeb8580.gyakovlev@gentoo> Subject: [gentoo-commits] proj/cargo-ebuild:master commit in: / X-VCS-Repository: proj/cargo-ebuild X-VCS-Files: README.md X-VCS-Directories: / X-VCS-Committer: gyakovlev X-VCS-Committer-Name: Georgy Yakovlev X-VCS-Revision: 455448fa078437b2a411550f7189461aaaeb8580 X-VCS-Branch: master Date: Wed, 25 Aug 2021 15:35:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 8690c568-85b8-4e78-a776-b474e33ddb22 X-Archives-Hash: 396ae053bca13ec4bc0a74715f5de49b commit: 455448fa078437b2a411550f7189461aaaeb8580 Author: Luca Barbato gentoo org> AuthorDate: Thu Jul 29 17:11:32 2021 +0000 Commit: Georgy Yakovlev gentoo 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 gentoo.org> Signed-off-by: Georgy Yakovlev 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 -%} +```