Skip to content

Commit

Permalink
Update to Zig 0.13 (#480)
Browse files Browse the repository at this point in the history
* Fix Elixir 1.17 compilation warnings

* Update to Zig 0.13
  • Loading branch information
rbino authored Aug 12, 2024
1 parent 781b45a commit a4e3f08
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ by adding `zigler` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:zigler, "~> 0.12.1", runtime: false}
{:zigler, "~> 0.13.0", runtime: false}
]
end
```
Expand All @@ -43,7 +43,7 @@ have difficulty.
```erlang
{plugins, [rebar_mix]}.

{deps, [{zigler, "0.12"}]}.
{deps, [{zigler, "0.13"}]}.

```

Expand Down
5 changes: 4 additions & 1 deletion VERSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ Thanks to Dave Cottlehuber @dch for testing.
- smarter `beam.send`
- attributes imported as compile-time values

## 0.13.0
- updated to zig 0.13.0

## Upcoming
- `precompiled` mode that will let you obtain packages with precompiled assets.
- Breaking changes:
Expand All @@ -143,4 +146,4 @@ Thanks to Dave Cottlehuber @dch for testing.

## Possible
- `beam.call` which lets you call back a beam function.
- `struct` which lets you declare a struct inside your zig code as the module's struct
- `struct` which lets you declare a struct inside your zig code as the module's struct
2 changes: 1 addition & 1 deletion installer/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ end
defmodule Zig.Get.MixProject do
use Mix.Project

@version "0.12.2"
@version "0.13.0"
@scm_url "https://github.com/e-xyza/zigler"

@elixir_requirement "~> 1.14"
Expand Down
2 changes: 1 addition & 1 deletion installer/mix.tasks/zig.get.ex
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ defmodule Mix.Tasks.Zig.Get do
end
end

@default_version "0.12.1"
@default_version "0.13.0"

defp defaults do
{os, arch} = Zig.Get.os_info()
Expand Down
2 changes: 1 addition & 1 deletion lib/zig/templates/build.zig.eex
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn build(b: *std.Build) void {

const lib = b.addSharedLibrary(.{
.name = "<%= @module %>",
.root_source_file = .{.path = "module.zig"},
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "module.zig"} },
.version = .{.major = <%= @version.major %>,
.minor = <%= @version.minor %>,
.patch = <%= @version.patch %>},
Expand Down
4 changes: 2 additions & 2 deletions lib/zig/type/enum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defmodule Zig.Type.Enum do

defp accumulate(number, []), do: [number]
defp accumulate(number, [succ | rest]) when succ == number + 1, do: [number..succ | rest]
defp accumulate(number, [succ..last | rest]) when succ == number + 1, do: [number..last | rest]
defp accumulate(number, [succ..last//_ | rest]) when succ == number + 1, do: [number..last | rest]
defp accumulate(number, noncontiguous), do: [number | noncontiguous]

defp unionize(content) do
Expand All @@ -95,7 +95,7 @@ defmodule Zig.Type.Enum do
end)
end

defp rerender(a..b) do
defp rerender(a..b//_) do
quote do
unquote(a)..unquote(b)
end
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Zigler.MixProject do
use Mix.Project

def zig_version, do: "0.12.1"
def zig_version, do: "0.13.0"

def project do
env = Mix.env()
Expand Down Expand Up @@ -72,7 +72,7 @@ defmodule Zigler.MixProject do
{:zig_parser, "~> 0.4.0"},
# utility to help manage type protocols
{:protoss, "~> 0.2"},
{:zig_get, "~> 0.12.1"},
{:zig_get, path: "installer"},
# documentation
{:markdown_formatter, "~> 0.6", only: :dev, runtime: false},
{:zig_doc, "~> 0.4.0", only: :dev, runtime: false}
Expand Down
1 change: 0 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
"pegasus": {:hex, :pegasus, "0.2.5", "38123461fe41add54f715ce41f89137a31cd217d353005b057f88b9b67c39b6f", [:mix], [{:nimble_parsec, "~> 1.2", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "ee80708608807f4447f1da1e6e0ebd9604f5bda4fbe2d4bdd9aa6dd67afde020"},
"protoss": {:hex, :protoss, "0.2.1", "fcf437ed65178d6cbf9a600886e3da9f7173697223972f062ee593941c2588b1", [:mix], [], "hexpm", "2261dbdc4d5913ce1e88d1410108d97f21140a118f45f6acc3edc4ecdb952052"},
"zig_doc": {:hex, :zig_doc, "0.4.0", "fdaee133165fa3c3a17e8ff7d62ab60be4ad011ff128d567151dbca2026f44d0", [:mix], [{:ex_doc, "~> 0.34.2", [hex: :ex_doc, repo: "hexpm", optional: false]}, {:zig_parser, "~> 0.4.0", [hex: :zig_parser, repo: "hexpm", optional: false]}], "hexpm", "d07c69a210d7ae3732493bf7e55628e30c4a68fec47c244e3f40f6c7323b819d"},
"zig_get": {:hex, :zig_get, "0.12.2", "713de7f73c508386e7ac93c8479b1e196a24834c95fd03f1dd3dc8133857c063", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "81a5c562fdef8b4affd28a94a41a725c355b26021f5a8ddb550f19d319aa3010"},
"zig_parser": {:hex, :zig_parser, "0.4.0", "5230576fcea30c061f08f6053448ad3dc5194a45485065564a7f8047bb351ce9", [:mix], [{:pegasus, "~> 0.2.4", [hex: :pegasus, repo: "hexpm", optional: false]}], "hexpm", "ec54cf14e80a1485e29a80b42756d0421426db81eb9e2630721fd46ab5c21bcb"},
}
7 changes: 6 additions & 1 deletion test/_support/compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ defmodule ZiglerTest.Compiler do
end

def compile_erlang(file) do
{:ok, mod} = :compile.file(file, [:return_errors, outdir: :code.lib_dir(:zigler, :ebin)])
{:ok, mod} =
:compile.file(file, [
:return_errors,
outdir: :filename.join(:code.lib_dir(:zigler), ~c"ebin")
])

Code.ensure_loaded(mod)
end
end
2 changes: 1 addition & 1 deletion test/_support/spec_template.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule ZiglerTest.SpecTemplate do
end
end

defp convert(a..b, context) do
defp convert(a..b//_, context) do
quote do
{:type, _, :range, [unquote(convert(a, context)), unquote(convert(b, context))]}
end
Expand Down

0 comments on commit a4e3f08

Please sign in to comment.