Skip to content

Commit

Permalink
Add Mix compiler that raises on missing parsetools
Browse files Browse the repository at this point in the history
I added a `:ensure_yecc_compiler` Mix compiler that raises when the
`:yecc` module is missing (because the `:parsetools` Erlang application
is missing). This should help a lot with issue #67.
  • Loading branch information
whatyouhide committed Jan 22, 2016
1 parent 629c08a commit 6ea9cb9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
defmodule Mix.Tasks.Compile.EnsureYeccCompiler do
def run(_args) do
yecc? = Code.ensure_loaded?(:yecc)
parsertools? = match?({:ok, _}, Application.ensure_all_started(:parsetools))

unless yecc? and parsertools? do
Mix.raise String.rstrip("""
Could not compile :gettext because the :yecc module could not be found.
This is likely caused by the lack of the :parsetools Erlang application.
This may happen if your package manager broke Erlang into multiple
packages and may be fixed by installing the missing package for Erlang.
For example, if your package manager is apt-get:
apt-get install erlang-parsetools

This comment has been minimized.

Copy link
@adam-stokes

adam-stokes Feb 23, 2016

I actually tried this first and on my ubuntu 14.04 system it failed. I actually needed to install erlang-dev in addition to erlang-parsetools. erlang-parsetools alone doesn't contain the necessary include files, here is the output for that:

😀  adam@deadpool:wffm_app 🌴  dpkg -L erlang-parsetools
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/erlang-parsetools
/usr/share/doc/erlang-parsetools/README.Debian
/usr/share/doc/erlang-parsetools/copyright
/usr/share/doc/erlang-parsetools/TODO.Debian
/usr/share/doc/erlang-parsetools/AUTHORS.gz
/usr/share/doc/erlang-parsetools/changelog.Debian.gz
/usr/lib
/usr/lib/erlang
/usr/lib/erlang/lib
/usr/lib/erlang/lib/parsetools-2.1.1
/usr/lib/erlang/lib/parsetools-2.1.1/ebin
/usr/lib/erlang/lib/parsetools-2.1.1/ebin/leex.beam
/usr/lib/erlang/lib/parsetools-2.1.1/ebin/yeccscan.beam
/usr/lib/erlang/lib/parsetools-2.1.1/ebin/yeccparser.beam
/usr/lib/erlang/lib/parsetools-2.1.1/ebin/yecc.beam
/usr/lib/erlang/lib/parsetools-2.1.1/ebin/parsetools.app
/usr/lib/erlang/lib/parsetools-2.1.1/ebin/parsetools.appup
You can find more information here:
https://github.com/elixir-lang/gettext/issues/67.
""", ?\n)
end
end
end

defmodule Gettext.Mixfile do
use Mix.Project

Expand All @@ -10,6 +33,7 @@ defmodule Gettext.Mixfile do
[app: :gettext,
version: @version,
elixir: "~> 1.1-beta",
compilers: [:ensure_yecc_compiler] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
deps: deps,

Expand Down

0 comments on commit 6ea9cb9

Please sign in to comment.