From patchwork Thu Oct 5 12:40:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 821746 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="AGtgdb9u"; 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 3y7C7M1cqLz9t2Z for ; Thu, 5 Oct 2017 23:41:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7ED1C87FA3; Thu, 5 Oct 2017 12:41:12 +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 rnv-9Bp_yk7O; Thu, 5 Oct 2017 12:41:10 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 4CA1D87FA6; Thu, 5 Oct 2017 12:41:10 +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 0DC401C01CA for ; Thu, 5 Oct 2017 12:41:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 07A5C88D7B for ; Thu, 5 Oct 2017 12:41:09 +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 WoqKkyYy8NDJ for ; Thu, 5 Oct 2017 12:41:08 +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 whitealder.osuosl.org (Postfix) with ESMTPS id E9CD488D7A for ; Thu, 5 Oct 2017 12:41:07 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id l10so1280083wre.3 for ; Thu, 05 Oct 2017 05:41:07 -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=Eko0xpfCy28l9xVvlO3dih2TzI4kAs6C2wxj2RMDtXc=; b=AGtgdb9uyvgLPV/p9n+dJji65TDgO59g4MJPstl3Q8RCsnX3kOnihPWWPt2uaUHrxD MXU4DnKdWL8xlJCM1WpogePdL1R89ddwW6pDCmC9Is6eszHeX6TStQcPV1NJ2M9U+2En JXL99zr7/1Z1w6ZcPC+rLVcOnzmp4NoHg+k7HmSIxPT3gD39yzUUKr2oRjhlVQEHFWkJ nD9oTXRDJazshfF0uL4jNgXCologTmbCMIQXAm7W4q4TIBnSsqdeEOp8tQ4fQ02Y1PKQ Ho5eZ+vXBEb5yy3BMvLDAPUjJSYHX4mjmweFcNwKrPyXrG/esUVVwIRI2D+TV1ZskvQX URKA== 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=Eko0xpfCy28l9xVvlO3dih2TzI4kAs6C2wxj2RMDtXc=; b=NiARPp3YyQf+wPADadKhZUnsYB/3B0/PWR7JWRemVE/d75Q/B/3TPUmt5W00DCqVW2 7pZNnGVRZfM81lv9BC5DNdcph8vJaSDEbFXiGdb5PaEaZgbp6Kj9ZRVmlhwxmwM9qplw 0nPyIaFkShL85IoaKCaxaoYk0q8ZvVXKzDqVyCkJc6ZEQH3Q1Y9MqXKgFy4EXDmp6hZp vrdlIgbWJMkon5w0uV2udjzSpyh6nMMF0gRVPuNjelDOPAJbj6L/PfXSi1pWfgGs+P0R xjgprNuQhoZUsBvBgSW9Vav4jPb07UDT2P7sksTqBeveZoKRF4+0GnDGWx3GXHOaWY5p fFrQ== X-Gm-Message-State: AMCzsaXsc+Qe4HvZd/Wip6rW+gOAHrHJ8Sa8b1zzWcXqrf35sTNtuqlC 7gG6HhXhQ9imCavkpVkkZ1tJZii8 X-Google-Smtp-Source: AOwi7QAMGQQWpmnnv+9itJK/J6NHxPRFEW2XQ+YOKDKvMdXxblMwQN4lM3TJxXaEeH8lGJK48Ogohw== X-Received: by 10.223.182.156 with SMTP id j28mr14137662wre.46.1507207265521; Thu, 05 Oct 2017 05:41:05 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id c37sm10056896wra.73.2017.10.05.05.41.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 05:41:04 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Thu, 5 Oct 2017 14:40:57 +0200 Message-Id: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 Subject: [Buildroot] [RFC 1/4] package/go: fixing crosscompilation settings 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 fixes a bug with the BR2_TOOLCHAIN_HAS_THREADS variable handling which causes CGO_ENABLED to be always 0. Furthermore, it fixes the cross compilation options for the go compiler: setting CGO_ENABLED should be done only for the target compiler not the host one. Signed-off-by: Angelo Compagnucci Reviewed-by: "Yann E. MORIN" --- package/go/go.mk | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/package/go/go.mk b/package/go/go.mk index 0781dff..8e510e7 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -52,7 +52,7 @@ HOST_GO_TARGET_ENV = \ # set, build in cgo support for any go programs that may need it. Note that # any target package needing cgo support must include # 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file. -ifeq (BR2_TOOLCHAIN_HAS_THREADS,y) +ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y) HOST_GO_CGO_ENABLED = 1 else HOST_GO_CGO_ENABLED = 0 @@ -74,8 +74,8 @@ HOST_GO_MAKE_ENV = \ GOARCH=$(GO_GOARCH) \ $(if $(GO_GOARM),GOARM=$(GO_GOARM)) \ GOOS=linux \ - CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \ - CC=$(HOSTCC_NOCCACHE) + CC=$(HOSTCC_NOCCACHE) \ + CXX=$(HOSTCXX_NOCCACHE) HOST_GO_TARGET_CC = \ CC_FOR_TARGET="$(TARGET_CC)" \ @@ -83,16 +83,18 @@ HOST_GO_TARGET_CC = \ HOST_GO_HOST_CC = \ CC_FOR_TARGET=$(HOSTCC_NOCCACHE) \ - CXX_FOR_TARGET=$(HOSTCC_NOCCACHE) + CXX_FOR_TARGET=$(HOSTCXX_NOCCACHE) HOST_GO_TMP = $(@D)/host-go-tmp define HOST_GO_BUILD_CMDS - cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_HOST_CC) ./make.bash + cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_HOST_CC) \ + CGO_ENABLED=0 ./make.bash mkdir -p $(HOST_GO_TMP) mv $(@D)/pkg/tool $(HOST_GO_TMP)/ mv $(@D)/bin/ $(HOST_GO_TMP)/ - cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_TARGET_CC) ./make.bash + cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_TARGET_CC) \ + CGO_ENABLED=$(HOST_GO_CGO_ENABLED) ./make.bash endef define HOST_GO_INSTALL_CMDS From patchwork Thu Oct 5 12:40:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 821747 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="nTFc8rQR"; 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 3y7C7N01h3z9t2l for ; Thu, 5 Oct 2017 23:41:19 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D32A4889D0; Thu, 5 Oct 2017 12:41:16 +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 AypIG2BjfGAu; Thu, 5 Oct 2017 12:41:14 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 2A7B8889C9; Thu, 5 Oct 2017 12:41:14 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 5451E1C01CA for ; Thu, 5 Oct 2017 12:41:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 46E1F26695 for ; Thu, 5 Oct 2017 12:41:12 +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 T8tA9HFCEB+o for ; Thu, 5 Oct 2017 12:41:11 +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 silver.osuosl.org (Postfix) with ESMTPS id 3F56E25DBB for ; Thu, 5 Oct 2017 12:41:11 +0000 (UTC) Received: by mail-wr0-f194.google.com with SMTP id l10so1280132wre.3 for ; Thu, 05 Oct 2017 05:41:11 -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=TptsfQWpg7Js2I+qWEY2FX7rqankaz/422AfU5pEEd4=; b=nTFc8rQR3pu0XMyt+++eQ/iTwqh+vGuwYJdjJCoeefCdsG/PHqMldJhl/BwLicOB3g 8IQXQgbjXxZaTHajDkEE4E3lF6Ylc1oAMI6hoBFWH3oB9avLqtwDNaHdaG8Dugik1Dcv +yZr7buWNDRy2pIZcYKR5tXgS2b8M4ZleCwQEP3/H8Lh0hGchITYSUmSvUJg5RXaT9iy GRulUbzxRc8GmwnGHLVhQS1aqBqbD3OMAcu/w/nmCwiEGdjd5HZIQ+2VFLQ48J5epwxn 7KhVyYTNLWY1ra6+9+uMs+V8ga8BxUciD+I2f8daqFF55BKyGStFRlpjsEM+qWK9LSy5 WKsw== 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=TptsfQWpg7Js2I+qWEY2FX7rqankaz/422AfU5pEEd4=; b=ptBNIPZyiHmN+ivseYTStKlUx5KjY1gfyBJykKyCdTl077HHhho5CcnIUsC+Eif2Qf kXxTCd9xQHsfIk7rHS6K7TXEw677mnarwkjitO09i1BKZCpcSzB8QgFDS7L81NnaWoeK 4FmTgLHH20woTKKqy8sXd428Kuzm1VGcxX6GkjVePZ4g4pyyrbbvF4DmO0AkojdwS2EY dN6t6Otd0DxrNVHNgNK3nRvq0n90UQHA+yYcFNfC53rmGQ83E0aqQubStmUbWP1vv6bA 5N+HjoLFBQAossoOPuKvpoMA0Lym1mP9BXhBkDUUqGxQ6XAgayeVs9CsYhLfdCtDTYPL NDng== X-Gm-Message-State: AMCzsaWc+SKOs9lt46nvieVQ/zEDOBNdA55tRXlqGO6ThtghtEdYIstm V7SaEp6jzRc6+v/ACXFRAsV/v1ED X-Google-Smtp-Source: AOwi7QBQA0fFPCskKCTb9+AJhtht/fuC5xfbo0UsHu9pRUzX75VAa2UHK83z/7anINakNJ1qtKlgBg== X-Received: by 10.223.180.82 with SMTP id v18mr8958792wrd.61.1507207269063; Thu, 05 Oct 2017 05:41:09 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id c37sm10056896wra.73.2017.10.05.05.41.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 05:41:08 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Thu, 5 Oct 2017 14:40:58 +0200 Message-Id: <1507207260-26734-2-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> References: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> Subject: [Buildroot] [RFC 2/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 --- package/Makefile.in | 1 + package/pkg-golang.mk | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 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..c4e6410 --- /dev/null +++ b/package/pkg-golang.mk @@ -0,0 +1,121 @@ +################################################################################ +# 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 behaviour. 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 specifities 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 + +ifndef $(2)_MAKE_ENV +define $(2)_MAKE_ENV + $$(HOST_GO_TARGET_ENV) \ + GOPATH="$$(@D)/gopath" \ + CGO_ENABLED=$$(HOST_GO_CGO_ENABLED) +endef +endif + +# Target packages need the Go compiler on the host. +$(2)_DEPENDENCIES += host-go + +# +# go install command doesn't work well when cross compilation is enabled, +# we set the executable output of the compilation to a specific location. +# We set this variable here to be used by packages if needed. +# +$(2)_EXECUTABLE = $$(@D)/gopath/bin/$(1) + +# +# Source files in Go should be uncompressed in a precise folder in the +# hiearchy of GOPATH. It usually resolves around domain/vendor/software. +# +$(1)_src_path ?= $$(call domain,$($(2)_SITE))/$$(firstword $$(subst /, ,$$(call notdomain,$($(2)_SITE)))) +$(2)_SRC_PATH = $$(@D)/gopath/src/$$($(1)_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)/gopath/bin + mkdir -p $$(@D)/gopath/src/$$($(1)_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. +# +ifndef $(2)_BUILD_CMDS +define $(2)_BUILD_CMDS + cd $$($(2)_SRC_PATH) && $$($(2)_MAKE_ENV) $(HOST_DIR)/bin/go build \ + -o $$($(2)_EXECUTABLE) -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)_EXECUTABLE) $(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)_EXECUTABLE) $(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 Thu Oct 5 12:40:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 821748 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.136; helo=silver.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="tllcoDik"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7C7Q4LqNz9t2Z for ; Thu, 5 Oct 2017 23:41:22 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 37AEC301EB; Thu, 5 Oct 2017 12:41:19 +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 mSFsh4h9FNv0; Thu, 5 Oct 2017 12:41:17 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id F2949301DC; Thu, 5 Oct 2017 12:41:16 +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 024541C01CA for ; Thu, 5 Oct 2017 12:41:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id EF2FB87FA7 for ; Thu, 5 Oct 2017 12:41:13 +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 Uog78keQh035 for ; Thu, 5 Oct 2017 12:41:13 +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 1436187FAA for ; Thu, 5 Oct 2017 12:41:13 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id z1so9563314wre.1 for ; Thu, 05 Oct 2017 05:41:12 -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=XV2FrRod4LXuT7dJSXjjJ33xp/BlDs84B/SVG4evcgU=; b=tllcoDiknjNQPDB8dnlycAgNmqg7q2cj++I/fC3x6nSDHkcppwFOlZ+a8SC+ECC+rt BhzSDsiCsgcfXWAeoN1ZF4AH1NI415PabyYfw9RjDjih3ojQyq7CWxeBamAqHj9xJWUO IBhC6Ey2hlkLSZFJhO+ZT/dFjisVUhxKzC4O5IeiWR+VPBCtL7yRhyBpGWh0Rn/MHXr7 5/E/0D523/k8gRsTtP1Iv6tLwN1vL6vWv5991MA0CNu5y37xXga/uxhZnKtwJ5u5wKVK Je0WezbAGj8bVNGZzWe2AM+ZC747FjvlWzMbSqXy2qojOdhQ+xl9B5jN+z8ct0No+8qH /oVA== 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=XV2FrRod4LXuT7dJSXjjJ33xp/BlDs84B/SVG4evcgU=; b=crrjqJkMJGoX6V9i1m14Ehb1IelyTrGKY0OY3ymkS+wDj8b0D/xAqxKdH57VBJlKRI hVEoS5lFlDKPO11JoXExaDtQpO12VeODqI7oMNvSKdIAWBXgRQe7NZtSZYSnMsvLwV8z dBhpl6bWzJLYlzUdn5jzwXXYPeKiiA1wvJ/a+AtlX5NUcRCLfBJfMC4xZRf30m9NF2vO tXM4fxKfllz5VNJkF9z5IAHJGhcNddY7gf1fwVkCxrrlrA3kn0y754LC3CyiZ9FcxDDe l7QNfOGlM/pDv/PJ7L3b5oDGa1RbIcyKkhYd9A6nc6JfChc2YFZ5kyQQvLpd+/UFcaxm iyPw== X-Gm-Message-State: AHPjjUgdI943JLo3e+ZPp1FAxlT2RWSP3Nw7/9KfVk7tA1nUKZmMxJ93 RsO5qhbn1dZ66z/LojkoZgBPuSsB X-Google-Smtp-Source: AOwi7QBcXcnOlcAPI7U6tn3J+pFG1eEjgR0T/o7DAKyeo1tJvF+v5xNr+c1NiXnaJ1jiYcl96Ovjnw== X-Received: by 10.223.198.15 with SMTP id n15mr17313194wrg.200.1507207270748; Thu, 05 Oct 2017 05:41:10 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id c37sm10056896wra.73.2017.10.05.05.41.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 05:41:09 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Thu, 5 Oct 2017 14:40:59 +0200 Message-Id: <1507207260-26734-3-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> References: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> Subject: [Buildroot] [RFC 3/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 | 111 +++++++++++++++++++++++++++++++++ docs/manual/adding-packages.txt | 2 + 2 files changed, 113 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..2ba45f0 --- /dev/null +++ b/docs/manual/adding-packages-golang.txt @@ -0,0 +1,111 @@ +// -*- 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. + +* +GO_FOO_GO_SRC_PATH+: go sources should be compiled inside GOPATH. + The golang package infrastructure tries to guess the correct + GOPATH subfolder to compile in. If guessing is not correct or your + package behaves differently, you can use this variable to + adjust the path. + + +* +GO_FOO_BUILD_OPTS+, to specify additional options to pass to the + Go +setup.py+ script during the build step. For target distutils + packages, the +PKG_GO_DISTUTILS_BUILD_OPTS+ options are already + passed automatically by the infrastructure. + +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 Thu Oct 5 12:41:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angelo Compagnucci X-Patchwork-Id: 821749 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.136; helo=silver.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="m966zsma"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7C7T61PNz9t2Z for ; Thu, 5 Oct 2017 23:41:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7F32F266C6; Thu, 5 Oct 2017 12:41:22 +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 XXtrNmnvXxk7; Thu, 5 Oct 2017 12:41:19 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id D7C8F301E2; Thu, 5 Oct 2017 12:41:18 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id ED7C21C01CA for ; Thu, 5 Oct 2017 12:41:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E9E80301E2 for ; Thu, 5 Oct 2017 12:41:17 +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 5854A4VFrlT8 for ; Thu, 5 Oct 2017 12:41:16 +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 silver.osuosl.org (Postfix) with ESMTPS id BD54C2634A for ; Thu, 5 Oct 2017 12:41:14 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id b189so1859764wmd.4 for ; Thu, 05 Oct 2017 05:41:14 -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=pvhYTaxxPFg53+BjF+lVa8DV2TtVC7pA1SPKL6OXn0E=; b=m966zsmaeAL4Hw8IzKAhN6SmjIHSokmeyrqUgtMHpfKIIIrNQy2ZL/IhSkgKr/q3zH TiXGLB17a5khyN/IdcE68xAYRvrQen64A4OFK8vxdhVc0jGJMRLC0lVLxJhK+rPjWuuq 8f/2NukGjx/4pXoYR4hoI4vceEOZ+2NMOiIcSBGIVL72AcXYIpjGXUYqiCQL+0Bc9pc9 jDLLI833p9dCXkY5Htr1cixwnrxUIxJuP1TsNDhzleZs5+PCLgGnkrd+MrPBdjrVPz0b uZjDjB/7S0sS5TscGiGKcH6XEQ0XILD0Zuv71CCH5kKa++ixn6vfx/SBdVcJlgQdL4N+ iItw== 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=pvhYTaxxPFg53+BjF+lVa8DV2TtVC7pA1SPKL6OXn0E=; b=oPh6jXUBBg4boMKWqspwGfa1Vf7sIbHMOsaVKYfbmQp9Vl+YYkGOp6kRA5PeaqwbLJ 1uDsPyXb8JnurBBq9gVKl0Lg8lmbexUYvk1WSNK6NnXiV+BvzZgK/43U2jynEktDIBWP yOjFzaiApwMaIVbdKJb8srEKNypnxldC8MyFQeNykCWnBYaMxRhAUTB3AnDSu1Qqmb38 d66cmFgM7vokO15Ni4Gz6fNjw2KKsFBdIqGcMiz9+6BKZzC5x9w7R5kTnj7EOurB/brj QQoIt2kA7BTF6SupV8ImTXYCsisAYcLgVFj7CzPCS65xC0roxakQOK1q/d1GJAOsrqSN gVqw== X-Gm-Message-State: AHPjjUjogqFfHaqrtIkvpYcYo161Xk5tDV+7VNtH+dO+sXbOG7IAxxJ/ JRaIlg3CtNCj6Wj0QsKrJ/v9EDxV X-Google-Smtp-Source: AOwi7QBTFKRGatRUAzprD8Bj/GovyqPltHTK5n1j3eJWHFznx+wIBqbTF0JNb+XuxGCY5pSMWvO86A== X-Received: by 10.28.71.25 with SMTP id u25mr17567996wma.22.1507207272500; Thu, 05 Oct 2017 05:41:12 -0700 (PDT) Received: from localhost.localdomain ([89.202.204.147]) by smtp.gmail.com with ESMTPSA id c37sm10056896wra.73.2017.10.05.05.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Oct 2017 05:41:11 -0700 (PDT) From: Angelo Compagnucci To: buildroot@buildroot.org Date: Thu, 5 Oct 2017 14:41:00 +0200 Message-Id: <1507207260-26734-4-git-send-email-angelo.compagnucci@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> References: <1507207260-26734-1-git-send-email-angelo.compagnucci@gmail.com> Subject: [Buildroot] [RFC 4/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 | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/package/flannel/flannel.mk b/package/flannel/flannel.mk index bbb2c72..641bb97 100644 --- a/package/flannel/flannel.mk +++ b/package/flannel/flannel.mk @@ -11,14 +11,6 @@ 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) @@ -26,21 +18,12 @@ 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_BUILD_OPTS = -ldflags "$(FLANNEL_GLDFLAGS)" +# 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_EXECUTABLE) $(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))