From patchwork Thu Feb 20 16:01:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Havelange X-Patchwork-Id: 1241514 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=essensium.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=essensium.com header.i=@essensium.com header.a=rsa-sha256 header.s=google header.b=f19CT91c; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48NfV3611bz9sRG for ; Fri, 21 Feb 2020 03:01:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4B21784D2E; Thu, 20 Feb 2020 16:01:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dBQEXyPUEyAY; Thu, 20 Feb 2020 16:01:44 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9FC2B85FAE; Thu, 20 Feb 2020 16:01:44 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 5F5E71BF9B5 for ; Thu, 20 Feb 2020 16:01:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5979184D2E for ; Thu, 20 Feb 2020 16:01:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XWHx-vCymrXD for ; Thu, 20 Feb 2020 16:01:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DD64785FAD for ; Thu, 20 Feb 2020 16:01:39 +0000 (UTC) Received: by mail-wm1-f46.google.com with SMTP id p17so2642735wma.1 for ; Thu, 20 Feb 2020 08:01:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mU3TCxvq0yLeKKSRMYsEx3RYQZF6a1oaQ0E0vtkG7co=; b=f19CT91cAohDxkthP0IqUCekk29g4ZMcy5mOR7xvRWprNggreGjXZmpNfq6H9NNl7X U/E7zXp71dTfLv2uBHRoc+Drr7Naf5QbfPCfnVakUoT8YyhqqhRBlwbzFV05WFJvfASY EBTTlV9f2gBBEnuNC73aJ/wnR+xUVRkJljkmnVtL4xktF218dcLR9YDPfMJETghwlAAf 0nJ1M8V2YldhdQq9X+UaGzt4uX+XlcNemqY6GgXXNqfIlU3kZ9LUeuyzO8KWLQdhZJr0 ZuFPm2odJoiYbe/k/2DqCHhw5CcjJa4NZR/i4EhV3+z3MTGeD/mrLZsvYXY1yVmsxp8p HPhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mU3TCxvq0yLeKKSRMYsEx3RYQZF6a1oaQ0E0vtkG7co=; b=JcVjrEbfdF5+oZyKiHAUSTE3956RYEA+oHD9Q6W5rrRsfgWas/EXTPiab9v0tNJHYa uTRh4U0fYc2M1fkcQFuyv+erSHXGQwvvq3XH8EZbnlbhyBxMi6BUhVS8gmgI2WHl5Lzr tLPVWwgXDTvmV7B+zRBwCQHzgtQhcP4UWNMhn7WSiGwCeZ65Fvsw9v5zwCA7cPUh+LWG 00bEMIMoh2DpUpv8X5BLf6kC5O8h91VNFTGEx4tOoQMuV7rN74P6/Zhs+KjjKInjbRRf 5bt4m9nzJJnDtz+hSnpixr8vRKNifa6YrK3cbAmiPjxD5jVddMGQ2xXBqvtRU27hXN6+ NL9A== X-Gm-Message-State: APjAAAUJ0DCXmsfLIFVnOioHclhBMoeAr3J8SY9MDHDiARh0si6wm0lh Y44wmFhirbXjnI7FkS7sZY9j9Kp7C86ymA== X-Google-Smtp-Source: APXvYqys+i5TgeQlPiVl6rSipZNy1mSps5pQP1YtcynXYp8npMfaQ9azjUYz7CUV4SMnEAIoRSPisA== X-Received: by 2002:a1c:7f0d:: with SMTP id a13mr5046197wmd.182.1582214497643; Thu, 20 Feb 2020 08:01:37 -0800 (PST) Received: from ph-ThinkPad-E560.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id h5sm5483691wmf.8.2020.02.20.08.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 08:01:36 -0800 (PST) From: Patrick Havelange To: buildroot@buildroot.org Date: Thu, 20 Feb 2020 17:01:11 +0100 Message-Id: <20200220160119.3407-2-patrick.havelange@essensium.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200220160119.3407-1-patrick.havelange@essensium.com> References: <20200220160119.3407-1-patrick.havelange@essensium.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 02/10] docs/manual/cargo: Update manual for cargo packages. X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas De Schampheleire , Patrick Havelange , Sam Voss , "Yann E . MORIN" , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Signed-off-by: Patrick Havelange --- docs/manual/adding-packages-cargo.txt | 54 +++++---------------------- 1 file changed, 10 insertions(+), 44 deletions(-) diff --git a/docs/manual/adding-packages-cargo.txt b/docs/manual/adding-packages-cargo.txt index bb078b6981..9a496224e3 100644 --- a/docs/manual/adding-packages-cargo.txt +++ b/docs/manual/adding-packages-cargo.txt @@ -27,9 +27,9 @@ The +Config.in+ file of Cargo-based package 'foo' should contain: ==== Cargo-based package's +.mk+ file -Buildroot does not (yet) provide a dedicated package infrastructure for -Cargo-based packages. So, we will explain how to write a +.mk+ file for such a -package. Let's start with an example: +Buildroot provides a dedicated package infrastructure for Cargo-based packages. +So, we will explain how to write a +.mk+ file for such a package. Let's start +with an example: ------------------------------ 01: ################################################################################ @@ -44,53 +44,19 @@ package. Let's start with an example: 10: FOO_LICENSE = GPL-3.0+ 11: FOO_LICENSE_FILES = COPYING 12: -13: FOO_DEPENDENCIES = host-rustc -14: -15: FOO_CARGO_ENV = CARGO_HOME=$(HOST_DIR)/share/cargo -16: FOO_CARGO_MODE = $(if $(BR2_ENABLE_DEBUG),debug,release) -17: -18: FOO_BIN_DIR = target/$(RUSTC_TARGET_NAME)/$(FOO_CARGO_MODE) -19: -20: FOO_CARGO_OPTS = \ -21: --$(FOO_CARGO_MODE) \ -22: --target=$(RUSTC_TARGET_NAME) \ -23: --manifest-path=$(@D)/Cargo.toml -24: -25: define FOO_BUILD_CMDS -26: $(TARGET_MAKE_ENV) $(FOO_CARGO_ENV) \ -27: cargo build $(FOO_CARGO_OPTS) -28: endef -29: -30: define FOO_INSTALL_TARGET_CMDS -31: $(INSTALL) -D -m 0755 $(@D)/$(FOO_BIN_DIR)/foo \ -32: $(TARGET_DIR)/usr/bin/foo -33: endef -34: -35: $(eval $(generic-package)) +13: $(eval $(cargo-package)) -------------------------------- The Makefile starts with the definition of the standard variables for package declaration (lines 7 to 11). -As seen in line 35, it is based on the -xref:generic-package-tutorial[+generic-package+ infrastructure]. So, it defines -the variables required by this particular infrastructure, where Cargo is -invoked: +As seen in line 13, it is based on the cargo-package infrastructure. Cargo will +be invoked automatically by this infrastructure. The required dependencies of the +crate will be downloaded and the buildroot dependencies will also be set. -* +FOO_BUILD_CMDS+: Cargo is invoked to perform the build. The options required - to configure the cross-compilation of the package are passed via - +FOO_CONF_OPTS+. - -* +FOO_INSTALL_TARGET_CMDS+: The binary executable generated is installed on - the target. - -In order to have Cargo available for the build, +FOO_DEPENDENCIES+ needs to -contain +host-cargo+. - -To sum it up, to add a new Cargo-based package, the Makefile example can be -copied verbatim then edited to replace all occurences of +FOO+ with the -uppercase name of the new package and update the values of the standard -variables. +It is still possible to define custom build commands or install commands (i.e. +with FOO_BUILD_CMDS and FOO_INSTALL_TARGET_CMDS). +Those will then replace the commands from the cargo infrastructure. ==== About Dependencies Management