Current section
8 Versions
Jump to
Current section
8 Versions
Compare versions
4
files changed
+38
additions
-24
deletions
| @@ -13,4 +13,4 @@ | |
| 13 13 | {<<"GitHub">>,<<"https://github.com/diodechain/libsecp256k1">>}]}. |
| 14 14 | {<<"name">>,<<"libsecp256k1_diode_fork">>}. |
| 15 15 | {<<"requirements">>,[]}. |
| 16 | - {<<"version">>,<<"0.1.16">>}. |
| 16 | + {<<"version">>,<<"0.1.17">>}. |
| @@ -12,27 +12,29 @@ defmodule Mix.Tasks.Eunit do | |
| 12 12 | """ |
| 13 13 | |
| 14 14 | def run(args) do |
| 15 | - {opts, args, rem_opts} = OptionParser.parse(args, strict: [verbose: :boolean], aliases: [v: :verbose]) |
| 15 | + {opts, args, rem_opts} = |
| 16 | + OptionParser.parse(args, strict: [verbose: :boolean], aliases: [v: :verbose]) |
| 17 | + |
| 16 18 | new_args = args ++ MixErlangTasks.Util.filter_opts(rem_opts) |
| 17 19 | |
| 18 20 | # use a different env from :test because compilation options differ |
| 19 | - Mix.env :etest |
| 21 | + Mix.env(:etest) |
| 20 22 | |
| 21 | - compile_opts = [{:d,:TEST}|Mix.Project.config[:erlc_options]] |
| 22 | - System.put_env "ERL_COMPILER_OPTIONS", format_compile_opts(compile_opts) |
| 23 | + compile_opts = [{:d, :TEST} | Mix.Project.config()[:erlc_options]] |
| 24 | + System.put_env("ERL_COMPILER_OPTIONS", format_compile_opts(compile_opts)) |
| 23 25 | |
| 24 | - Mix.Task.run "compile", new_args |
| 26 | + Mix.Task.run("compile", new_args) |
| 25 27 | |
| 26 28 | # This is run independently, so that the test modules don't end up in the |
| 27 29 | # .app file |
| 28 | - ebin_test = Path.join([Mix.Project.app_path, "test_beams"]) |
| 30 | + ebin_test = Path.join([Mix.Project.app_path(), "test_beams"]) |
| 29 31 | MixErlangTasks.Util.compile_files(Path.wildcard("etest/**/*_tests.erl"), ebin_test) |
| 30 32 | |
| 31 33 | options = if Keyword.get(opts, :verbose, false), do: [:verbose], else: [] |
| 32 | - :eunit.test {:application, Mix.Project.config[:app]}, options |
| 34 | + :eunit.test({:application, Mix.Project.config()[:app]}, options) |
| 33 35 | end |
| 34 36 | |
| 35 37 | defp format_compile_opts(opts) do |
| 36 | - :io_lib.format("~p", [opts]) |> List.to_string |
| 38 | + :io_lib.format("~p", [opts]) |> List.to_string() |
| 37 39 | end |
| 38 40 | end |
| @@ -1,7 +1,7 @@ | |
| 1 1 | defmodule MixErlangTasks.Util do |
| 2 2 | def filter_opts(opts) do |
| 3 3 | Enum.reduce(opts, [], fn |
| 4 | - {name, nil}, acc -> [name|acc] |
| 4 | + {name, nil}, acc -> [name | acc] |
| 5 5 | {name, val}, acc -> [name, val | acc] |
| 6 6 | end) |
| 7 7 | end |
| @@ -9,14 +9,22 @@ defmodule MixErlangTasks.Util do | |
| 9 9 | def compile_files(files, dir) do |
| 10 10 | File.mkdir_p!(dir) |
| 11 11 | |
| 12 | - status = Enum.reduce(files, :ok, fn path, status -> |
| 13 | - case :compile.file(String.to_charlist(path), |
| 14 | - [{:outdir, String.to_charlist(dir)}, :report]) do |
| 15 | - {:ok, _} -> IO.puts "Compiled #{path}"; status |
| 16 | - :error -> :error |
| 17 | - end |
| 18 | - end) |
| 19 | - if status == :error, do: Mix.raise "Encountered compilation errors" |
| 12 | + status = |
| 13 | + Enum.reduce(files, :ok, fn path, status -> |
| 14 | + case :compile.file( |
| 15 | + String.to_charlist(path), |
| 16 | + [{:outdir, String.to_charlist(dir)}, :report] |
| 17 | + ) do |
| 18 | + {:ok, _} -> |
| 19 | + IO.puts("Compiled #{path}") |
| 20 | + status |
| 21 | + |
| 22 | + :error -> |
| 23 | + :error |
| 24 | + end |
| 25 | + end) |
| 26 | + |
| 27 | + if status == :error, do: Mix.raise("Encountered compilation errors") |
| 20 28 | |
| 21 29 | Code.prepend_path(dir) |
| 22 30 | end |
| @@ -1,10 +1,14 @@ | |
| 1 1 | defmodule Mix.Tasks.Compile.MakeBindings do |
| 2 2 | def run(_) do |
| 3 | - {_, exit_code} = System.cmd("make", [], into: IO.stream(:stdio, :line)) |
| 3 | + if :os.type() != {:win32, :nt} or not File.exists?("priv/libsecp256k1_nif.dll") do |
| 4 | + {_, exit_code} = System.cmd("make", [], into: IO.stream(:stdio, :line)) |
| 4 5 | |
| 5 | - case exit_code do |
| 6 | - 0 -> :ok |
| 7 | - _ -> :error |
| 6 | + case exit_code do |
| 7 | + 0 -> :ok |
| 8 | + _ -> :error |
| 9 | + end |
| 10 | + else |
| 11 | + :ok |
| 8 12 | end |
| 9 13 | end |
| 10 14 | end |
| @@ -15,7 +19,7 @@ defmodule Libsecp256k1.Mixfile do | |
| 15 19 | def project do |
| 16 20 | [ |
| 17 21 | app: :libsecp256k1, |
| 18 | - version: "0.1.16", |
| 22 | + version: "0.1.17", |
| 19 23 | language: :erlang, |
| 20 24 | description: "Erlang NIF bindings for the the libsecp256k1 library", |
| 21 25 | package: [ |
| @@ -45,7 +49,7 @@ defmodule Libsecp256k1.Mixfile do | |
| 45 49 | end |
| 46 50 | |
| 47 51 | def application() do |
| 48 | - [extra_applications: [common_test: :optional, edoc: :optional, eunit: :optional]] |
| 52 | + [extra_applications: [common_test: :optional, edoc: :optional, eunit: :optional, mix: :optional]] |
| 49 53 | end |
| 50 54 | |
| 51 55 | defp deps() do |