floof/mix.exs

107 lines
3.3 KiB
Elixir
Raw Normal View History

2022-11-22 15:41:59 +00:00
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(),
2022-11-22 16:43:01 +00:00
asn1_options: [:per],
2022-11-24 18:38:32 +00:00
deps: deps(),
package: package()
2022-11-22 15:41:59 +00:00
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:asn1, :crypto, :logger],
2022-11-23 22:27:16 +00:00
mod: {Floof.Application, []},
env: [
2022-11-24 19:29:30 +00:00
# listen_port cam be set to `nil` to disable to server-socket listener
listen_port: 2540,
# listen_opts can be used to specify e.g. `[ip: {192,168,0,133}]` a specific interface IP
listen_opts: [],
# upstreams have structure `{host, port}` or `{host}` (port defaults to 2540)
upstreams: [],
2022-11-23 22:27:16 +00:00
# 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: [],
# a list of functions which can be used to further filter packets
# (by returning nil if unwanted) and modify them
extra_filters: [],
2022-11-26 14:34:51 +00:00
# file locations
# the spool dir saves messages in-transit, and is used to prevent RAM OOM
spool_dir: "mock_spool",
2022-11-26 14:42:15 +00:00
# the sessions file is used for persistence of session data across restarts
2022-11-26 15:04:37 +00:00
sessions_file: "mock_sessions.dets"
2022-11-23 22:27:16 +00:00
]
2022-11-22 15:41:59 +00:00
]
end
2022-11-24 18:38:32 +00:00
defp package do
[
maintainers: ["Alain Zscheile"],
licenses: ["Apache-2.0"]
]
end
2022-11-22 15:41:59 +00:00
# Run "mix help deps" to learn about dependencies.
defp deps do
[
2022-11-27 23:54:25 +00:00
{:enacl, "~> 1.0.0"},
{:logger_file_backend, "~> 0.0.13"}
2022-11-22 15:41:59 +00:00
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
]
end
end
2022-11-23 22:06:28 +00:00
# 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])
2022-11-24 19:01:34 +00:00
project = Mix.Project.config()
2022-11-23 22:06:28 +00:00
source_paths = project[:asn1_paths] || ["asn1"]
2022-11-24 19:01:34 +00:00
dest_paths = project[:asn1_target] || ["src"]
mappings = Enum.zip(source_paths, dest_paths)
options = project[:asn1_options] || []
2022-11-23 22:06:28 +00:00
2022-11-24 19:01:34 +00:00
force =
case opts[:force] do
true -> [force: true]
2022-11-23 22:06:28 +00:00
_ -> [force: false]
2022-11-24 19:01:34 +00:00
end
2022-11-23 22:06:28 +00:00
Erlang.compile(manifest(), mappings, :asn1, :erl, force, fn
input, output ->
2022-11-24 23:42:44 +00:00
File.mkdir(Path.dirname(output))
2022-11-23 22:06:28 +00:00
options = options ++ [:noobj, outdir: Erlang.to_erl_file(Path.dirname(output))]
2022-11-24 19:01:34 +00:00
2022-11-23 22:06:28 +00:00
case :asn1ct.compile(Erlang.to_erl_file(input), options) do
2022-11-24 23:42:44 +00:00
:ok -> {:ok, [], []}
:error -> {:error, [], []}
2022-11-23 22:06:28 +00:00
end
end)
end
def manifests, do: [manifest()]
2022-11-24 19:01:34 +00:00
defp manifest, do: Path.join(Mix.Project.manifest_path(), @manifest)
2022-11-23 22:06:28 +00:00
def clean, do: Erlang.clean(manifest())
end