Class: Perkins::Build::Script::Go

Inherits:
Perkins::Build::Script show all
Defined in:
lib/perkins/build/script/go.rb

Constant Summary collapse

DEFAULTS =
{
  gobuild_args: '-v',
  go: '1.3.1'
}

Constants inherited from Perkins::Build::Script

STAGES, TEMPLATES_PATH

Instance Attribute Summary

Attributes inherited from Perkins::Build::Script

#data, #options, #repo, #stack

Instance Method Summary collapse

Methods inherited from Perkins::Build::Script

#compile, defaults, #initialize

Methods included from Helpers

#announce?, #before_install, #failure, #sh, #stacking

Methods included from Stages

#call_custom_stage, #run_builtin_stage, #run_stage, #run_stages

Constructor Details

This class inherits a constructor from Perkins::Build::Script

Instance Method Details

#announceObject



27
28
29
30
31
32
# File 'lib/perkins/build/script/go.rb', line 27

def announce
  super
  'gvm version && ' <<
  'go version && ' <<
  'go env'
end

#cache_slugObject



10
11
12
# File 'lib/perkins/build/script/go.rb', line 10

def cache_slug
  super << "--go-" << config[:go].to_s
end

#configureObject



18
19
20
# File 'lib/perkins/build/script/go.rb', line 18

def configure
  puts "configure"
end

#exportObject



22
23
24
25
# File 'lib/perkins/build/script/go.rb', line 22

def export
  super
  "export GO_VERSION=#{go_version}"
end

#installObject



54
55
56
57
58
59
60
# File 'lib/perkins/build/script/go.rb', line 54

def install
  if uses_make?
    'true'
  else
    "go get #{config[:gobuild_args]} ./..."
  end
end

#pre_setupObject



14
15
16
# File 'lib/perkins/build/script/go.rb', line 14

def pre_setup
  puts "configure"
end

#scriptObject



62
63
64
65
66
67
68
# File 'lib/perkins/build/script/go.rb', line 62

def script
  if uses_make?
    'make'
  else
    "go test #{config[:gobuild_args]} ./..."
  end
end

#setupObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/perkins/build/script/go.rb', line 34

def setup
  super
  "gvm get &&" <<
  "gvm update && source #{HOME_DIR}/.gvm/scripts/gvm && " <<
  "gvm install #{go_version} --binary || gvm install #{go_version} && " <<
  "gvm use #{go_version} && "
  # Prepend *our* GOPATH entry so that built binaries and packages are
  # easier to find and our `git clone`'d libraries are found by the
  # `go` commands.
  source_path = repo.url.gsub(/https\:\/\/|\.git/, "")
  source_owner_path = source_path.split('/')[0..1].join("/")
  local_path = self.repo.working_dir + self.repo.download_name
  "export GOPATH=#{HOME_DIR}/gopath:$GOPATH && " <<
  #binding.pry
  "mkdir -p #{HOME_DIR}/gopath/src/#{source_owner_path} && " <<
  "cp -r #{local_path} #{HOME_DIR}/gopath/src/#{source_owner_path} && " <<
  "export BUILD_DIR=#{HOME_DIR}/gopath/src/#{source_path} && " <<
  "cd #{HOME_DIR}/gopath/src/#{source_path}"
end