duktape: use github releases & install duk binary
Closes #57098. Signed-off-by: chenrui <chenrui333@gmail.com>master
parent
99b7d72201
commit
4cc375d017
|
@ -1,8 +1,9 @@
|
|||
class Duktape < Formula
|
||||
desc "Embeddable Javascript engine with compact footprint"
|
||||
homepage "https://duktape.org"
|
||||
url "https://duktape.org/duktape-2.5.0.tar.xz"
|
||||
url "https://github.com/svaarala/duktape/releases/download/v2.5.0/duktape-2.5.0.tar.xz"
|
||||
sha256 "83d411560a1cd36ea132bd81d8d9885efe9285c6bc6685c4b71e69a0c4329616"
|
||||
revision 1
|
||||
|
||||
bottle do
|
||||
cellar :any
|
||||
|
@ -12,27 +13,29 @@ class Duktape < Formula
|
|||
end
|
||||
|
||||
def install
|
||||
inreplace "Makefile.sharedlibrary" do |s|
|
||||
s.gsub! %r{/usr/local}, prefix
|
||||
end
|
||||
system "make", "-f", "Makefile.sharedlibrary"
|
||||
inreplace "Makefile.sharedlibrary", /INSTALL_PREFIX\s*=.*$/, "INSTALL_PREFIX = #{prefix}"
|
||||
system "make", "-f", "Makefile.sharedlibrary", "install"
|
||||
system "make", "-f", "Makefile.cmdline"
|
||||
bin.install "duk"
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.js").write "console.log('Hello Homebrew!');"
|
||||
assert_equal "Hello Homebrew!", shell_output("#{bin}/duk test.js").strip
|
||||
|
||||
(testpath/"test.cc").write <<~EOS
|
||||
#include <stdio.h>
|
||||
#include \"duktape.h\"
|
||||
#include "duktape.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
duk_context *ctx = duk_create_heap_default();
|
||||
duk_eval_string(ctx, \"1+2\");
|
||||
printf(\"1+2=%d\\n\", (int) duk_get_int(ctx, -1));
|
||||
duk_eval_string(ctx, "1 + 2");
|
||||
printf("1 + 2 = %d\\n", (int) duk_get_int(ctx, -1));
|
||||
duk_destroy_heap(ctx);
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
system ENV.cc, "-I#{include}", "-L#{lib}", "-lduktape",
|
||||
testpath/"test.cc", "-o", testpath/"test"
|
||||
assert_equal "1+2=3", shell_output(testpath/"test").strip, "Duktape can add number"
|
||||
system ENV.cc, "test.cc", "-o", "test", "-I#{include}", "-L#{lib}", "-lduktape"
|
||||
assert_equal "1 + 2 = 3", shell_output("./test").strip, "Duktape can add number"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue