1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
.\" $OpenBSD: go-module.5,v 1.4 2021/07/25 11:29:42 espie Exp $
.\"
.\" Copyright (c) 2008 Marc Espie
.\"
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: July 25 2021 $
.Dt GO-MODULE 5
.Os
.Sh NAME
.Nm go-module
.Nd lang/go port module
.Sh DESCRIPTION
This manual page documents the behavior of setting
.Li MODULES=lang/go
in the
.Xr ports 7
tree.
.Pp
Adds Go toolchain support.
Requires
.Ev ALL_TARGET
to be set to canonical Go import path of port.
(Module sets it automatically for ports that use
.Ev GH_ACCOUNT
and
.Ev GH_PROJECT
macros.)
.Pp
During execution of
.Cm pre-configure
target module moves source code from
.Pa ${MODGO_SUBDIR}
to
.Pa ${WRKSRC} ,
subdirectory of
.Pa ${MODGO_WORKSPACE}
- specially-crafted Go workspace located at
.Pa ${WRKDIR}/go .
During
.Cm do-build
module calls
.Dq go install
with
.Ev GOPATH
set to
.Pa ${MODGO_WORKSPACE} ,
runs its output through sed to prevent writes outside
.Ev WRKDIR
sandbox and sends output to
.Xr sh 1 .
During
.Cm do-install
it copies executables from
.Pa ${MODGO_WORKSPACE}/bin
to
.Pa ${PREFIX}/bin ,
and/or directories
.Pa ${MODGO_WORKSPACE}/pkg
and
.Pa ${MODGO_WORKSPACE}/src
to
.Pa ${PREFIX}/go ,
depending on
.Ev MODGO_TYPE
contents.
.Pp
Sets
.Ev BUILD_DEPENDS ,
.Ev RUN_DEPENDS ,
.Ev ALL_TARGET ,
.Ev TEST_TARGET ,
.Ev ONLY_FOR_ARCHS ,
.Ev SEPARATE_BUILD ,
and
.Ev WRKSRC .
.Pp
Appends to
.Ev CATEGORIES .
.Pp
Defines:
.Bl -tag -width MODGO_WORKSPACE
.It Ev MODGO_TYPE
Type of port.
May be any combination of:
.Bl -tag -width lib
.It bin
ordinary binary, which should be installed to
.Pa ${PREFIX}/bin ,
.It lib
library, which should come with source code.
.El
.Pp
Defaults to
.Ar bin .
.It Ev MODGO_WORKSPACE
Path to Go workspace set up for port build process.
Defaults to
.Pa ${WRKDIR}/go .
See Go documentation for details.
.It Ev MODGO_SUBDIR
Path to Go source code within port's sources tarball.
Defaults to
.Pa ${WRKDIST} .
.It Ev MODGO_SETUP_WORKSPACE
Commands setting up Go workspace for building ports.
By default, happens during execution of
.Cm pre-configure
target.
.It Ev MODGO_BUILDDEP
Controls whether contents of
.Ev MODGO_BUILD_DEPENDS
are appended to port's
.Ev BUILD_DEPENDS .
Defaults to
.Ar Yes .
.It Ev MODGO_MODNAME
Name of Go module as defined in the
.Pa go.mod
file contained in a project.
If this is set,
.Ev MODGO_MODULES ,
.Ev MODGO_MODFILES
and
.Ev MODGO_VERSION
need to be defined as well.
Setting this will also set
.Ev ALL_TARGET .
When
.Ev MODGO_MODFILES
is set, and a "cmd" directory is found in
.Ev WRKSRC ,
"./cmd/..." is also built by
.Cm do-build
automatically.
.It Ev MODGO_VERSION
Sets the specific version of a Go module to use.
For example: v0.1.3.
.It Ev MODGO_MODULES
List of modules and their specific versions that an application depends on.
.It Ev MODGO_MODFILES
List of go.mod files and their versions that are required for dependency
resolution.
These are required by Go to determine the full dependency graph.
.El
.Pp
Additionally defines
.Ev MODGO_PACKAGES ,
.Ev MODGO_SOURCES
and
.Ev MODGO_TOOLS
(paths for installed Go packages, sources and tools respectively),
.Ev MODGO_CMD
and
.Ev MODGO_FLAGS
(source code build command and flags passed as its arguments),
.Ev MODGO_LDFLAGS ,
.Ev MODGO_BUILD_CMD
and
.Ev MODGO_TEST_CMD
(commands for building and testing go packages; normally called with canonical
Go package names as arguments),
.Ev MODGO_{BUILD,INSTALL,TEST}_TARGET
and
.Ev MODGO_{BUILD,RUN}_DEPENDS .
.Pp
This module adds one
.Xr make 1
target:
.Bl -tag -width modgo-gen-modules
.It Cm modgo-gen-modules
Generate the
.Ev MODGO_MODULES
and the
.Ev MODGO_MODFILES
lists.
If
.Ev MODGO_VERSION
is set to "latest", the latest known-to-Go version of a package will be used
to build the list of modules.
Similarly, if
.Ev MODGO_VERSION
is empty, the latest version will be fetched.
.El
.Sh SEE ALSO
.Xr port-modules 5
|