-
Notifications
You must be signed in to change notification settings - Fork 3
/
smithy-cli.rb
58 lines (53 loc) · 2.24 KB
/
smithy-cli.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
require_relative '../ConfigProvider/config_provider'
class SmithyCli < Formula
$config_provider = ConfigProvider.new('smithy-cli')
desc "Smithy CLI - A CLI for building, validating, querying, and iterating on Smithy models"
homepage "https://smithy.io"
version $config_provider.version
if OS.mac?
if Hardware::CPU.intel?
url "#{$config_provider.root_url}-darwin-x86_64.zip"
sha256 $config_provider.sierra_hash
elsif Hardware::CPU.arm?
url "#{$config_provider.root_url}-darwin-aarch64.zip"
sha256 $config_provider.arm64_big_sur_hash
end
elsif OS.linux?
if Hardware::CPU.intel?
url "#{$config_provider.root_url}-linux-x86_64.zip"
sha256 $config_provider.linux_hash
elsif Hardware::CPU.arm?
url "#{$config_provider.root_url}-linux-aarch64.zip"
sha256 $config_provider.linux_arm_hash
end
end
def install
# install everything in archive into libexec, so that
# the contents are private to homebrew, which means it won't try
# to symlink anything in this directory automatically
libexec.install Dir["*"]
# create a symlink to the private executable
bin.install_symlink "#{libexec}/bin/smithy" => "smithy"
end
def post_install
# brew relocates dylibs and assigns different ids, which is problematic since
# we package a runtime image ourselves
if OS.mac?
Dir["#{libexec}/lib/**/*.dylib"].each do |dylib|
chmod 0664, dylib
MachO::Tools.change_dylib_id(dylib, "@rpath/#{File.basename(dylib)}")
# we also need to resign the dylibs, so that their ad-hoc signatures are not invalid
MachO.codesign!(dylib)
chmod 0444, dylib
end
end
# call warmup command to generate the jsa
system "#{bin}/#{$config_provider.bin}" " warmup"
end
test do
assert_predicate lib/"#{$config_provider.bin}.jsa", :exist?
assert_match $config_provider.version, shell_output("#{bin}/#{$config_provider.bin} --version")
assert_match "Usage: #{$config_provider.bin}", shell_output("#{bin}/#{$config_provider.bin} --help")
end
end