Skip to content

Commit

Permalink
support elixir_make pre-compiler API
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper committed Feb 18, 2024
1 parent 01fc356 commit 6d03dc7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/zig_precompiler.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Kinda.Precompiler do
@behaviour ElixirMake.Precompiler

@impl true
def current_target, do: RustlerPrecompiled.target()

@impl true
def all_supported_targets(_), do: ~w(
aarch64-apple-darwin
x86_64-unknown-linux-gnu
)

@impl true
def build_native(args) do
{:ok, t} = current_target()
System.put_env("KINDA_NIF_TARGET", t)
ElixirMake.Compiler.compile(args)
end

@impl true
def precompile(args, _target) do
ElixirMake.Compiler.compile(args)
:ok
end
end
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ defmodule Kinda.MixProject do
[
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:rustler_precompiled, "~> 0.5"},
{:zig_parser, "~> 0.1.0"}
{:zig_parser, "~> 0.1.0"},
{:elixir_make, "~> 0.4", runtime: false}
]
end

Expand Down

0 comments on commit 6d03dc7

Please sign in to comment.