From 339586d4b744b199a2b1af4b04594174be684575 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Thu, 23 Apr 2020 11:54:06 +0200 Subject: [PATCH 1/8] Ensure that rebar3 is installed for mix --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab6484ec..115449aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -119,8 +119,10 @@ jobs: - name: Extend PATH run: echo "C:\\ProgramData\\chocolatey\\lib\\Elixir\\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - name: Hex - run: mix local.hex --force + - name: Mix tools + run: | + mix local.hex --force + mix local.rebar --force - name: Test rustler_mix working-directory: rustler_mix From 29d585b3d50a602815e30c8b915a476c1fc9007d Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Wed, 20 Nov 2019 17:33:24 +0100 Subject: [PATCH 2/8] Move compilation to erlang-cargo - Implement basic compile functionality to make tests pass - Run a single common compilation --- .gitignore | 2 +- rustler_mix/lib/mix/tasks/compile.rustler.ex | 19 -- rustler_mix/lib/mix/tasks/rustler.new.ex | 37 +++- rustler_mix/lib/rustler.ex | 23 +-- rustler_mix/lib/rustler/compiler.ex | 184 +++---------------- rustler_mix/lib/rustler/compiler/config.ex | 62 +------ rustler_mix/lib/rustler/compiler/rustup.ex | 44 ----- rustler_mix/lib/rustler/compiler/server.ex | 39 ++++ rustler_mix/mix.exs | 5 +- rustler_mix/mix.lock | 16 +- rustler_mix/test.sh | 2 +- rustler_tests/mix.exs | 1 - rustler_tests/test/binary_example_test.exs | 2 +- 13 files changed, 127 insertions(+), 309 deletions(-) delete mode 100644 rustler_mix/lib/mix/tasks/compile.rustler.ex delete mode 100644 rustler_mix/lib/rustler/compiler/rustup.ex create mode 100644 rustler_mix/lib/rustler/compiler/server.ex diff --git a/.gitignore b/.gitignore index 08e3d7b4..d9b4f43f 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ Session.vim # Generated by Cargo **/target/* /rustler/target/ -/rustler_tests/priv/native/* +/rustler_tests/priv/crates/* /rustler_tests/target/ /rustler_tests/_build /rustler_tests/deps diff --git a/rustler_mix/lib/mix/tasks/compile.rustler.ex b/rustler_mix/lib/mix/tasks/compile.rustler.ex deleted file mode 100644 index 3e01f68f..00000000 --- a/rustler_mix/lib/mix/tasks/compile.rustler.ex +++ /dev/null @@ -1,19 +0,0 @@ -defmodule Mix.Tasks.Compile.Rustler do - @moduledoc false - - use Mix.Task - - def run(_args) do - IO.puts([ - IO.ANSI.yellow(), - """ - - The `:rustler` compiler has been deprecated since v0.22.0 and will be - removed in v1.0. - - To remove this warning, please consult the CHANGELOG for v0.22.0. - """, - IO.ANSI.default_color() - ]) - end -end diff --git a/rustler_mix/lib/mix/tasks/rustler.new.ex b/rustler_mix/lib/mix/tasks/rustler.new.ex index 465508ab..5b746396 100644 --- a/rustler_mix/lib/mix/tasks/rustler.new.ex +++ b/rustler_mix/lib/mix/tasks/rustler.new.ex @@ -25,7 +25,6 @@ defmodule Mix.Tasks.Rustler.New do for {format, source, _} <- @basic do unless format == :keep do - @external_resource Path.join(root, source) defp render(unquote(source)), do: unquote(File.read!(Path.join(root, source))) end end @@ -68,8 +67,12 @@ defmodule Mix.Tasks.Rustler.New do check_module_name_validity!(module) - path = Path.join([File.cwd!(), "native/", name]) + sub_path = Path.join("native", name) + + path = Path.join([File.cwd!(), sub_path]) new(otp_app, path, module, name, opts) + + add_to_workspace(sub_path) end defp new(otp_app, path, module, name, _opts) do @@ -89,6 +92,36 @@ defmodule Mix.Tasks.Rustler.New do Mix.Shell.IO.info([:green, "Ready to go! See #{path}/README.md for further instructions."]) end + defp add_to_workspace(sub_path) do + Mix.Shell.IO.info([:green, "Adding #{sub_path} to workspace"]) + cargo_toml_fn = Path.join(File.cwd!(), "Cargo.toml") + + cargo_toml = + case Toml.decode_file(cargo_toml_fn) do + {:ok, data} -> + data + + {:error, _} -> + %{} + end + + workspace = Map.get(cargo_toml, "workspace", %{}) + + members = + MapSet.new(Map.get(workspace, "members", [])) + |> MapSet.put(sub_path) + |> MapSet.to_list() + + workspace_section = """ + [workspace] + members = [#{members |> Enum.map(&inspect/1) |> Enum.join(", ")}] + """ + + # TODO: Only replace the existing workspace.members entry + + File.write(cargo_toml_fn, workspace_section) + end + defp check_module_name_validity!(name) do unless name =~ ~r/^[A-Z]\w*(\.[A-Z]\w*)*$/ do Mix.raise( diff --git a/rustler_mix/lib/rustler.ex b/rustler_mix/lib/rustler.ex index 083d1b52..7e6bd3b0 100644 --- a/rustler_mix/lib/rustler.ex +++ b/rustler_mix/lib/rustler.ex @@ -33,13 +33,8 @@ defmodule Rustler do value. If you have more than one crate in your project, you will need to be explicit about which crate you intend to use. - * `:default_features` - a boolean to specify whether the crate's default features - should be used. - * `:env` - Specify a list of environment variables when envoking the compiler. - * `:features` - a list of features to enable when compiling the crate. - * `:load_data` - Any valid term. This value is passed into the NIF when it is loaded (default: `0`) @@ -56,12 +51,6 @@ defmodule Rustler do - When `Mix.env()` is `:dev` or `:test`, the crate will be compiled in `:debug` mode. - When `Mix.env()` is `:prod` or `:bench`, the crate will be compiled in `:release` mode. - * `:path` - By default, rustler expects the crate to be found in `native/` in the - root of the project. Use this option to override this. - - * `:skip_compilation?` - This option skips envoking the rust compiler. Specify this option - in combination with `:load_from` to load a pre-compiled artifact. - * `:target` - Specify a compile [target] triple. * `:target_dir`: Override the compiler output directory. @@ -82,12 +71,8 @@ defmodule Rustler do quote bind_quoted: [opts: opts] do config = Rustler.Compiler.compile_crate(__MODULE__, opts) - for resource <- config.external_resources do - @external_resource resource - end - if config.lib do - @load_from config.load_from + @load_from {config.otp_app, config.load_path} @load_data config.load_data @before_compile Rustler @@ -107,10 +92,7 @@ defmodule Rustler do {otp_app, path} = @load_from - load_path = - otp_app - |> Application.app_dir(path) - |> to_charlist() + load_path = Path.join(:code.priv_dir(otp_app), path) |> to_charlist() :erlang.load_nif(load_path, @load_data) end @@ -118,6 +100,7 @@ defmodule Rustler do end @doc false + @spec rustler_version() :: binary() def rustler_version, do: "0.22.0" @doc """ diff --git a/rustler_mix/lib/rustler/compiler.ex b/rustler_mix/lib/rustler/compiler.ex index e991b5b6..435deb95 100644 --- a/rustler_mix/lib/rustler/compiler.ex +++ b/rustler_mix/lib/rustler/compiler.ex @@ -1,178 +1,46 @@ defmodule Rustler.Compiler do @moduledoc false - alias Rustler.Compiler.{Config, Messages, Rustup} + alias Rustler.Compiler.{Config} + alias Rustler.Compiler.{Server} @doc false def compile_crate(module, opts) do + shell = Mix.shell() otp_app = Keyword.fetch!(opts, :otp_app) + crate = Atom.to_string(Keyword.fetch!(opts, :crate)) config = Config.from(otp_app, module, opts) - unless config.skip_compilation? do - crate_full_path = Path.expand(config.path, File.cwd!()) + artifacts = Server.build() - File.mkdir_p!(priv_dir()) + is_release = Mix.env() in [:prod, :bench] - Mix.shell().info("Compiling crate #{config.crate} in #{config.mode} mode (#{config.path})") + entry = + artifacts + |> Map.values() + |> Enum.find(&(crate == &1[:name])) - [cmd | args] = - make_base_command(config.cargo) - |> make_no_default_features_flag(config.default_features) - |> make_features_flag(config.features) - |> make_target_flag(config.target) - |> make_build_mode_flag(config.mode) - |> make_platform_hacks(crate_full_path, :os.type()) + [filename] = entry[:filenames] + out_path = Path.join(priv_dir(entry, is_release), Path.basename(filename)) + shell.info(" Copying file #{filename} to #{out_path}") - compile_result = - System.cmd(cmd, args, - cd: crate_full_path, - stderr_to_stdout: true, - env: [{"CARGO_TARGET_DIR", config.target_dir} | config.env], - into: IO.stream(:stdio, :line) - ) + dest = Path.join(:code.priv_dir(config.otp_app), out_path) + File.mkdir_p!(Path.dirname(dest)) + File.copy!(filename, dest) - case compile_result do - {_, 0} -> :ok - {_, code} -> raise "Rust NIF compile error (rustc exit code #{code})" - end - - handle_artifacts(crate_full_path, config) - # See #326: Ensure that the libraries are copied into the correct subdirectory - # in `_build`. - Mix.Project.build_structure() - end - - config - end - - defp make_base_command(:system), do: ["cargo", "rustc"] - defp make_base_command({:system, channel}), do: ["cargo", channel, "rustc"] - defp make_base_command({:bin, path}), do: [path, "rustc"] - - defp make_base_command({:rustup, version}) do - if Rustup.version() == :none do - throw_error(:rustup_not_installed) - end - - unless Rustup.version_installed?(version) do - throw_error({:rust_version_not_installed, version}) - end - - ["rustup", "run", version, "cargo", "rustc"] - end - - defp make_platform_hacks(args, crate_path, {:unix, :darwin}) do - root = Path.join([".cargo", "config"]) - path = Path.join([crate_path, ".cargo", "config"]) - - if File.exists?(root) || File.exists?(path) do - args - else - IO.write([ - "\n", - IO.ANSI.yellow(), - """ - Compiling on macOS requires special link args in order to compile - correctly. - - Rustler is currently working around this issue in the compiler task. - This will be removed in v1.0.0 in favor of a user supplied .cargo/config - file. - - To remove this warning, please create #{path} - with the following content: - - [target.x86_64-apple-darwin] - rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", - ] - - See https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html - for more details. - - """, - IO.ANSI.default_color(), - "\n" - ]) - - args ++ ["--", "-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] - end - end + is_lib = entry[:kind] == ["cdylib"] - defp make_platform_hacks(args, _, _), do: args - - defp make_no_default_features_flag(args, true), do: args - defp make_no_default_features_flag(args, false), do: args ++ ["--no-default-features"] - - defp make_features_flag(args, []), do: args - defp make_features_flag(args, flags), do: args ++ ["--features", Enum.join(flags, ",")] - - defp make_target_flag(args, target) when is_binary(target), do: args ++ ["--target=#{target}"] - defp make_target_flag(args, _), do: args - - defp make_build_mode_flag(args, :release), do: args ++ ["--release"] - defp make_build_mode_flag(args, :debug), do: args - - defp handle_artifacts(path, config) do - toml = toml_data(path) - names = get_name(toml, :lib) ++ get_name(toml, :bin) - - Enum.each(names, fn {name, type} -> - {src_file, dst_file} = make_file_names(name, type) - compiled_lib = Path.join([config.target_dir, Atom.to_string(config.mode), src_file]) - destination_lib = Path.join(priv_dir(), dst_file) - - # If the file exists already, we delete it first. This is to ensure that another - # process, which might have the library dynamically linked in, does not generate - # a segfault. By deleting it first, we ensure that the copy operation below does - # not write into the existing file. - File.rm(destination_lib) - File.cp!(compiled_lib, destination_lib) - end) - end - - defp get_name(toml, section) do - case toml[to_string(section)] do - nil -> [] - values when is_map(values) -> [{values["name"], section}] - values when is_list(values) -> Enum.map(values, &{&1["name"], section}) - end + %Config{config | lib: is_lib, load_path: Path.rootname(out_path)} end - defp make_file_names(base_name, :lib) do - case :os.type() do - {:win32, _} -> {"#{base_name}.dll", "lib#{base_name}.dll"} - {:unix, :darwin} -> {"lib#{base_name}.dylib", "lib#{base_name}.so"} - {:unix, _} -> {"lib#{base_name}.so", "lib#{base_name}.so"} - end - end - - defp make_file_names(base_name, :bin) do - case :os.type() do - {:win32, _} -> {"#{base_name}.exe", "#{base_name}.exe"} - {:unix, _} -> {base_name, base_name} - end - end - - defp throw_error(error_descr) do - Mix.shell().error(Messages.message(error_descr)) - raise "Compilation error" - end - - defp toml_data(path) do - unless File.dir?(path) do - throw_error({:nonexistent_crate_directory, path}) - end - - case File.read("#{path}/Cargo.toml") do - {:error, :enoent} -> - throw_error({:cargo_toml_not_found, path}) + defp priv_dir(entry, is_release) do + type = + if is_release do + "release" + else + "debug" + end - {:ok, text} -> - Toml.decode!(text) - end + "crates/#{entry[:name]}/#{entry[:version]}/#{type}" end - - defp priv_dir, do: "priv/native" end diff --git a/rustler_mix/lib/rustler/compiler/config.ex b/rustler_mix/lib/rustler/compiler/config.ex index eac34784..f4c4c852 100644 --- a/rustler_mix/lib/rustler/compiler/config.ex +++ b/rustler_mix/lib/rustler/compiler/config.ex @@ -2,31 +2,20 @@ defmodule Rustler.Compiler.Config do @moduledoc false @type rust_version :: :stable | :beta | :nightly | binary() - @type cargo :: :system | {:rustup, rust_version()} | {:bin, Path.t()} @type crate :: binary() @type default_features :: boolean() @type env :: [{binary(), binary()}] @type features :: [binary()] @type mode :: :debug | :release @type load_data :: term() - @type path :: Path.t() - defstruct cargo: :system, - crate: nil, - default_features: true, - env: [], - external_resources: [], - features: [], + defstruct crate: nil, lib: true, load_data: 0, - load_from: nil, + load_path: nil, mode: :release, otp_app: nil, - path: "", - priv_dir: "", - skip_compilation?: false, - target: nil, - target_dir: "" + target: nil alias Rustler.Compiler.Config @@ -35,53 +24,22 @@ defmodule Rustler.Compiler.Config do crate = config[:crate] || opts[:crate] || otp_app - # TODO: Remove in 1.0 - rustler_crates = Mix.Project.config()[:rustler_crates] || [] - legacy_config = rustler_crates[to_atom(crate)] || [] - defaults = %Config{ crate: crate, - load_from: {otp_app, "priv/native/lib#{crate}"}, mode: build_mode(Mix.env()), - otp_app: otp_app, - path: "native/#{crate}", - target_dir: Application.app_dir(otp_app, "native/#{crate}") + otp_app: otp_app } - defaults - |> Map.from_struct() - |> Enum.into([]) - |> Keyword.merge(legacy_config) - |> Keyword.merge(opts) - |> Keyword.merge(config) - |> build() - end - - defp build(opts) do - resources = - opts - |> Keyword.get(:path) - |> external_resources() - - opts = Keyword.put(opts, :external_resources, resources) + opts = + defaults + |> Map.from_struct() + |> Enum.into([]) + |> Keyword.merge(opts) + |> Keyword.merge(config) struct!(Config, opts) end - defp external_resources(crate_path) do - "#{crate_path}/**/*" - |> Path.wildcard() - |> Enum.reject(fn path -> - String.starts_with?(path, "#{crate_path}/target/") - end) - end - defp build_mode(env) when env in [:prod, :bench], do: :release defp build_mode(_), do: :debug - - defp to_atom(name) when is_binary(name), - do: String.to_atom(name) - - defp to_atom(name) when is_atom(name), - do: name end diff --git a/rustler_mix/lib/rustler/compiler/rustup.ex b/rustler_mix/lib/rustler/compiler/rustup.ex deleted file mode 100644 index 2b48b92a..00000000 --- a/rustler_mix/lib/rustler/compiler/rustup.ex +++ /dev/null @@ -1,44 +0,0 @@ -defmodule Rustler.Compiler.Rustup do - @moduledoc false - - def rustup_binary, do: System.get_env("RUSTUP_BINARY") || "rustup" - - def version do - multirust_exec = System.find_executable(rustup_binary()) - - if multirust_exec == nil do - :none - else - {version, 0} = System.cmd(rustup_binary(), ["--version"]) - {:ok, version} - end - end - - def version_installed?(version) do - {_resp, return} = System.cmd(rustup_binary(), ["run", version, "rustc", "--version"]) - - case return do - 0 -> true - _ -> false - end - end - - # def rust_versions do - # {versions_raw, 0} = System.cmd("rustup", ["list-toolchains"]) - # versions_raw - # |> String.strip(?\n) - # |> String.split("\n") - # end - - def install_toolchain(version) do - {_resp, 0} = System.cmd(rustup_binary(), ["install", version], into: IO.stream(:stdio, :line)) - end - - def compile_with(path, version, args \\ [], env \\ [], into \\ "") do - System.cmd(rustup_binary(), ["run", version, "cargo", "build" | args], - cd: path, - into: into, - env: env - ) - end -end diff --git a/rustler_mix/lib/rustler/compiler/server.ex b/rustler_mix/lib/rustler/compiler/server.ex new file mode 100644 index 00000000..bbcd06fc --- /dev/null +++ b/rustler_mix/lib/rustler/compiler/server.ex @@ -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 diff --git a/rustler_mix/mix.exs b/rustler_mix/mix.exs index e61b2401..6792db02 100644 --- a/rustler_mix/mix.exs +++ b/rustler_mix/mix.exs @@ -24,8 +24,9 @@ defmodule Rustler.Mixfile do defp deps do [ - {:toml, "~> 0.5.2", runtime: false}, - {:ex_doc, ">= 0.0.0", only: :dev, runtime: false} + {:cargo, git: "https://github.com/filmor/erlang-cargo.git"}, + {:toml, "~> 0.6"}, + {:ex_doc, "~> 0.21", only: :dev, runtime: false} ] end diff --git a/rustler_mix/mix.lock b/rustler_mix/mix.lock index 68ee4081..65c756a4 100644 --- a/rustler_mix/mix.lock +++ b/rustler_mix/mix.lock @@ -1,10 +1,10 @@ %{ - "earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, - "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, - "toml": {:hex, :toml, "0.5.2", "e471388a8726d1ce51a6b32f864b8228a1eb8edc907a0edf2bb50eab9321b526", [:mix], [], "hexpm", "f1e3dabef71fb510d015fad18c0e05e7c57281001141504c6b69d94e99750a07"}, + "cargo": {:git, "https://github.com/filmor/erlang-cargo.git", "1456f74ae8b064ad2c9e853953a30b6392a249ab", []}, + "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, + "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, + "jsx": {:hex, :jsx, "2.10.0", "77760560d6ac2b8c51fd4c980e9e19b784016aa70be354ce746472c33beb0b1c", [:rebar3], [], "hexpm", "9a83e3704807298016968db506f9fad0f027de37546eb838b3ae1064c3a0ad62"}, + "makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49736fe5b66a08d8575bf5321d716bac5da20c8e6b97714fec2bcd6febcfa1f8"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, + "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"}, + "toml": {:hex, :toml, "0.6.1", "e1c3c91c1fc1ed87e7315a5a88e4bd1eeddf3e61dca2b708724a6a2d1a013844", [:mix], [], "hexpm", "d73b447d2605e23fa3bbbf80342e27e7e1bca51733d5e65c026d97c7e1a7cabb"}, } diff --git a/rustler_mix/test.sh b/rustler_mix/test.sh index 8bfd3e68..c8153351 100755 --- a/rustler_mix/test.sh +++ b/rustler_mix/test.sh @@ -91,4 +91,4 @@ EOF mix test echo "Done; cleaning up" -rm -r $tmp +rm -rf "$tmp" diff --git a/rustler_tests/mix.exs b/rustler_tests/mix.exs index daa116e3..0a8fab2f 100644 --- a/rustler_tests/mix.exs +++ b/rustler_tests/mix.exs @@ -6,7 +6,6 @@ defmodule RustlerTest.Mixfile do app: :rustler_test, version: "0.0.1", elixir: "~> 1.2", - compilers: [:rustler] ++ Mix.compilers(), build_embedded: Mix.env() == :prod, start_permanent: Mix.env() == :prod, deps: deps() diff --git a/rustler_tests/test/binary_example_test.exs b/rustler_tests/test/binary_example_test.exs index 1d3a2dc9..7c1476c5 100644 --- a/rustler_tests/test/binary_example_test.exs +++ b/rustler_tests/test/binary_example_test.exs @@ -14,7 +14,7 @@ defmodule BinaryExampleTest do end defp assert_exists(name, {:win32, _} = type) do - assert File.exists?("priv/native/#{name}.exe") + assert File.exists?("priv/crates/#{name}.exe") end defp assert_exists(name, type) do From f7179a7a55d587945a972ba19188c103b7116602 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sat, 25 Apr 2020 22:51:34 +0200 Subject: [PATCH 3/8] Improve messages, make the tests pass --- rustler_mix/lib/rustler.ex | 30 ++++++++++++++------ rustler_mix/lib/rustler/compiler.ex | 14 ++++----- rustler_mix/lib/rustler/compiler/server.ex | 9 ++++-- rustler_tests/lib/binary_example.ex | 3 +- rustler_tests/native/rustler_test/Cargo.toml | 4 --- rustler_tests/test/binary_example_test.exs | 19 ++----------- 6 files changed, 39 insertions(+), 40 deletions(-) diff --git a/rustler_mix/lib/rustler.ex b/rustler_mix/lib/rustler.ex index 7e6bd3b0..730e9508 100644 --- a/rustler_mix/lib/rustler.ex +++ b/rustler_mix/lib/rustler.ex @@ -71,30 +71,44 @@ defmodule Rustler do quote bind_quoted: [opts: opts] do config = Rustler.Compiler.compile_crate(__MODULE__, opts) + @load_from {config.otp_app, config.load_path} + if config.lib do - @load_from {config.otp_app, config.load_path} @load_data config.load_data - + @before_compile {Rustler, :__before_compile_nif__} + else @before_compile Rustler end end end defmacro __before_compile__(_env) do + quote do + def rustler_path do + {otp_app, path} = @load_from + Path.join(:code.priv_dir(otp_app), path) + end + end + end + + defmacro __before_compile_nif__(_env) do quote do @on_load :rustler_init + def rustler_path do + # TODO: Parametrise, and keep all crates in the list + {otp_app, path} = @load_from + Path.join(:code.priv_dir(otp_app), path) + end + @doc false def rustler_init do # Remove any old modules that may be loaded so we don't get # {:error, {:upgrade, 'Upgrade not supported by this NIF library.'}} :code.purge(__MODULE__) - - {otp_app, path} = @load_from - - load_path = Path.join(:code.priv_dir(otp_app), path) |> to_charlist() - - :erlang.load_nif(load_path, @load_data) + load_path = String.to_charlist(rustler_path()) + data = @load_data + :erlang.load_nif(load_path, data) end end end diff --git a/rustler_mix/lib/rustler/compiler.ex b/rustler_mix/lib/rustler/compiler.ex index 435deb95..00692763 100644 --- a/rustler_mix/lib/rustler/compiler.ex +++ b/rustler_mix/lib/rustler/compiler.ex @@ -14,17 +14,17 @@ defmodule Rustler.Compiler do artifacts = Server.build() is_release = Mix.env() in [:prod, :bench] + entry = artifacts[crate] - entry = - artifacts - |> Map.values() - |> Enum.find(&(crate == &1[:name])) - + # Only a single file result per crate is supported right now [filename] = entry[:filenames] - out_path = Path.join(priv_dir(entry, is_release), Path.basename(filename)) - shell.info(" Copying file #{filename} to #{out_path}") + rel_filename = Path.basename(filename) + out_path = Path.join(priv_dir(entry, is_release), Path.basename(filename)) dest = Path.join(:code.priv_dir(config.otp_app), out_path) + rel_dest = Path.relative_to_cwd(dest) + + shell.info(" Copying #{rel_filename} to #{rel_dest}") File.mkdir_p!(Path.dirname(dest)) File.copy!(filename, dest) diff --git a/rustler_mix/lib/rustler/compiler/server.ex b/rustler_mix/lib/rustler/compiler/server.ex index bbcd06fc..827d6203 100644 --- a/rustler_mix/lib/rustler/compiler/server.ex +++ b/rustler_mix/lib/rustler/compiler/server.ex @@ -20,8 +20,6 @@ defmodule Rustler.Compiler.Server do @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 = %{ @@ -30,6 +28,13 @@ defmodule Rustler.Compiler.Server do cargo = :cargo.init(File.cwd!(), cargo_opts) artifacts = :cargo.build_and_capture(cargo) + + # This drops the unique key in favour of the crate name + artifacts = + artifacts + |> Map.values() + |> Map.new(&{&1[:name], &1}) + {:reply, artifacts, artifacts} end diff --git a/rustler_tests/lib/binary_example.ex b/rustler_tests/lib/binary_example.ex index b21f1373..5946f27c 100644 --- a/rustler_tests/lib/binary_example.ex +++ b/rustler_tests/lib/binary_example.ex @@ -1,6 +1,5 @@ defmodule BinaryExample do use Rustler, otp_app: :rustler_test, - crate: :binary_example, - lib: false + crate: :binary_example end diff --git a/rustler_tests/native/rustler_test/Cargo.toml b/rustler_tests/native/rustler_test/Cargo.toml index 9f0b4d04..0bd0d3da 100644 --- a/rustler_tests/native/rustler_test/Cargo.toml +++ b/rustler_tests/native/rustler_test/Cargo.toml @@ -13,10 +13,6 @@ crate-type = ["cdylib"] name = "hello_rust" path = "src/main.rs" -[[bin]] -name = "hello_rust2" -path = "src/main.rs" - [dependencies] lazy_static = "1.4" rustler = { path = "../../../rustler" } diff --git a/rustler_tests/test/binary_example_test.exs b/rustler_tests/test/binary_example_test.exs index 7c1476c5..81154516 100644 --- a/rustler_tests/test/binary_example_test.exs +++ b/rustler_tests/test/binary_example_test.exs @@ -2,22 +2,7 @@ defmodule BinaryExampleTest do use ExUnit.Case test "binary is compiled" do - bins = ~w(binary_example hello_rust hello_rust2) - - for bin <- bins do - assert_exists(bin) - end - end - - defp assert_exists(name) do - assert_exists(name, :os.type()) - end - - defp assert_exists(name, {:win32, _} = type) do - assert File.exists?("priv/crates/#{name}.exe") - end - - defp assert_exists(name, type) do - assert File.exists?("priv/native/#{name}") + path = BinaryExample.rustler_path() + File.exists?(path) end end From cdbc0d0c848790af1edb30e0786a50fc01030fd1 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Sat, 25 Apr 2020 23:01:54 +0200 Subject: [PATCH 4/8] Allow both strings and atoms for crate name --- rustler_mix/lib/rustler/compiler.ex | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/rustler_mix/lib/rustler/compiler.ex b/rustler_mix/lib/rustler/compiler.ex index 00692763..57b8445a 100644 --- a/rustler_mix/lib/rustler/compiler.ex +++ b/rustler_mix/lib/rustler/compiler.ex @@ -8,7 +8,8 @@ defmodule Rustler.Compiler do def compile_crate(module, opts) do shell = Mix.shell() otp_app = Keyword.fetch!(opts, :otp_app) - crate = Atom.to_string(Keyword.fetch!(opts, :crate)) + + crate = ensure_string(Keyword.fetch!(opts, :crate)) config = Config.from(otp_app, module, opts) artifacts = Server.build() @@ -43,4 +44,16 @@ defmodule Rustler.Compiler do "crates/#{entry[:name]}/#{entry[:version]}/#{type}" end + + defp ensure_string(atom) when is_atom(atom) do + Atom.to_string(atom) + end + + defp ensure_string(list) when is_list(list) do + IO.iodata_to_binary(list) + end + + defp ensure_string(str) when is_binary(str) do + str + end end From ed245a17c2aa814e5f6c616aca827c53f1fe23c3 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Thu, 30 Apr 2020 14:12:45 +0200 Subject: [PATCH 5/8] Update cargo and fix multiple artifacts per package --- rustler_mix/lib/rustler.ex | 36 +++++++++-------- rustler_mix/lib/rustler/compiler.ex | 45 ++++++++++++++++------ rustler_mix/lib/rustler/compiler/server.ex | 7 ++-- rustler_mix/mix.lock | 2 +- 4 files changed, 57 insertions(+), 33 deletions(-) diff --git a/rustler_mix/lib/rustler.ex b/rustler_mix/lib/rustler.ex index 730e9508..ce0eb0f1 100644 --- a/rustler_mix/lib/rustler.ex +++ b/rustler_mix/lib/rustler.ex @@ -92,25 +92,27 @@ defmodule Rustler do end defmacro __before_compile_nif__(_env) do - quote do - @on_load :rustler_init - - def rustler_path do - # TODO: Parametrise, and keep all crates in the list - {otp_app, path} = @load_from - Path.join(:code.priv_dir(otp_app), path) + quoted = + quote do + def rustler_path do + # TODO: Parametrise, and keep all crates in the list + {otp_app, path} = @load_from + Path.join(:code.priv_dir(otp_app), path) + end + + @on_load :rustler_init + @doc false + def rustler_init do + # Remove any old modules that may be loaded so we don't get + # :error, {:upgrade, 'Upgrade not supported by this NIF library.'}} + :code.purge(__MODULE__) + load_path = String.to_charlist(rustler_path()) + :ok = :erlang.load_nif(load_path, @load_data) + end end - @doc false - def rustler_init do - # Remove any old modules that may be loaded so we don't get - # {:error, {:upgrade, 'Upgrade not supported by this NIF library.'}} - :code.purge(__MODULE__) - load_path = String.to_charlist(rustler_path()) - data = @load_data - :erlang.load_nif(load_path, data) - end - end + # quoted |> Macro.to_string |> IO.puts + quoted end @doc false diff --git a/rustler_mix/lib/rustler/compiler.ex b/rustler_mix/lib/rustler/compiler.ex index 57b8445a..c5b5bb4b 100644 --- a/rustler_mix/lib/rustler/compiler.ex +++ b/rustler_mix/lib/rustler/compiler.ex @@ -17,21 +17,39 @@ defmodule Rustler.Compiler do is_release = Mix.env() in [:prod, :bench] entry = artifacts[crate] - # Only a single file result per crate is supported right now - [filename] = entry[:filenames] - rel_filename = Path.basename(filename) + is_lib = :cargo_artifact.kind(entry) == :cdylib + is_bin = :cargo_artifact.kind(entry) == :bin - out_path = Path.join(priv_dir(entry, is_release), Path.basename(filename)) - dest = Path.join(:code.priv_dir(config.otp_app), out_path) - rel_dest = Path.relative_to_cwd(dest) + if !is_lib and !is_bin do + Mix.raise("Crate #{crate} is neither a 'bin' nor a 'cdylib' but #{entry[:kind]}") + end - shell.info(" Copying #{rel_filename} to #{rel_dest}") - File.mkdir_p!(Path.dirname(dest)) - File.copy!(filename, dest) + priv_dir = priv_dir(entry, is_release) + dest_root = :code.priv_dir(config.otp_app) - is_lib = entry[:kind] == ["cdylib"] + out_paths = + for filename <- :cargo_artifact.filenames(entry) do + out_path = Path.join(priv_dir, Path.basename(filename)) + dest = Path.join(dest_root, out_path) + rel_filename = Path.basename(filename) + rel_dest = Path.relative_to_cwd(dest) - %Config{config | lib: is_lib, load_path: Path.rootname(out_path)} + shell.info(" Copying #{rel_filename} to #{rel_dest}") + File.mkdir_p!(Path.dirname(dest)) + File.copy!(filename, dest) + + out_path + end + + [load_path] = + if is_lib do + out_paths |> Enum.filter(&:cargo_util.is_dylib/1) + else + exec = :cargo_artifact.executable(entry) + [Path.join(priv_dir, Path.basename(exec))] + end + + %Config{config | lib: is_lib, load_path: Path.rootname(load_path)} end defp priv_dir(entry, is_release) do @@ -42,7 +60,10 @@ defmodule Rustler.Compiler do "debug" end - "crates/#{entry[:name]}/#{entry[:version]}/#{type}" + name = :cargo_artifact.name(entry) + version = :cargo_artifact.version(entry) + + "crates/#{name}/#{version}/#{type}" end defp ensure_string(atom) when is_atom(atom) do diff --git a/rustler_mix/lib/rustler/compiler/server.ex b/rustler_mix/lib/rustler/compiler/server.ex index 827d6203..1808a4a6 100644 --- a/rustler_mix/lib/rustler/compiler/server.ex +++ b/rustler_mix/lib/rustler/compiler/server.ex @@ -26,14 +26,15 @@ defmodule Rustler.Compiler.Server do release: is_release } + Mix.shell().info("Starting build in #{File.cwd!()}") + cargo = :cargo.init(File.cwd!(), cargo_opts) - artifacts = :cargo.build_and_capture(cargo) + artifacts = :cargo.build(cargo) # This drops the unique key in favour of the crate name artifacts = artifacts - |> Map.values() - |> Map.new(&{&1[:name], &1}) + |> Map.new(&{:cargo_artifact.name(&1), &1}) {:reply, artifacts, artifacts} end diff --git a/rustler_mix/mix.lock b/rustler_mix/mix.lock index 65c756a4..81e735df 100644 --- a/rustler_mix/mix.lock +++ b/rustler_mix/mix.lock @@ -1,5 +1,5 @@ %{ - "cargo": {:git, "https://github.com/filmor/erlang-cargo.git", "1456f74ae8b064ad2c9e853953a30b6392a249ab", []}, + "cargo": {:git, "https://github.com/filmor/erlang-cargo.git", "b4159576565554e689eb1ac25ae2e634252d514b", []}, "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, "jsx": {:hex, :jsx, "2.10.0", "77760560d6ac2b8c51fd4c980e9e19b784016aa70be354ce746472c33beb0b1c", [:rebar3], [], "hexpm", "9a83e3704807298016968db506f9fad0f027de37546eb838b3ae1064c3a0ad62"}, From 036001952bc1e981a15c781a584efaec92345d25 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Wed, 6 May 2020 19:52:40 +0200 Subject: [PATCH 6/8] Update erlang-cargo --- rustler_mix/mix.exs | 2 +- rustler_mix/mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rustler_mix/mix.exs b/rustler_mix/mix.exs index 6792db02..446f9eef 100644 --- a/rustler_mix/mix.exs +++ b/rustler_mix/mix.exs @@ -24,7 +24,7 @@ defmodule Rustler.Mixfile do defp deps do [ - {:cargo, git: "https://github.com/filmor/erlang-cargo.git"}, + {:cargo, git: "https://github.com/rusterlium/erlang-cargo.git"}, {:toml, "~> 0.6"}, {:ex_doc, "~> 0.21", only: :dev, runtime: false} ] diff --git a/rustler_mix/mix.lock b/rustler_mix/mix.lock index 81e735df..711dd084 100644 --- a/rustler_mix/mix.lock +++ b/rustler_mix/mix.lock @@ -1,5 +1,5 @@ %{ - "cargo": {:git, "https://github.com/filmor/erlang-cargo.git", "b4159576565554e689eb1ac25ae2e634252d514b", []}, + "cargo": {:git, "https://github.com/rusterlium/erlang-cargo.git", "0e612bf1e321c6ae062b98f9079f24b6bedfba01", []}, "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, "jsx": {:hex, :jsx, "2.10.0", "77760560d6ac2b8c51fd4c980e9e19b784016aa70be354ce746472c33beb0b1c", [:rebar3], [], "hexpm", "9a83e3704807298016968db506f9fad0f027de37546eb838b3ae1064c3a0ad62"}, From 72f4ecce869cbb4185d3aad20cf3250472b6548a Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Thu, 21 May 2020 12:49:49 +0200 Subject: [PATCH 7/8] Update erlang-cargo for partial compiles and take release flag into account --- rustler_mix/lib/rustler/compiler.ex | 20 ++++++++-- rustler_mix/lib/rustler/compiler/server.ex | 45 ---------------------- rustler_mix/mix.lock | 17 ++++---- 3 files changed, 26 insertions(+), 56 deletions(-) delete mode 100644 rustler_mix/lib/rustler/compiler/server.ex diff --git a/rustler_mix/lib/rustler/compiler.ex b/rustler_mix/lib/rustler/compiler.ex index c5b5bb4b..a654fc5e 100644 --- a/rustler_mix/lib/rustler/compiler.ex +++ b/rustler_mix/lib/rustler/compiler.ex @@ -2,7 +2,6 @@ defmodule Rustler.Compiler do @moduledoc false alias Rustler.Compiler.{Config} - alias Rustler.Compiler.{Server} @doc false def compile_crate(module, opts) do @@ -12,9 +11,9 @@ defmodule Rustler.Compiler do crate = ensure_string(Keyword.fetch!(opts, :crate)) config = Config.from(otp_app, module, opts) - artifacts = Server.build() + is_release = config.mode == :release + artifacts = do_compile(crate, is_release) - is_release = Mix.env() in [:prod, :bench] entry = artifacts[crate] is_lib = :cargo_artifact.kind(entry) == :cdylib @@ -77,4 +76,19 @@ defmodule Rustler.Compiler do defp ensure_string(str) when is_binary(str) do str end + + defp do_compile(crate, is_release) do + cargo_opts = %{ + release: is_release + } + + Mix.shell().info("Starting build in #{File.cwd!()}") + + cargo = :cargo.init(File.cwd!(), cargo_opts) + + artifacts = :cargo.build(cargo, crate) + + # This drops the unique key in favour of the crate name + artifacts |> Map.new(&{:cargo_artifact.name(&1), &1}) + end end diff --git a/rustler_mix/lib/rustler/compiler/server.ex b/rustler_mix/lib/rustler/compiler/server.ex deleted file mode 100644 index 1808a4a6..00000000 --- a/rustler_mix/lib/rustler/compiler/server.ex +++ /dev/null @@ -1,45 +0,0 @@ -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 - is_release = Mix.env() in [:prod, :bench] - - cargo_opts = %{ - release: is_release - } - - Mix.shell().info("Starting build in #{File.cwd!()}") - - cargo = :cargo.init(File.cwd!(), cargo_opts) - artifacts = :cargo.build(cargo) - - # This drops the unique key in favour of the crate name - artifacts = - artifacts - |> Map.new(&{:cargo_artifact.name(&1), &1}) - - {:reply, artifacts, artifacts} - end - - def handle_call(:compile, _from, artifacts) do - {:reply, artifacts, artifacts} - end -end diff --git a/rustler_mix/mix.lock b/rustler_mix/mix.lock index 711dd084..3047cb6d 100644 --- a/rustler_mix/mix.lock +++ b/rustler_mix/mix.lock @@ -1,10 +1,11 @@ %{ - "cargo": {:git, "https://github.com/rusterlium/erlang-cargo.git", "0e612bf1e321c6ae062b98f9079f24b6bedfba01", []}, - "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, - "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, - "jsx": {:hex, :jsx, "2.10.0", "77760560d6ac2b8c51fd4c980e9e19b784016aa70be354ce746472c33beb0b1c", [:rebar3], [], "hexpm", "9a83e3704807298016968db506f9fad0f027de37546eb838b3ae1064c3a0ad62"}, - "makeup": {:hex, :makeup, "1.0.1", "82f332e461dc6c79dbd82fbe2a9c10d48ed07146f0a478286e590c83c52010b5", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "49736fe5b66a08d8575bf5321d716bac5da20c8e6b97714fec2bcd6febcfa1f8"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, - "nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"}, - "toml": {:hex, :toml, "0.6.1", "e1c3c91c1fc1ed87e7315a5a88e4bd1eeddf3e61dca2b708724a6a2d1a013844", [:mix], [], "hexpm", "d73b447d2605e23fa3bbbf80342e27e7e1bca51733d5e65c026d97c7e1a7cabb"}, + "cargo": {:git, "https://github.com/rusterlium/erlang-cargo.git", "f2a2ac09c7e34bdcbac9bd0c2ccb73d8b74e2490", []}, + "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, + "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, + "jsx": {:hex, :jsx, "2.11.0", "08154624050333919b4ac1b789667d5f4db166dc50e190c4d778d1587f102ee0", [:rebar3], [], "hexpm", "eed26a0d04d217f9eecefffb89714452556cf90eb38f290a27a4d45b9988f8c0"}, + "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "toml": {:hex, :toml, "0.6.2", "38f445df384a17e5d382befe30e3489112a48d3ba4c459e543f748c2f25dd4d1", [:mix], [], "hexpm", "d013e45126d74c0c26a38d31f5e8e9b83ea19fc752470feb9a86071ca5a672fa"}, } From 109b73b87cbdabf1ba91a328f53d5f008323c7e5 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Thu, 21 May 2020 13:50:13 +0200 Subject: [PATCH 8/8] Use published version of erlang-cargo --- rustler_mix/mix.exs | 2 +- rustler_mix/mix.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rustler_mix/mix.exs b/rustler_mix/mix.exs index 446f9eef..38587133 100644 --- a/rustler_mix/mix.exs +++ b/rustler_mix/mix.exs @@ -24,7 +24,7 @@ defmodule Rustler.Mixfile do defp deps do [ - {:cargo, git: "https://github.com/rusterlium/erlang-cargo.git"}, + {:cargo, "~> 0.1"}, {:toml, "~> 0.6"}, {:ex_doc, "~> 0.21", only: :dev, runtime: false} ] diff --git a/rustler_mix/mix.lock b/rustler_mix/mix.lock index 3047cb6d..56e2618b 100644 --- a/rustler_mix/mix.lock +++ b/rustler_mix/mix.lock @@ -1,5 +1,5 @@ %{ - "cargo": {:git, "https://github.com/rusterlium/erlang-cargo.git", "f2a2ac09c7e34bdcbac9bd0c2ccb73d8b74e2490", []}, + "cargo": {:hex, :cargo, "0.1.2", "1245b5a21454ebeabacf403911d54a82a0d457a3f635511a03ad06845f5abf95", [:mix, :rebar3], [{:jsx, "~> 2.8", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "eb614ba74f9f5b61643e5cc607bbf7ddc8420d368661e31c04e0db7ad47e21b3"}, "earmark_parser": {:hex, :earmark_parser, "1.4.13", "0c98163e7d04a15feb62000e1a891489feb29f3d10cb57d4f845c405852bbef8", [:mix], [], "hexpm", "d602c26af3a0af43d2f2645613f65841657ad6efc9f0e361c3b6c06b578214ba"}, "ex_doc": {:hex, :ex_doc, "0.24.2", "e4c26603830c1a2286dae45f4412a4d1980e1e89dc779fcd0181ed1d5a05c8d9", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e134e1d9e821b8d9e4244687fb2ace58d479b67b282de5158333b0d57c6fb7da"}, "jsx": {:hex, :jsx, "2.11.0", "08154624050333919b4ac1b789667d5f4db166dc50e190c4d778d1587f102ee0", [:rebar3], [], "hexpm", "eed26a0d04d217f9eecefffb89714452556cf90eb38f290a27a4d45b9988f8c0"},