From patchwork Fri Mar 8 01:31:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Price X-Patchwork-Id: 226003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 59E902C02C0 for ; Fri, 8 Mar 2013 12:31:39 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 709F831234; Fri, 8 Mar 2013 01:31:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LXFEDAFeEVF7; Fri, 8 Mar 2013 01:31:31 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id D1A20305BC; Fri, 8 Mar 2013 01:31:30 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id B389B8F753 for ; Fri, 8 Mar 2013 01:31:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4BFD28CB48 for ; Fri, 8 Mar 2013 01:31:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Y6O7c2hxl8dJ for ; Fri, 8 Mar 2013 01:31:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by whitealder.osuosl.org (Postfix) with ESMTPS id 952B48BA2C for ; Fri, 8 Mar 2013 01:31:27 +0000 (UTC) Received: by mail-pa0-f44.google.com with SMTP id kp1so890408pab.31 for ; Thu, 07 Mar 2013 17:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=RF1yzZfxn1gwTTu94GCunrljLU7lrZyrldqLSNxrB5k=; b=NWMWHZBvRsB+keUKbWU4uFslV9QbeNX5rbhx4BtcuFiihsoDuz96T0SmVdolF+st4p vwpjlIfZukEqdcMkttFmvi3IYo4SMIRei1A60RjrkAye7PepIYBZSBVi45mj3o4Zq89Q 5cdyGCJK8rL1XQ1+jYxdNoR3t42St69zHqRQF5LOyscVzA0tEaOEAetieUwsXKO7pK4+ QtIlgS+oPeLwSQmVh+jY4UZ2OqgT5pd/Sq5lt9v7OWvgU87prGWUvmPpXiw0Ertvhh9s PIXWTIF+sYHUBcYjrL9GwiReeMnHsdls14ekGpffwuX6leXGvj4Q/qtPd99W0PFwbYEF hy5A== X-Received: by 10.68.9.67 with SMTP id x3mr474367pba.219.1362706286948; Thu, 07 Mar 2013 17:31:26 -0800 (PST) Received: from localhost.localdomain (50-76-39-249-ip-static.hfc.comcastbusiness.net. [50.76.39.249]) by mx.google.com with ESMTPS id gf6sm3527978pbc.24.2013.03.07.17.31.25 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Mar 2013 17:31:25 -0800 (PST) From: Daniel Price To: buildroot@busybox.net Date: Thu, 7 Mar 2013 17:31:16 -0800 Message-Id: <1362706276-11111-1-git-send-email-daniel.price@gmail.com> X-Mailer: git-send-email 1.7.6.5 Subject: [Buildroot] [PATCH V6] nodejs: new package X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net Based off of patches posted by (and Signed-off-by:) Jonathan Liu Signed-off-by: Daniel Price Acked-by: Thomas Petazzoni --- package/Config.in | 1 + package/nodejs/Config.in | 79 ++++++++++++++ .../nodejs-remove-python-bz2-dependency.patch | 27 +++++ package/nodejs/nodejs-v8-gregs-fix.patch | 29 +++++ package/nodejs/nodejs.mk | 114 ++++++++++++++++++++ 5 files changed, 250 insertions(+), 0 deletions(-) create mode 100644 package/nodejs/Config.in create mode 100644 package/nodejs/nodejs-remove-python-bz2-dependency.patch create mode 100644 package/nodejs/nodejs-v8-gregs-fix.patch create mode 100644 package/nodejs/nodejs.mk diff --git a/package/Config.in b/package/Config.in index 22e64f8..e46d7a8 100644 --- a/package/Config.in +++ b/package/Config.in @@ -310,6 +310,7 @@ source "package/wsapi/Config.in" source "package/xavante/Config.in" endmenu endif +source "package/nodejs/Config.in" source "package/perl/Config.in" if BR2_PACKAGE_PERL menu "Perl libraries/modules" diff --git a/package/nodejs/Config.in b/package/nodejs/Config.in new file mode 100644 index 0000000..1f4d671 --- /dev/null +++ b/package/nodejs/Config.in @@ -0,0 +1,79 @@ +config BR2_PACKAGE_NODEJS + bool "nodejs" + depends on BR2_INET_IPV6 + depends on BR2_LARGEFILE + depends on BR2_TOOLCHAIN_HAS_THREADS + depends on BR2_INSTALL_LIBSTDCPP + depends on BR2_arm || BR2_i386 || BR2_x86_64 + # uses fork() + depends on BR2_USE_MMU + help + Event-driven I/O server-side JavaScript environment based on V8. + + http://nodejs.org/ + +comment "nodejs requires a toolchain with C++, IPv6, large files, and threading" + depends on !BR2_INSTALL_LIBSTDCPP || !BR2_LARGEFILE || \ + !BR2_TOOLCHAIN_HAS_THREADS || !BR2_INET_IPV6 + +if BR2_PACKAGE_NODEJS + +menu "Module Selection" + +config BR2_PACKAGE_NODEJS_NPM + bool "NPM for the target" + select BR2_PACKAGE_OPENSSL + help + NPM is the package manager for the Node JavaScript platform. + Note that enabling NPM on the target also selects OpenSSL for the + target. + + http://www.npmjs.org + + Note that NPM is always built for the buildroot host. + +config BR2_PACKAGE_NODEJS_MODULES_EXPRESS + bool "Express web application framework" + help + Express is a minimal and flexible node.js web application + framework, providing a robust set of features for building + single and multi-page, and hybrid web applications. + + http://www.expressjs.com + https://github.com/visionmedia/express + +config BR2_PACKAGE_NODEJS_MODULES_COFFEESCRIPT + bool "CoffeeScript" + help + CoffeeScript is a little language that compiles into JavaScript. + + http://www.coffeescript.org + +config BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL + string "Additional modules" + help + List of space-separated nodejs modules to install via npm. + See https://npmjs.org/ to find modules and 'npm help install' + for available installation methods. For repeatable builds, + download and save tgz files or clone git repos for the + components you care about. + + Example: serialport uglify-js@1.3.4 /my/module/mymodule.tgz git://github.com/someuser/somemodule.git#v1.2 + + This would install the serialport module (at the newest version), + the uglify-js module at 1.3.4, a module from a filesystem path, + and a module from a git repository. + +config BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL_DEPS + string "Additional module dependencies" + help + List of space-separated buildroot recipes which must be built before + your npms can be installed. For example, if in 'Additional modules' + you specified 'node-curl' (see: + https://github.com/jiangmiao/node-curl), you could then specify + 'libcurl' here, to ensure that buildroot builds the libcurl package, + and does so before building your node modules. + +endmenu + +endif diff --git a/package/nodejs/nodejs-remove-python-bz2-dependency.patch b/package/nodejs/nodejs-remove-python-bz2-dependency.patch new file mode 100644 index 0000000..75fe437 --- /dev/null +++ b/package/nodejs/nodejs-remove-python-bz2-dependency.patch @@ -0,0 +1,27 @@ +Remove dependency on Python bz2 module + +The Python bz2 module is only needed in certain cases, so only import +it when needed. In the normal nodejs build, this allows to remove the +dependency on this module. + +Signed-off-by: Thomas Petazzoni +Index: b/deps/v8/tools/js2c.py +=================================================================== +--- a/deps/v8/tools/js2c.py ++++ b/deps/v8/tools/js2c.py +@@ -33,7 +33,6 @@ + + import os, re, sys, string + import jsmin +-import bz2 + + + def ToCAsciiArray(lines): +@@ -344,6 +343,7 @@ + else: + raw_sources_declaration = RAW_SOURCES_COMPRESSION_DECLARATION + if env['COMPRESSION'] == 'bz2': ++ import bz2 + all_sources = bz2.compress("".join(all_sources)) + total_length = len(all_sources) + sources_data = ToCArray(all_sources) diff --git a/package/nodejs/nodejs-v8-gregs-fix.patch b/package/nodejs/nodejs-v8-gregs-fix.patch new file mode 100644 index 0000000..4af33bc --- /dev/null +++ b/package/nodejs/nodejs-v8-gregs-fix.patch @@ -0,0 +1,29 @@ +Fix compilation for ARM/uClibc +Patch from Remi Duraffort , taken from +https://code.google.com/p/v8/source/detail?r=12094 + +Signed-off-by: Daniel Price + +--- a/deps/v8/src/platform-linux.cc ++++ b/deps/v8/src/platform-linux.cc +@@ -1025,7 +1025,8 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { + sample->fp = reinterpret_cast
(mcontext.gregs[REG_RBP]); + #elif V8_HOST_ARCH_ARM + // An undefined macro evaluates to 0, so this applies to Android's Bionic also. +-#if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) ++#if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3) && \ ++ !defined(__UCLIBC__)) + sample->pc = reinterpret_cast
(mcontext.gregs[R15]); + sample->sp = reinterpret_cast
(mcontext.gregs[R13]); + sample->fp = reinterpret_cast
(mcontext.gregs[R11]); +@@ -1033,7 +1034,8 @@ static void ProfilerSignalHandler(int signal, siginfo_t* info, void* context) { + sample->pc = reinterpret_cast
(mcontext.arm_pc); + sample->sp = reinterpret_cast
(mcontext.arm_sp); + sample->fp = reinterpret_cast
(mcontext.arm_fp); +-#endif // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3)) ++#endif // (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ <= 3) && ++ // !defined(__UCLIBC__)) + #elif V8_HOST_ARCH_MIPS + sample->pc = reinterpret_cast
(mcontext.pc); + sample->sp = reinterpret_cast
(mcontext.gregs[29]); + diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk new file mode 100644 index 0000000..a77709d --- /dev/null +++ b/package/nodejs/nodejs.mk @@ -0,0 +1,114 @@ +############################################################# +# +# nodejs +# +############################################################# + +NODEJS_VERSION = 0.8.22 +NODEJS_SOURCE = node-v$(NODEJS_VERSION).tar.gz +NODEJS_SITE = http://nodejs.org/dist/v$(NODEJS_VERSION) +NODEJS_DEPENDENCIES = host-python host-nodejs \ + $(call qstrip,$(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL_DEPS)) +HOST_NODEJS_DEPENDENCIES = host-python +NODEJS_LICENSE = MIT (core code); MIT, Apache and BSD family licenses (Bundled components) +NODEJS_LICENSE_FILES = LICENSE + +ifeq ($(BR2_PACKAGE_OPENSSL),y) + NODEJS_DEPENDENCIES += openssl +endif + +define HOST_NODEJS_CONFIGURE_CMDS + # Build with the static, built-in OpenSSL which is supplied as part of + # the nodejs source distribution. This is needed on the host because + # NPM is non-functional without it, and host-openssl isn't part of + # buildroot. + (cd $(@D); \ + ./configure \ + --prefix=$(HOST_DIR)/usr \ + --without-snapshot \ + --without-dtrace \ + --without-etw \ + ) +endef + +define HOST_NODEJS_BUILD_CMDS + $(HOST_MAKE_ENV) $(MAKE) -C $(@D) +endef + +define HOST_NODEJS_INSTALL_CMDS + $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install +endef + +ifeq ($(BR2_i386),y) +NODEJS_CPU=ia32 +else ifeq ($(BR2_x86_64),y) +NODEJS_CPU=x64 +else ifeq ($(BR2_arm),y) +NODEJS_CPU=arm +# V8 needs to know what floating point ABI the target is using. There's also +# a 'hard' option which we're not exposing here at the moment, because +# buildroot itself doesn't really support it at present. +ifeq ($(BR2_SOFT_FLOAT),y) +NODEJS_ARM_FP=soft +else +NODEJS_ARM_FP=softfp +endif +endif + +define NODEJS_CONFIGURE_CMDS + (cd $(@D); \ + $(TARGET_CONFIGURE_OPTS) \ + LD="$(TARGET_CXX)" \ + ./configure \ + --prefix=/usr \ + --without-snapshot \ + $(if $(BR2_PACKAGE_OPENSSL),--shared-openssl,--without-ssl) \ + $(if $(BR2_PACKAGE_NODEJS_NPM),,--without-npm) \ + --without-dtrace \ + --without-etw \ + --dest-cpu=$(NODEJS_CPU) \ + $(if $(NODEJS_ARM_FP),--with-arm-float-abi=$(NODEJS_ARM_FP)) \ + --dest-os=linux \ + ) +endef + +define NODEJS_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) +endef + +# +# Build the list of modules to install based on the booleans for +# popular modules, as well as the "additional modules" list. +# +NODEJS_MODULES_LIST= $(call qstrip,\ + $(if $(BR2_PACKAGE_NODEJS_MODULES_EXPRESS),express) \ + $(if $(BR2_PACKAGE_NODEJS_MODULES_COFFEESCRIPT),coffee-script) \ + $(BR2_PACKAGE_NODEJS_MODULES_ADDITIONAL)) + +# +# We can only call NPM if there's something to install. +# +ifneq ($(NODEJS_MODULES_LIST),) +define NODEJS_INSTALL_MODULES + # If you're having trouble with module installation, adding -d to the + # npm install call below and setting npm_config_rollback=false can both + # help in diagnosing the problem. + (cd $(TARGET_DIR)/usr/lib && mkdir -p node_modules && \ + $(TARGET_CONFIGURE_OPTS) \ + LD="$(TARGET_CXX)" \ + npm_config_arch=$(NODEJS_CPU) \ + npm_config_nodedir=$(BUILD_DIR)/nodejs-$(NODEJS_VERSION) \ + $(HOST_DIR)/usr/bin/npm install \ + $(NODEJS_MODULES_LIST) \ + ) +endef +endif + +define NODEJS_INSTALL_TARGET_CMDS + $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) DESTDIR=$(TARGET_DIR) install + $(NODEJS_INSTALL_MODULES) +endef + +# node.js configure is a Python script and does not use autotools +$(eval $(generic-package)) +$(eval $(host-generic-package))