From ffdbefa6797176543efa750212f48fe9495caaac Mon Sep 17 00:00:00 2001
From: Martin Nijboer <mrnijboer@gmail.com>
Date: Fri, 8 Dec 2023 19:18:20 +0100
Subject: [PATCH] Upgrade RustlerPrecompiled and add build targets

---
 .github/workflows/elixir.yml     |  4 ++--
 .tool-versions                   |  4 ++--
 CHANGELOG.md                     |  7 ++++++-
 lib/uuidv7.ex                    | 12 +++---------
 mix.exs                          | 12 ++++++------
 mix.lock                         |  8 ++++----
 native/uuidv7/.cargo/config.toml |  3 ---
 native/uuidv7/Cargo.lock         | 14 +++++++-------
 native/uuidv7/Cargo.toml         |  8 ++++----
 9 files changed, 34 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml
index 6398f15..60d9d57 100644
--- a/.github/workflows/elixir.yml
+++ b/.github/workflows/elixir.yml
@@ -14,8 +14,8 @@ jobs:
       - uses: actions/checkout@v3
       - uses: erlef/setup-beam@v1
         with:
-          elixir-version: "1.14.2"
-          otp-version: "25.1.2"
+          elixir-version: "1.15.7"
+          otp-version: "26.1.2"
       - uses: actions/cache@v3
         with:
           path: deps
diff --git a/.tool-versions b/.tool-versions
index 12be720..989b51f 100644
--- a/.tool-versions
+++ b/.tool-versions
@@ -1,2 +1,2 @@
-erlang 25.1.2
-elixir 1.14.2-otp-25
+erlang 26.1.2
+elixir 1.15.7-otp-26
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ac9a3b..d527d9d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,12 @@
+# 0.2.2
+
+- Add more build targets for the NIFs
+- Build NIFs for version 2.16 and 2.17
+
 # 0.2.1
 
 - Add more build targets for the NIFs
-- Build NIFs for version 2.17
+- Build NIFs for version 2.16
 
 # 0.2.0
 
diff --git a/lib/uuidv7.ex b/lib/uuidv7.ex
index 7ce3267..4f69fbf 100644
--- a/lib/uuidv7.ex
+++ b/lib/uuidv7.ex
@@ -89,15 +89,9 @@ defmodule UUIDv7 do
     otp_app: :uuidv7,
     crate: "uuidv7",
     base_url: "https://github.com/martinthenth/uuidv7/releases/download/v#{@version}",
-    targets: [
-      "aarch64-unknown-linux-gnu",
-      "aarch64-apple-darwin",
-      "riscv64gc-unknown-linux-gnu",
-      "x86_64-apple-darwin",
-      "x86_64-unknown-linux-gnu",
-      "x86_64-unknown-linux-musl"
-    ],
-    nif_versions: ["2.16"],
+    nif_versions: ["2.16", "2.17"],
+    targets:
+      Enum.uniq(["aarch64-unknown-linux-musl" | RustlerPrecompiled.Config.default_targets()]),
     force_build: System.get_env("FORCE_BUILD") in ["1", "true"],
     version: @version
 
diff --git a/mix.exs b/mix.exs
index 3fdc00e..747e580 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,7 +1,7 @@
 defmodule UUIDv7.MixProject do
   use Mix.Project
 
-  @version "0.2.1"
+  @version "0.2.2"
   @source_url "https://github.com/martinthenth/uuidv7"
   @changelog_url "https://github.com/martinthenth/uuidv7/blob/main/CHANGELOG.md"
 
@@ -26,14 +26,14 @@ defmodule UUIDv7.MixProject do
 
   defp deps do
     [
-      {:rustler, "~> 0.30.0"},
-      {:ecto, "~> 3.10"},
+      {:benchee, "~> 1.1", only: :dev},
       {:credo, "~> 1.6", only: [:dev, :test], runtime: false},
       {:dialyxir, "~> 1.0", only: [:dev], runtime: false},
+      {:ecto, "~> 3.10"},
       {:ex_doc, "~> 0.27", only: :dev, runtime: false},
-      {:benchee, "~> 1.1", only: :dev},
-      {:uniq, "~> 0.1", only: :dev},
-      {:rustler_precompiled, "~> 0.6"}
+      {:rustler, "~> 0.30.0", optional: true},
+      {:rustler_precompiled, "~> 0.7"},
+      {:uniq, "~> 0.1", only: :dev}
     ]
   end
 
