diff options
Diffstat (limited to 'lang/elixir')
-rw-r--r-- | lang/elixir/bsd.elixir.mk | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/lang/elixir/bsd.elixir.mk b/lang/elixir/bsd.elixir.mk new file mode 100644 index 000000000000..55930f6a5789 --- /dev/null +++ b/lang/elixir/bsd.elixir.mk @@ -0,0 +1,95 @@ +# $FreeBSD$ +# +# bsd.elixir.mk - Helper for Elixir applications +# +# ELIXIR_APP_NAME - Elixir app name as installed in Elixir's lib directory +# 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 +# MIX_BUILD_DEPS - List of BUILD_DEPENDS in category/portname format +# (commonly referenced to as "deps" in Erlang and Elixir) +# 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) +# 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} +# 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 + +ELIXIR_APP_NAME?= ${PORTNAME} +ELIXIR_APP_ROOT?= ${PREFIX}/lib/elixir/lib/${ELIXIR_APP_NAME} +ELIXIR_HIDDEN?= ${PORTNAME} +ELIXIR_LOCALE?= en_US.UTF-8 +MIX_CMD?= ${LOCALBASE}/bin/mix +MIX_COMPILE?= LANG=${ELIXIR_LOCALE} MIX_ENV=${MIX_ENV_NAME} ELIXIR_HIDDEN=${ELIXIR_HIDDEN} ${MIX_CMD} compile +MIX_BUILD_DEPS?= +MIX_RUN_DEPS?= +MIX_DOC_DIRS?= +MIX_DOC_FILES?= README.md +MIX_ENV_NAME?= prod +MIX_BUILD_NAME?= prod +MIX_EXTRA_APPS?= +MIX_EXTRA_DIRS?= +MIX_EXTRA_FILES?= + +BUILD_DEPENDS+= elixir:${PORTSDIR}/lang/elixir +RUN_DEPENDS+= elixir:${PORTSDIR}/lang/elixir + +.for depend in ${MIX_BUILD_DEPS} +BUILD_DEPENDS+= ${depend:T}>=0:${PORTSDIR}/${depend} +.endfor + +.for depend in ${MIX_RUN_DEPS} +RUN_DEPENDS+= ${depend:T}>=0:${PORTSDIR}/${depend} +.endfor + +.if !target(do-build) +do-build: do-build-elixir +.endif + +.if !target(do-install) +do-install: do-install-elixir +.endif + +do-build-elixir: + @${RM} -f ${WRKSRC}/mix.lock + @cd ${WRKSRC} && ${MIX_COMPILE} +.for app in ${MIX_EXTRA_APPS} + @${RM} -f ${WRKSRC}/${app}/mix.lock + @cd ${WRKSRC}/${app} && ${MIX_COMPILE} +.endfor + +do-install-elixir: + @${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 + ${INSTALL_DATA} ${WRKSRC}/_build/${MIX_BUILD_NAME}/lib/${PORTNAME}/ebin/* \ + ${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 +.if MIX_DOC_FILES != "" || MIX_DOC_DIRS != "" + @${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 |