Skip to content

Commit

Permalink
Drop debug output, add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Apr 25, 2020
1 parent dd91119 commit 5d635f8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
2 changes: 0 additions & 2 deletions rustler_mix/lib/rustler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ defmodule Rustler do

{otp_app, path} = @load_from

IO.warn("#{inspect(otp_app)}, #{path}")

load_path = Path.join(:code.priv_dir(otp_app), path) |> to_charlist()

:erlang.load_nif(load_path, @load_data)
Expand Down
2 changes: 0 additions & 2 deletions rustler_mix/lib/rustler/compiler/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ defmodule Rustler.Compiler.Config do
otp_app: otp_app
}

IO.inspect(defaults)

opts =
defaults
|> Map.from_struct()
Expand Down
39 changes: 39 additions & 0 deletions rustler_mix/lib/rustler/compiler/server.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
defmodule Rustler.Compiler.Server do
use GenServer

defp ensure_running() do
case GenServer.start(__MODULE__, [], name: __MODULE__) do
{:ok, _pid} -> :ok
{:error, {:already_started, _pid}} -> :ok
end
end

def build() do
ensure_running()
GenServer.call(__MODULE__, :compile, :infinity)
end

@impl true
def init([]) do
{:ok, nil}
end

@impl true
def handle_call(:compile, _from, nil) do
shell = Mix.shell()
_otp_app = Mix.Project.config() |> Keyword.get(:app)
is_release = Mix.env() in [:prod, :bench]

cargo_opts = %{
release: is_release
}

cargo = :cargo.init(File.cwd!(), cargo_opts)
artifacts = :cargo.build_and_capture(cargo)
{:reply, artifacts, artifacts}
end

def handle_call(:compile, _from, artifacts) do
{:reply, artifacts, artifacts}
end
end
2 changes: 2 additions & 0 deletions rustler_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["native/binary_example", "native/deprecated_macros", "native/rustler_test"]

0 comments on commit 5d635f8

Please sign in to comment.