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 |
# GO_ARGS : arguments to supply to the go command |
12 |
# GO_TAGS : tags to use with the go command |
13 |
# |
14 |
# Port's Makefile should supply these items: |
15 |
# * base go packages in GO_BASE in the form: commit-tag:package ... |
16 |
# * (optional) the list of packages from GitHub in GH_TUPLE variable |
17 |
# account:project:tagname:group:gh (with suffix :gh) |
18 |
# * (optional) the list of go modules in the form |
19 |
# account:project:tagname:group:version#:pkg (with suffix :pkg) |
20 |
# |
21 |
# Framework installs one execuatble: ${LOCALBASE}/libexec/${PORTNAME}. |
22 |
# In post-install port is expected to add symbolic links or services |
23 |
# that use this executable. |
24 |
# |
25 |
|
26 |
.if !defined(_INCLUDE_USES_GO_MK) |
27 |
_INCLUDE_USES_GO_MK= yes |
28 |
|
29 |
# depends |
30 |
BUILD_DEPENDS+= go:${PORTSDIR}/lang/go |
31 |
RUN_DEPENDS+= go:${PORTSDIR}/lang/go |
32 |
|
33 |
# commands |
34 |
GO_CMD?= ${LOCALBASE}/bin/go |
35 |
|
36 |
# internal variables |
37 |
_GO_DIR?= ${PORTNAME}-${PORTVERSION} |
38 |
_GO_DO_FAIL= return 1 |
39 |
|
40 |
# paths and environment |
41 |
WRKSRC= ${WRKDIR}/${_GO_DIR} |
42 |
GOPATH:= ${WRKSRC} |
43 |
GO_ENV+= GOPATH=${GOPATH} |
44 |
.for opt in ${OPTIONS_FILE_SET} |
45 |
GO_TAGS+= ${${opt}_GO_TAGS} |
46 |
.endfor |
47 |
.if defined(GO_TAGS) |
48 |
GO_ARGS+= -tags="${GO_TAGS}" |
49 |
.endif |
50 |
|
51 |
# distfiles |
52 |
.for _GO_BASE_ONE in ${GO_BASE} |
53 |
MASTER_SITES+= https://go.googlesource.com/${_GO_BASE_ONE:C@.*:@@}/+archive/${_GO_BASE_ONE:C@:.*@@}.tar.gz?dummy=/:golang-${_GO_BASE_ONE:C@.*:@@} |
54 |
DISTFILES+= golang-${_GO_BASE_ONE:C@.*:@@}-${_GO_BASE_ONE:C@:.*@@}.tgz:golang-${_GO_BASE_ONE:C@.*:@@} |
55 |
.endfor |
56 |
|
57 |
# targets |
58 |
_GO_GH_TUPLE_GH= ${GH_TUPLE:M*\:*\:*\:*\:gh:C@:gh@@} |
59 |
_GO_GH_TUPLE_PKG= ${GH_TUPLE:M*\:pkg:C@:pkg$@@} |
60 |
|
61 |
do-extract: |
62 |
@${MKDIR} ${WRKDIR}/${_GO_DIR} && \ |
63 |
cd ${WRKDIR}/${_GO_DIR} && \ |
64 |
${MKDIR} src/${GO_MAIN_PATH} && \ |
65 |
${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} ${DISTDIR}/${DISTFILES:N*\:*} ${EXTRACT_AFTER_ARGS} \ |
66 |
-C src/${GO_MAIN_PATH} --strip 1 && \ |
67 |
${ECHO} ${_GO_GH_TUPLE_GH:M*\:*\:*\:*:C@:@ @g} | xargs -n4 \ |
68 |
${SH} -c 'acc=$$0;proj=$$1;h=$$2;grp=$$3; df=$$(echo ${DISTFILES} | tr " " "\\n" | grep ":$${grp}$$" | ${SED} -e "s/:.*//g"); \ |
69 |
'"${MKDIR} src/github.com/"'$$acc'"/"'$$proj'"; \ |
70 |
${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "'${DISTDIR}/$${df}'" ${EXTRACT_AFTER_ARGS} -C src/github.com/"'$$acc'"/"'$$proj'" --strip 1" && \ |
71 |
${ECHO} ${_GO_GH_TUPLE_PKG:M*\:*\:*\:*:C@:@ @g} | xargs -n5 \ |
72 |
${SH} -c 'acc=$$0;proj=$$1;h=$$2;grp=$$3;vers=$$4; df=$$(echo ${DISTFILES} | tr " " "\\n" | grep ":$${grp}$$" | ${SED} -e "s/:.*//g"); \ |
73 |
'"${MKDIR} src/gopkg.in/"'$${proj}.$${vers}'"; \ |
74 |
${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "'${DISTDIR}/$${df}'" ${EXTRACT_AFTER_ARGS} -C src/gopkg.in/"'$${proj}.$${vers}'" --strip 1" && \ |
75 |
${ECHO} ${GO_BASE} | ${SED} -e 's/:/ /g' | xargs -n2 \ |
76 |
${SH} -c 'pkg=$$1; df=$$(echo ${DISTFILES} | tr " " "\\n" | grep ":golang-$${pkg}$$" | ${SED} -e "s/:.*//g"); \ |
77 |
'"${MKDIR} src/golang.org/x/"'$$pkg'"; \ |
78 |
${EXTRACT_CMD} ${EXTRACT_BEFORE_ARGS} "'${DISTDIR}/$${df}'" ${EXTRACT_AFTER_ARGS} -C src/golang.org/x/"'$${pkg}' |
79 |
|
80 |
do-build: |
81 |
@cd ${GOPATH}/src/${GO_MAIN_PATH} && \ |
82 |
${GO_ENV} ${GO_CMD} build ${GO_ARGS} |
83 |
|
84 |
do-install: |
85 |
${MKDIR} ${STAGEDIR}${LOCALBASE}/libexec/${PORTNAME} |
86 |
${INSTALL_PROGRAM} ${WRKSRC}/src/${GO_MAIN_PATH}/${PORTNAME} ${STAGEDIR}${LOCALBASE}/libexec/${PORTNAME}/ |
87 |
|
88 |
.endif |