mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] Integration of node.js
@ 2014-11-21  7:27 Alex Raimondi
  2014-11-24  8:08 ` Juergen Borleis
  2014-12-09 10:04 ` Jean-Claude Monnin
  0 siblings, 2 replies; 5+ messages in thread
From: Alex Raimondi @ 2014-11-21  7:27 UTC (permalink / raw)
  To: ptxdist

Hi

I am working on adding nodejs to ptxdist. I use ptxdist to crosscompile 
my ARM based linux.

I already succeeded in crosscompiling the nodejs base package and it 
works on the target.

Node.js is special in some kind. To add extra modules it uses its own 
packet manager "npm". Some packages will build some binaries right on 
the target system upon installing. This will not work on a cross 
compiled target (with no compilers installed)

So my approach is to allow the user to select additional modules and 
cross compile these modules on the host.

So I guess I also need to build nodejs for the host to get my hands on 
the npm package manager. I created a host-node package and it 
successfully compiles.

About the next steps I am unsure how to do that:

- My host-node package currently does fetch/prepare/compile. What do I 
need to do in install or targetinstall? Currently my host-node gets 
installed into platform-XXX/sysroot-host

- I need to use host built npm in (target) node to fetch modules. How do 
I correctly access the npm package manager?

Is there any documentation about host tools usage? What is the meaning 
of cross tools?

Thanks for any hint

Best regards
Alex Raimondi


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ptxdist] Integration of node.js
  2014-11-21  7:27 [ptxdist] Integration of node.js Alex Raimondi
@ 2014-11-24  8:08 ` Juergen Borleis
  2014-12-09 10:04 ` Jean-Claude Monnin
  1 sibling, 0 replies; 5+ messages in thread
From: Juergen Borleis @ 2014-11-24  8:08 UTC (permalink / raw)
  To: ptxdist; +Cc: Alex Raimondi

Hi Alex,

On Friday 21 November 2014 08:27:54 Alex Raimondi wrote:
> [...]
> - My host-node package currently does fetch/prepare/compile. What do I
> need to do in install or targetinstall? Currently my host-node gets
> installed into platform-XXX/sysroot-host

A host package has only an "install" stage (but no targetinstall stage) and 
installs its results into the "<platform-dir>/sysroot-host".

> What is the meaning of cross tools?

- target: runs on the target, creates data for the target
- host: runs on the host, creates data for the host
- cross: runs on host, creates data for the target ("cross compiler")

Regards,
Juergen

-- 
Pengutronix e.K.                              | Juergen Borleis             |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ptxdist] Integration of node.js
  2014-11-21  7:27 [ptxdist] Integration of node.js Alex Raimondi
  2014-11-24  8:08 ` Juergen Borleis
@ 2014-12-09 10:04 ` Jean-Claude Monnin
  2014-12-10  8:38   ` Alexander Raimondi
  1 sibling, 1 reply; 5+ messages in thread
From: Jean-Claude Monnin @ 2014-12-09 10:04 UTC (permalink / raw)
  To: ptxdist

Hi Alex,

I would like to integrate node.js in my image.
Would it be possible to share your existing rules (even if it’s in a unfinished state)?

Thanks,
Jean-Claude

> On 21 Nov 2014, at 08:27, Alex Raimondi <raimondi@miromico.ch> wrote:
> 
> Hi
> 
> I am working on adding nodejs to ptxdist. I use ptxdist to crosscompile my ARM based linux.
> 
> I already succeeded in crosscompiling the nodejs base package and it works on the target.
> 
> Node.js is special in some kind. To add extra modules it uses its own packet manager "npm". Some packages will build some binaries right on the target system upon installing. This will not work on a cross compiled target (with no compilers installed)
> 
> So my approach is to allow the user to select additional modules and cross compile these modules on the host.
> 
> So I guess I also need to build nodejs for the host to get my hands on the npm package manager. I created a host-node package and it successfully compiles.
> 
> About the next steps I am unsure how to do that:
> 
> - My host-node package currently does fetch/prepare/compile. What do I need to do in install or targetinstall? Currently my host-node gets installed into platform-XXX/sysroot-host
> 
> - I need to use host built npm in (target) node to fetch modules. How do I correctly access the npm package manager?
> 
> Is there any documentation about host tools usage? What is the meaning of cross tools?
> 
> Thanks for any hint
> 
> Best regards
> Alex Raimondi
> 
> 
> -- 
> ptxdist mailing list
> ptxdist@pengutronix.de


-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ptxdist] Integration of node.js
  2014-12-09 10:04 ` Jean-Claude Monnin
@ 2014-12-10  8:38   ` Alexander Raimondi
  2014-12-10 14:15     ` Alexander Stein
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Raimondi @ 2014-12-10  8:38 UTC (permalink / raw)
  To: ptxdist

[-- Attachment #1: Type: text/plain, Size: 3312 bytes --]

Hi Jean-Claude

Yes, I can give you my current work state. It is attached as tar.gz

You will find:
- A patch that will add support for node.js to a local project (not 
into ptxdist itself)
- A local_src directory with a build script

Everything is based on ptxdist 14.1.0 (from phytec)

Some comments
- I only tested node +ssl +npm (no ssl doesn't compile for some reason)
- It will also add a host node package. This is necessary to build 
node_modules for the target on the host. This should probably be moved 
into cross section.
- npm on the target works, as long as it doesn't want to compile 
anything.
- My procedure to get node_modules on the target is: extract local_src 
from tar.gz into your project. Use the ./build_module.sh with a list of 
module required on target (e.g. ./build_module.sh can socket.io ejs) and 
move the node_modules directory to the target

This currently works for me. Things to do:
- Creation of node modules withing ptxdist (E.g. through node 
application in ptxdist with a dependency list)
- More important: How to strip down node.js and node_modules (Remove 
documentation, sources, ... not needed on a embedded target)

Hope this helps. Any feedback is appreciated.

Alex

On 2014-12-09 11:04, Jean-Claude Monnin wrote:
> Hi Alex,
>
> I would like to integrate node.js in my image.
> Would it be possible to share your existing rules (even if it’s in a
> unfinished state)?
>
> Thanks,
> Jean-Claude
>
>> On 21 Nov 2014, at 08:27, Alex Raimondi <raimondi@miromico.ch> 
>> wrote:
>>
>> Hi
>>
>> I am working on adding nodejs to ptxdist. I use ptxdist to 
>> crosscompile my ARM based linux.
>>
>> I already succeeded in crosscompiling the nodejs base package and it 
>> works on the target.
>>
>> Node.js is special in some kind. To add extra modules it uses its 
>> own packet manager "npm". Some packages will build some binaries right 
>> on the target system upon installing. This will not work on a cross 
>> compiled target (with no compilers installed)
>>
>> So my approach is to allow the user to select additional modules and 
>> cross compile these modules on the host.
>>
>> So I guess I also need to build nodejs for the host to get my hands 
>> on the npm package manager. I created a host-node package and it 
>> successfully compiles.
>>
>> About the next steps I am unsure how to do that:
>>
>> - My host-node package currently does fetch/prepare/compile. What do 
>> I need to do in install or targetinstall? Currently my host-node gets 
>> installed into platform-XXX/sysroot-host
>>
>> - I need to use host built npm in (target) node to fetch modules. 
>> How do I correctly access the npm package manager?
>>
>> Is there any documentation about host tools usage? What is the 
>> meaning of cross tools?
>>
>> Thanks for any hint
>>
>> Best regards
>> Alex Raimondi
>>
>>
>> --
>> ptxdist mailing list
>> ptxdist@pengutronix.de

-- 
Mit freundlichen Grüssen

Alex Raimondi

--
------------------------------------------------------------------
Miromico AG
Alexander Raimondi            phone : +41 43 222 57 00
Senior Design Engineer        direct: +41 43 222 57 12
Gallusstrasse 4               email : alex.raimondi@miromico.ch
CH-8006 Zurich, Switzerland   www   : www.miromico.ch
------------------------------------------------------------------

[-- Attachment #2: patch.tar.gz --]
[-- Type: application/octet-stream, Size: 2862 bytes --]

[-- Attachment #3: Type: text/plain, Size: 48 bytes --]

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [ptxdist] Integration of node.js
  2014-12-10  8:38   ` Alexander Raimondi
@ 2014-12-10 14:15     ` Alexander Stein
  0 siblings, 0 replies; 5+ messages in thread
From: Alexander Stein @ 2014-12-10 14:15 UTC (permalink / raw)
  To: ptxdist; +Cc: Alexander Raimondi

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]

Hello Alexander :),

On Wednesday 10 December 2014 09:38:58, Alexander Raimondi wrote:
> Hi Jean-Claude
> 
> Yes, I can give you my current work state. It is attached as tar.gz

Thanks for your current work. By coincidence I need to take a look at nodejs myself :)

> You will find:
> - A patch that will add support for node.js to a local project (not 
> into ptxdist itself)
> - A local_src directory with a build script
> 
> Everything is based on ptxdist 14.1.0 (from phytec)
> 
> Some comments
> - I only tested node +ssl +npm (no ssl doesn't compile for some reason)

Thanks for your effor so far. I've done some work based on it, e.g. compile without ssl is patched.
I also cleaned up the rules a bit, including moving to cross. Feel free to try and comment.

Best regards,
Alexander
-- 
Dipl.-Inf. Alexander Stein

SYS TEC electronic GmbH
Am Windrad 2
08468 Heinsdorfergrund
Tel.: 03765 38600-1156
Fax: 03765 38600-4100
Email: alexander.stein@systec-electronic.com
Website: www.systec-electronic.com
 
Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Chemnitz, HRB 28082

[-- Attachment #2: 0001-Add-node.js.patch --]
[-- Type: text/x-patch, Size: 10790 bytes --]

From 118e006c128ff7c873b898bf3869bd7e0c3c9cd7 Mon Sep 17 00:00:00 2001
From: Alexander Stein <alexander.stein@systec-electronic.com>
Date: Wed, 10 Dec 2014 15:09:40 +0100
Subject: [PATCH 1/1] Add node.js

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
 .../0001-node.cc-Fix-without-ssl-compilation.patch |  38 +++++
 patches/node-v0.10.33/series                       |   4 +
 rules/cross-node.in                                |  13 ++
 rules/cross-node.make                              |  31 +++++
 rules/node.in                                      |  30 ++++
 rules/node.make                                    | 154 +++++++++++++++++++++
 6 files changed, 270 insertions(+)
 create mode 100644 patches/node-v0.10.33/0001-node.cc-Fix-without-ssl-compilation.patch
 create mode 100644 patches/node-v0.10.33/series
 create mode 100644 rules/cross-node.in
 create mode 100644 rules/cross-node.make
 create mode 100644 rules/node.in
 create mode 100644 rules/node.make

diff --git a/patches/node-v0.10.33/0001-node.cc-Fix-without-ssl-compilation.patch b/patches/node-v0.10.33/0001-node.cc-Fix-without-ssl-compilation.patch
new file mode 100644
index 0000000..c7ac4d5
--- /dev/null
+++ b/patches/node-v0.10.33/0001-node.cc-Fix-without-ssl-compilation.patch
@@ -0,0 +1,38 @@
+From: Alexander Stein <alexander.stein@systec-electronic.com>
+Date: Wed, 10 Dec 2014 11:56:59 +0100
+Subject: [PATCH] node.cc: Fix --without-ssl compilation
+
+The SSL parts of code were not encapsulated correctly.
+
+Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
+---
+ src/node.cc | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/node.cc b/src/node.cc
+index 18c743f..0d67745 100644
+--- a/src/node.cc
++++ b/src/node.cc
+@@ -82,7 +82,6 @@ typedef int mode_t;
+ #include "node_script.h"
+ #include "v8_typed_array.h"
+ 
+-#include "node_crypto.h"
+ #include "util.h"
+ 
+ using namespace v8;
+@@ -2579,12 +2578,14 @@ static void ParseArgs(int argc, char **argv) {
+       p = 1 + strchr(arg, '=');
+       max_stack_size = atoi(p);
+       argv[i] = const_cast<char*>("");
++#if HAVE_OPENSSL
+     } else if (strcmp(arg, "--enable-ssl2") == 0) {
+       SSL2_ENABLE = true;
+       argv[i] = const_cast<char*>("");
+     } else if (strcmp(arg, "--enable-ssl3") == 0) {
+       SSL3_ENABLE = true;
+       argv[i] = const_cast<char*>("");
++#endif
+     } else if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0) {
+       PrintHelp();
+       exit(0);
diff --git a/patches/node-v0.10.33/series b/patches/node-v0.10.33/series
new file mode 100644
index 0000000..a75a360
--- /dev/null
+++ b/patches/node-v0.10.33/series
@@ -0,0 +1,4 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-node.cc-Fix-without-ssl-compilation.patch
+# 43e6493f1a10493aadadef4852982922  - git-ptx-patches magic
diff --git a/rules/cross-node.in b/rules/cross-node.in
new file mode 100644
index 0000000..5e467e0
--- /dev/null
+++ b/rules/cross-node.in
@@ -0,0 +1,13 @@
+## SECTION=crosstools
+
+config CROSS_NODE
+	bool
+	help
+	  Fast, scalable network application scripting environment
+
+	  Node.js® is a platform built on Chrome's JavaScript runtime for
+	  easily building fast, scalable network applications. Node.js uses
+	  an event-driven, non-blocking I/O model that makes it lightweight
+	  and efficient, perfect for data-intensive real-time applications
+	  that run across distributed devices.
+
diff --git a/rules/cross-node.make b/rules/cross-node.make
new file mode 100644
index 0000000..5077742
--- /dev/null
+++ b/rules/cross-node.make
@@ -0,0 +1,31 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2014 by Alex Raimondi <raimondi@miromico.ch>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+CROSS_PACKAGES-$(PTXCONF_CROSS_NODE) += cross-node
+
+#
+# autoconf
+#
+CROSS_NODE_CONF_OPT	:= --prefix=/usr \
+		 	--without-snapshot \
+		   	--dest-os=linux
+
+$(STATEDIR)/host-node.prepare:
+	@$(call targetinfo)
+	@$(call clean, $(CROSS_NODE_DIR)/config.cache)
+	cd $(CROSS_NODE_DIR) && \
+		$(CROSS_NODE_PATH) $(CROSS_NODE_ENV) \
+		./configure $(CROSS_NODE_CONF_OPT)
+	@$(call touch)
+
+# vim: syntax=make
diff --git a/rules/node.in b/rules/node.in
new file mode 100644
index 0000000..47fe839
--- /dev/null
+++ b/rules/node.in
@@ -0,0 +1,30 @@
+## SECTION=networking
+
+menuconfig NODE
+	tristate
+	prompt "node                          "
+	select CROSS_NODE
+	help
+	  Fast, scalable network application scripting environment
+
+	  Node.js® is a platform built on Chrome's JavaScript runtime for
+	  easily building fast, scalable network applications. Node.js uses
+	  an event-driven, non-blocking I/O model that makes it lightweight
+	  and efficient, perfect for data-intensive real-time applications
+	  that run across distributed devices.
+
+if NODE
+
+config NODE_SSL
+	tristate
+	prompt "SSL support"
+	help
+	  Enable support for ssl
+
+config NODE_NPM
+	tristate
+	prompt "Include npm packet manager"
+	help
+	  Include packet manager
+
+endif
diff --git a/rules/node.make b/rules/node.make
new file mode 100644
index 0000000..b711eec
--- /dev/null
+++ b/rules/node.make
@@ -0,0 +1,154 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2014 by Alex Raimondi <raimondi@miromico.ch>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_NODE) += node
+
+#
+# Paths and names
+#
+NODE_VERSION	:= 0.10.33
+NODE_MD5	:= 626ca8a4f8fec4df49c78ed53d46f1f7
+NODE		:= node-v$(NODE_VERSION)
+NODE_SUFFIX	:= tar.gz
+NODE_URL	:= http://nodejs.org/dist/v$(NODE_VERSION)/$(NODE).$(NODE_SUFFIX)
+NODE_SOURCE	:= $(SRCDIR)/$(NODE).$(NODE_SUFFIX)
+NODE_DIR	:= $(BUILDDIR)/$(NODE)
+NODE_LICENSE	:= MIT
+
+# ----------------------------------------------------------------------------
+# Get
+# ----------------------------------------------------------------------------
+
+#$(NODE_SOURCE):
+#	@$(call targetinfo)
+#	@$(call get, NODE)
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+#NODE_PATH   := PATH=$(CROSS_PATH)
+NODE_ENV    := $(CROSS_ENV)
+
+#
+# autoconf
+#
+#NODE_AUTOCONF := \
+#        $(CROSS_AUTOCONF_USR) 
+#        --libdir=/usr/lib/lighttpd \
+#        --$(call ptx/endis, PTXCONF_GLOBAL_LARGE_FILE)-lfs \
+#        $(GLOBAL_IPV6_OPTION) \
+#        --without-libev \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_MYSQL)-mysql \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_LDAP)-ldap \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_ATTR)-attr \
+#        --without-valgrind \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_OPENSSL)-openssl \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_KERBEROS)-kerberos5 \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_PCRE)-pcre \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_ZLIB)-zlib \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_BZ2LIB)-bzip2 \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_FAM)-fam \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_WEBDAV_PROPS)-webdav-props \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_WEBDAV_LOCKS)-webdav-locks \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_GDBM)-gdbm \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_MEMCACHE)-memcache \
+#        --$(call ptx/wwo, PTXCONF_LIGHTTPD_LUA)-lua
+
+#NODE_CONF_ENV	:= $(CROSS_ENV)
+
+#
+# autoconf
+#
+#NODE_CONF_TOOL	:= autoconf
+NODE_CONF_OPT	:= --prefix=/usr \
+		   --without-snapshot \
+		   --dest-cpu=arm \
+		   --dest-os=linux
+
+ifndef PTXCONF_NODE_SSL
+NODE_CONF_OPT += --without-ssl
+endif
+
+ifndef PTXCONF_NODE_NPM
+NODE_CONF_OPT += --without-npm
+endif
+
+$(STATEDIR)/node.prepare:
+	@echo $(NODE_CONF_OPT)
+	@$(call targetinfo)
+	@$(call clean, $(NODE_DIR)/config.cache)
+	cd $(NODE_DIR) && \
+		$(NODE_PATH) $(NODE_ENV) \
+		./configure $(NODE_CONF_OPT)
+	@$(call touch)
+
+# ----------------------------------------------------------------------------
+# Compile
+# ----------------------------------------------------------------------------
+
+#$(STATEDIR)/node.compile:
+#	@$(call targetinfo)
+#	@$(call world/compile, NODE)
+#	@$(call touch)
+
+# ----------------------------------------------------------------------------
+# Install
+# ----------------------------------------------------------------------------
+
+#$(STATEDIR)/node.install:
+#	@$(call targetinfo)
+#	@$(call world/install, NODE)
+#	@$(call touch)
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/node.targetinstall:
+	@$(call targetinfo)
+
+	@$(call install_init, node)
+	@$(call install_fixup, node,PRIORITY,optional)
+	@$(call install_fixup, node,SECTION,base)
+	@$(call install_fixup, node,AUTHOR,"Alex Raimondi <raimondi@miromico.ch>")
+	@$(call install_fixup, node,DESCRIPTION,missing)
+
+	@$(call install copy, node, 0, 0, 0755, /usr/share/nodejs)
+	@$(call install_copy, node, 0, 0, 0755, $(NODE_DIR)/node, /usr/bin/node)
+	@$(call install_copy, node, 0, 0, 0755, $(NODE_DIR)/node, /usr/bin/nodejs)
+	@$(call install_link, node, ../lib/node_modules/npm/bin/npm-cli.js, /usr/bin/npm)
+
+	@$(call install_tree, node, 0, 0, $(NODE_DIR)/deps/npm/node_modules, /usr/lib/node_modules/npm/node_modules)
+	@$(call install_tree, node, 0, 0, $(NODE_DIR)/deps/npm/lib, /usr/lib/node_modules/npm/lib)
+	@$(call install_tree, node, 0, 0, $(NODE_DIR)/deps/npm/bin, /usr/lib/node_modules/npm/bin)
+	@$(call install_tree, node, 0, 0, $(NODE_DIR)/lib, /usr/lib/nodejs)
+	@$(call install_tree, node, 0, 0, $(NODE_DIR)/deps/npm/scripts, /usr/lib/node_modules/npm/scripts)
+
+	@for i in $(shell cd $(NODE_DIR)/deps && find npm -maxdepth 1 -type f); do \
+	    $(call install_copy, node, 0, 0, 0755, -, /usr/lib/node_modules/$$i); \
+	done
+
+	@$(call install_finish, node)
+
+	@$(call touch)
+
+# ----------------------------------------------------------------------------
+# Clean
+# ----------------------------------------------------------------------------
+
+#$(STATEDIR)/node.clean:
+#	@$(call targetinfo)
+#	@$(call clean_pkg, NODE)
+
+# vim: syntax=make
-- 
2.0.4


[-- Attachment #3: Type: text/plain, Size: 48 bytes --]

-- 
ptxdist mailing list
ptxdist@pengutronix.de

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-12-10 14:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-21  7:27 [ptxdist] Integration of node.js Alex Raimondi
2014-11-24  8:08 ` Juergen Borleis
2014-12-09 10:04 ` Jean-Claude Monnin
2014-12-10  8:38   ` Alexander Raimondi
2014-12-10 14:15     ` Alexander Stein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox