View | Details | Raw Unified | Return to bug 205282 | Differences between
and this patch

Collapse All | Expand All

(-)Mk2/Uses/go.mk (+101 lines)
Line 0 Link Here
1
# $FreeBSD$
2
#
3
# Provide support for NodeJS based projects
4
#
5
# Feature:	go
6
# Usage:	USES=go
7
#
8
# MAINTAINER: portmgr@FreeBSD.org
9
10
# GO_MAIN_PATH   : where is the main part of the project,
11
#                  main distfile is extracted there and build
12
#                  is performed
13
# GO_EXTRA_PATH  : additional directory to perform the build in
14
# GO_ARGS        : arguments to supply to the go command
15
# GO_TAGS        : tags to use with the go command
16
#
17
# Port's Makefile should supply these items:
18
# * base go packages in GO_BASE in the form: commit-tag:package ...
19
# * (optional) the list of packages from GitHub in GH_TUPLE variable
20
#   account:project:tagname:group:gh (with suffix :gh)
21
# * (optional) the list of go modules in the form
22
#   account:project:tagname:group:version#:pkg (with suffix :pkg)
23
#
24
# Framework installs one executable: ${LOCALBASE}/libexec/${PORTNAME}.
25
# In post-install port is expected to add symbolic links or services
26
# that use this executable.
27
#
28
29
.if !defined(_INCLUDE_USES_GO_MK)
30
_INCLUDE_USES_GO_MK=	yes
31
32
# depends
33
BUILD_DEPENDS+=		go:${PORTSDIR}/lang/go
34
RUN_DEPENDS+=		go:${PORTSDIR}/lang/go
35
36
# commands
37
GO_CMD?=		${LOCALBASE}/bin/go
38
39
GO_MAIN_BUILD_PATH?=    ${GO_MAIN_PATH}
40
41
# internal variables
42
_GO_DIR?=		${PORTNAME}-${PORTVERSION}
43
_GO_DO_FAIL?=		return 1
44
45
# paths and environment
46
WRKSRC=			${WRKDIR}/${_GO_DIR}
47
GOPATH:=		${WRKSRC}
48
GO_ENV+=		GOPATH=${GOPATH}
49
.for opt in ${OPTIONS_FILE_SET}
50
GO_TAGS+=		${${opt}_GO_TAGS}
51
.endfor
52
.if defined(GO_TAGS)
53
GO_ARGS+=		-tags="${GO_TAGS}"
54
.endif
55
56
# distfiles
57
.for _GO_BASE_ONE in ${GO_BASE}
58
#MASTER_SITES+=		https://go.googlesource.com/${_GO_BASE_ONE:C@.*:@@}/+archive/${_GO_BASE_ONE:C@:.*@@}.tar.gz?dummy=/:golang-${_GO_BASE_ONE:C@.*:@@}
59
MASTER_SITES+=		https://codeload.github.com/golang/${_GO_BASE_ONE:C@.*:@@}/tar.gz/${_GO_BASE_ONE:C@:.*@@}?dummy=/:golang-${_GO_BASE_ONE:C@.*:@@}
60
#https://codeload.github.com/coreos/etcd/tar.gz/v2.2.2?dummy=/coreos-etcd-v2.2.2_GH0.tar.gz
61
#DISTFILES+=		golang-${_GO_BASE_ONE:C@.*:@@}-${_GO_BASE_ONE:C@:.*@@}.tgz:golang-${_GO_BASE_ONE:C@.*:@@}
62
DISTFILES+=		golang-${_GO_BASE_ONE:C@.*:@@}-${_GO_BASE_ONE:C@:.*@@}.tar.gz:golang-${_GO_BASE_ONE:C@.*:@@}
63
.endfor
64
65
# targets
66
_GO_GH_TUPLE_GH=	${GH_TUPLE:M*\:*\:*\:*\:gh:C@:gh@@}
67
_GO_GH_TUPLE_PKG=	${GH_TUPLE:M*\:pkg:C@:pkg$@@}
68
69
do-extract:
70
	@${MKDIR} ${WRKDIR}/${_GO_DIR} && \
71
	cd ${WRKDIR}/${_GO_DIR} && \
72
	${MKDIR} src/${GO_MAIN_PATH} && \
73
	${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/${DISTFILES:N*\:*} ${EXTRACT_AFTER_ARGS} \
74
	  -C src/${GO_MAIN_PATH} --strip 1 && \
75
	${ECHO} ${_GO_GH_TUPLE_GH:M*\:*\:*\:*:C@:@ @g} | xargs -n4 \
76
	  ${SH} -c 'acc=$$0;proj=$$1;h=$$2;grp=$$3; df=$$(echo ${DISTFILES} | tr " " "\\n" | grep ":$${grp}$$" | ${SED} -e "s/:.*//g"); \
77
	    '"${MKDIR} src/github.com/"'$$acc'"/"'$$proj'"; \
78
	    ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "'${DISTDIR}/$${df}'" ${EXTRACT_AFTER_ARGS} -C src/github.com/"'$$acc'"/"'$$proj'" --strip 1" && \
79
	${ECHO} ${_GO_GH_TUPLE_PKG:M*\:*\:*\:*:C@:@ @g} | xargs -n5 \
80
	  ${SH} -c 'acc=$$0;proj=$$1;h=$$2;grp=$$3;vers=$$4; df=$$(echo ${DISTFILES} | tr " " "\\n" | grep ":$${grp}$$" | ${SED} -e "s/:.*//g"); \
81
	    '"${MKDIR} src/gopkg.in/"'$${proj}.$${vers}'"; \
82
	    ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "'${DISTDIR}/$${df}'" ${EXTRACT_AFTER_ARGS} -C src/gopkg.in/"'$${proj}.$${vers}'" --strip 1" && \
83
	${ECHO} ${GO_BASE} | ${SED} -e 's/:/ /g' | xargs -n2 \
84
	  ${SH} -c 'pkg=$$1; df=$$(echo ${DISTFILES} | tr " " "\\n" | grep ":golang-$${pkg}$$" | ${SED} -e "s/:.*//g"); \
85
	    '"${MKDIR} src/golang.org/x/"'$$pkg'"; \
86
	    ${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "'${DISTDIR}/$${df}'" ${EXTRACT_AFTER_ARGS} -C src/golang.org/x/"'$${pkg} --strip 1'
87
88
do-build:
89
	@for dir in ${GO_MAIN_BUILD_PATH} ${GO_EXTRA_PATH}; do \
90
	  ${ECHO} "===>  Building in the Go directory $$dir" && \
91
	  (cd ${GOPATH}/src/$$dir && \
92
	   ${GO_ENV} ${GO_CMD} build ${GO_ARGS}) || ${_GO_DO_FAIL}; \
93
	done
94
95
.if !target(do-install)
96
do-install:
97
	${MKDIR} ${STAGEDIR}${LOCALBASE}/libexec/${PORTNAME}
98
	${INSTALL_PROGRAM} ${WRKSRC}/src/${GO_MAIN_PATH}/${PORTNAME} ${STAGEDIR}${LOCALBASE}/libexec/${PORTNAME}/
99
100
.endif
101
.endif

Return to bug 205282