summaryrefslogtreecommitdiff
path: root/bin/compile
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-04-12 12:26:00 +0000
committerRémy Coutable <remy@rymai.me>2017-04-12 12:26:00 +0000
commit3986309c0aee87ee5091c6b3de1205c3411cb45b (patch)
treec38e0cedd9f4dab4e0b4f6a89c261b0646c3a63a /bin/compile
parent684599daddefd2b6149c5f99a620424f6f26166c (diff)
parent4240f8e0f92bf77963ee030fd882050eb9f8c17d (diff)
downloadgitlab-shell-3986309c0aee87ee5091c6b3de1205c3411cb45b.tar.gz
Merge branch 'go-hello-world' into 'master'
Add hello-world Go executable and gitaly-proto 0.5.0 Closes gitaly#186 See merge request !127
Diffstat (limited to 'bin/compile')
-rwxr-xr-xbin/compile36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/compile b/bin/compile
new file mode 100755
index 0000000..faf3e4c
--- /dev/null
+++ b/bin/compile
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+
+require 'fileutils'
+
+# This will set the ROOT_PATH variable
+require_relative '../lib/gitlab_init'
+
+GO_DIR = 'go'
+BUILD_DIR = File.join(ROOT_PATH, 'go_build')
+GO_PACKAGE = File.join('gitlab.com/gitlab-org/gitlab-shell', GO_DIR)
+
+def main
+ FileUtils.rm_rf(BUILD_DIR)
+ build_source_dir = File.join(BUILD_DIR, 'src', GO_PACKAGE)
+ FileUtils.mkdir_p(build_source_dir)
+ FileUtils.cp_r(File.join(ROOT_PATH, GO_DIR, '.'), build_source_dir)
+ env = {
+ 'GOPATH' => BUILD_DIR,
+ 'GO15VENDOREXPERIMENT' => '1',
+ }
+ run!(env, %W[go install #{GO_PACKAGE}/cmd/...])
+ executables = Dir[File.join(BUILD_DIR, 'bin', '*')]
+ FileUtils.chmod(0755, executables)
+ FileUtils.cp(executables, File.join(ROOT_PATH, 'bin'))
+end
+
+def run!(env, cmd)
+ raise "env must be a hash" unless env.is_a?(Hash)
+ raise "cmd must be an array" unless cmd.is_a?(Array)
+
+ if !system(env, *cmd)
+ abort "command failed: #{env.inspect} #{cmd.join(' ')}"
+ end
+end
+
+main