From c0006e254b350ecca3dc60dcc8069661b0fe614a Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Fri, 28 Feb 2025 10:26:25 +0100 Subject: [PATCH] Support Linux MUSL v3 and v4 --- CHANGELOG.md | 11 ++++++----- README.md | 9 ++------- lib/tailwind.ex | 31 ++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e048849..8f128d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,14 @@ # CHANGELOG +## v0.3.1 + +* Support correct target for Linux MUSL with Tailwind v3. + ## v0.3.0 (2025-02-26) -Support Tailwind v4+. This release drops official support for Tailwind v3. -If you want to continue using Tailwind v3, please pin the `tailwind` dependency to a 0.2 version: +* Support Tailwind v4+. This release assumes Tailwind v4 for new projects. -```elixir -{:tailwind, "~> 0.2.0", only: :dev}` -``` +Note: v0.3.0 dropped target code for handling Linux MUSL with Tailwind v3. Use v0.3.1+ instead. ## v0.2.4 (2024-10-18) diff --git a/README.md b/README.md index 3af3ca4..e14efdc 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,8 @@ Tailwind version of choice: config :tailwind, version: "4.0.9" ``` -Note that `:tailwind` 0.3+ supports Tailwind v4+. If you need to use Tailwind v3, use - -``` -{:tailwind, "~> 0.2.0", only: :dev} -``` - -instead, and refer to [the README in the 0.2 branch](https://github.com/phoenixframework/tailwind/blob/v0.2/README.md). +Note that `:tailwind` 0.3+ assumes Tailwind v4+ by default. It still supports Tailwind v3, but some configuration options when setting up a new +project might be different. If you use Tailwind v3, also have a look at [the README in the 0.2 branch](https://github.com/phoenixframework/tailwind/blob/v0.2/README.md). Now you can install Tailwind by running: diff --git a/lib/tailwind.ex b/lib/tailwind.ex index 3d5503d..63b3115 100644 --- a/lib/tailwind.ex +++ b/lib/tailwind.ex @@ -282,23 +282,36 @@ defmodule Tailwind do {{:unix, :freebsd}, arch, _abi, 64} when arch in ~w(x86_64 amd64) -> "freebsd-x64" - {{:unix, :linux}, "aarch64", "musl", 64} -> - "linux-arm64-musl" + {{:unix, :linux}, "aarch64", abi, 64} -> + "linux-arm64" <> maybe_add_abi_suffix(abi) - {{:unix, :linux}, "aarch64", _abi, 64} -> - "linux-arm64" + {{:unix, :linux}, "arm", _abi, 32} -> + "linux-armv7" - {{:unix, _osname}, arch, "musl", 64} when arch in ~w(x86_64 amd64) -> - "linux-x64-musl" + {{:unix, :linux}, "armv7" <> _, _abi, 32} -> + "linux-armv7" - {{:unix, _osname}, arch, _abi, 64} when arch in ~w(x86_64 amd64) -> - "linux-x64" + {{:unix, _osname}, arch, abi, 64} when arch in ~w(x86_64 amd64) -> + "linux-x64" <> maybe_add_abi_suffix(abi) {_os, _arch, _abi, _wordsize} -> raise "tailwind is not available for architecture: #{arch_str}" end end + defp maybe_add_abi_suffix("musl") do + # Tailwind CLI v4+ added explicit musl versions for Linux as + # tailwind-linux-x64-musl + # tailwind-linux-arm64-musl + if Version.match?(configured_version(), "~> 4.0") do + "-musl" + else + "" + end + end + + defp maybe_add_abi_suffix(_), do: "" + defp fetch_body!(url, retry \\ true) when is_binary(url) do scheme = URI.parse(url).scheme url = String.to_charlist(url) @@ -339,7 +352,7 @@ defmodule Tailwind do The tailwind binary couldn't be found at: #{url} This could mean that you're trying to install a version that does not support the detected - target architecture. + target architecture. For example, Tailwind v4+ dropped support for 32-bit ARM. You can see the available files for the configured version at: