Changeset View
Standalone View
Mk/Uses/nodejs.mk
- This file was added.
# Provide support for NodeJS | |||||
# | |||||
# Feature: nodejs | |||||
# Usage: USES=nodejs or USES=nodejs:args | |||||
# Valid ARGS: build and/or run <version> | |||||
# version: lts, current, 10, 14, 16, 17 | |||||
# Default is: build,run | |||||
# Note: if you define a version, you must provide run and/or build | |||||
bhughes: bhughes@FreeBSD.org | |||||
# | |||||
# MAINTAINER: bhughes@FreeBSD.org | |||||
.if !defined(_INCLUDE_USES_NODEJS_MK) | |||||
_INCLUDE_USES_NODEJS_MK= yes | |||||
_VALID_NODEJS_VERSION= 10 14 16 17 lts current | |||||
_NODEJS_VERSION_SUFFIX= ${NODEJS_DEFAULT} | |||||
.if ! ${_VALID_NODEJS_VERSION:M${_NODEJS_VERSION_SUFFIX}} | |||||
IGNORE= Invalid nodejs default version ${_NODEJS_VERSION_SUFFIX}; valid versions are ${_VALID_NODEJS_VERSION} | |||||
.endif | |||||
.if empty(nodejs_ARGS) | |||||
nodejs_ARGS= build,run | |||||
Done Inline ActionsWhy add "lts" here? It should always follow NODEJS_DEFAULT. Otherwise, it is not a default version. sunpoet: Why add "lts" here? It should always follow NODEJS_DEFAULT. Otherwise, it is not a default… | |||||
.endif | |||||
. if ${nodejs_ARGS:M10} | |||||
Not Done Inline Actionswhy not loop over _VALID_NODEJS_VERSION ? tcberner: why not loop over `_VALID_NODEJS_VERSION` ?
| |||||
Done Inline ActionsCould you please help me here, I do not write Makefile every day, but only once or twice a year ;) mfechner: Could you please help me here, I do not write Makefile every day, but only once or twice a year… | |||||
_NODEJS_VERSION_SUFFIX= 10 | |||||
. elif ${nodejs_ARGS:M14} | |||||
_NODEJS_VERSION_SUFFIX= 14 | |||||
. elif ${nodejs_ARGS:M16} | |||||
_NODEJS_VERSION_SUFFIX= 16 | |||||
. elif ${nodejs_ARGS:Mlts} | |||||
_NODEJS_VERSION_SUFFIX= lts | |||||
. elif ${nodejs_ARGS:M17} | |||||
_NODEJS_VERSION_SUFFIX= 17 | |||||
. elif ${nodejs_ARGS:Mcurrent} | |||||
_NODEJS_VERSION_SUFFIX= current | |||||
Done Inline ActionsSome ports will only need the BUILD_DEPENDS, others only the RUN_DEPENDS, and some need both. I think it would make sense to have the ability to say which one you need, e.g. USES=nodejs:build and USES=nodejs:run, with the default being USES=nodejs:build,run. bhughes: Some ports will only need the BUILD_DEPENDS, others only the RUN_DEPENDS, and some need both. I… | |||||
. elif defined(NODEJS_DEFAULT) | |||||
. endif | |||||
# The nodejs 17 version is named www/node | |||||
. if ${_NODEJS_VERSION_SUFFIX:Mcurrent} | |||||
_NODEJS_VERSION_SUFFIX= | |||||
. endif | |||||
. if ${_NODEJS_VERSION_SUFFIX:M17} | |||||
_NODEJS_VERSION_SUFFIX= | |||||
. endif | |||||
# The nodejs LTS is version 16 | |||||
. if ${_NODEJS_VERSION_SUFFIX:Mlts} | |||||
_NODEJS_VERSION_SUFFIX= 16 | |||||
. endif | |||||
. if ${nodejs_ARGS:M*run*} | |||||
RUN_DEPENDS+= node:www/node${_NODEJS_VERSION_SUFFIX} | |||||
Done Inline Actions^ nit pick: from the usage and wrt to for example line 45, it would likely more sense to call it _NODEJS_VERSION_SUFFIX tcberner: ^ nit pick: from the usage and wrt to for example line 45, it would likely more sense to call… | |||||
Done Inline ActionsGood idea, is changed. mfechner: Good idea, is changed. | |||||
. endif | |||||
. if ${nodejs_ARGS:M*build*} | |||||
BUILD_DEPENDS+= node:www/node${_NODEJS_VERSION_SUFFIX} | |||||
. endif | |||||
.endif | |||||
Done Inline Actions^ is that case even needed? tcberner: ^ is that case even needed? | |||||
Done Inline Actionsas I define in line 22 now a default, this is not required anymore, will update in next diff. mfechner: as I define in line 22 now a default, this is not required anymore, will update in next diff. | |||||
Done Inline Actions^ why not match *build* and *run*? . if ${nodejs_ARGS:M*run*} RUN_DEPENDS+=.... . endif . if ${nodejs_ARGS:M*build*} BUILD_DEPENDS+=.... . endif instead of the combinatorial explosion :D tcberner: ^ why not match `*build*` and `*run*`?
```
. if ${nodejs_ARGS:M*run*}
RUN_DEPENDS+=....
. | |||||
Done Inline ActionsWe can change this, but the consequence is, if you define USES=nodejs,14 it will not work, so you must define USES=nodejs,14,run,build I think it is a valid requirement, I will update the diff. mfechner: We can change this, but the consequence is, if you define USES=nodejs,14 it will not work, so… |
bhughes@FreeBSD.org