Skip to content

Commit

Permalink
adds more changes to 0.11.1-pre-3
Browse files Browse the repository at this point in the history
  • Loading branch information
ityonemo committed Apr 4, 2024
1 parent b89f7cb commit 58d1de6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
16 changes: 11 additions & 5 deletions installer/mix.tasks/zig.get.ex
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,16 @@ defmodule Mix.Tasks.Zig.Get do
end

defp get_public_key(%{verify: false} = opts), do: opts

defp get_public_key(opts) do
# this might be fragile.
public_key = http_get!("https://ziglang.org/download/")
|> Floki.parse_document!()
|> Floki.find("[role=\"main\"] .container pre code")
|> Floki.text
|> String.trim
public_key =
http_get!("https://ziglang.org/download/")
|> Floki.parse_document!()
|> Floki.find("[role=\"main\"] .container pre code")
|> Floki.text()
|> String.trim()

%{opts | public_key: public_key}
end

Expand Down Expand Up @@ -229,15 +232,18 @@ defmodule Mix.Tasks.Zig.Get do
],
body_format: :binary
)

body
end

defp fetch_signature!(%{verify: false} = opts), do: opts

defp fetch_signature!(opts) do
%{opts | signature: http_get!(opts.url ++ ~c'.minisig')}
end

defp verify_signature!({bin, %{verify: false}}), do: bin

defp verify_signature!({bin, opts}) do
Minisign.verify!(bin, opts.signature, opts.public_key)
bin
Expand Down
11 changes: 6 additions & 5 deletions lib/zig/assembler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ defmodule Zig.Assembler do

opts = Keyword.merge([to: directory], opts)

opts = if Keyword.has_key?(opts, :link_lib) do
Keyword.put(opts, :link_lib, adjust_link_lib(opts[:link_lib], opts[:from]))
end
opts =
if Keyword.has_key?(opts, :link_lib) do
Keyword.put(opts, :link_lib, adjust_link_lib(opts[:link_lib], opts[:from]))
end

#Enum.each(opts[:link_lib], fn
# Enum.each(opts[:link_lib], fn
# {:system, _} -> :pass
# lib ->
# target = Path.join(opts[:to], lib)
Expand All @@ -46,7 +47,7 @@ defmodule Zig.Assembler do
# |> Path.join(lib)
# |> File.ln_s!(target)
# end
#end)
# end)

Builder.build(module, opts)
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Zigler.MixProject do

[
app: :zigler,
version: "0.11.1-pre-2",
version: "0.11.1-pre-3",
elixir: "~> 1.13",
start_permanent: env == :prod,
elixirc_paths: elixirc_paths(env),
Expand Down
2 changes: 1 addition & 1 deletion test/_support/support_content.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ defmodule ZiglerTest.SupportContent do
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/integration/cxx/easy_c_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if {:unix, :linux} == :os.type() do
otp_app: :zigler,
easy_c: "cblas.h",
link_lib: {:system, "blas"},
#leak_check: true,
# leak_check: true,
nifs: [
:cblas_dasum,
cblas_daxpy: [return: [4, length: {:arg, 0}]],
Expand Down
7 changes: 5 additions & 2 deletions test/integration/cxx/link_lib_local_test.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
ZiglerTest.SupportContent.ensure_lib("test/integration/cxx/libtest.a", "test/integration/cxx/test.zig")
ZiglerTest.SupportContent.ensure_lib(
"test/integration/cxx/libtest.a",
"test/integration/cxx/test.zig"
)

defmodule ZiglerTest.Integration.CXX.LinkLibLocalTest do
use ZiglerTest.IntegrationCase, async: true
Expand All @@ -18,4 +21,4 @@ defmodule ZiglerTest.Integration.CXX.LinkLibLocalTest do
test "can link a local library" do
assert 48 == test_add_one(47)
end
end
end

0 comments on commit 58d1de6

Please sign in to comment.