Skip to content

Commit

Permalink
macos build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicletz committed Aug 2, 2023
1 parent 56c90e4 commit c1da2a4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ mix deps.get
mix compile
```

## erl_nif.h not found

In case you receive the `erl_nif.h` not found error add this:
```bash
export CFLAGS=-I`erl -eval 'io:format("~s", [lists:concat([code:root_dir(), "/erts-", erlang:system_info(version), "/include"])])' -s init stop -noshell`
```

## Building on macOS

On macOS after installing boost with brew you might need to add it to the environment variables, so the compiler can find it:
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"hex2bin": {:hex, :hex2bin, "1.0.0", "aac26eab998ae80eacee1c7607c629ab503ebf77a62b9242bae2b94d47dcb71e", [:rebar3], [], "hexpm"},
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
"keccakf1600": {:git, "https://github.com/diodechain/erlang-keccakf1600.git", "5bc1fdda7a5ac0a198cad164bf46af44aa3737f7", []},
"keccakf1600": {:git, "https://github.com/diodechain/erlang-keccakf1600.git", "d121a7828a2d217112e55a8815ba575a6261f8c5", []},
"libsecp256k1": {:git, "https://github.com/diodechain/libsecp256k1.git", "812c8091899b9ea7f73d59a1d2738067d9e075c4", []},
"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.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"},
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/edge2_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ defmodule Edge2Client do
def client(n) do
# :io.format("client(~p)~n", [n])
cert = "./test/pems/device#{n}_certificate.pem"
{:ok, socket} = :ssl.connect('localhost', Diode.edge2_port(), options(cert), 5000)
{:ok, socket} = :ssl.connect('localhost', hd(Diode.edge2_ports()), options(cert), 5000)
wallet = clientid(n)
key = Wallet.privkey!(wallet)
fleet = Diode.fleet_address()
Expand Down
6 changes: 3 additions & 3 deletions test/rpc_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ defmodule RpcTest do
"id" => 1,
"jsonrpc" => "2.0",
"result" => %{
"blockNumber" => "0x03",
"blockNumber" => "0x3",
"contractAddress" => nil,
"cumulativeGasUsed" => _variable,
"from" => ^from,
"gasUsed" => "0x5208",
"logs" => [],
"logsBloom" =>
"0x0000000000000000000000000000000000000000000000000000000000000000",
"status" => "0x01",
"status" => "0x1",
"to" => ^to,
"transactionHash" => ^hash,
"transactionIndex" => "0x00"
"transactionIndex" => "0x0"
}
}} = ret
end
Expand Down
17 changes: 13 additions & 4 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,23 @@ defmodule TestHelper do
)
end

def is_macos() do
:os.type() == {:unix, :darwin}
end

def count_clones() do
{ret, _} = System.cmd("pgrep", ["-fc", @cookie])
{count, _} = Integer.parse(ret)
count
if is_macos() do
{ret, _} = System.cmd("pgrep", ["-f", @cookie])
String.split(ret, "\n", trim: true) |> Enum.count()
else
{ret, _} = System.cmd("pgrep", ["-fc", @cookie])
{count, _} = Integer.parse(ret)
count
end
end

def kill_clones() do
System.cmd("pkill", ["-fc", "-9", @cookie])
System.cmd("pkill", ["-9", "-f", @cookie])
:ok = wait_clones(0, 60)
end

Expand Down

0 comments on commit c1da2a4

Please sign in to comment.