processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6k stars 1.5k forks source link

Improve support for Elixir, Mix and Rebar3 #4143

Closed badlop closed 5 months ago

badlop commented 6 months ago

This PR includes many commits related to fixing and improving compilation with newer Rebar3, Erlang and Elixir.

The commit messages should be clear enough. Here I provide a general explanation of the major changes, hopefully ready for inclusion in the release notes:


Summary of compilation methods

When compiling ejabberd from source code, you may have noticed there are a lot of possibilities. Let's take an overview before digging in the new improvements:

For example:

Several combinations didn't work correctly until now and have been fixed, for example:

Use Mix or Rebar3 by default instead of Rebar to compile ejabberd

ejabberd uses Rebar to manage dependencies and compilation since ejabberd 13.10 4d8f7706240a1603468968f47fc7b150b788d62f. However, that tool is obsolete and unmaintained since years ago, because there is a complete replacement:

Rebar3 is supported by ejabberd since 20.12 0fc1aea379924b6f83f274f173d0bbd163cae1c2. Among other benefits, this allows to download dependencies from hex.pm and cache them in your system instead of downloading them from git every time, and allows to compile Elixir files and Elixir dependencies.

In fact, ejabberd can be compiled using mix (a tool included with the Elixir programming language) since ejabberd 15.04 ea8db9967fbfe53f581c3ae721657d9e6f919864 (with improvements in ejabberd 21.07 4c5641a6489d0669b4220b5ac759a4e1271af3b5)

For those reasons, the tool selection performed by ./configure will now be:

Removed Elixir support in Rebar

Support for Elixir 1.1 was added as a dependency in ejabberd 15.02 01e1f677c72b923251f7021bc024319ff129d42d. This allowed to compile Elixir files. But since Elixir 1.4.5 (released Jun 22, 2017) it isn't possible to get Elixir as a dependency... it's nowadays a standalone program. For that reason, support to download old Elixir 1.4.4 as a dependency has been removed.

When Elixir support is required, better simply install Elixir and use mix as build tool:

./configure --with-rebar=mix

Or install Elixir and use the experimental Rebar3 support to compile Elixir files and dependencies:

./configure --with-rebar=rebar3 --enable-elixir

Added Elixir support in Rebar3

It is now possible to compile ejabberd using Rebar3 and support Elixir compilation. This compiles the Elixir files included in ejabberd's lib/ path. There's also support to get dependencies written in Elixir, and it's possible to build OTP releases including Elixir support.

It is necessary to have Elixir installed in the system, and configure the compilation using --enable-elixir. For example:

apt-get install erlang erlang-dev elixir
git clone https://github.com/processone/ejabberd.git ejabberd
cd ejabberd
./autogen.sh
./configure --with-rebar=rebar3 --enable-elixir
make
make dev
_build/dev/rel/ejabberd/bin/ejabberdctl iexlive

Elixir versions supported

Elixir 1.10.3 is the minimum supported, but:

For all those reasons, if you want to use Elixir, it is highly recommended to use Elixir 1.13.4 or higher with Erlang/OTP 23.0 or higher.

Rebar and Rebar3 binaries updated

The ejabberd source code includes the rebar and rebar3 binaries, and you can use them to compile ejabberd in case they are not installed in your operating system. Those binaries have been updated to support Erlang/OTP from version 23 up to 26.

If you are using Erlang 22.3 or older, you can download the old binaries from ejabberd 21.12, available at:

make rel is renamed to make prod

When ejabberd started to use Rebar2 build tool, that tool could create an OTP release, and the target in Makefile.in was conveniently named make rel.

However, newer tools like Rebar3 and Elixir's Mix support creating different types of releases: production, development, ... In this sense, our make rel target is nowadays more properly named make prod.

For backwards compatibility, make rel redirects to make prod.

New make install-rel and make uninstall-rel

This is an alternative method to install ejabberd in the system, based in the OTP release process. It should produce exactly the same results than the existing make install.

The benefits of make install-rel over the existing method:

This is still experimental, and it would be great if you are able to test it and report any problem; eventually this method could replace the existing one.

Just for curiosity:

coveralls commented 6 months ago

Coverage Status

coverage: 32.567% (-0.003%) from 32.57% when pulling b4b85e569e14d674531199b8c6497105b18c4772 on badlop:elixir-all-in into 29ec5bff606da07b03cc3c7a9d5f963008996474 on processone:master.