From owner-svn-ports-all@freebsd.org Sat Sep 14 08:20:39 2019 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0CF1EECFA3; Sat, 14 Sep 2019 08:20:39 +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 46VlnL6c3Fz3C0J; Sat, 14 Sep 2019 08:20: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 C740C1CF44; Sat, 14 Sep 2019 08:20: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 x8E8KceN052120; Sat, 14 Sep 2019 08:20:38 GMT (envelope-from tobik@FreeBSD.org) Received: (from tobik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8E8KcIT052119; Sat, 14 Sep 2019 08:20:38 GMT (envelope-from tobik@FreeBSD.org) Message-Id: <201909140820.x8E8KcIT052119@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tobik set sender to tobik@FreeBSD.org using -f From: Tobias Kortkamp Date: Sat, 14 Sep 2019 08:20:38 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r512001 - head/Mk/Uses X-SVN-Group: ports-head X-SVN-Commit-Author: tobik X-SVN-Commit-Paths: head/Mk/Uses X-SVN-Commit-Revision: 512001 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2019 08:20:39 -0000 Author: tobik Date: Sat Sep 14 08:20:38 2019 New Revision: 512001 URL: https://svnweb.freebsd.org/changeset/ports/512001 Log: Mk/Uses/go.mk: Allow naming output executable in GO_TARGET - Allow GO_TARGET to be specified as a tuple in the form package:output - Rework build/install targets PR: 240535 Submitted by: Dmitri Goutnik Exp-run by: antoine Differential Revision: https://reviews.freebsd.org/D21562 Modified: head/Mk/Uses/go.mk Modified: head/Mk/Uses/go.mk ============================================================================== --- head/Mk/Uses/go.mk Sat Sep 14 07:29:45 2019 (r512000) +++ head/Mk/Uses/go.mk Sat Sep 14 08:20:38 2019 (r512001) @@ -20,23 +20,27 @@ # You can set the following variables to control the process. # # GO_PKGNAME -# 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. +# 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. If not set explicitly and GH_SUBDIR or +# GL_SUBDIR is present, GO_PKGNAME will be inferred from it. +# It is not needed when building in modules-aware mode. # # GO_TARGET -# The names of the package(s) to build. If not set explicitly, -# defaults to GO_PKGNAME. +# The packages to build. If not set explicitly, defaults to +# GO_PKGNAME. GO_TARGET can also be a tuple in the form +# package:path where path can be either a simple filename or a +# full path starting with ${PREFIX}. Specifying a full path +# like ${PREFIX}/sbin/binary will install the resulting binary +# as ${PREFIX}/sbin/binary. Using just simple filename is a +# shortcut to installing it as ${PREFIX}/bin/filename. # # CGO_CFLAGS -# Addional CFLAGS variables to be passed to the C compiler by the `go` +# Additional CFLAGS variables to be passed to the C compiler by the `go` # command # # CGO_LDFLAGS -# Addional LDFLAGS variables to be passed to the C compiler by the `go` +# Additional LDFLAGS variables to be passed to the C compiler by the `go` # command # # GO_BUILDFLAGS @@ -61,6 +65,8 @@ IGNORE= USES=go has invalid arguments: ${go_ARGS:Nmodu .if empty(GO_PKGNAME) . if !empty(GH_SUBDIR) GO_PKGNAME= ${GH_SUBDIR:S|^src/||} +. elif !empty(GL_SUBDIR) +GO_PKGNAME= ${GL_SUBDIR:S|^src/||} . else GO_PKGNAME= ${PORTNAME} . endif @@ -116,14 +122,31 @@ post-extract: .if !target(do-build) && empty(go_ARGS:Mno_targets) do-build: (cd ${GO_WRKSRC}; \ - ${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} install ${GO_BUILDFLAGS} ${GO_TARGET:S/^${PORTNAME}$/./}) + for t in ${GO_TARGET}; do \ + out=$$(${BASENAME} $$(${ECHO_CMD} $${t} | \ + ${SED} -Ee 's/^[^:]*:([^:]+).*$$/\1/' -e 's/^\.$$/${PORTNAME}/')); \ + pkg=$$(${ECHO_CMD} $${t} | \ + ${SED} -Ee 's/^([^:]*).*$$/\1/' -e 's/^${PORTNAME}$$/./'); \ + ${ECHO_MSG} "===> Building $${out} from $${pkg}"; \ + ${SETENV} ${MAKE_ENV} ${GO_ENV} ${GO_CMD} build ${GO_BUILDFLAGS} \ + -o ${GO_WRKDIR_BIN}/$${out} \ + $${pkg}; \ + done) .endif .if !target(do-install) && empty(go_ARGS:Mno_targets) do-install: -.for _TARGET in ${GO_TARGET} - ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/${_TARGET:T:S/^.$/${PORTNAME}/} ${STAGEDIR}${PREFIX}/bin -.endfor + for t in ${GO_TARGET}; do \ + dst=$$(${ECHO_CMD} $${t} | \ + ${SED} -Ee 's/^[^:]*:([^:]+).*$$/\1/' -e 's/^\.$$/${PORTNAME}/'); \ + src=$$(${BASENAME} $${dst}); \ + case $${dst} in \ + /*) dst=${STAGEDIR}$${dst}; ${MKDIR} $$(${DIRNAME} $${dst}) ;; \ + *) dst=${STAGEDIR}${PREFIX}/bin/$${src} ;; \ + esac; \ + ${ECHO_MSG} "===> Installing $${src} as $${dst}"; \ + ${INSTALL_PROGRAM} ${GO_WRKDIR_BIN}/$${src} $${dst}; \ + done .endif # Helper targets for port maintainers