Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions Formula/d/dart-sass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class DartSass < Formula
desc "Reference implementation of Sass, written in Dart"
homepage "https://sass-lang.com/dart-sass"
url "https://github.com/sass/dart-sass/archive/refs/tags/1.99.0.tar.gz"
sha256 "5f969b2eedf86384d90a9a339824b6652a4600e9e5f32784a7e48e453e145016"
license "MIT"

depends_on "buf" => :build
depends_on "dart-sdk" => :build
depends_on "dartaotruntime"

resource "language" do
url "https://github.com/sass/sass/archive/refs/tags/embedded-protocol-3.2.0.tar.gz"
sha256 "4e1f81684bc1666f03e52ddc790d0c2c22d99a5313fa2efe1dde4a5b5733c186"
end

def install
ENV["PUB_ENVIRONMENT"] = "homebrew:sass"
ENV["DART_SUPPRESS_ANALYTICS"] = "true"

(buildpath/"build/language").install resource("language")

system "dart", "pub", "get"
with_env(UPDATE_SASS_PROTOCOL: "false") do
system "dart", "run", "grinder", "protobuf"
end

args = %W[
-Dversion=#{version}
-Ddart-version=#{Formula["dart-sdk"].version}
-Dcompiler-version=#{version}
-Dprotocol-version=#{resource("language").version}
]
system "dart", "compile", "aot-snapshot", "--output", "sass.aot", *args, "bin/sass.dart"
libexec.install "sass.aot"

(bin/"sass").write <<~BASH
#!/bin/bash
exec "#{Formula["dartaotruntime"].opt_bin}/dartaotruntime" "#{libexec}/sass.aot" "$@"
BASH
end

test do
assert_match version.to_s, shell_output("#{bin}/sass --version")

(testpath/"test.scss").write(".class {property: 1 + 1}")
assert_match "property: 2;", shell_output("#{bin}/sass test.scss 2>&1")

(testpath/"input.scss").write <<~EOS
div {
img {
border: 0px;
}
}
EOS

assert_equal "div img{border:0px}",
shell_output("#{bin}/sass --style compressed input.scss").strip
end
end
14 changes: 14 additions & 0 deletions Formula/d/dart-sdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ def install
system "gclient", "config", "--name", "sdk", "https://dart.googlesource.com/sdk.git@#{version}"
system "gclient", "sync", "--no-history"

# Workaround for error: 'readdir_r' is deprecated
# Issue ref: https://github.com/dart-lang/sdk/issues/63089
inreplace "sdk/build/config/compiler/BUILD.gn",
"\"-Wno-tautological-constant-compare\",",
"\\0\n \"-Wno-deprecated-declarations\","

# Workaround for dependants audit failure: Libraries were compiled with a flat namespace.
# Issue ref: https://github.com/dart-lang/sdk/issues/63115
# PR ref: https://github.com/dart-lang/sdk/pull/63116
inreplace "sdk/runtime/platform/mach_o.h",
"MH_NO_REEXPORTED_DYLIBS = 0x100000;",
"\\0\nstatic constexpr uint32_t MH_TWOLEVEL = 0x80;"
inreplace "sdk/runtime/vm/mach_o.cc", "MH_NO_REEXPORTED_DYLIBS", "\\0 | mach_o::MH_TWOLEVEL"

chdir "sdk" do
arch = Hardware::CPU.arm? ? "arm64" : "x64"
system "./tools/build.py", "--mode=release", "--arch=#{arch}", "create_sdk"
Expand Down
Loading