Skip to content

Commit

Permalink
Trying to implement nodejs from binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Aug 22, 2024
1 parent 0b178d0 commit 37e3d5c
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions metacall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,27 @@ class Metacall < Formula
head "https://github.com/metacall/core.git", branch: "develop"

depends_on "cmake" => :build
depends_on "node@20"
# TODO: Enable NodeJS
# depends_on "node@20"
depends_on "[email protected]"
depends_on "[email protected]"
depends_on "openjdk"
# TODO: Enable Java
# depends_on "openjdk"

# Define NodeJS resource
if OS.mac? && Hardware::CPU.intel?
resource "node" do
url "https://github.com/metacall/libnode/releases/download/v22.6.0/libnode-amd64-macos.tar.xz"
sha256 "aa62ed6bb5b85c57fc58850540c66953302982bda46300056705035400d65967"
end
end

if OS.mac? && Hardware::CPU.arm?
resource "node" do
url "https://github.com/metacall/libnode/releases/download/v22.6.0/libnode-arm64-macos.tar.xz"
sha256 "26c661e9a8e553614e719644f05bb46ffa397e85b658aa9853257f65f8ea9270"
end
end

def python
deps.map(&:to_formula)
Expand All @@ -25,6 +42,8 @@ def python_executable
def install
Dir.mkdir("build")
Dir.chdir("build")

# Set Python
py3ver = Language::Python.major_minor_version python_executable
py3prefix = if OS.mac?
python.opt_frameworks/"Python.framework/Versions"/py3ver
Expand All @@ -35,6 +54,21 @@ def install
py3rootdir = py3prefix
py3lib = py3prefix/"lib/libpython#{py3ver}.dylib"

# Set NodeJS
resource("node").stage do
(buildpath/"build").install resource("node")
end

system "echo", "TEST ------------------------------"
system "echo", "TEST ------------------------------"
system "pwd"
system "ls -la"
system "ls -la build"
system "echo", "TEST ------------------------------"
system "echo", "TEST ------------------------------"


# Set the compiler
cc_compiler = `xcrun --find clang`.tr("\n","")
cxx_compiler = `xcrun --find clang++`.tr("\n","")
xcode_prefix = `xcode-select -p`.tr("\n","")
Expand All @@ -53,9 +87,11 @@ def install
-DOPTION_BUILD_TESTS=OFF
-DOPTION_BUILD_EXAMPLES=OFF
-DOPTION_BUILD_LOADERS_PY=ON
# TODO: Enable NodeJS
-DOPTION_BUILD_LOADERS_NODE=ON
-DNodeJS_INSTALL_PREFIX=/usr/local/Cellar/metacall/#{version}
-DOPTION_BUILD_LOADERS_JAVA=OFF
# -DNodeJS_INSTALL_PREFIX=/usr/local/Cellar/metacall/#{version}
# TODO: Enable Java
# -DOPTION_BUILD_LOADERS_JAVA=ON
-DOPTION_BUILD_LOADERS_JS=OFF
-DOPTION_BUILD_LOADERS_C=OFF
-DOPTION_BUILD_LOADERS_COB=OFF
Expand Down Expand Up @@ -155,7 +191,7 @@ def install
assert_match "Hello from NodeJS", shell_output("#{bin}/metacall test.js")
assert_match "54321", shell_output(testpath/"test_typescript.sh")

# TODO
# TODO: Enable Java
# assert_match "Hello from Java", shell_output("#{bin}/metacall test.java")
end
end

0 comments on commit 37e3d5c

Please sign in to comment.