Skip to content

Commit

Permalink
Make abi key optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Noarkhh committed Dec 11, 2023
1 parent d803621 commit 48aec6d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/bundlex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ defmodule Bundlex do
* architecture - e.g. `x86_64` or `arm64`
* vendor - e.g. `pc`
* os - operating system, e.g. `linux` or `darwin20.6.0`
* abi - application binary interface, e.g. `musl` or `gnu` (nil if unknown / non-existent)
* abi (optional) - application binary interface, e.g. `musl` or `gnu`
"""
@type target ::
%{architecture: String.t(), vendor: String.t(), os: String.t(), abi: String.t() | nil}
%{
required(:architecture) => String.t(),
required(:vendor) => String.t(),
required(:os) => String.t(),
optional(:abi) => String.t()
}
@doc """
A function returning a target triplet for the environment on which it is run.
"""
Expand All @@ -27,12 +32,16 @@ defmodule Bundlex do
[architecture, vendor, os | maybe_abi] =
:erlang.system_info(:system_architecture) |> List.to_string() |> String.split("-")

%{
target = %{
architecture: architecture,
vendor: vendor,
os: os,
abi: List.first(maybe_abi)
os: os
}

case maybe_abi do
[] -> target
[abi] -> Map.put(target, :abi, abi)
end
end

@doc """
Expand Down

0 comments on commit 48aec6d

Please sign in to comment.