137 lines
4.5 KiB
Elixir
137 lines
4.5 KiB
Elixir
defmodule BDS.MixProject do
|
|
use Mix.Project
|
|
|
|
def project do
|
|
ensure_xla_compiler_flags()
|
|
|
|
[
|
|
app: :bds,
|
|
version: "0.1.0",
|
|
elixir: "~> 1.17",
|
|
default_release: :bds,
|
|
releases: releases(),
|
|
start_permanent: Mix.env() == :prod,
|
|
dialyzer: dialyzer(),
|
|
aliases: aliases(),
|
|
deps: deps()
|
|
]
|
|
end
|
|
|
|
# XLA 0.9.x headers (pulled by exla) illegally specialize `std::is_signed`,
|
|
# which Apple clang 17+/libc++ rejects with a hard `-Winvalid-specialization`
|
|
# error, breaking the exla NIF build. Disable just that diagnostic on macOS so
|
|
# the C++ compile succeeds. Guarded to Darwin so the Linux/gcc build path is
|
|
# untouched. Appends rather than overwrites any CFLAGS the caller already set.
|
|
defp ensure_xla_compiler_flags do
|
|
if :os.type() == {:unix, :darwin} do
|
|
flag = "-Wno-invalid-specialization"
|
|
current = System.get_env("CFLAGS", "")
|
|
|
|
unless String.contains?(current, flag) do
|
|
System.put_env("CFLAGS", String.trim(flag <> " " <> current))
|
|
end
|
|
end
|
|
end
|
|
|
|
def application do
|
|
[
|
|
extra_applications: [:logger, :wx, :ssl],
|
|
mod: {BDS.Application, []}
|
|
]
|
|
end
|
|
|
|
def cli do
|
|
[preferred_envs: [validate: :test]]
|
|
end
|
|
|
|
defp deps do
|
|
[
|
|
{:ecto_sql, "~> 3.14"},
|
|
{:ecto_sqlite3, "~> 0.24"},
|
|
{:luerl, "~> 1.5"},
|
|
{:jason, "~> 1.4"},
|
|
{:optimus, "~> 0.5"},
|
|
{:mdex, "~> 0.13"},
|
|
{:liquex, "~> 0.13.1"},
|
|
{:plug, "~> 1.18"},
|
|
{:bandit, "~> 1.5"},
|
|
{:req, "~> 0.5"},
|
|
{:live_toast, "~> 0.8.0"},
|
|
{:saxy, "~> 1.4"},
|
|
{:desktop, "~> 1.5"},
|
|
{:ex_ratatui, "~> 0.11"},
|
|
{:image, "~> 0.67"},
|
|
{:nx, "~> 0.10"},
|
|
# Only one ML inference backend ships per platform; NIF releases are
|
|
# host-built, so the build OS is the target OS. EXLA (283 MB XLA CPU
|
|
# payload) never runs in the macOS app — EMLX always wins on Apple
|
|
# Silicon — but `runtime: false` alone can't exclude it there because
|
|
# the `image` dep declares exla as an optional application, which drags
|
|
# it into the release whenever it exists in the prod dep tree. Scoping
|
|
# it to dev/test on macOS keeps it fully out of macOS releases while
|
|
# Linux/Windows ship it as their production inference backend.
|
|
{:exla, "~> 0.10", if(macos?(), do: [only: [:dev, :test]], else: [])},
|
|
# Apple Silicon GPU (Metal) acceleration for embedding inference. Ships
|
|
# precompiled MLX binaries; the Neural backend prefers it on arm64 macOS
|
|
# and falls back to EXLA-CPU elsewhere (SPECGAPS A1-14c). Apple-only, so
|
|
# non-macOS releases exclude it (runtime: false deps stay out of
|
|
# releases — nothing pulls emlx in optionally, unlike exla above).
|
|
{:emlx, "~> 0.2.0", runtime: macos?()},
|
|
{:bumblebee, "~> 0.6.3"},
|
|
{:hnswlib, "~> 0.1.7"},
|
|
{:stemex, "~> 0.2.1"},
|
|
{:gettext, "~> 0.24"},
|
|
{:tailwind, "~> 0.3", runtime: Mix.env() == :dev},
|
|
{:esbuild, "~> 0.10", runtime: Mix.env() == :dev},
|
|
{:lazy_html, ">= 0.1.0", only: :test},
|
|
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
|
|
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false},
|
|
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
|
|
{:ex_doc, "~> 0.34", only: :dev, runtime: false}
|
|
]
|
|
end
|
|
|
|
defp aliases do
|
|
[
|
|
setup: ["deps.get", "ecto.setup"],
|
|
"ecto.setup": ["ecto.create", "ecto.migrate"],
|
|
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
|
"assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
|
|
"assets.build": ["tailwind default", "esbuild default", "esbuild monaco", "esbuild monaco_workers"],
|
|
"assets.deploy": [
|
|
"tailwind default --minify",
|
|
"esbuild default --minify",
|
|
"esbuild monaco --minify",
|
|
"esbuild monaco_workers --minify"
|
|
],
|
|
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
|
|
validate: ["test", "credo --strict", "deps.audit --ignore-file .mix_audit.ignore", "dialyzer"]
|
|
]
|
|
end
|
|
|
|
defp dialyzer do
|
|
env = Mix.env()
|
|
|
|
[
|
|
plt_add_apps: [:mix, :inets, :ssl, :nx, :exla, :emlx, :bumblebee, :hnswlib],
|
|
paths: ["_build/#{env}/lib/bds/ebin"]
|
|
]
|
|
end
|
|
|
|
defp releases do
|
|
[
|
|
bds: [
|
|
include_executables_for: [:unix, :windows],
|
|
applications: [bds: :permanent]
|
|
],
|
|
bds_mcp: [
|
|
path: "_build/#{Mix.env()}/rel/bds_mcp",
|
|
include_executables_for: [:unix, :windows],
|
|
applications: [bds: :permanent]
|
|
]
|
|
]
|
|
end
|
|
|
|
defp macos?, do: :os.type() == {:unix, :darwin}
|
|
end
|