Skip to contentSkip to conversation

package/nodejs: expose capability to compile host library

PATCH In review James Hilliard 2 participants 2 messages Oct 23, 2021 – Dec 28, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/nodejs: expose capability to compile host library

From: Linus Kaschulla <[email protected]>

To use nodejs on the host (independant of the actual system) to create some static files to place onto the target rootfs nodejs can be very helpful.

The provided nodejs package didn't show the possibility to create a host package. But upon further examination I noticed that the package does it in fact (in the .mk). It specifies dependencies for the package with the host prefix and also invokes $(host-generic-package) as well as $(generic-package) which is the only one assumed from the config.

With this change other packages can require BR2_PACKAGE_HOST_NODEJS without any problems or the buildsystem not fully knowing about this. Seems that someone added the capability (as a step for the cross- compiled nodejs) and didn't notice that this is a handy package by itself.

When installing global npm packages (with -g), the parameter --prefix $(HOST_DIR) can be used to ensure that nodejs doesn't try to install it onto the real host filesystem.

I already used this change to create static web files from Angular and place onto a target that doesn't need nodejs itself.

This patch contains fixes based on feedback from:
- Peter Seiderer <[email protected]>
- Yann E. MORIN <[email protected]>

---
Changes v1 -> v2:
- move nodejs 14 dependency selection to host package

---
 package/Config.in.host        |  1 +
 package/nodejs/Config.in      |  6 +-----
 package/nodejs/Config.in.host | 13 +++++++++++++
 3 files changed, 15 insertions(+), 5 deletions(-)
 create mode 100644 package/nodejs/Config.in.host
package/Config.in.host +1 -0
index 6e5a5c5fc5..7400da5894 100644
@@ -56,6 +56,7 @@ menu "Host utilities"
 	source "package/mtd/Config.in.host"
 	source "package/mtools/Config.in.host"
 	source "package/mxsldr/Config.in.host"
+	source "package/nodejs/Config.in.host"
 	source "package/odb/Config.in.host"
 	source "package/omap-u-boot-utils/Config.in.host"
 	source "package/openocd/Config.in.host"
package/nodejs/Config.in +1 -5
index 771f735e97..8a2a6cf91b 100644
@@ -27,11 +27,7 @@ config BR2_PACKAGE_NODEJS
 	# uses dlopen(). On ARMv5, we could technically support static
 	# linking, but that's too much of a corner case to support it.
 	depends on !BR2_STATIC_LIBS
-	select BR2_PACKAGE_HOST_PYTHON3
-	select BR2_PACKAGE_HOST_PYTHON3_BZIP2
-	select BR2_PACKAGE_HOST_PYTHON3_SSL
-	select BR2_PACKAGE_HOST_QEMU
-	select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
+	select BR2_PACKAGE_HOST_NODEJS
 	select BR2_PACKAGE_C_ARES
 	select BR2_PACKAGE_LIBUV
 	select BR2_PACKAGE_ZLIB
package/nodejs/Config.in.host new file +13 -0
new file mode 100644
index 0000000000..86eaf21dac
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_HOST_NODEJS
+	bool "host nodejs"
+	depends on BR2_HOST_GCC_AT_LEAST_7
+	select BR2_PACKAGE_HOST_PYTHON3
+	select BR2_PACKAGE_HOST_PYTHON3_BZIP2
+	select BR2_PACKAGE_HOST_PYTHON3_SSL
+	select BR2_PACKAGE_HOST_QEMU
+	select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
+	help
+	  Event-driven I/O server-side JavaScript environment based on
+	  V8.
+
+	  http://nodejs.org/
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 34 lines · On Fri, 22 Oct 2021 23:01:19 -0600 James Hilliard <[email protected]>…

From: Linus Kaschulla <[email protected]>

To use nodejs on the host (independant of the actual system) to create some static files to place onto the target rootfs nodejs can be very helpful.

The provided nodejs package didn't show the possibility to create a host package. But upon further examination I noticed that the package does it in fact (in the .mk). It specifies dependencies for the package with the host prefix and also invokes $(host-generic-package) as well as $(generic-package) which is the only one assumed from the config.

With this change other packages can require BR2_PACKAGE_HOST_NODEJS without any problems or the buildsystem not fully knowing about this. Seems that someone added the capability (as a step for the cross- compiled nodejs) and didn't notice that this is a handy package by itself.

When installing global npm packages (with -g), the parameter --prefix $(HOST_DIR) can be used to ensure that nodejs doesn't try to install it onto the real host filesystem.

I already used this change to create static web files from Angular and place onto a target that doesn't need nodejs itself.

This patch contains fixes based on feedback from:
- Peter Seiderer <[email protected]>
- Yann E. MORIN <[email protected]>

---
Changes v1 -> v2:
- move nodejs 14 dependency selection to host package

Quoted 6 lines
---
 package/Config.in.host        |  1 +
 package/nodejs/Config.in      |  6 +-----
 package/nodejs/Config.in.host | 13 +++++++++++++
 3 files changed, 15 insertions(+), 5 deletions(-)
 create mode 100644 package/nodejs/Config.in.host

I've applied to master, after significantly simplifying the commit log, which was a bit verbose for no good reason.

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot