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
|
import os
import shutil
import glob
import llnl.util.tty as tty
from spack import *
class Go(Package):
"""The golang compiler and build environment"""
homepage = "https://golang.org"
url = "https://go.googlesource.com/go"
extendable = True
version('1.5.4', git='https://go.googlesource.com/go', tag='go1.5.4')
version('1.6.2', git='https://go.googlesource.com/go', tag='go1.6.2')
variant('test',
default=True,
description="Run tests as part of build, a good idea but quite"
" time consuming")
provides('golang')
# to-do, make non-c self-hosting compilers feasible without backflips
# should be a dep on external go compiler
depends_on('go-bootstrap')
depends_on('git')
def install(self, spec, prefix):
bash = which('bash')
with working_dir('src'):
if '+test' in spec:
bash('all.bash')
else:
bash('make.bash')
try:
os.makedirs(prefix)
except OSError:
pass
for f in glob.glob('*'):
if os.path.isdir(f):
shutil.copytree(f, os.path.join(prefix, f))
else:
shutil.copy2(f, os.path.join(prefix, f))
def setup_environment(self, spack_env, run_env):
spack_env.set('GOROOT_FINAL', self.spec.prefix)
spack_env.set('GOROOT_BOOTSTRAP', self.spec['go-bootstrap'].prefix)
def setup_dependent_package(self, module, ext_spec):
"""Called before go modules' install() methods.
In most cases, extensions will only need to set GOPATH and use go::
env = os.environ
env['GOPATH'] = self.source_path + ':' + env['GOPATH']
go('get', '<package>', env=env)
shutil.copytree('bin', os.path.join(prefix, '/bin'))
"""
# Add a go command/compiler for extensions
module.go = Executable(join_path(self.spec.prefix.bin, 'go'))
def setup_dependent_environment(self, spack_env, run_env, ext_spec):
if os.environ.get('GOROOT', False):
tty.warn('GOROOT is set, this is not recommended')
path_components = []
# Set GOPATH to include paths of dependencies
for d in ext_spec.traverse():
if d.package.extends(self.spec):
path_components.append(d.prefix)
# This *MUST* be first, this is where new code is installed
spack_env.set('GOPATH', ':'.join(path_components))
# Allow packages to find this when using module or dotkit
run_env.prepend_path('GOPATH', ':'.join(
[ext_spec.prefix] + path_components))
|