forked from syncthing/syncthing-inotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross-compile-xgo.rb
executable file
·41 lines (35 loc) · 944 Bytes
/
cross-compile-xgo.rb
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
#!/usr/bin/env ruby
targets = "darwin/amd64,
dragonfly/amd64,
freebsd/*,
linux/*,
netbsd/*,
openbsd/*,
windows/*"
targets.gsub!(" ","").gsub!("\n","")
version = `git describe --abbrev=0 --tags`.chomp
diff = `git diff`.chomp
#unless diff.empty?
# puts "Forgot to git reset --hard?"
# exit if gets.chomp != "n"
#end
vars = "GO386=387"
ldflags = "-w -X main.Version=#{version}"
build = "#{vars} xgo -v --targets=#{targets} -ldflags '#{ldflags}' ."
puts "Running #{build}"
#`#{build}`
Dir.glob("syncthing-inotify-*").each do |file|
next unless File.file?(file)
next if file.include?(".tar.gz")
name = "syncthing-inotify"
if file.include?("windows")
name = "syncthing-inotify.exe"
end
move = "cp #{file} #{name}"
package = "tar -czf #{file}-#{version}.tar.gz #{name}"
rm = "rm -f syncthing-inotify"
#rm = "rm -f syncthing-inotify #{name}"
puts "Packaging #{file}"
`#{move} && #{package}
& #{rm}`
end