From owner-svn-ports-head@freebsd.org Mon Apr 8 16:46:39 2019 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D4599155F5EE; Mon, 8 Apr 2019 16:46:38 +0000 (UTC) (envelope-from tobik@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7760B80BE8; Mon, 8 Apr 2019 16:46:38 +0000 (UTC) (envelope-from tobik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4BAFC2615C; Mon, 8 Apr 2019 16:46:38 +0000 (UTC) (envelope-from tobik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x38GkcuZ099804; Mon, 8 Apr 2019 16:46:38 GMT (envelope-from tobik@FreeBSD.org) Received: (from tobik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x38GkcQh099803; Mon, 8 Apr 2019 16:46:38 GMT (envelope-from tobik@FreeBSD.org) Message-Id: <201904081646.x38GkcQh099803@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tobik set sender to tobik@FreeBSD.org using -f From: Tobias Kortkamp Date: Mon, 8 Apr 2019 16:46:38 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r498386 - head/Mk/Uses X-SVN-Group: ports-head X-SVN-Commit-Author: tobik X-SVN-Commit-Paths: head/Mk/Uses X-SVN-Commit-Revision: 498386 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 7760B80BE8 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.972,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2019 16:46:39 -0000 Author: tobik Date: Mon Apr 8 16:46:37 2019 New Revision: 498386 URL: https://svnweb.freebsd.org/changeset/ports/498386 Log: Mk/Uses/go.mk: Remove support for installing Go libs and sources All ports that depend on it have been removed in r497504. - Restrict build to only main packages by adding -buildmode=exe to GO_BUILDFLAGS - Add initial support for building in module-aware mode PR: 236509 Submitted by: Dmitri Goutnik Reviewed by: 0mp, jlaffaye, tobik Approved by: jlaffaye (maintainer) Differential Revision: https://reviews.freebsd.org/D19570 Modified: head/Mk/Uses/go.mk Modified: head/Mk/Uses/go.mk ============================================================================== --- head/Mk/Uses/go.mk Mon Apr 8 16:46:06 2019 (r498385) +++ head/Mk/Uses/go.mk Mon Apr 8 16:46:37 2019 (r498386) @@ -1,20 +1,29 @@ # $FreeBSD$ # -# This file contains logic to ease porting of Go packages or binaries using -# the `go` command. +# This file contains logic to ease porting of Go binaries using the +# `go` command. # # Feature: go # Usage: USES=go -# Valid ARGS: none +# Valid ARGS: (none), modules # +# (none) Setup GOPATH and build in GOPATH mode. +# modules If the upstream uses Go modules, this can be set to build +# in modules-aware mode. +# # You can set the following variables to control the process. # # GO_PKGNAME -# The name of the package. This is the directory that will be -# created in GOPATH/src and seen by the `go` command +# The name of the package. When building in GOPATH mode, this is +# the directory that will be created in GOPATH/src and seen by the +# `go` command. When building in modules-aware mode, no directories +# will be created and GO_PKGNAME value will be only used as a default +# for GO_TARGET. If not set explicitly and GH_SUBDIR is present, +# GO_PKGNAME will be inferred from GH_SUBDIR. # # GO_TARGET -# The names of the package(s) to build +# The names of the package(s) to build. If not set explicitly, +# defaults to GO_PKGNAME. # # CGO_CFLAGS # Addional CFLAGS variables to be passed to the C compiler by the `go` @@ -32,39 +41,44 @@ .if !defined(_INCLUDE_USES_GO_MK) _INCLUDE_USES_GO_MK= yes -.if ${ARCH} == "i386" -GOARCH= 386 -GOOBJ= 8 -.else -GOARCH= amd64 -GOOBJ= 6 +.if !empty(go_ARGS) && ${go_ARGS:Nmodules} +IGNORE= USES=go only accepts no arguments or 'modules' .endif # Settable variables -GO_PKGNAME?= ${PORTNAME} +.if empty(GO_PKGNAME) +. if !empty(GH_SUBDIR) +GO_PKGNAME= ${GH_SUBDIR:S|^src/||} +. else +GO_PKGNAME= ${PORTNAME} +. endif +.endif GO_TARGET?= ${GO_PKGNAME} -GO_BUILDFLAGS+= -v +GO_BUILDFLAGS+= -v -buildmode=exe CGO_CFLAGS+= -I${LOCALBASE}/include CGO_LDFLAGS+= -L${LOCALBASE}/lib # Read-only variables GO_CMD= ${LOCALBASE}/bin/go -LOCAL_GOPATH= ${LOCALBASE}/share/go -GO_LIBDIR= share/go/pkg/${OPSYS:tl}_${GOARCH} -GO_SRCDIR= share/go/src -GO_WRKSRC= ${GO_WRKDIR_SRC}/${GO_PKGNAME} GO_WRKDIR_BIN= ${WRKDIR}/bin + +GO_ENV+= CGO_CFLAGS="${CGO_CFLAGS}" \ + CGO_LDFLAGS="${CGO_LDFLAGS}" + +.if ${go_ARGS:Mmodules} +GO_BUILDFLAGS+= -mod=vendor +GO_WRKSRC= ${WRKSRC} +GO_ENV+= GOPATH="" \ + GOBIN="${GO_WRKDIR_BIN}" +.else GO_WRKDIR_SRC= ${WRKDIR}/src -GO_WRKDIR_PKG= ${WRKDIR}/pkg/${OPSYS:tl}_${GOARCH} +GO_WRKSRC= ${GO_WRKDIR_SRC}/${GO_PKGNAME} +GO_ENV+= GOPATH="${WRKDIR}" \ + GOBIN="" +.endif BUILD_DEPENDS+= ${GO_CMD}:lang/go -GO_ENV+= GOPATH="${WRKDIR}:${LOCAL_GOPATH}" \ - CGO_CFLAGS="${CGO_CFLAGS}" \ - CGO_LDFLAGS="${CGO_LDFLAGS}" \ - GOBIN="" -PLIST_SUB+= GO_LIBDIR=${GO_LIBDIR} \ - GO_SRCDIR=${GO_SRCDIR} \ - GO_PKGNAME=${GO_PKGNAME} +PLIST_SUB+= GO_PKGNAME=${GO_PKGNAME} _USES_POST+= go .endif # !defined(_INCLUDE_USES_GO_MK) @@ -72,7 +86,7 @@ _USES_POST+= go .if defined(_POSTMKINCLUDED) && !defined(_INCLUDE_USES_GO_POST_MK) _INCLUDE_USES_GO_POST_MK= yes -.if !target(post-extract) +.if !target(post-extract) && empty(go_ARGS) post-extract: @${MKDIR} ${GO_WRKSRC:H} @${LN} -sf ${WRKSRC} ${GO_WRKSRC} @@ -80,24 +94,14 @@ post-extract: .if !target(do-build) do-build: - @(cd ${GO_WRKSRC}; \ + (cd ${GO_WRKSRC}; \ ${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} install ${GO_BUILDFLAGS} ${GO_TARGET}) .endif .if !target(do-install) do-install: .for _TARGET in ${GO_TARGET} - @if [ -e "${GO_WRKDIR_PKG}/${_TARGET}.a" ]; then \ - _TARGET_LIBDIR="${STAGEDIR}/${PREFIX}/${GO_LIBDIR}/${_TARGET:H}"; \ - ${MKDIR} $${_TARGET_LIBDIR}; \ - ${INSTALL_DATA} ${GO_WRKDIR_PKG}/${_TARGET}.a $${_TARGET_LIBDIR}; \ - _TARGET_SRCDIR="${STAGEDIR}/${PREFIX}/${GO_SRCDIR}/${_TARGET}"; \ - ${MKDIR} $${_TARGET_SRCDIR}; \ - (cd ${GO_WRKDIR_SRC}/${_TARGET}/ && ${COPYTREE_SHARE} \* $${_TARGET_SRCDIR}); \ - fi; \ - if [ -e "${GO_WRKDIR_BIN}/${_TARGET:T}" ]; then \ - ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/${_TARGET:T} ${STAGEDIR}/${LOCALBASE}/bin; \ - fi; + ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/${_TARGET:T} ${STAGEDIR}${PREFIX}/bin .endfor .endif