From patchwork Tue Oct 24 21:14:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 830039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Dg0mmkeg"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yM5d54ZWWz9t2c for ; Wed, 25 Oct 2017 08:14:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 2B74C88D58; Tue, 24 Oct 2017 21:14:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id goNMqlaF828n; Tue, 24 Oct 2017 21:14:43 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 1005088A98; Tue, 24 Oct 2017 21:14:43 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 3717E1BF25F for ; Tue, 24 Oct 2017 21:14:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 26A5388A98 for ; Tue, 24 Oct 2017 21:14:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id htcgFMzdwv-E for ; Tue, 24 Oct 2017 21:14:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by whitealder.osuosl.org (Postfix) with ESMTPS id 3590B88A96 for ; Tue, 24 Oct 2017 21:14:41 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id q124so18180440wmb.0 for ; Tue, 24 Oct 2017 14:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=glvIbDkEHDst7u26F0o//MS7HuHAly+HAP0sUJi2zpQ=; b=Dg0mmkegsfRNtheqCDmMpByBUNKXcvB0hkJXZ/sPNZB67KoiBjznMsXulONRHGBm/x 6qeV/4Kmx9KZ2LLiPbESS9rd+agd3FHdwmlcwmZ7eWz61WwR8+Ah2oFsmxpiUeHHdqdN vAloGo4V1cmLtG5RV0eLhuSU5OCBIJV1/b0o3sD4eZsYsRbbKxbY3jMMZfIdRSZ6hdDa BdPSWkW9wtDV3Qwksn0sJeY0jMI2txiBvMmh9DiVj7wZdg8QzsWC4WdroMb7g9rfUQQa adPpb9er6qCH3bqcznncEQrWwnydqba593dN6hUroyPudqNMmEuLcJadF2vq2jUvFuUt gjnw== 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; bh=glvIbDkEHDst7u26F0o//MS7HuHAly+HAP0sUJi2zpQ=; b=DpafGiIvUcV9668F/oC4Ltob1g+wMvCtApsjvx3uewARDJs3GcUVJo3uR/7xjlJuwE CRK5LYontCXKNR1Pt+sT+6lrRTcLSPXsiZQCWpVgEWcnFLT3XArX6u31jxayMBrXUA77 VFQKjXZf5TzfqXLFDippxJzZZP8QqqD5iukLZo0pYOd/Xn9H91cozebVzql3ENF58+/n cVEl9o8sNiTfvwY0A+6qBUOsyYIwF4RalFdeMu4dJvDS2nZGi/JMlzfVIM4iJlXUJtF9 EQv1bfx44eBAjPrOvNcJkaURqs7pP/i96dfH/9WhqHdE0rSnaRA25QLRMgx7oH6QsXFy VWgg== X-Gm-Message-State: AMCzsaXdIxexqgI6MbjPRDyt6TfQKvPqbhYWKK96OCwM6ISKVOz2S68E U/RxjYH0O8tUIKztNtmjAeQ6UG0z X-Google-Smtp-Source: ABhQp+RWMUP3Eufb5EdQ4HkpfCT7drfIlrcZh84200a2ST9GntjmgGy8H2yaFaOflS1rHAG+xQfIhw== X-Received: by 10.28.136.146 with SMTP id k140mr81227wmd.147.1508879679006; Tue, 24 Oct 2017 14:14:39 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id k105sm1240527wrc.90.2017.10.24.14.14.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 14:14:37 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Tue, 24 Oct 2017 23:14:29 +0200 Message-Id: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: christian@paral.in Subject: [Buildroot] [RFC v4 1/4] package/pkg-golang: new package infrastructure X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch adds a new infrastructure for golang based packages. Signed-off-by: Angelo Compagnucci --- Changelog: v2 -> v3: * Adding GO_LDFLAGS and GO_TAGS variables * Adding GOPATH variable * Adding option to build as static when BR2_STATIC_LIBS is enabled * Changed building logic to take into account multiple binaries v3 -> v4: * Changing GOPATH default value from gopath to _gopath package/Makefile.in | 1 + package/pkg-golang.mk | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 package/pkg-golang.mk diff --git a/package/Makefile.in b/package/Makefile.in index a1a5316..60d98d0 100644 --- a/package/Makefile.in +++ b/package/Makefile.in @@ -429,3 +429,4 @@ include package/pkg-kconfig.mk include package/pkg-rebar.mk include package/pkg-kernel-module.mk include package/pkg-waf.mk +include package/pkg-golang.mk diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk new file mode 100644 index 0000000..2edc366 --- /dev/null +++ b/package/pkg-golang.mk @@ -0,0 +1,140 @@ +################################################################################ +# Golang package infrastructure +# +# This file implements an infrastructure that eases development of +# package .mk files for Go packages. It should be used for all +# packages that are written in go. +# +# See the Buildroot documentation for details on the usage of this +# infrastructure +# +# +# In terms of implementation, this golang infrastructure requires +# the .mk file to only specify metadata information about the +# package: name, version, download URL, etc. +# +# We still allow the package .mk file to override what the different +# steps are doing, if needed. For example, if _BUILD_CMDS is +# already defined, it is used as the list of commands to perform to +# build the package, instead of the default golang behavior. The +# package can also define some post operation hooks. +# +################################################################################ + +################################################################################ +# inner-golang-package -- defines how the configuration, compilation and +# installation of a Go package should be done, implements a few hooks to +# tune the build process for Go specificities and calls the generic package +# infrastructure to generate the necessary make targets +# +# argument 1 is the lowercase package name +# argument 2 is the uppercase package name, including a HOST_ prefix +# for host packages +# argument 3 is the uppercase package name, without the HOST_ prefix +# for host packages +# argument 4 is the type (target or host) +################################################################################ + +define inner-golang-package + +$(2)_GOPATH ?= _gopath + +ifndef $(2)_MAKE_ENV +define $(2)_MAKE_ENV + $$(HOST_GO_TARGET_ENV) \ + GOPATH="$$(@D)/$$($(2)_GOPATH)" \ + CGO_ENABLED=$$(HOST_GO_CGO_ENABLED) +endef +endif + +ifdef $(2)_GO_LDFLAGS + $(2)_BUILD_OPTS += -ldflags "$$($(2)_GO_LDFLAGS)" +endif + +ifeq ($(BR2_STATIC_LIBS),y) + $(2)_BUILD_OPTS += -extldflags '-static' +endif + +ifdef $(2)_GO_TAGS + $(2)_BUILD_OPTS += -tags "$$($(2)_GO_TAGS)" +endif + +# Target packages need the Go compiler on the host. +$(2)_DEPENDENCIES += host-go + +# +# The go build/install command installs the binaries inside +# gopath/bin/linux_GOARCH/ when cross compilation is enabled. +# We set this variable here to be used by packages if needed. +# +$(2)_BINDIR = $$(@D)/$$($(2)_GOPATH)/bin/linux_$$(GO_GOARCH) + +# +# Source files in Go should be uncompressed in a precise folder in the +# hierarchy of GOPATH. It usually resolves around domain/vendor/software. +# +$(2)_GO_SRC_PATH ?= $$(call domain,$($(2)_SITE))/$$(firstword $$(subst /, ,$$(call notdomain,$($(2)_SITE)))) +$(2)_SRC_PATH = $$(@D)/$$($(2)_GOPATH)/src/$$($(2)_GO_SRC_PATH)/$(1) + +# +# Configure step. Only define it if not already defined by the package +# .mk file. And take care of the differences between host and target +# packages. +# +ifndef $(2)_CONFIGURE_CMDS +define $(2)_CONFIGURE_CMDS + mkdir -p $$(@D)/$$($(2)_GOPATH)/bin + mkdir -p $$(@D)/$$($(2)_GOPATH)/src/$$($(2)_GO_SRC_PATH) + ln -sf $$(@D) $$($(2)_SRC_PATH) +endef +endif + +# +# Build step. Only define it if not already defined by the package .mk file. +# There is no differences between host and target packages. +# We use the install command instead of build command here because the +# install command also moves the package binaries in gopath/bin/linux_GOARCH/. +# Using the install command also leverages the go build infrastructure +# for building and installing multiple binaries. +# +ifndef $(2)_BUILD_CMDS +define $(2)_BUILD_CMDS + cd $$($(2)_SRC_PATH) && \ + $$($(2)_MAKE_ENV) $(HOST_DIR)/bin/go install \ + -v $$($(2)_BUILD_OPTS) +endef +endif + +# +# Host installation step. Only define it if not already defined by the +# package .mk file. +# +ifndef $(2)_INSTALL_CMDS +define $(2)_INSTALL_CMDS + $(INSTALL) -D -m 0755 $$($(2)_BINDIR)/$(1) $(HOST_DIR)/usr/bin/ +endef +endif + +# +# Target installation step. Only define it if not already defined by the +# package .mk file. +# +ifndef $(2)_INSTALL_TARGET_CMDS +define $(2)_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 0755 $$($(2)_BINDIR)/$(1) $(TARGET_DIR)/usr/bin/ +endef +endif + +# Call the generic package infrastructure to generate the necessary make +# targets +$(call inner-generic-package,$(1),$(2),$(3),$(4)) + +endef # inner-golang-package + +################################################################################ +# golang-package -- the target generator macro for Go packages +################################################################################ + +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) + From patchwork Tue Oct 24 21:14:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 830040 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DOHZpKMq"; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yM5d73Q1dz9t2h for ; Wed, 25 Oct 2017 08:14:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 300EA886AE; Tue, 24 Oct 2017 21:14:48 +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 ZReu_H7Pk_WD; Tue, 24 Oct 2017 21:14:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id EFCB787F7D; Tue, 24 Oct 2017 21:14:45 +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 839E91BF25F for ; Tue, 24 Oct 2017 21:14:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7DD5887F7D for ; Tue, 24 Oct 2017 21:14:43 +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 ZJISRVDuTT5v for ; Tue, 24 Oct 2017 21:14:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 9B45387EBA for ; Tue, 24 Oct 2017 21:14:42 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id k62so22002896wrc.9 for ; Tue, 24 Oct 2017 14:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xh1pTArp/1x9Q7N2dM5lva0CV0P6ezYimSLkV2JHXkE=; b=DOHZpKMqjcOiO5VKYn3/F12wxsMleBOh18R2+9pb2enn4G8zKlLUH8X5wzf+SdPUse SqwKztdsZqRKz4nrInOrwys9cBTjb7oT0lcNMHmSRnykg9RhwwBO4fhnvG7Ws1b1vufi KvPX3pRw8k27mDwY9wqvaTsMCujcjImZWw5AZDfq+L8+N7obf1RpfU3eRyapbhBKrnTO XSPQuhIfukUA7AicXnH06J+2LnVj5WTysos6eewy4n62P+DIoFGDljLk6a/s9daPKTtG QVIdmpE4ALI+fDMncp07DS6ZUdRyeCynPHuiz8Pw5/Ox9umsoh3Sp605uS83UzIMznfU SF8g== 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=xh1pTArp/1x9Q7N2dM5lva0CV0P6ezYimSLkV2JHXkE=; b=No/NKtskADSHdqVHP2ROEIkvskB0CaqVlWavPj5c/ssPWIMvaJklOJVhZIbGYT9/B5 WG31G1OP1+TxKTR6iL+1ZplbABSgz1pAYglhHd0ePYplEW/5RNnjL54Jatm29GRxV9Vy TvI0uwn0QS2RD7s8BL5XZxiaD+tMP1InYw1VoY/pRWZ5jKIRrKPeqUgrWj1T6G4Sp/AN elCWb106fYsoZXXxTYBxnwO8AAq1t+cNBZ6gOjeHRZqe7OU0z1xFPGA36Vo3FxIoS00F 3Exgs7CgWN2bQT1biIZS2YftcB2r0/fG4PDbh6qrnP4Ka8qwJK+2eXEKpW5ExLdTIHs+ CdyA== X-Gm-Message-State: AMCzsaWOlcEON5FIByFKJirZ+G+dDwWFmFMDKjy9KECZCKm1HqgtoRTZ FqiLat4h4JkuxwDu2FXhp5027SBx X-Google-Smtp-Source: ABhQp+SIg20O2ImqrFb74g7NhZN5sQdymA+E/TzbjV5WHQ9Z5ur7Y5HJtUXLk+fGuPNhAhx783kq/Q== X-Received: by 10.223.144.71 with SMTP id h65mr16029890wrh.41.1508879680664; Tue, 24 Oct 2017 14:14:40 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id k105sm1240527wrc.90.2017.10.24.14.14.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 14:14:39 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Tue, 24 Oct 2017 23:14:30 +0200 Message-Id: <1508879672-12957-2-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> References: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> Cc: christian@paral.in Subject: [Buildroot] [RFC v4 2/4] docs/manual: adding documentation for the golang infrastructure X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch adds the documentation for the golang infrastructure. Signed-off-by: Angelo Compagnucci --- docs/manual/adding-packages-golang.txt | 117 +++++++++++++++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + 2 files changed, 119 insertions(+) create mode 100644 docs/manual/adding-packages-golang.txt diff --git a/docs/manual/adding-packages-golang.txt b/docs/manual/adding-packages-golang.txt new file mode 100644 index 0000000..a0e617f --- /dev/null +++ b/docs/manual/adding-packages-golang.txt @@ -0,0 +1,117 @@ +// -*- mode:doc; -*- +// vim: set syntax=asciidoc: + +=== Infrastructure for Go packages + +This infrastructure applies to Go packages that use the standard +build system and use bundled dependencies. + +[[golang-package-tutorial]] + +==== +golang-package+ tutorial + +First, let's see how to write a +.mk+ file for a go package, +with an example : + +------------------------ +01: ################################################################################ +02: # +03: # go-foo +04: # +05: ################################################################################ +06: +07: GO_FOO_VERSION = 1.0 +08: GO_FOO_SOURCE = go-foo-$(GO_FOO_VERSION).tar.xz +09: GO_FOO_SITE = http://www.foosoftware.org/download +10: GO_FOO_LICENSE = BSD-3-Clause +11: GO_FOO_LICENSE_FILES = LICENSE +12: +13: $(eval $(golang-package)) +------------------------ + +On line 7, we declare the version of the package. + +On line 8 and 9, we declare the name of the tarball (xz-ed tarball +recommended) and the location of the tarball on the Web. Buildroot +will automatically download the tarball from this location. + +On line 10 and 11, we give licensing details about the package (its +license on line 10, and the file containing the license text on line +11). + +Finally, on line 13, we invoke the +golang-package+ macro that +generates all the Makefile rules that actually allow the package to be +built. + +[[golang-package-reference]] + +==== +golang-package+ reference + +As a policy packages can freely choose their name (existing example in +Buildroot is +flannel+). + +In their +Config.in+ file, they should depend on ++BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS+ and ++BR2_PACKAGE_HOST_GO_CGO_LINKING_SUPPORTS+ cause host-go will compile when Buildroot will add the +dependency automatically. + +The main macro of the Go package infrastructure is ++golang-package+. It is similar to the +generic-package+ macro. It is +also possible to create Go host packages 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+ +or +host-golang-package+ macros. + +All the package metadata information variables that exist in the +xref:generic-package-reference[generic package infrastructure] also +exist in the Go infrastructure: +GO_FOO_VERSION+, ++GO_FOO_SOURCE+, +GO_FOO_PATCH+, +GO_FOO_SITE+, ++GO_FOO_SUBDIR+, +GO_FOO_DEPENDENCIES+, +GO_FOO_LICENSE+, ++GO_FOO_LICENSE_FILES+, +GO_FOO_INSTALL_STAGING+, etc. + +Note that: + + * It is not necessary to add +go+ or +host-go+ in the + +GO_FOO_DEPENDENCIES+ variable of a package, since these basic + dependencies are automatically added as needed by the Go + package infrastructure. + +A few additional variables, specific to the Go infrastructure, can +optionally be defined, depending on the package's needs. Many of them +are only useful in very specific cases, typical packages will +therefore only use a few of them, or none. + +* If your package need a custom GOPATH to be compiled in, you can use the + +GO_FOO_GOPATH+. + +* +GO_FOO_GO_SRC_PATH+ is the path where your source will be compiled + relatively to the GOPATH. + The golang package infrastructure tries to guess the correct + sub folder to compile in but if guessing is not correct for you or your + package behaves differently, you can use this variable to + redefine the path. + +* +GOO_FOO_GO_LDFLAGS+ and +GO_FOO_GO_TAGS+ can be used to pass + respectively the LDFLAGS or the TAGS to the build command. + +GOO_FOO_GO_LDFLAGS+ and +GO_FOO_GO_TAGS+ will be combined into + the proper command line options to be passed to the compiler. + +* If you need to customize the install location for you binaries, you + can use +GOO_FOO_BINDIR+ to know where the binaries are. + +With the Go infrastructure, all the steps required to build and +install the packages are already defined, and they generally work well +for most Go-based packages. However, when required, it is still +possible to customize what is done in any particular step: + +* By adding a post-operation hook (after extract, patch, configure, + build or install). See xref:hooks[] for details. + +* By overriding one of the steps. For example, even if the Go + infrastructure is used, if the package +.mk+ file defines its own + +GO_FOO_BUILD_CMDS+ variable, it will be used instead of the + default Go one. However, using this method should be restricted + to very specific cases. Do not use it in the general case. + diff --git a/docs/manual/adding-packages.txt b/docs/manual/adding-packages.txt index d577ff0..be7468b 100644 --- a/docs/manual/adding-packages.txt +++ b/docs/manual/adding-packages.txt @@ -34,6 +34,8 @@ include::adding-packages-rebar.txt[] include::adding-packages-waf.txt[] +include::adding-packages-golang.txt[] + include::adding-packages-kernel-module.txt[] include::adding-packages-asciidoc.txt[] From patchwork Tue Oct 24 21:14:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 830041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZrfRO4rC"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yM5dC5rphz9t2c for ; Wed, 25 Oct 2017 08:14:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id F2004898A3; Tue, 24 Oct 2017 21:14:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LrYWoRqPfSXp; Tue, 24 Oct 2017 21:14:50 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id DA69989869; Tue, 24 Oct 2017 21:14:49 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 4F8151BF25F for ; Tue, 24 Oct 2017 21:14:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 44E3988AA6 for ; Tue, 24 Oct 2017 21:14:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y5P+X8YQU0yw for ; Tue, 24 Oct 2017 21:14:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by whitealder.osuosl.org (Postfix) with ESMTPS id 8256088A96 for ; Tue, 24 Oct 2017 21:14:44 +0000 (UTC) Received: by mail-wr0-f194.google.com with SMTP id y9so9787384wrb.2 for ; Tue, 24 Oct 2017 14:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s51PPjhKKRDbmrQNcVO7GX5EnWvdvo4RsHfbuWfg/MA=; b=ZrfRO4rCBc3pfXg1fNYe3Ra6HwMD0lCVfmQQ9hR4+ahezZa02kutoYuidSuCi8bEcD 8LEQnBCNlS7rxJhsPxMvhHn5Px+PKooTd5f4CjR8llRvsx1aNt/qfTO7OpzFKixC6y8r XJxQaNRBTomXsfAwKUqhKhgVKl0BT1w/jtmo7SC2DoMbAwj8CyT8487sx9PRAfw8e6/A XzNqaBfkGeyK9Otya0sqs5JS6G1Gi+ji2YWf/MengtKX3Sd4B3CXzIs5uT50jP6cNC/a OcHcIHI6EhbgvzYEAA+PoTIUGefUkqK4GbgkgJZpHiN0Q402L8L6SlMi/TjBee1qoCyf lVWw== 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=s51PPjhKKRDbmrQNcVO7GX5EnWvdvo4RsHfbuWfg/MA=; b=iYldHh8lbodsDleM8S3q9qzZNK4Qj89AO8GR9eUHZpn892ZmUllxueg9GAPiAlhiTb en06ogNn63s/kO3KfRH+Wa6OvSAy3T3axd4Qx6NLbIZXJ5ybN2VVH1FaiLp0YWKo/u8N y6pRKM+clo7DRPO+tbXGuyXUIXueMoiiAd/ekExPZ5lnm/fqygq0Z4SA+kVlHanFC6u7 mMbJMc+3oP0qlbiKtFabjMqwOQD+sIx8qd8TxWn71q8cR1984kpbHadSM4yPDqt+WNVD WoucA/FOdgFZ9XehzhDNbR1n9T/SaZ2rUrz9/AKfxQjfZeF7Zx/muJCvVuV+j2ZaOFpL segw== X-Gm-Message-State: AMCzsaWCCUOGNerWjAW6Y3PGHi8wCBv6bjZmJUAhFYfRW6VzDGLYK4zf nqR34mGPZBV8Fe8euLQvAE7OCY2a X-Google-Smtp-Source: ABhQp+RN/NreCW+8388AlgIZmdYPXCLhSswThf8w7DrK6fpJFOmKDRcT7ay3yGQkPQKp4v9gFIuwDQ== X-Received: by 10.223.132.135 with SMTP id 7mr10150wrg.74.1508879682528; Tue, 24 Oct 2017 14:14:42 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id k105sm1240527wrc.90.2017.10.24.14.14.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 14:14:41 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Tue, 24 Oct 2017 23:14:31 +0200 Message-Id: <1508879672-12957-3-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> References: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> Cc: christian@paral.in Subject: [Buildroot] [RFC v4 3/4] package/flannel: converting to golang infrastructure X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch converts the flannel package to the new golang infrastructure. Signed-off-by: Angelo Compagnucci --- package/flannel/flannel.mk | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/package/flannel/flannel.mk b/package/flannel/flannel.mk index bbb2c72..6c9d9dd 100644 --- a/package/flannel/flannel.mk +++ b/package/flannel/flannel.mk @@ -11,36 +11,12 @@ FLANNEL_SOURCE = $(FLANNEL_VERSION).tar.gz FLANNEL_LICENSE = Apache-2.0 FLANNEL_LICENSE_FILES = LICENSE -FLANNEL_DEPENDENCIES = host-go - -FLANNEL_MAKE_ENV = \ - $(HOST_GO_TARGET_ENV) \ - GOBIN="$(@D)/bin" \ - GOPATH="$(@D)/gopath" \ - CGO_ENABLED=1 - -FLANNEL_GLDFLAGS = \ - -X github.com/coreos/flannel/version.Version=$(FLANNEL_VERSION) - -ifeq ($(BR2_STATIC_LIBS),y) -FLANNEL_GLDFLAGS += -extldflags '-static' -endif - -define FLANNEL_CONFIGURE_CMDS - # Put sources at prescribed GOPATH location. - mkdir -p $(@D)/gopath/src/github.com/coreos - ln -s $(@D) $(@D)/gopath/src/github.com/coreos/flannel -endef - -define FLANNEL_BUILD_CMDS - cd $(@D) && $(FLANNEL_MAKE_ENV) $(HOST_DIR)/bin/go \ - build -v -o $(@D)/bin/flanneld -ldflags "$(FLANNEL_GLDFLAGS)" . -endef +FLANNEL_GO_LDFLAGS = -X github.com/coreos/flannel/version.Version=$(FLANNEL_VERSION) +# Install flannel to its well known location. define FLANNEL_INSTALL_TARGET_CMDS - # Install flannel to its well known location. - $(INSTALL) -D -m 0755 $(@D)/bin/flanneld $(TARGET_DIR)/opt/bin/flanneld + $(INSTALL) -D -m 0755 $(FLANNEL_BINDIR)/flannel $(TARGET_DIR)/opt/bin/flanneld $(INSTALL) -D -m 0755 $(@D)/dist/mk-docker-opts.sh $(TARGET_DIR)/opt/bin/mk-docker-opts.sh endef -$(eval $(generic-package)) +$(eval $(golang-package)) From patchwork Tue Oct 24 21:14:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 830042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Vy1Dfd/i"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yM5dF0LCcz9t2c for ; Wed, 25 Oct 2017 08:14:57 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id D88A188A96; Tue, 24 Oct 2017 21:14:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pMgeN4F3pcVz; Tue, 24 Oct 2017 21:14:51 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 149E088AA6; Tue, 24 Oct 2017 21:14:51 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 0E6621BF25F for ; Tue, 24 Oct 2017 21:14:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 084FC88B74 for ; Tue, 24 Oct 2017 21:14:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OBfLomKo04mq for ; Tue, 24 Oct 2017 21:14:46 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by hemlock.osuosl.org (Postfix) with ESMTPS id 0E87F88B50 for ; Tue, 24 Oct 2017 21:14:46 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id u138so18889547wmu.4 for ; Tue, 24 Oct 2017 14:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uQ9DsNBPBlbahU5LLqiEqTaXFlZGKoN5mNY1UJL3x4Y=; b=Vy1Dfd/ih9xo+eNQXwaJGA4ILfyYKtc6SFiglaUc/NObVSpB+ZnVbEBfSKfpGZ222W 83RSaXhMN5ebi/41/DPHWSVgPYKHDhIzFv23HJB5NK0HmA4otOWREVpUCVI2Rlltxlwj 5pOhYQ38l0b35scyPqSr44fHHPi8QUBXLRXguRbLdgwUSJzyEMEennUbxPhq/sc0zS14 B1yqh2U1/gcBNdH1cGS/HexgFjmUM3dZ57SdlzgqlGdzp/O70/JOM/uyJs1g64WQd/Bp Es72Ojlq5FWyH0+HrMU2fdLv4+0sWvDAbHf4LD2VxX70jcKhr21OeH9g5b0ay0vJbmMH s3nw== 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=uQ9DsNBPBlbahU5LLqiEqTaXFlZGKoN5mNY1UJL3x4Y=; b=nr8p/k3UVnN8Bz+reUDLJxG0RVzNvQjVptavssmp7AidtxvX/NasLBFRfx1RK8bgdq 9I+wGkoC2pHkLWx3Jjlsea1Zs9/ezJZAUHZa8GQCGYhhvzakHeQyyqYQiSNukCPOhhkC BRbXAr7G9ChwpBxdswIQ4ez7zHE3aW6VLwFAtURItSxrHtHkECk/WV6+FBJ/KtZI93fY nfIfEa+XUYy+Lj/OTvBgQLUbD+lXVIPJsCfbzit0r/nVsTkmtgod5k4IzFv3mdQMjwah o7yXvYxlRCSvVP7h0sHuIODjKISiRW7i849WDRBXwEzOAgaPcyTJ7YljMmEJ/wd1epno YKNQ== X-Gm-Message-State: AMCzsaWT3w0D70KDsIfynHI7zp4JCV3IYINbpXSU2KXlHCM9LFlsFA/S vYFHL9urAv4CbCHDSN+kGrHB3ON4 X-Google-Smtp-Source: ABhQp+QO9GGCZkq+xpj/IMRoPZs/fk8sg2Lo/DMP7Zahnhs8hrV5pYb6juy8Divk1Q5ijpFAuKw9nQ== X-Received: by 10.28.50.200 with SMTP id y191mr5832wmy.74.1508879684016; Tue, 24 Oct 2017 14:14:44 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id k105sm1240527wrc.90.2017.10.24.14.14.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Oct 2017 14:14:43 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Tue, 24 Oct 2017 23:14:32 +0200 Message-Id: <1508879672-12957-4-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> References: <1508879672-12957-1-git-send-email-angelo.compagnucci@gmail.com> Cc: christian@paral.in Subject: [Buildroot] [RFC v4 4/4] package/runc: converting to golang infrastructure X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This patch converts the runc package to the new golang infrastructure. Signed-off-by: Angelo Compagnucci --- package/runc/runc.mk | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/package/runc/runc.mk b/package/runc/runc.mk index 0b51e11..5d9e732 100644 --- a/package/runc/runc.mk +++ b/package/runc/runc.mk @@ -9,43 +9,13 @@ RUNC_SITE = $(call github,opencontainers,runc,$(RUNC_VERSION)) RUNC_LICENSE = Apache-2.0 RUNC_LICENSE_FILES = LICENSE -RUNC_DEPENDENCIES = host-go +RUNC_GO_LDFLAGS = -X main.gitCommit=$(RUNC_VERSION) -RUNC_GOPATH = "$(@D)/Godeps/_workspace" -RUNC_MAKE_ENV = $(HOST_GO_TARGET_ENV) \ - CGO_ENABLED=1 \ - GOBIN="$(@D)/bin" \ - GOPATH="$(RUNC_GOPATH)" \ - PATH=$(BR_PATH) - -RUNC_GLDFLAGS = \ - -X main.gitCommit=$(RUNC_VERSION) - -ifeq ($(BR2_STATIC_LIBS),y) -RUNC_GLDFLAGS += -extldflags '-static' -endif - -RUNC_GOTAGS = cgo static_build +RUNC_GO_TAGS = cgo static_build ifeq ($(BR2_PACKAGE_LIBSECCOMP),y) RUNC_GOTAGS += seccomp RUNC_DEPENDENCIES += libseccomp host-pkgconf endif -define RUNC_CONFIGURE_CMDS - mkdir -p $(RUNC_GOPATH)/src/github.com/opencontainers - ln -s $(@D) $(RUNC_GOPATH)/src/github.com/opencontainers/runc -endef - -define RUNC_BUILD_CMDS - cd $(RUNC_GOPATH)/src/github.com/opencontainers/runc && \ - $(RUNC_MAKE_ENV) $(HOST_DIR)/bin/go \ - build -v -o $(@D)/bin/runc \ - -tags "$(RUNC_GOTAGS)" -ldflags "$(RUNC_GLDFLAGS)" . -endef - -define RUNC_INSTALL_TARGET_CMDS - $(INSTALL) -D -m 0755 $(@D)/bin/runc $(TARGET_DIR)/usr/bin/runc -endef - -$(eval $(generic-package)) +$(eval $(golang-package))