rework for gopath and bootstrapping
This commit is contained in:
parent
62dd040a8f
commit
af4af94203
4 changed files with 78 additions and 21 deletions
51
var/spack/repos/builtin/packages/go-bootstrap/package.py
Normal file
51
var/spack/repos/builtin/packages/go-bootstrap/package.py
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import glob
|
||||||
|
from spack import *
|
||||||
|
|
||||||
|
# THIS PACKAGE SHOULD NOT EXIST
|
||||||
|
# it exists to make up for the inability to:
|
||||||
|
# * use an external go compiler
|
||||||
|
# * have go depend on itself
|
||||||
|
# * have a sensible way to find gccgo without a dep on gcc
|
||||||
|
|
||||||
|
class GoBootstrap(Package):
|
||||||
|
"""Old C-bootstrapped go to bootstrap real go"""
|
||||||
|
homepage = "https://golang.org"
|
||||||
|
url = "https://go.googlesource.com/go"
|
||||||
|
|
||||||
|
extendable = True
|
||||||
|
|
||||||
|
# temporary fix until tags are pulled correctly
|
||||||
|
version('1.4.2', git='https://go.googlesource.com/go', tag='go1.4.2')
|
||||||
|
|
||||||
|
variant('test',
|
||||||
|
default=True,
|
||||||
|
description="Run tests as part of build, a good idea but quite"
|
||||||
|
" time consuming")
|
||||||
|
|
||||||
|
provides('golang@:1.4.2')
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
|
import llnl.util.tty as tty
|
||||||
from spack import *
|
from spack import *
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,8 +12,6 @@ class Go(Package):
|
||||||
|
|
||||||
extendable = True
|
extendable = True
|
||||||
|
|
||||||
# temporary fix until tags are pulled correctly
|
|
||||||
version('1.4.2', git='https://go.googlesource.com/go', tag='go1.4.2')
|
|
||||||
version('1.5.4', git='https://go.googlesource.com/go', tag='go1.5.4')
|
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')
|
version('1.6.2', git='https://go.googlesource.com/go', tag='go1.6.2')
|
||||||
|
|
||||||
|
@ -24,8 +23,8 @@ class Go(Package):
|
||||||
provides('golang')
|
provides('golang')
|
||||||
|
|
||||||
# to-do, make non-c self-hosting compilers feasible without backflips
|
# to-do, make non-c self-hosting compilers feasible without backflips
|
||||||
# should be go_compiler, but that creates an infinite loop
|
# should be a dep on external go compiler
|
||||||
depends_on('gcc@5:', when='@1.5:')
|
depends_on('go-bootstrap')
|
||||||
depends_on('git')
|
depends_on('git')
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
|
@ -47,34 +46,37 @@ def install(self, spec, prefix):
|
||||||
shutil.copy2(f, os.path.join(prefix, f))
|
shutil.copy2(f, os.path.join(prefix, f))
|
||||||
|
|
||||||
def setup_environment(self, spack_env, run_env):
|
def setup_environment(self, spack_env, run_env):
|
||||||
# spack_env.set("GOROOT", self.spec.prefix)
|
|
||||||
# run_env.set("GOROOT", self.spec.prefix)
|
|
||||||
spack_env.set('GOROOT_FINAL', self.spec.prefix)
|
spack_env.set('GOROOT_FINAL', self.spec.prefix)
|
||||||
spack_env.set('GOROOT_BOOTSTRAP', self.spec['gcc'].prefix)
|
spack_env.set('GOROOT_BOOTSTRAP', self.spec['go-bootstrap'].prefix)
|
||||||
|
|
||||||
def setup_dependent_package(self, module, ext_spec):
|
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
|
# Add a go command/compiler for extensions
|
||||||
module.go = Executable(join_path(self.spec.prefix.bin, 'go'))
|
module.go = Executable(join_path(self.spec.prefix.bin, 'go'))
|
||||||
|
|
||||||
def setup_dependent_environment(self, spack_env, run_env, ext_spec):
|
def setup_dependent_environment(self, spack_env, run_env, ext_spec):
|
||||||
"""Called before go modules' install() methods.
|
|
||||||
|
|
||||||
In most cases, extensions will only need to have two lines::
|
|
||||||
|
|
||||||
go('get', '<package>')
|
|
||||||
shutil.copytree('bin', os.path.join(prefix, '/bin'))
|
|
||||||
"""
|
|
||||||
|
|
||||||
if os.environ.get('GOROOT', False):
|
if os.environ.get('GOROOT', False):
|
||||||
tty.warn('GOROOT is set, this is not recommended')
|
tty.warn('GOROOT is set, this is not recommended')
|
||||||
|
|
||||||
|
path_components = []
|
||||||
# Set GOPATH to include paths of dependencies
|
# Set GOPATH to include paths of dependencies
|
||||||
for d in extension_spec.traverse():
|
for d in ext_spec.traverse():
|
||||||
if d.package.extends(self.spec):
|
if d.package.extends(self.spec):
|
||||||
spack_env.prepend_path('GOPATH', d.prefix)
|
path_components.append(d.prefix)
|
||||||
|
|
||||||
# This *MUST* be first, this is where new code is installed
|
# This *MUST* be first, this is where new code is installed
|
||||||
spack_env.prepend_path('GOPATH', ext_spec.package.stage.source_path)
|
spack_env.set('GOPATH', ':'.join(path_components))
|
||||||
|
|
||||||
# Allow packages to find this when using module or dotkit
|
# Allow packages to find this when using module or dotkit
|
||||||
run_env.prepend_path('GOPATH', ext_spec.prefix)
|
run_env.prepend_path('GOPATH', ':'.join(
|
||||||
|
[ext_spec.prefix] + path_components))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from spack import *
|
from spack import *
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
class Hub(Package):
|
class Hub(Package):
|
||||||
|
@ -16,7 +17,8 @@ class Hub(Package):
|
||||||
extends("go")
|
extends("go")
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
os.environ['GOPATH'] = os.getcwd()
|
env = os.environ
|
||||||
|
env['GOPATH'] = self.stage.source_path + ':' + env['GOPATH']
|
||||||
bash = which('bash')
|
bash = which('bash')
|
||||||
bash(os.path.join('script', 'build'), '-o', os.path.join(prefix, 'bin',
|
bash(os.path.join('script', 'build'), '-o', os.path.join(prefix, 'bin',
|
||||||
'hub'))
|
'hub'))
|
||||||
|
|
|
@ -15,5 +15,7 @@ class ThePlatinumSearcher(Package):
|
||||||
extends("go")
|
extends("go")
|
||||||
|
|
||||||
def install(self, spec, prefix):
|
def install(self, spec, prefix):
|
||||||
go('install', self.package)
|
env = os.environ
|
||||||
|
env['GOPATH'] = self.stage.source_path + ':' + env['GOPATH']
|
||||||
|
go('install', self.package, env=env)
|
||||||
shutil.copytree('bin', os.path.join(prefix, 'bin'))
|
shutil.copytree('bin', os.path.join(prefix, 'bin'))
|
||||||
|
|
Loading…
Reference in a new issue