project init
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
defmodule Chromaprint.MixProject do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[
|
||||
app: :chromaprint,
|
||||
version: "0.1.0",
|
||||
elixir: "~> 1.20-rc",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
compilers: [:elixir_make] ++ Mix.compilers(),
|
||||
make_targets: ["all"],
|
||||
make_clean: ["clean"],
|
||||
make_env: &make_env/0
|
||||
]
|
||||
end
|
||||
|
||||
def application do
|
||||
[
|
||||
extra_applications: [:logger]
|
||||
]
|
||||
end
|
||||
|
||||
defp deps do
|
||||
[
|
||||
{:elixir_make, "~> 0.9", runtime: false},
|
||||
]
|
||||
end
|
||||
|
||||
defp make_env do
|
||||
verify_chromaprint_source!()
|
||||
|
||||
%{
|
||||
"ERTS_INCLUDE_DIR" => erts_include_dir(),
|
||||
"CHROMAPRINT_USE_SYSTEM" =>
|
||||
if(System.get_env("CHROMAPRINT_USE_SYSTEM") in ~w(1 true on ON YES yes),
|
||||
do: "ON",
|
||||
else: "OFF"
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
defp erts_include_dir do
|
||||
Path.join([
|
||||
:code.root_dir() |> to_string(),
|
||||
"erts-#{:erlang.system_info(:version)}",
|
||||
"include"
|
||||
])
|
||||
end
|
||||
|
||||
defp verify_chromaprint_source! do
|
||||
use_system = System.get_env("CHROMAPRINT_USE_SYSTEM") in ~w(1 true on ON YES yes)
|
||||
submodule_cmake = Path.join([__DIR__, "c_src", "chromaprint", "CMakeLists.txt"])
|
||||
|
||||
if not use_system and not File.exists?(submodule_cmake) do
|
||||
Mix.raise("""
|
||||
The chromaprint source submodule is missing at c_src/chromaprint/.
|
||||
|
||||
Either initialise it:
|
||||
|
||||
git submodule update --init c_src/chromaprint
|
||||
|
||||
Or, to link against a system-provided libchromaprint (recommended for
|
||||
Nix and other sandboxed builds), set CHROMAPRINT_USE_SYSTEM=1 and ensure
|
||||
chromaprint.h and libchromaprint can be found via the compiler's default
|
||||
paths (or CHROMAPRINT_INCLUDE_DIR / CHROMAPRINT_LIB_DIR if not).
|
||||
""")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user