-
Notifications
You must be signed in to change notification settings - Fork 6
61 lines (51 loc) · 2.21 KB
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
class FvmAT200Dev3 < Formula
desc "Simple cli to manage Flutter SDK versions per project"
homepage "https://github.com/leoafarias/fvm"
url "https://github.com/leoafarias/fvm/archive/2.0.0-dev.3.tar.gz"
sha256 "b84acf7ac01dbed49a82edab3bdaad73a139ef363668bb14b2bd2c89ba34162f"
license "MIT"
depends_on "dart-lang/dart/dart" => :build
def install
dart = Formula["dart-lang/dart/dart"].opt_bin
pubspec = YAML.safe_load(File.read("pubspec.yaml"))
version = pubspec["version"]
# Tell the pub server where these installations are coming from.
ENV["PUB_ENVIRONMENT"] = "homebrew:fvm"
system dart/"pub", "get"
if Hardware::CPU.is_64_bit?
# Build a native-code executable on 64-bit systems only. 32-bit Dart
# doesn't support this.
system dart/"dart2native", "-Dversion=#{version}", "bin/main.dart",
"-o", "fvm"
bin.install "fvm"
else
system dart/"dart",
"-Dversion=#{version}",
"--snapshot=main.dart.app.snapshot",
"--snapshot-kind=app-jit",
"bin/main.dart", "version"
lib.install "main.dart.app.snapshot"
# Copy the version of the Dart VM we used into our lib directory so that if
# the user upgrades their Dart VM version it doesn't break Sass's snapshot,
# which was compiled with an older version.
cp dart/"dart", lib
(bin/"fvm").write <<~SH
#!/bin/sh
exec "#{lib}/dart" "#{lib}/main.dart.app.snapshot" "$@"
SH
end
chmod 0555, "#{bin}/fvm"
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! For Homebrew/homebrew-core
# this will need to be a test that verifies the functionality of the
# software. Run the test with `brew test fvm`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "false"
end
end