-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ejabberd can be embedded in an Elixir application
- Loading branch information
Showing
4 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
defmodule Mix.Tasks.Compile.Asn1 do | ||
use Mix.Task | ||
alias Mix.Compilers.Erlang | ||
|
||
@recursive true | ||
@manifest ".compile.asn1" | ||
|
||
@moduledoc """ | ||
Compile ASN.1 source files. | ||
When this task runs, it will check the modification time of every file, and | ||
if it has changed, the file will be compiled. Files will be | ||
compiled in the source directory with a .erl extension and generate a .hrl file. | ||
You can force compilation regardless of modification times by passing | ||
the `--force` option. | ||
## Command line options | ||
* `--force` - forces compilation regardless of modification times | ||
## Configuration | ||
* `:asn1_paths` - directories to find asn1 files. Defaults to `["asn1"]`. | ||
""" | ||
|
||
@doc """ | ||
Runs this task. | ||
""" | ||
@spec run(OptionParser.argv) :: :ok | :noop | ||
def run(args) do | ||
{opts, _, _} = OptionParser.parse(args, switches: [force: :boolean]) | ||
|
||
project = Mix.Project.config | ||
source_paths = project[:asn1_paths] || ["asn1"] | ||
dest_paths = project[:erlc_paths] | ||
mappings = Enum.zip(source_paths, dest_paths) | ||
options = project[:asn1_options] || [] | ||
|
||
Erlang.compile(manifest(), mappings, :asn1, :erl, opts[:force], fn | ||
input, output -> | ||
options = options ++ [:noobj, outdir: Erlang.to_erl_file(Path.dirname(output))] | ||
:asn1ct.compile(Erlang.to_erl_file(input), options) | ||
end) | ||
end | ||
|
||
@doc """ | ||
Returns ASN.1 manifests. | ||
""" | ||
def manifests, do: [manifest] | ||
defp manifest, do: Path.join(Mix.Project.manifest_path, @manifest) | ||
|
||
@doc """ | ||
Cleans up compilation artifacts. | ||
""" | ||
def clean do | ||
Erlang.clean(manifest()) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
defmodule Ejabberd.Mixfile do | ||
use Mix.Project | ||
|
||
def project do | ||
[app: :ejabberd, | ||
version: "15.03.0", | ||
elixir: "~> 1.0", | ||
elixirc_paths: ["lib"], | ||
compile_path: ".", | ||
compilers: Mix.compilers, | ||
erlc_options: erlc_options, | ||
deps: deps] | ||
end | ||
|
||
def application do | ||
[mod: {:ejabberd_app, []}, | ||
applications: [:kernel, :stdlib]] | ||
end | ||
|
||
defp erlc_options do | ||
includes = Path.wildcard(Path.join("..", "/*/include")) | ||
[:debug_info, {:d, :NO_EXT_LIB}] ++ Enum.map(includes, fn(path) -> {:i, path} end) | ||
end | ||
|
||
defp deps do | ||
[ | ||
{:p1_xml, github: "processone/xml"}, | ||
{:p1_logger, github: "processone/p1_logger"}, | ||
{:p1_yaml, github: "processone/p1_yaml"}, | ||
{:p1_tls, github: "processone/tls"}, | ||
{:p1_stringprep, github: "processone/stringprep"}, | ||
{:p1_zlib, github: "processone/zlib"}, | ||
{:p1_cache_tab, github: "processone/cache_tab"}, | ||
{:p1_utils, github: "processone/p1_utils"}, | ||
{:p1_iconv, github: "processone/eiconv"}, | ||
{:esip, github: "processone/p1_sip"}, | ||
{:p1_stun, github: "processone/stun"}, | ||
{:ehyperloglog, github: "vaxelfel/eHyperLogLog"}, | ||
{:p1_mysql, github: "processone/mysql"}, | ||
{:p1_pgsql, github: "processone/pgsql"}, | ||
{:eredis, github: "wooga/eredis"} | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters