-
Notifications
You must be signed in to change notification settings - Fork 82
/
build_gem_with_dependencies.rake
61 lines (49 loc) · 2 KB
/
build_gem_with_dependencies.rake
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# frozen_string_literal: true
require_relative "../support/downloader/overmind_downloader"
require_relative "../support/downloader/tmux_downloader"
GEM_PLATFORMS = {
"linux-arm" => "arm-linux",
"linux-arm64" => "arm64-linux",
"linux-386" => "x86-linux",
"linux-amd64" => "x86_64-linux",
"macos-amd64" => "x86_64-darwin",
"macos-arm64" => "arm64-darwin",
"freebsd-386" => "x86-freebsd",
"freebsd-amd64" => "x86_64-freebsd",
"freebsd-arm" => "arm-freebsd"
}.freeze
namespace :overmind do
namespace :build do
desc "Download `Overmind` and `tmux` binaries, and prepare gem"
task :all do
GEM_PLATFORMS.each do |file_platform, gem_platform|
os, arch = file_platform.split("-")
Overmind::Downloader::OvermindDownloader.new(os: os, arch: arch).call
Overmind::Downloader::TmuxDownloader.new(os: os, arch: arch).call
system("gem build overmind.gemspec --platform #{gem_platform}")
end
end
desc "Prepare gem for Linux with optional ARCH (e.g., rake overmind:build:linux[arm64])"
task :linux, [:arch] do |_t, args|
build_for_os("linux", args[:arch])
end
desc "Prepare gem for macOS with optional ARCH (e.g., rake overmind:build:macos[amd64])"
task :macos, [:arch] do |_t, args|
build_for_os("macos", args[:arch])
end
desc "Prepare gem for FreeBSD with optional ARCH (e.g., rake overmind:build:freebsd[amd64])"
task :freebsd, [:arch] do |_t, args|
build_for_os("freebsd", args[:arch])
end
def build_for_os(os, arch = nil)
platforms = GEM_PLATFORMS.select { |k, _| k.start_with?(os) }
platforms = platforms.select { |k, _| k.end_with?(arch) } if arch
platforms.each do |file_platform, gem_platform|
os, arch = file_platform.split("-")
Overmind::Downloader::OvermindDownloader.new(os: os, arch: arch).call
Overmind::Downloader::TmuxDownloader.new(os: os, arch: arch).call
system("gem build overmind.gemspec --platform #{gem_platform}")
end
end
end
end