homebrew-core/Formula/libsass.rb
2018-03-12 22:36:46 -07:00

56 lines
2 KiB
Ruby

class Libsass < Formula
desc "C implementation of a Sass compiler"
homepage "https://github.com/sass/libsass"
url "https://github.com/sass/libsass.git",
:tag => "3.5.1",
:revision => "6ee62bdef0bfe35274e3416f63024247e963f030"
head "https://github.com/sass/libsass.git"
bottle do
cellar :any
sha256 "82ea0421e47cb1a6e77fa9724e2a0e9b765b52341b35fc841889a06ba5f0b1d7" => :high_sierra
sha256 "1f70a2bbe1d0be47d10a9f7f5a40c7ac129f3ebd0be4059fd709c4a9f2e6b3a7" => :sierra
sha256 "ead5c0b530dddaae533768cbb01ab6ff035337882f33067dc19dfff4284ad1ac" => :el_capitan
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
needs :cxx11
def install
ENV.cxx11
system "autoreconf", "-fvi"
system "./configure", "--prefix=#{prefix}", "--disable-silent-rules",
"--disable-dependency-tracking"
system "make", "install"
end
test do
# This will need to be updated when devel = stable due to API changes.
(testpath/"test.c").write <<~EOS
#include <sass/context.h>
#include <string.h>
int main()
{
const char* source_string = "a { color:blue; &:hover { color:red; } }";
struct Sass_Data_Context* data_ctx = sass_make_data_context(strdup(source_string));
struct Sass_Options* options = sass_data_context_get_options(data_ctx);
sass_option_set_precision(options, 1);
sass_option_set_source_comments(options, false);
sass_data_context_set_options(data_ctx, options);
sass_compile_data_context(data_ctx);
struct Sass_Context* ctx = sass_data_context_get_context(data_ctx);
int err = sass_context_get_error_status(ctx);
if(err != 0) {
return 1;
} else {
return strcmp(sass_context_get_output_string(ctx), "a {\\n color: blue; }\\n a:hover {\\n color: red; }\\n") != 0;
}
}
EOS
system ENV.cc, "-o", "test", "test.c", "-L#{lib}", "-lsass"
system "./test"
end
end