From patchwork Tue Feb 5 16:00:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 1036855 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="b6yiHtpy"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43v8Sc5tYGz9sMl for ; Wed, 6 Feb 2019 03:01:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 753F230D6D; Tue, 5 Feb 2019 16:01:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aQTnzt9VZRMV; Tue, 5 Feb 2019 16:01:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id E69D721FAC; Tue, 5 Feb 2019 16:00:59 +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 13EDF1BF958 for ; Tue, 5 Feb 2019 16:00:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 11C7786825 for ; Tue, 5 Feb 2019 16:00:58 +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 kDIv8UeWpPG5 for ; Tue, 5 Feb 2019 16:00:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 07B5086132 for ; Tue, 5 Feb 2019 16:00:54 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id a16so4252024wrv.0 for ; Tue, 05 Feb 2019 08:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5wmRGjBD41plNanab+YGWAy068/SczN1tmYbk1UyYOU=; b=b6yiHtpyEzF5i+Jp5dE/RF5zjBSDq1XuVnQYHZ23qoKiEBxN8KT+CtQyXMyPJre/Su 01obNTmLcwAKwNY+IIv3+dBpKfa9ksj5FuG5/rHSQEcpN3B6vo21SpyXprcNp2O4PbzA mIRxf0mm0zdysrzVy1udM5yma3+pD5SAAT85g= 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; bh=5wmRGjBD41plNanab+YGWAy068/SczN1tmYbk1UyYOU=; b=lY5Z7NVDEpaLZab/nLWg+UCcNdygWrNsSes+/XHGnfLF+CcaeS5bi0TXjlSEQlYyOO uBmAsVR6OFA6Bo3n+EcMHhIYAQKrWe+J5s/zdTBtGwC5cQ1cMlsOhuiWsrq8y87o4J8I MEFEq6niEg2N6qLLXXUuOY25JyByTdUz+NnvdGeZjS3Y5CBe9xVz7DwEElTyq2yrLfCF IYfZp5Rs3UWAk66ewdjn08vdtFLYJIF66XGJev1EZcsdetzL3mPlJ990ibaxs3CrqrKz PAPg9oObE9mGTUdJUUkET+8kIX1MYYHSz5cJorKjAM8IT/pO/QyG28VFWBDa6PtsetVC LAaw== X-Gm-Message-State: AHQUAuaPMxxnIwZRvTvBHTA8DGqMW2qj8x4k8xI/Su73MdMAl4T+ak4p 9QiNWPJJp/L9BRp72uuBd9NMZ2f8QIDQNA== X-Google-Smtp-Source: AHgI3IZL+/f7ZnkIzmSikcRxIZ2vtRQENrKsgXQJGqGd+6NvgYoaKhyiDBcQQnFbHdc+Ampu3IMRrQ== X-Received: by 2002:a5d:664a:: with SMTP id f10mr4118304wrw.311.1549382450803; Tue, 05 Feb 2019 08:00:50 -0800 (PST) Received: from localhost.localdomain ([2620:0:1055:fd00:3c25:d51f:f59f:7d82]) by smtp.gmail.com with ESMTPSA id r14sm503986wrr.65.2019.02.05.08.00.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Feb 2019 08:00:45 -0800 (PST) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Tue, 5 Feb 2019 17:00:27 +0100 Message-Id: <1549382436-15177-2-git-send-email-angelo@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549382436-15177-1-git-send-email-angelo@amarulasolutions.com> References: <1549382436-15177-1-git-send-email-angelo@amarulasolutions.com> Subject: [Buildroot] [PATCH v2 01/10] package/pkg-golang: add support for building host 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: Mirza Krak , Angelo Compagnucci MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Mirza Krak With this you can add: $(eval $(host-golang-package)) to a package .mk file to build for host. Signed-off-by: Mirza Krak Acked-by: Angelo Compagnucci Tested-by: Angelo Compagnucci Signed-off-by: Angelo Compagnucci --- docs/manual/adding-packages-golang.txt | 5 +++-- package/pkg-golang.mk | 37 +++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/docs/manual/adding-packages-golang.txt b/docs/manual/adding-packages-golang.txt index efcf696..9452048 100644 --- a/docs/manual/adding-packages-golang.txt +++ b/docs/manual/adding-packages-golang.txt @@ -50,8 +50,9 @@ and +BR2_PACKAGE_HOST_GO_CGO_LINKING_SUPPORTS+ because Buildroot will automatically add a dependency on +host-go+ to such packages. The main macro of the Go package infrastructure is -+golang-package+. It is similar to the +generic-package+ macro. Only -target packages are supported with +golang-package+. ++golang-package+. It is similar to the +generic-package+ macro. The +ability to build host packages is also available, with the ++host-golang-package+ macro. Just like the generic infrastructure, the Go infrastructure works by defining a number of variables before calling the +golang-package+. diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk index 4f2c7e7..b4e8a53 100644 --- a/package/pkg-golang.mk +++ b/package/pkg-golang.mk @@ -25,12 +25,18 @@ GO_BIN = $(HOST_DIR)/bin/go # We pass an empty GOBIN, otherwise "go install: cannot install # cross-compiled binaries when GOBIN is set" -GO_TARGET_ENV = \ - $(HOST_GO_TARGET_ENV) \ +GO_COMMON_ENV = \ PATH=$(BR_PATH) \ GOBIN= \ CGO_ENABLED=$(HOST_GO_CGO_ENABLED) +GO_TARGET_ENV = \ + $(HOST_GO_TARGET_ENV) \ + $(GO_COMMON_ENV) + +GO_HOST_ENV = \ + $(GO_COMMON_ENV) + ################################################################################ # inner-golang-package -- defines how the configuration, compilation and # installation of a Go package should be done, implements a few hooks to tune @@ -44,7 +50,6 @@ GO_TARGET_ENV = \ # packages # argument 4 is the type (target or host) # -# NOTE Only type target is supported at the moment ################################################################################ define inner-golang-package @@ -98,6 +103,8 @@ endif # Build step. Only define it if not already defined by the package .mk # file. ifndef $(2)_BUILD_CMDS +ifeq ($(4),target) +# Build package for target define $(2)_BUILD_CMDS $$(foreach d,$$($(2)_BUILD_TARGETS),\ cd $$($(2)_SRC_PATH); \ @@ -109,6 +116,20 @@ define $(2)_BUILD_CMDS ./$$(d) ) endef +else +# Build package for host +define $(2)_BUILD_CMDS + $$(foreach d,$$($(2)_BUILD_TARGETS),\ + cd $$($(2)_SRC_PATH); \ + $$(GO_HOST_ENV) \ + GOPATH="$$(@D)/$$($(2)_WORKSPACE)" \ + $$($(2)_GO_ENV) \ + $$(GO_BIN) build -v $$($(2)_BUILD_OPTS) \ + -o $$(@D)/bin/$$(or $$($(2)_BIN_NAME),$$(notdir $$(d))) \ + ./$$(d) + ) +endef +endif endif # Target installation step. Only define it if not already defined by the @@ -121,6 +142,15 @@ define $(2)_INSTALL_TARGET_CMDS endef endif +# Host installation step +ifndef $(2)_INSTALL_CMDS +define $(2)_INSTALL_CMDS + $$(foreach d,$$($(2)_INSTALL_BINS),\ + $(INSTALL) -D -m 0755 $$(@D)/bin/$$(d) $(HOST_DIR)/bin/$$(d) + ) +endef +endif + # Call the generic package infrastructure to generate the necessary make # targets $(call inner-generic-package,$(1),$(2),$(3),$(4)) @@ -132,3 +162,4 @@ endef # inner-golang-package ################################################################################ golang-package = $(call inner-golang-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target) +host-golang-package = $(call inner-golang-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)