defmodule LLVMConfig do defp llvm_config_from_sys_env() do System.get_env("LLVM_CONFIG_PATH", "llvm-config") end defp run_llvm_config(sub_cmd) do llvm_config = llvm_config_from_sys_env() try do case System.cmd(llvm_config, [sub_cmd]) do {path, 0} -> {:ok, String.trim(path)} _ -> {:error, "failed to run llvm-config"} end rescue value -> {:error, "failed to run llvm-config, #{inspect(value)}"} end end def include_dir() do run_llvm_config("--includedir") end def lib_dir() do run_llvm_config("--libdir") end end