Skip to content
Closed
Changes from all 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
25 changes: 12 additions & 13 deletions Formula/l/llgo.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
class Llgo < Formula
desc "Go compiler based on LLVM integrate with the C ecosystem and Python"
homepage "https://github.com/goplus/llgo"
url "https://github.com/goplus/llgo/archive/refs/tags/v0.11.5.tar.gz"
sha256 "e025993d12c1f5e49e5b8dcb31c0e8b349efe56970d1a23d6c089ebd10928c6b"
homepage "https://github.com/luoliwoshang/llgo"
url "https://github.com/luoliwoshang/llgo/archive/refs/tags/v0.12.11.tar.gz"
sha256 "ee3817eaadd5feb1dd253da2a297239d3575a7825cae6d6cc06905a4693026ce"
license "Apache-2.0"
head "https://github.com/goplus/llgo.git", branch: "main"
head "https://github.com/luoliwoshang/llgo.git", branch: "main"

livecheck do
url :stable
Expand All @@ -31,10 +31,6 @@ class Llgo < Formula
depends_on "pkgconf"
uses_from_macos "zlib"

on_linux do
depends_on "libunwind"
end

def find_dep(name)
deps.find { |f| f.name.match?(/^#{name}(@\d+(\.\d+)*)?$/) }
.to_formula
Expand Down Expand Up @@ -69,9 +65,8 @@ def install
script_env = { PATH: "#{path_deps.join(":")}:$PATH" }

if OS.linux?
libunwind = find_dep("libunwind")
script_env[:CFLAGS] = "-I#{libunwind.opt_include} $CFLAGS"
script_env[:LDFLAGS] = "-L#{libunwind.opt_lib} -rpath #{libunwind.opt_lib} $LDFLAGS"
script_env[:CFLAGS] = "-I#{llvm.opt_include} $CFLAGS"
script_env[:LDFLAGS] = "-L#{llvm.opt_lib} -rpath #{llvm.opt_lib} $LDFLAGS"
end

(libexec/"bin").children.each do |f|
Expand Down Expand Up @@ -100,6 +95,7 @@ def install
"fmt"

"github.com/goplus/lib/c"
"github.com/goplus/lib/cpp/std"
)

func Foo() string {
Expand All @@ -109,6 +105,7 @@ def install
func main() {
fmt.Println("Hello LLGo by fmt.Println")
c.Printf(c.Str("Hello LLGo by c.Printf\\n"))
c.Printf(std.Str("Hello LLGo by cpp/std.Str\\n").CStr())
}
GO
(testpath/"hello_test.go").write <<~GO
Expand All @@ -130,12 +127,14 @@ module hello
system go.opt_bin/"go", "get", "github.com/goplus/lib"
# Test llgo run
assert_equal "Hello LLGo by fmt.Println\n" \
"Hello LLGo by c.Printf\n",
"Hello LLGo by c.Printf\n" \
"Hello LLGo by cpp/std.Str\n",
shell_output("#{bin}/llgo run .")
# Test llgo build
system bin/"llgo", "build", "-o", "hello", "."
assert_equal "Hello LLGo by fmt.Println\n" \
"Hello LLGo by c.Printf\n",
"Hello LLGo by c.Printf\n" \
"Hello LLGo by cpp/std.Str\n",
shell_output("./hello")
# Test llgo test
assert_match "PASS", shell_output("#{bin}/llgo test .")
Expand Down
Loading