diff --git a/mix.lock b/mix.lock
index 53efab7..71958fe 100644
--- a/mix.lock
+++ b/mix.lock
@@ -6,16 +6,16 @@
   "decimal": {:hex, :decimal, "2.1.1", "5611dca5d4b2c3dd497dec8f68751f1f1a54755e8ed2a966c2633cf885973ad6", [:mix], [], "hexpm", "53cfe5f497ed0e7771ae1a475575603d77425099ba5faef9394932b35020ffcc"},
   "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
   "dialyxir": {:hex, :dialyxir, "1.4.2", "764a6e8e7a354f0ba95d58418178d486065ead1f69ad89782817c296d0d746a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "516603d8067b2fd585319e4b13d3674ad4f314a5902ba8130cd97dc902ce6bbd"},
-  "earmark_parser": {:hex, :earmark_parser, "1.4.37", "2ad73550e27c8946648b06905a57e4d454e4d7229c2dafa72a0348c99d8be5f7", [:mix], [], "hexpm", "6b19783f2802f039806f375610faa22da130b8edc21209d0bff47918bb48360e"},
+  "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
   "ecto": {:hex, :ecto, "3.11.1", "4b4972b717e7ca83d30121b12998f5fcdc62ba0ed4f20fd390f16f3270d85c3e", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ebd3d3772cd0dfcd8d772659e41ed527c28b2a8bde4b00fe03e0463da0f1983b"},
   "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
   "ex_doc": {:hex, :ex_doc, "0.30.9", "d691453495c47434c0f2052b08dd91cc32bc4e1a218f86884563448ee2502dd2", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d7aaaf21e95dc5cddabf89063327e96867d00013963eadf2c6ad135506a8bc10"},
   "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
   "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
-  "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
+  "makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"},
   "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
-  "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
-  "nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
+  "makeup_erlang": {:hex, :makeup_erlang, "0.1.3", "d684f4bac8690e70b06eb52dad65d26de2eefa44cd19d64a8095e1417df7c8fd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "b78dc853d2e670ff6390b605d807263bf606da3c82be37f9d7f68635bd886fc9"},
+  "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"},
   "rustler": {:hex, :rustler, "0.30.0", "cefc49922132b072853fa9b0ca4dc2ffcb452f68fb73b779042b02d545e097fb", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:toml, "~> 0.6", [hex: :toml, repo: "hexpm", optional: false]}], "hexpm", "9ef1abb6a7dda35c47cfc649e6a5a61663af6cf842a55814a554a84607dee389"},
   "rustler_precompiled": {:hex, :rustler_precompiled, "0.7.1", "ecadf02cc59a0eccbaed6c1937303a5827fbcf60010c541595e6d3747d3d0f9f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:rustler, "~> 0.23", [hex: :rustler, repo: "hexpm", optional: true]}], "hexpm", "b9e4657b99a1483ea31502e1d58c464bedebe9028808eda45c3a429af4550c66"},
   "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
diff --git a/native/uuidv7/.cargo/config.toml b/native/uuidv7/.cargo/config.toml
index 6c5a6d8..fe3ae51 100644
--- a/native/uuidv7/.cargo/config.toml
+++ b/native/uuidv7/.cargo/config.toml
@@ -1,9 +1,6 @@
 [target.'cfg(target_os = "macos")']
 rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]
 
-[target.'cfg(any(unix))']
-rustflags = ["--cfg", "uuid_unstable"]
-
 # See https://github.com/rust-lang/rust/issues/59302
 [target.x86_64-unknown-linux-musl]
 rustflags = ["-C", "target-feature=-crt-static"]
diff --git a/native/uuidv7/Cargo.lock b/native/uuidv7/Cargo.lock
index 9f8a336..96d9c63 100644
--- a/native/uuidv7/Cargo.lock
+++ b/native/uuidv7/Cargo.lock
@@ -95,9 +95,9 @@ checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
 
 [[package]]
 name = "rustler"
-version = "0.29.0"
+version = "0.30.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "095fb0fb2864560480609c5b1427fe9f3872f6b3e400036f5531e8f06ff33026"
+checksum = "c4b4fea69e23de68c42c06769d6624d2d018da550c17244dd4b691f90ced4a7e"
 dependencies = [
  "lazy_static",
  "rustler_codegen",
@@ -106,9 +106,9 @@ dependencies = [
 
 [[package]]
 name = "rustler_codegen"
-version = "0.29.0"
+version = "0.30.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a8911f25973c1d68a3ffdea53d664026f6b0877c949bd3f9f5bc263385c33553"
+checksum = "406061bd07aaf052c344257afed4988c5ec8efe4d2352b4c2cf27ea7c8575b12"
 dependencies = [
  "heck",
  "proc-macro2",
@@ -154,9 +154,9 @@ dependencies = [
 
 [[package]]
 name = "uuid"
-version = "1.3.4"
+version = "1.6.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0fa2982af2eec27de306107c027578ff7f423d65f7250e40ce0fea8f45248b81"
+checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
 dependencies = [
  "atomic",
  "getrandom",
@@ -164,7 +164,7 @@ dependencies = [
 
 [[package]]
 name = "uuidv7"
-version = "0.1.0"
+version = "0.1.1"
 dependencies = [
  "rustler",
  "uuid",
diff --git a/native/uuidv7/Cargo.toml b/native/uuidv7/Cargo.toml
index ecf447d..19a6d10 100644
--- a/native/uuidv7/Cargo.toml
+++ b/native/uuidv7/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "uuidv7"
-version = "0.1.0"
+version = "0.1.1"
 authors = []
 edition = "2021"
 
@@ -10,8 +10,8 @@ path = "src/lib.rs"
 crate-type = ["cdylib"]
 
 [dependencies]
-rustler = { version = "0.29", default-features = false, features = [
+rustler = { version = "0.30", default-features = false, features = [
   "derive",
-  "nif_version_2_15",
+  "nif_version_2_16",
 ] }
-uuid = { version = "1.3.4", features = ["v7"] }
+uuid = { version = "1.6.1", features = ["v7"] }