summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Scogland <scogland1@llnl.gov>2016-05-17 05:21:11 -0700
committerTom Scogland <scogland1@llnl.gov>2016-05-17 05:21:11 -0700
commitaf4af94203d0dc7cebd110c2bd43707e527c63cb (patch)
treee2f9698f997e0e23009e5fad09a2ec98b4468fb0
parent62dd040a8fd7f6f8993640156049eeb061efe955 (diff)
downloadspack-af4af94203d0dc7cebd110c2bd43707e527c63cb.tar.gz
spack-af4af94203d0dc7cebd110c2bd43707e527c63cb.tar.bz2
spack-af4af94203d0dc7cebd110c2bd43707e527c63cb.tar.xz
spack-af4af94203d0dc7cebd110c2bd43707e527c63cb.zip
rework for gopath and bootstrapping
-rw-r--r--var/spack/repos/builtin/packages/go-bootstrap/package.py51
-rw-r--r--var/spack/repos/builtin/packages/go/package.py36
-rw-r--r--var/spack/repos/builtin/packages/hub/package.py4
-rw-r--r--var/spack/repos/builtin/packages/the_platinum_searcher/package.py4
4 files changed, 76 insertions, 19 deletions
diff --git a/var/spack/repos/builtin/packages/go-bootstrap/package.py b/var/spack/repos/builtin/packages/go-bootstrap/package.py
new file mode 100644
index 0000000000..fd0b5bc5d1
--- /dev/null
+++ b/var/spack/repos/builtin/packages/go-bootstrap/package.py
@@ -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)
+
diff --git a/var/spack/repos/builtin/packages/go/package.py b/var/spack/repos/builtin/packages/go/package.py
index f1057e6bed..28e0d1ba7f 100644
--- a/var/spack/repos/builtin/packages/go/package.py
+++ b/var/spack/repos/builtin/packages/go/package.py
@@ -1,6 +1,7 @@
import os
import shutil
import glob
+import llnl.util.tty as tty
from spack import *
@@ -11,8 +12,6 @@ class Go(Package):
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.6.2', git='https://go.googlesource.com/go', tag='go1.6.2')
@@ -24,8 +23,8 @@ class Go(Package):
provides('golang')
# to-do, make non-c self-hosting compilers feasible without backflips
- # should be go_compiler, but that creates an infinite loop
- depends_on('gcc@5:', when='@1.5:')
+ # should be a dep on external go compiler
+ depends_on('go-bootstrap')
depends_on('git')
def install(self, spec, prefix):
@@ -47,34 +46,37 @@ class Go(Package):
shutil.copy2(f, os.path.join(prefix, f))
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_BOOTSTRAP', self.spec['gcc'].prefix)
+ spack_env.set('GOROOT_BOOTSTRAP', self.spec['go-bootstrap'].prefix)
def setup_dependent_package(self, module, ext_spec):
- # 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):
"""Called before go modules' install() methods.
- In most cases, extensions will only need to have two lines::
+ In most cases, extensions will only need to set GOPATH and use go::
- go('get', '<package>')
+ 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 extension_spec.traverse():
+ for d in ext_spec.traverse():
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
- 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
- run_env.prepend_path('GOPATH', ext_spec.prefix)
+ run_env.prepend_path('GOPATH', ':'.join(
+ [ext_spec.prefix] + path_components))
+
+
diff --git a/var/spack/repos/builtin/packages/hub/package.py b/var/spack/repos/builtin/packages/hub/package.py
index 5f3926533a..ed8b742e42 100644
--- a/var/spack/repos/builtin/packages/hub/package.py
+++ b/var/spack/repos/builtin/packages/hub/package.py
@@ -1,4 +1,5 @@
from spack import *
+import os
class Hub(Package):
@@ -16,7 +17,8 @@ class Hub(Package):
extends("go")
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(os.path.join('script', 'build'), '-o', os.path.join(prefix, 'bin',
'hub'))
diff --git a/var/spack/repos/builtin/packages/the_platinum_searcher/package.py b/var/spack/repos/builtin/packages/the_platinum_searcher/package.py
index da21a0f656..9c9a66cdef 100644
--- a/var/spack/repos/builtin/packages/the_platinum_searcher/package.py
+++ b/var/spack/repos/builtin/packages/the_platinum_searcher/package.py
@@ -15,5 +15,7 @@ class ThePlatinumSearcher(Package):
extends("go")
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'))