defmodule MDExNative.MixProject do use Mix.Project @source_url "https://github.com/leandrocp/mdex_native" @version "0.1.2" @force_build? System.get_env("MDEX_NATIVE_BUILD") in ["1", "true"] def project do [ app: :mdex_native, version: @version, elixir: "~> 1.15", start_permanent: Mix.env() == :prod, package: package(), deps: deps(), aliases: aliases(), name: "MDExNative", homepage_url: @source_url, description: "Native foundation for MDEx: Comrak, Ammonia, and Lumis" ] end def application do [ extra_applications: [:logger] ] end defp package do [ maintainers: ["Leandro Pereira"], licenses: ["MIT"], links: %{ GitHub: @source_url }, files: ~w[ lib examples native/mdex_native_nif/src native/mdex_native_nif/.cargo native/mdex_native_nif/Cargo.* native/mdex_native_nif/Cross.toml mix.exs README.md LICENSE.md CHANGELOG.md checksum-Elixir.MDExNative.Native.exs ] ] end defp deps do [ {:rustler, "~> 0.32", optional: not @force_build?}, {:rustler_precompiled, "~> 0.7"} ] end defp aliases do [ docs: &build_docs/1, setup: ["deps.get", "compile"], "gen.checksum": "rustler_precompiled.download MDExNative.Native --all --print", "format.all": ["format", "rust.fmt"], "rust.lint": [ "cmd cargo clippy --manifest-path=native/mdex_native_nif/Cargo.toml -- -Dwarnings" ], "rust.fmt": ["cmd cargo fmt --manifest-path=native/mdex_native_nif/Cargo.toml --all"] ] end defp build_docs(_) do Mix.Task.run("compile") ex_doc = Path.join(Mix.path_for(:escripts), "ex_doc") unless File.exists?(ex_doc) do raise "cannot build docs because the ex_doc escript is not installed, " <> "make sure to run `mix escript.install hex ex_doc` before" end args = ["MDExNative", @version, Mix.Project.compile_path()] opts = ~w[--main MDExNative.Comrak --source-ref v#{@version} --source-url #{@source_url}] System.cmd(ex_doc, args ++ opts) end end