82 lines
2.4 KiB
Elixir
82 lines
2.4 KiB
Elixir
defmodule Floof.MixProject do
|
|
use Mix.Project
|
|
|
|
def project do
|
|
[
|
|
app: :floof,
|
|
version: "0.1.0",
|
|
elixir: "~> 1.13",
|
|
start_permanent: Mix.env() == :prod,
|
|
compilers: [:asn1] ++ Mix.compilers(),
|
|
asn1_options: [:per],
|
|
deps: deps()
|
|
]
|
|
end
|
|
|
|
# Run "mix help compile.app" to learn about applications.
|
|
def application do
|
|
[
|
|
extra_applications: [:asn1, :logger],
|
|
mod: {Floof.Application, []},
|
|
env: [
|
|
port: 2540,
|
|
# markers have the structure {bool(), {:RelativeDistinguishedName, oid-as-list(), value()}}
|
|
# all of the markers marked with 'true' should be included in each message to-be-processed
|
|
# and none of the markers marked with 'false' should be included. the same holds for attrs.
|
|
markers: [],
|
|
attrs: [],
|
|
# these are the markers of form {:RelativeDistinguishedName, oid-as-list(), value()}
|
|
# which get added to all processed messages
|
|
set_markers: [],
|
|
keydb: ".keydb",
|
|
]
|
|
]
|
|
end
|
|
|
|
# Run "mix help deps" to learn about dependencies.
|
|
defp deps do
|
|
[
|
|
{:enacl, "~> 1.0.0"}
|
|
# {:dep_from_hexpm, "~> 0.3.0"},
|
|
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
|
|
]
|
|
end
|
|
end
|
|
|
|
# source: https://github.com/processone/ejabberd/blob/441eca75b23ecc3fd2ae35655d23061fb28cdefa/mix.exs
|
|
defmodule Mix.Tasks.Compile.Asn1 do
|
|
use Mix.Task
|
|
alias Mix.Compilers.Erlang
|
|
|
|
@recursive true
|
|
@manifest ".compile.asn1"
|
|
|
|
def run(args) do
|
|
{opts, _, _} = OptionParser.parse(args, switches: [force: :boolean])
|
|
|
|
project = Mix.Project.config
|
|
source_paths = project[:asn1_paths] || ["asn1"]
|
|
dest_paths = project[:asn1_target] || ["src"]
|
|
mappings = Enum.zip(source_paths, dest_paths)
|
|
options = project[:asn1_options] || []
|
|
|
|
force = case opts[:force] do
|
|
:true -> [force: true]
|
|
_ -> [force: false]
|
|
end
|
|
|
|
Erlang.compile(manifest(), mappings, :asn1, :erl, force, fn
|
|
input, output ->
|
|
options = options ++ [:noobj, outdir: Erlang.to_erl_file(Path.dirname(output))]
|
|
case :asn1ct.compile(Erlang.to_erl_file(input), options) do
|
|
:ok -> {:ok, :done}
|
|
error -> error
|
|
end
|
|
end)
|
|
end
|
|
|
|
def manifests, do: [manifest()]
|
|
defp manifest, do: Path.join(Mix.Project.manifest_path, @manifest)
|
|
|
|
def clean, do: Erlang.clean(manifest())
|
|
end
|