Current section

34 Versions

Jump to

Compare versions

20 files changed
+377 additions
-417 deletions
  @@ -5,3 +5,5 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
5 5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 6
7 7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 +
9 + priv/patches contains header files which are LGPL 2.1, that are only used for cross-compiling arm32 software.
  @@ -23,10 +23,6 @@ end
23 23
24 24 Docs can be found at [https://hexdocs.pm/zigler](https://hexdocs.pm/zigler).
25 25
26 - once you have this dependency, you should cache the zig build tools by running the following:
27 -
28 - `mix zigler.get_zig latest`
29 -
30 26 ## Currently supported platforms
31 27
32 28 - Linux
  @@ -38,3 +38,12 @@ Thanks to Dave Cottlehuber @dch for testing.
38 38
39 39 - supported zig version: 0.6.0
40 40 - disabled `:long` mode
41 +
42 + ## 0.3.0-pre2
43 +
44 + - support for (and autodetect) nerves
45 + - use erlang nif headers taken from the `include` directory of your erts.
46 + - correct and verified support for releases
47 + - adds a mechanism for patching errors in zig/llvm releases
48 + - adds ~z for substituted values
49 + - zigler fetches zig on compile when it's in prod.
  @@ -11,14 +11,14 @@
11 11 <<"lib/zigler/compiler.ex">>,<<"lib/zigler/assembler.ex">>,
12 12 <<"lib/zigler/typespec.ex">>,<<"lib/zigler/doc">>,
13 13 <<"lib/zigler/doc/parser.ex">>,<<"lib/zigler/doc/retriever.ex">>,
14 - <<"lib/zigler/code">>,<<"lib/zigler/code/long_running.ex">>,
15 - <<"lib/zigler/parser.ex">>,<<"lib/zigler/zig.ex">>,<<"lib/zigler/unit.ex">>,
16 - <<"lib/zigler/code.ex">>,<<"lib/mix.tasks">>,
17 - <<"lib/mix.tasks/zigler.get_zig.ex">>,<<"lib/mix.tasks/zig_doc.ex">>,
18 - <<"lib/zigler.ex">>,<<"mix.exs">>,<<"README.md">>,<<"LICENSE">>,
19 - <<"VERSIONS.md">>,<<"priv">>,<<"priv/include">>,
20 - <<"priv/include/erl_nif_zig.h">>,<<"priv/beam">>,<<"priv/beam/beam.zig">>,
21 - <<"priv/beam/erl_nif.zig">>]}.
14 + <<"lib/zigler/patches.ex">>,<<"lib/zigler/code">>,
15 + <<"lib/zigler/code/long_running.ex">>,<<"lib/zigler/parser.ex">>,
16 + <<"lib/zigler/zig.ex">>,<<"lib/zigler/unit.ex">>,<<"lib/zigler/code.ex">>,
17 + <<"lib/mix.tasks">>,<<"lib/mix.tasks/zig_doc.ex">>,<<"lib/zigler.ex">>,
18 + <<"mix.exs">>,<<"README.md">>,<<"LICENSE">>,<<"VERSIONS.md">>,<<"priv">>,
19 + <<"priv/beam">>,<<"priv/beam/beam.zig">>,<<"priv/beam/erl_nif.zig">>,
20 + <<"priv/patches">>,<<"priv/patches/pthreadtypes-arch.h">>,
21 + <<"priv/patches/struct_rwlock.h">>]}.
22 22 {<<"licenses">>,[<<"MIT">>]}.
23 23 {<<"links">>,
24 24 [{<<"GitHub">>,<<"https://github.com/ityonemo/zigler">>},
  @@ -45,4 +45,4 @@
45 45 {<<"optional">>,false},
46 46 {<<"repository">>,<<"hexpm">>},
47 47 {<<"requirement">>,<<"~> 0.21">>}]]}.
48 - {<<"version">>,<<"0.3.0-pre">>}.
48 + {<<"version">>,<<"0.3.0-pre2">>}.
  @@ -1,97 +0,0 @@
1 - defmodule Mix.Tasks.Zigler.GetZig do
2 -
3 - use Mix.Task
4 -
5 - @moduledoc """
6 - gets a zig version and puts it into the zigler directory under
7 - the subdirectory zig.
8 -
9 - ## usage
10 -
11 - `mix zigler.get_zig <version>`
12 -
13 - version can be "latest"
14 - """
15 -
16 - @shortdoc "caches a version of zig."
17 -
18 - require Logger
19 - require Zigler
20 -
21 - alias Zigler.Compiler
22 -
23 - @zig_dir_path Path.expand("../../zig", Path.dirname(__ENV__.file))
24 -
25 - @impl true
26 - def run(["latest"]) do
27 - run([latest_version()])
28 - end
29 - def run([version]) do
30 -
31 - # make sure that we're in the correct operating system.
32 - if match?({:win32, _}, :os.type()) do
33 - Mix.raise("""
34 - non-unix systems not currently supported.
35 -
36 - If you think you can help, please help out! There's no
37 - reason why zigler can't run on MacOS, butI have no
38 - way of testing anything MacOS related.
39 -
40 - https://github.com/ityonemo/zigler/issues/15
41 - """)
42 - end
43 -
44 - Logger.configure(level: :info)
45 - Application.ensure_all_started(:mojito)
46 -
47 - tarfile = Compiler.basename(version) <> ".tar.xz"
48 - # make sure the zig directory path exists and is ready.
49 - File.mkdir_p!(@zig_dir_path)
50 - zig_download_path = Path.join(@zig_dir_path, tarfile)
51 -
52 - unless File.exists?(zig_download_path) do
53 - Logger.info("downloading zig version #{version} and caching in #{@zig_dir_path}.")
54 - download_location = "https://ziglang.org/download/#{version}/#{tarfile}"
55 -
56 - download_zig_tarball(zig_download_path, download_location)
57 - end
58 -
59 - # untar the zig directory.
60 - zig_version_cache = Path.join(@zig_dir_path, Compiler.basename(version))
61 - unless File.dir?(zig_version_cache) do
62 - System.cmd("tar", ["xvf", tarfile], cd: @zig_dir_path)
63 - end
64 - end
65 -
66 - def download_zig_tarball(zig_download_path, download_location) do
67 - Application.ensure_all_started(:ssl)
68 - case Mojito.get(download_location, [], pool: false, timeout: 100_000) do
69 - {:ok, download = %{status_code: 200}} ->
70 - File.write!(zig_download_path, download.body)
71 - _ -> Mix.raise("failed to download the appropriate zig binary.")
72 - end
73 - end
74 -
75 - @doc """
76 - queries the zig website to obtain the latest version of zig. Only performed at compile time.
77 - """
78 - def latest_version do
79 - Application.ensure_all_started(:ssl)
80 - # find the latest version by querying the download index
81 - case Mojito.get("https://ziglang.org/download/index.json", [], pool: false, timeout: 100_000) do
82 - {:ok, %{status_code: 200, body: json}} ->
83 - json
84 - |> Jason.decode!
85 - |> Map.keys
86 - |> Enum.reject(&(&1 == "master"))
87 - |> Enum.map(&String.split(&1, "."))
88 - |> Enum.map(&List.to_tuple/1)
89 - |> Enum.sort
90 - |> List.last
91 - |> Tuple.to_list
92 - |> Enum.join(".")
93 - _ -> Mix.raise("failed to ascertain the latest version of zig.")
94 - end
95 - end
96 -
97 - end
Loading more files…