2015-07-02 12:34:53 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
#
|
2015-07-03 13:59:45 +00:00
|
|
|
# Handle Elixir related ports
|
|
|
|
#
|
|
|
|
# Feature: elixir
|
|
|
|
# Usage: USES=elixir
|
|
|
|
# Valid ARGS: does not require args
|
|
|
|
#
|
|
|
|
# Additional variables:
|
2015-07-02 12:34:53 +00:00
|
|
|
#
|
|
|
|
# ELIXIR_APP_NAME - Elixir app name as installed in Elixir's lib directory
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
# ELIXIR_LIB_ROOT - Elixir default library path
|
2015-07-02 12:34:53 +00:00
|
|
|
# ELIXIR_APP_ROOT - Root directory for this Elixir app
|
|
|
|
# ELIXIR_HIDDEN - Applications to be hidden from the code path; usually ${PORTNAME}
|
|
|
|
# ELIXIR_LOCALE - An UTF-8 locale to be used by Elixir during builds (any UTF-8 locale is good)
|
|
|
|
# MIX_CMD - The "mix" command
|
|
|
|
# MIX_COMPILE - The "mix" command used to compile an Elixir app
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
# MIX_REWRITE - Automatically replace Mix dependencies with code paths
|
2015-07-02 12:34:53 +00:00
|
|
|
# MIX_BUILD_DEPS - List of BUILD_DEPENDS in category/portname format
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
# (commonly referenced to as "deps" in Erlang and Elixir)
|
2015-07-02 12:34:53 +00:00
|
|
|
# MIX_RUN_DEPS - List of RUN_DEPENDS in category/portname format
|
|
|
|
# MIX_DOC_DIRS - Extra doc directories to be installed in DOCSDIR
|
|
|
|
# MIX_DOC_FILES - Extra doc files to be installed in DOCSDIR (usually README.md)
|
2015-07-13 11:23:37 +00:00
|
|
|
# MIX_ENV - Environment for the Mix build (same format as MAKE_ENV)
|
2015-07-02 12:34:53 +00:00
|
|
|
# MIX_ENV_NAME - Name of the Mix build environment, usually "prod"
|
|
|
|
# MIX_BUILD_NAME - Name of the build output in _build/, usually ${MIX_ENV_NAME}
|
2015-07-13 11:23:37 +00:00
|
|
|
# MIX_TARGET - Name of the Mix target, usually "compile"
|
2015-07-02 12:34:53 +00:00
|
|
|
# MIX_EXTRA_APPS - List of sub-applications to be built, if any
|
|
|
|
# MIX_EXTRA_DIRS - List of extra directories to be installed in ELIXIR_APP_ROOT
|
|
|
|
# MIX_EXTRA_FILES - List of extra files to be installed in ELIXIR_APP_ROOT
|
2015-07-03 13:59:45 +00:00
|
|
|
#
|
|
|
|
# MAINTAINER: olgeni@FreeBSD.org
|
|
|
|
|
|
|
|
.if !defined(_INCLUDE_USES_ELIXIR_MK)
|
|
|
|
_INCLUDE_USES_ELIXIR_MK=yes
|
|
|
|
|
|
|
|
.if !empty(elixir_ARGS)
|
|
|
|
IGNORE= USES=elixir does not require args
|
|
|
|
.endif
|
2015-07-02 12:34:53 +00:00
|
|
|
|
|
|
|
ELIXIR_APP_NAME?= ${PORTNAME}
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
ELIXIR_LIB_ROOT?= ${LOCALBASE}/lib/elixir/lib
|
2015-07-02 12:34:53 +00:00
|
|
|
ELIXIR_APP_ROOT?= ${PREFIX}/lib/elixir/lib/${ELIXIR_APP_NAME}
|
2015-07-14 17:44:22 +00:00
|
|
|
ELIXIR_HIDDEN?= "^${ELIXIR_APP_NAME}$$"
|
2015-07-02 12:34:53 +00:00
|
|
|
ELIXIR_LOCALE?= en_US.UTF-8
|
|
|
|
MIX_CMD?= ${LOCALBASE}/bin/mix
|
2017-01-18 13:20:31 +00:00
|
|
|
MIX_COMPILE?= ${SETENV} ${MIX_ENV} LANG=${ELIXIR_LOCALE} LC_ALL=${ELIXIR_LOCALE} MIX_ENV=${MIX_ENV_NAME} ELIXIR_HIDDEN=${ELIXIR_HIDDEN} ${MIX_CMD} ${MIX_TARGET}
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
MIX_REWRITE?=
|
2015-07-02 12:34:53 +00:00
|
|
|
MIX_BUILD_DEPS?=
|
|
|
|
MIX_RUN_DEPS?=
|
|
|
|
MIX_DOC_DIRS?=
|
|
|
|
MIX_DOC_FILES?= README.md
|
2015-07-13 11:23:37 +00:00
|
|
|
MIX_ENV?=
|
2015-07-02 12:34:53 +00:00
|
|
|
MIX_ENV_NAME?= prod
|
|
|
|
MIX_BUILD_NAME?= prod
|
2015-07-13 11:23:37 +00:00
|
|
|
MIX_TARGET?= compile
|
2015-07-02 12:34:53 +00:00
|
|
|
MIX_EXTRA_APPS?=
|
|
|
|
MIX_EXTRA_DIRS?=
|
|
|
|
MIX_EXTRA_FILES?=
|
|
|
|
|
2016-03-27 01:23:25 +00:00
|
|
|
BUILD_DEPENDS+= elixir:lang/elixir
|
|
|
|
RUN_DEPENDS+= elixir:lang/elixir
|
2015-07-02 12:34:53 +00:00
|
|
|
|
|
|
|
.for depend in ${MIX_BUILD_DEPS}
|
2016-03-27 01:23:25 +00:00
|
|
|
BUILD_DEPENDS+= ${depend:T}>=0:${depend}
|
2015-07-02 12:34:53 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.for depend in ${MIX_RUN_DEPS}
|
2016-03-27 01:23:25 +00:00
|
|
|
RUN_DEPENDS+= ${depend:T}>=0:${depend}
|
2015-07-02 12:34:53 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
.if !target(do-build)
|
2015-07-07 23:03:07 +00:00
|
|
|
do-build:
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
.if ${MIX_REWRITE} != ""
|
2017-04-25 08:34:26 +00:00
|
|
|
@${REINPLACE_CMD} -i '' -E -e "s@\{.*(only|optional): .*},?@@" ${WRKSRC}/mix.exs
|
2016-01-23 16:46:11 +00:00
|
|
|
.for depend in ${MIX_BUILD_DEPS}
|
|
|
|
@if [ $$(echo ${depend:T} | sed -e "s/erlang-//") != ${depend:T} ]; then \
|
2017-04-25 08:34:26 +00:00
|
|
|
${REINPLACE_CMD} -i '' -E -e "s@\{ *:(${depend:T:S/erlang-//}), *(github:|\").*} *,?@@" ${WRKSRC}/mix.exs; \
|
2016-01-23 16:46:11 +00:00
|
|
|
else \
|
2017-04-25 08:34:26 +00:00
|
|
|
${REINPLACE_CMD} -i '' -E -e "s@\{ *:(${depend:T:S/elixir-//}), *(github:|\").*}@{ :\1, path: \"${ELIXIR_LIB_ROOT}/\\1\", compile: false }@" ${WRKSRC}/mix.exs; \
|
2016-01-23 16:46:11 +00:00
|
|
|
fi
|
|
|
|
.endfor
|
In elixir.mk, add MIX_REWRITE and ELIXIR_LIB_ROOT.
ELIXIR_LIB_ROOT is the default Elixir library path in LOCALBASE.
If MIX_REWRITE is defined, all optional dependencies will be stripped
out (test, doc, etc.), while all required libs will be converted to
actual code paths in ELIXIR_LIB_ROOT.
For example, it will turn the following dependency definitions:
defp deps do
[
{ :inflex, "~> 1.0" },
{ :estree, "~> 2.0" },
{ :shouldi, only: :test },
{ :earmark, "~> 0.1", only: :dev },
{ :ex_doc, "~> 0.7", only: :dev }
]
end
into these:
defp deps do
[
{ :inflex, path: "/usr/local/lib/elixir/lib/inflex", compile: false },
{ :estree, path: "/usr/local/lib/elixir/lib/estree", compile: false },
]
end
Setting MIX_REWRITE allows escriptize to bundle all dependencies in the
script, else it will not be able to pull them from the usual code path.
It already works for all Elixir ports and should make patches to mix.exs
unnecessary, but for now the default is off.
Sneak in a whitespace fix while I'm here.
2015-07-14 23:05:31 +00:00
|
|
|
.endif
|
2016-10-21 12:51:40 +00:00
|
|
|
@${RM} ${WRKSRC}/mix.lock
|
2015-07-02 12:34:53 +00:00
|
|
|
@cd ${WRKSRC} && ${MIX_COMPILE}
|
|
|
|
.for app in ${MIX_EXTRA_APPS}
|
2016-10-21 12:51:40 +00:00
|
|
|
@${RM} ${WRKSRC}/${app}/mix.lock
|
2015-07-02 12:34:53 +00:00
|
|
|
@cd ${WRKSRC}/${app} && ${MIX_COMPILE}
|
|
|
|
.endfor
|
2015-07-07 23:03:07 +00:00
|
|
|
.endif # .if !target(do-build)
|
2015-07-02 12:34:53 +00:00
|
|
|
|
2015-07-07 23:03:07 +00:00
|
|
|
.if !target(do-install)
|
|
|
|
do-install:
|
2015-07-02 12:34:53 +00:00
|
|
|
@${MKDIR} ${STAGEDIR}${ELIXIR_APP_ROOT}
|
|
|
|
@${MKDIR} ${STAGEDIR}${ELIXIR_APP_ROOT}/lib
|
|
|
|
cd ${WRKSRC}/lib && ${COPYTREE_SHARE} \* ${STAGEDIR}${ELIXIR_APP_ROOT}/lib
|
|
|
|
@${MKDIR} ${STAGEDIR}${ELIXIR_APP_ROOT}/ebin
|
2015-07-02 23:09:03 +00:00
|
|
|
${INSTALL_DATA} ${WRKSRC}/_build/${MIX_BUILD_NAME}/lib/${ELIXIR_APP_NAME}/ebin/* \
|
2015-07-02 12:34:53 +00:00
|
|
|
${STAGEDIR}${ELIXIR_APP_ROOT}/ebin
|
|
|
|
if [ -d ${WRKSRC}/priv ]; then \
|
|
|
|
${MKDIR} ${STAGEDIR}${ELIXIR_APP_ROOT}/priv; \
|
|
|
|
cd ${WRKSRC}/priv && ${COPYTREE_SHARE} \* ${STAGEDIR}${ELIXIR_APP_ROOT}/priv; \
|
|
|
|
fi
|
2015-07-02 12:40:27 +00:00
|
|
|
.if ${MIX_DOC_FILES} != "" || ${MIX_DOC_DIRS} != ""
|
2015-07-02 12:34:53 +00:00
|
|
|
@${MKDIR} ${STAGEDIR}${DOCSDIR}
|
|
|
|
.endif
|
|
|
|
.for file in ${MIX_DOC_FILES}
|
|
|
|
${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${DOCSDIR}
|
|
|
|
.endfor
|
|
|
|
.for dir in ${MIX_DOC_DIRS}
|
|
|
|
cd ${WRKSRC} && ${COPYTREE_SHARE} ${dir} ${STAGEDIR}${DOCSDIR}
|
|
|
|
.endfor
|
|
|
|
.for file in ${MIX_EXTRA_FILES}
|
|
|
|
${INSTALL_DATA} ${WRKSRC}/${file} ${STAGEDIR}${ELIXIR_APP_ROOT}
|
|
|
|
.endfor
|
|
|
|
.for dir in ${MIX_EXTRA_DIRS}
|
|
|
|
@${MKDIR} ${STAGEDIR}${ELIXIR_APP_ROOT}/${dir}
|
|
|
|
cd ${WRKSRC}/${dir} && ${COPYTREE_SHARE} . ${STAGEDIR}${ELIXIR_APP_ROOT}/${dir}
|
|
|
|
.endfor
|
|
|
|
.for app in ${MIX_EXTRA_APPS}
|
|
|
|
${INSTALL_DATA} ${WRKSRC}/${app}/_build/${MIX_BUILD_NAME}/lib/*/ebin/* \
|
|
|
|
${STAGEDIR}${ELIXIR_APP_ROOT}/ebin
|
|
|
|
.endfor
|
2015-07-07 23:03:07 +00:00
|
|
|
.endif # .if !target(do-install)
|
2015-07-03 13:59:45 +00:00
|
|
|
|
|
|
|
.endif #!defined(_INCLUDE_USES_ELIXIR_MK)
|