nodejs: add 0.12 version of node
add node-js 0.12 and a few gyp bindings Signed-off-by: John Crispin <blogic@openwrt.org>
This commit is contained in:
parent
23bee2145f
commit
1fd7b5d1e6
12 changed files with 3171 additions and 0 deletions
63
lang/node-arduino-firmata/Makefile
Normal file
63
lang/node-arduino-firmata/Makefile
Normal file
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# Copyright (C) 2014 Arduino LLC
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NPM_NAME:=arduino-firmata
|
||||
PKG_NAME:=node-$(PKG_NPM_NAME)
|
||||
PKG_VERSION:=0.3.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=v$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/shokai/node-arduino-firmata/archive/
|
||||
|
||||
PKG_BUILD_DEPENDS:=node
|
||||
PKG_NODE_VERSION:=0.12.7
|
||||
|
||||
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||
PKG_LICENSE:=
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/node-arduino-firmata
|
||||
DEPENDS:=+node
|
||||
SUBMENU:=Node.js
|
||||
SECTION:=lang
|
||||
CATEGORY:=Languages
|
||||
DEPENDS:=+node +node-serialport
|
||||
TITLE:=Node.js package to access serial ports for reading and writing
|
||||
URL:=https://www.npmjs.org/package/serialport
|
||||
endef
|
||||
|
||||
define Package/node-arduino-firmata/description
|
||||
Node.js package to access serial ports for reading and writing OR Welcome your robotic JavaScript overlords. Better yet, program them!
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
/bin/tar xzf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components 1
|
||||
$(Build/Patch)
|
||||
endef
|
||||
|
||||
EXTRA_LDFLAGS="-L$(TOOLCHAIN_DIR)/lib/ -Wl,-rpath-link $(TOOLCHAIN_DIR)/lib/" \
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE_FLAGS) \
|
||||
npm_config_arch=$(CONFIG_ARCH) \
|
||||
npm_config_nodedir=$(BUILD_DIR)/node-v$(PKG_NODE_VERSION)/ \
|
||||
PREFIX="$(PKG_INSTALL_DIR)/usr/" \
|
||||
$(STAGING_DIR_HOST)/bin/npm install -g $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Package/node-arduino-firmata/install
|
||||
mkdir -p $(1)/usr/lib/node
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/* $(1)/usr/lib/node
|
||||
rm -rf $(1)/usr/lib/node/arduino-firmata/node_modules/serialport/
|
||||
$(CP) -r ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,node-arduino-firmata))
|
||||
|
|
@ -0,0 +1,306 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
var ArduinoFirmata, SerialPort, debug, events, exports, serialport,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
events = require('eventemitter2');
|
||||
|
||||
SerialPort = (serialport = require('serialport')).SerialPort;
|
||||
|
||||
debug = require('debug')('arduino-firmata');
|
||||
|
||||
exports = module.exports = ArduinoFirmata = (function(superClass) {
|
||||
extend(ArduinoFirmata, superClass);
|
||||
|
||||
ArduinoFirmata.Status = {
|
||||
CLOSE: 0,
|
||||
OPEN: 1
|
||||
};
|
||||
|
||||
ArduinoFirmata.INPUT = 0;
|
||||
|
||||
ArduinoFirmata.OUTPUT = 1;
|
||||
|
||||
ArduinoFirmata.ANALOG = 2;
|
||||
|
||||
ArduinoFirmata.PWM = 3;
|
||||
|
||||
ArduinoFirmata.SERVO = 4;
|
||||
|
||||
ArduinoFirmata.SHIFT = 5;
|
||||
|
||||
ArduinoFirmata.I2C = 6;
|
||||
|
||||
ArduinoFirmata.LOW = 0;
|
||||
|
||||
ArduinoFirmata.HIGH = 1;
|
||||
|
||||
ArduinoFirmata.MAX_DATA_BYTES = 32;
|
||||
|
||||
ArduinoFirmata.DIGITAL_MESSAGE = 0x90;
|
||||
|
||||
ArduinoFirmata.ANALOG_MESSAGE = 0xE0;
|
||||
|
||||
ArduinoFirmata.REPORT_ANALOG = 0xC0;
|
||||
|
||||
ArduinoFirmata.REPORT_DIGITAL = 0xD0;
|
||||
|
||||
ArduinoFirmata.SET_PIN_MODE = 0xF4;
|
||||
|
||||
ArduinoFirmata.REPORT_VERSION = 0xF9;
|
||||
|
||||
ArduinoFirmata.SYSTEM_RESET = 0xFF;
|
||||
|
||||
ArduinoFirmata.START_SYSEX = 0xF0;
|
||||
|
||||
ArduinoFirmata.END_SYSEX = 0xF7;
|
||||
|
||||
ArduinoFirmata.list = function(callback) {
|
||||
return serialport.list(function(err, ports) {
|
||||
var devices, j, len, port;
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
devices = [];
|
||||
for (j = 0, len = ports.length; j < len; j++) {
|
||||
port = ports[j];
|
||||
if (/usb|acm|com\d+/i.test(port.comName)) {
|
||||
devices.push(port.comName);
|
||||
}
|
||||
}
|
||||
return callback(null, devices);
|
||||
});
|
||||
};
|
||||
|
||||
function ArduinoFirmata() {
|
||||
this.status = ArduinoFirmata.Status.CLOSE;
|
||||
this.wait_for_data = 0;
|
||||
this.execute_multi_byte_command = 0;
|
||||
this.multi_byte_channel = 0;
|
||||
this.stored_input_data = [];
|
||||
this.parsing_sysex = false;
|
||||
this.sysex_bytes_read = 0;
|
||||
this.digital_output_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
this.digital_input_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
this.analog_input_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
this.boardVersion = null;
|
||||
}
|
||||
|
||||
ArduinoFirmata.prototype.isOldArduinoDevice = function() {
|
||||
return /usbserial|USB/.test(this.serialport_name);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.connect = function(serialport_name, opts) {
|
||||
this.serialport_name = serialport_name;
|
||||
if (opts == null) {
|
||||
opts = {
|
||||
baudrate: 57600
|
||||
};
|
||||
}
|
||||
opts.parser = serialport.parsers.raw;
|
||||
if (!this.serialport_name) {
|
||||
ArduinoFirmata.list((function(_this) {
|
||||
return function(err, devices) {
|
||||
return _this.connect(devices[0], opts);
|
||||
};
|
||||
})(this));
|
||||
return this;
|
||||
}
|
||||
this.once('boardReady', function() {
|
||||
var io_init_wait;
|
||||
debug('boardReady');
|
||||
io_init_wait = this.isOldArduinoDevice() ? (debug("old arduino device found " + this.serialport_name), 3000) : (debug("new arduino device found " + this.serialport_name), 100);
|
||||
debug("wait " + io_init_wait + "(msec)");
|
||||
return setTimeout((function(_this) {
|
||||
return function() {
|
||||
var i, j, k;
|
||||
for (i = j = 0; j < 6; i = ++j) {
|
||||
_this.write([ArduinoFirmata.REPORT_ANALOG | i, 1]);
|
||||
}
|
||||
for (i = k = 0; k < 2; i = ++k) {
|
||||
_this.write([ArduinoFirmata.REPORT_DIGITAL | i, 1]);
|
||||
}
|
||||
debug('init IO ports');
|
||||
return _this.emit('connect');
|
||||
};
|
||||
})(this), io_init_wait);
|
||||
});
|
||||
this.serialport = new SerialPort(this.serialport_name, opts);
|
||||
this.serialport.once('open', (function(_this) {
|
||||
return function() {
|
||||
var cid;
|
||||
cid = setInterval(function() {
|
||||
debug('request REPORT_VERSION');
|
||||
return _this.write([ArduinoFirmata.REPORT_VERSION]);
|
||||
}, 500);
|
||||
_this.once('boardVersion', function(version) {
|
||||
clearInterval(cid);
|
||||
_this.status = ArduinoFirmata.Status.OPEN;
|
||||
return _this.emit('boardReady');
|
||||
});
|
||||
return _this.serialport.on('data', function(data) {
|
||||
var byte, j, len, results;
|
||||
results = [];
|
||||
for (j = 0, len = data.length; j < len; j++) {
|
||||
byte = data[j];
|
||||
results.push(_this.process_input(byte));
|
||||
}
|
||||
return results;
|
||||
});
|
||||
};
|
||||
})(this));
|
||||
return this;
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.isOpen = function() {
|
||||
return this.status === ArduinoFirmata.Status.OPEN;
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.close = function(callback) {
|
||||
this.status = ArduinoFirmata.Status.CLOSE;
|
||||
return this.serialport.close(callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.reset = function(callback) {
|
||||
return this.write([ArduinoFirmata.SYSTEM_RESET], callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.write = function(bytes, callback) {
|
||||
return this.serialport.write(bytes, callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.sysex = function(command, data, callback) {
|
||||
var write_data;
|
||||
if (data == null) {
|
||||
data = [];
|
||||
}
|
||||
data = data.map(function(i) {
|
||||
return i & 0x7f;
|
||||
});
|
||||
write_data = [ArduinoFirmata.START_SYSEX, command].concat(data, [ArduinoFirmata.END_SYSEX]);
|
||||
return this.write(write_data, callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.pinMode = function(pin, mode, callback) {
|
||||
switch (mode) {
|
||||
case true:
|
||||
mode = ArduinoFirmata.OUTPUT;
|
||||
break;
|
||||
case false:
|
||||
mode = ArduinoFirmata.INPUT;
|
||||
}
|
||||
return this.write([ArduinoFirmata.SET_PIN_MODE, pin, mode], callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.digitalWrite = function(pin, value, callback) {
|
||||
var port_num;
|
||||
this.pinMode(pin, ArduinoFirmata.OUTPUT);
|
||||
port_num = (pin >>> 3) & 0x0F;
|
||||
if (value === 0 || value === false) {
|
||||
this.digital_output_data[port_num] &= ~(1 << (pin & 0x07));
|
||||
} else {
|
||||
this.digital_output_data[port_num] |= 1 << (pin & 0x07);
|
||||
}
|
||||
return this.write([ArduinoFirmata.DIGITAL_MESSAGE | port_num, this.digital_output_data[port_num] & 0x7F, this.digital_output_data[port_num] >>> 7], callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.analogWrite = function(pin, value, callback) {
|
||||
value = Math.floor(value);
|
||||
this.pinMode(pin, ArduinoFirmata.PWM);
|
||||
return this.write([ArduinoFirmata.ANALOG_MESSAGE | (pin & 0x0F), value & 0x7F, value >>> 7], callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.servoWrite = function(pin, angle, callback) {
|
||||
this.pinMode(pin, ArduinoFirmata.SERVO);
|
||||
return this.write([ArduinoFirmata.ANALOG_MESSAGE | (pin & 0x0F), angle & 0x7F, angle >>> 7], callback);
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.digitalRead = function(pin) {
|
||||
return ((this.digital_input_data[pin >>> 3] >>> (pin & 0x07)) & 0x01) > 0;
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.analogRead = function(pin) {
|
||||
return this.analog_input_data[pin];
|
||||
};
|
||||
|
||||
ArduinoFirmata.prototype.process_input = function(input_data) {
|
||||
var analog_value, command, diff, i, j, old_analog_value, results, stat, sysex_command, sysex_data;
|
||||
if (this.parsing_sysex) {
|
||||
if (input_data === ArduinoFirmata.END_SYSEX) {
|
||||
this.parsing_sysex = false;
|
||||
sysex_command = this.stored_input_data[0];
|
||||
sysex_data = this.stored_input_data.slice(1, this.sysex_bytes_read);
|
||||
return this.emit('sysex', {
|
||||
command: sysex_command,
|
||||
data: sysex_data
|
||||
});
|
||||
} else {
|
||||
this.stored_input_data[this.sysex_bytes_read] = input_data;
|
||||
return this.sysex_bytes_read += 1;
|
||||
}
|
||||
} else if (this.wait_for_data > 0 && input_data < 128) {
|
||||
this.wait_for_data -= 1;
|
||||
this.stored_input_data[this.wait_for_data] = input_data;
|
||||
if (this.execute_multi_byte_command !== 0 && this.wait_for_data === 0) {
|
||||
switch (this.execute_multi_byte_command) {
|
||||
case ArduinoFirmata.DIGITAL_MESSAGE:
|
||||
input_data = (this.stored_input_data[0] << 7) + this.stored_input_data[1];
|
||||
diff = this.digital_input_data[this.multi_byte_channel] ^ input_data;
|
||||
this.digital_input_data[this.multi_byte_channel] = input_data;
|
||||
if (this.listeners('digitalChange').length > 0) {
|
||||
results = [];
|
||||
for (i = j = 0; j <= 13; i = ++j) {
|
||||
if (((0x01 << i) & diff) > 0) {
|
||||
stat = (input_data & diff) > 0;
|
||||
results.push(this.emit('digitalChange', {
|
||||
pin: i + this.multi_byte_channel * 8,
|
||||
value: stat,
|
||||
old_value: !stat
|
||||
}));
|
||||
} else {
|
||||
results.push(void 0);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
break;
|
||||
case ArduinoFirmata.ANALOG_MESSAGE:
|
||||
analog_value = (this.stored_input_data[0] << 7) + this.stored_input_data[1];
|
||||
old_analog_value = this.analogRead(this.multi_byte_channel);
|
||||
this.analog_input_data[this.multi_byte_channel] = analog_value;
|
||||
if (old_analog_value !== analog_value) {
|
||||
return this.emit('analogChange', {
|
||||
pin: this.multi_byte_channel,
|
||||
value: analog_value,
|
||||
old_value: old_analog_value
|
||||
});
|
||||
}
|
||||
break;
|
||||
case ArduinoFirmata.REPORT_VERSION:
|
||||
this.boardVersion = this.stored_input_data[1] + "." + this.stored_input_data[0];
|
||||
return this.emit('boardVersion', this.boardVersion);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (input_data < 0xF0) {
|
||||
command = input_data & 0xF0;
|
||||
this.multi_byte_channel = input_data & 0x0F;
|
||||
} else {
|
||||
command = input_data;
|
||||
}
|
||||
if (command === ArduinoFirmata.START_SYSEX) {
|
||||
this.parsing_sysex = true;
|
||||
return this.sysex_bytes_read = 0;
|
||||
} else if (command === ArduinoFirmata.DIGITAL_MESSAGE || command === ArduinoFirmata.ANALOG_MESSAGE || command === ArduinoFirmata.REPORT_VERSION) {
|
||||
this.wait_for_data = 2;
|
||||
return this.execute_multi_byte_command = command;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return ArduinoFirmata;
|
||||
|
||||
})(events.EventEmitter2);
|
||||
|
||||
}).call(this);
|
10
lang/node-arduino-firmata/patches/000-new-serialport.patch
Normal file
10
lang/node-arduino-firmata/patches/000-new-serialport.patch
Normal file
|
@ -0,0 +1,10 @@
|
|||
--- a/package.json
|
||||
+++ b/package.json
|
||||
@@ -30,7 +30,6 @@
|
||||
"author": "Sho Hashimoto <hashimoto@shokai.org>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
- "serialport": "*",
|
||||
"eventemitter2": "*",
|
||||
"debug": "*"
|
||||
},
|
94
lang/node-cylon/Makefile
Normal file
94
lang/node-cylon/Makefile
Normal file
|
@ -0,0 +1,94 @@
|
|||
#
|
||||
# Copyright (C) 2014 Arduino LLC
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NPM_NAME:=cylon
|
||||
PKG_NAME:=node-$(PKG_NPM_NAME)
|
||||
PKG_VERSION:=1.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=v0.22.0.tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/hybridgroup/cylon-firmata/archive/
|
||||
|
||||
PKG_BUILD_DEPENDS:=node
|
||||
PKG_NODE_VERSION:=0.12.7
|
||||
|
||||
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/node-cylon/default
|
||||
DEPENDS:=+node $(2)
|
||||
SUBMENU:=Node.js
|
||||
SECTION:=lang
|
||||
CATEGORY:=Languages
|
||||
TITLE:=CylonJS - $(1)
|
||||
URL:=https://www.npmjs.org/package/cylon
|
||||
endef
|
||||
|
||||
define Package/node-cylon
|
||||
$(call Package/node-cylon/default,Core)
|
||||
endef
|
||||
|
||||
define Package/node-cylon-i2c
|
||||
$(call Package/node-cylon/default,I2C,+node-cylon)
|
||||
endef
|
||||
|
||||
define Package/node-cylon-gpio
|
||||
$(call Package/node-cylon/default,GPIO,+node-cylon)
|
||||
endef
|
||||
|
||||
define Package/node-cylon-firmata
|
||||
$(call Package/node-cylon/default,Firmata,+node-cylon-gpio +node-cylon-i2c +node-arduino-firmata)
|
||||
endef
|
||||
|
||||
define Package/node-cylon/description
|
||||
JavaScript Robotics, By Your Command Next generation robotics framework with support for 36 different platforms Get Started
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
/bin/tar xzf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components 1
|
||||
$(Build/Patch)
|
||||
endef
|
||||
|
||||
EXTRA_LDFLAGS="-L$(TOOLCHAIN_DIR)/lib/ -Wl,-rpath-link $(TOOLCHAIN_DIR)/lib/" \
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE_FLAGS) \
|
||||
npm_config_arch=$(CONFIG_ARCH) \
|
||||
npm_config_nodedir=$(BUILD_DIR)/node-v$(PKG_NODE_VERSION)/ \
|
||||
PREFIX="$(PKG_INSTALL_DIR)/usr/" \
|
||||
$(STAGING_DIR_HOST)/bin/npm install -g $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Package/node-cylon/install
|
||||
mkdir -p $(1)/usr/lib/node/cylon
|
||||
$(CP) -r $(PKG_INSTALL_DIR)/usr/lib/node_modules/cylon-firmata/node_modules/cylon/* $(1)/usr/lib/node/cylon/
|
||||
endef
|
||||
|
||||
define Package/node-cylon-i2c/install
|
||||
mkdir -p $(1)/usr/lib/node/cylon-i2c
|
||||
$(CP) -r $(PKG_INSTALL_DIR)/usr/lib/node_modules/cylon-firmata/node_modules/cylon-i2c/* $(1)/usr/lib/node/cylon-i2c/
|
||||
endef
|
||||
|
||||
define Package/node-cylon-gpio/install
|
||||
mkdir -p $(1)/usr/lib/node/cylon-gpio
|
||||
$(CP) -r $(PKG_INSTALL_DIR)/usr/lib/node_modules/cylon-firmata/node_modules/cylon-gpio/* $(1)/usr/lib/node/cylon-gpio/
|
||||
endef
|
||||
|
||||
define Package/node-cylon-firmata/install
|
||||
mkdir -p $(1)/usr/lib/node/cylon-firmata
|
||||
$(CP) -r $(PKG_INSTALL_DIR)/usr/lib/node_modules/cylon-firmata/{index.js,lib,LICENSE,package.json,README.md,RELEASES.md,spec} $(1)/usr/lib/node/cylon-firmata/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,node-cylon))
|
||||
$(eval $(call BuildPackage,node-cylon-i2c))
|
||||
$(eval $(call BuildPackage,node-cylon-gpio))
|
||||
$(eval $(call BuildPackage,node-cylon-firmata))
|
||||
|
62
lang/node-hid/Makefile
Normal file
62
lang/node-hid/Makefile
Normal file
|
@ -0,0 +1,62 @@
|
|||
#
|
||||
# Copyright (C) 2015 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NPM_NAME:=hid
|
||||
PKG_NAME:=node-$(PKG_NPM_NAME)
|
||||
PKG_VERSION:=0.4.0
|
||||
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/node-hid/node-hid.git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=c56c8aa5d113c6f2574d1f7e64d41745702965bb
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
|
||||
PKG_BUILD_DEPENDS:=node
|
||||
PKG_NODE_VERSION:=0.12.7
|
||||
|
||||
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||
PKG_LICENSE:=MIT
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/node-hid
|
||||
DEPENDS:=+node
|
||||
SUBMENU:=Node.js
|
||||
SECTION:=lang
|
||||
CATEGORY:=Languages
|
||||
DEPENDS:=+libusb-1.0 +hidapi +libstdcpp
|
||||
TITLE:=Node.js package to access HID devices
|
||||
URL:=https://github.com/node-hid/node-hid
|
||||
endef
|
||||
|
||||
define Package/node-hid/description
|
||||
Node.js package to access HID devices
|
||||
endef
|
||||
|
||||
EXTRA_LDFLAGS+="-lhidapi-libusb"
|
||||
EXTRA_CFLAGS+="-I$(STAGING_DIR)/usr/include/hidapi/"
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE_VARS) \
|
||||
$(MAKE_FLAGS) \
|
||||
npm_config_arch=$(CONFIG_ARCH) \
|
||||
npm_config_nodedir=$(BUILD_DIR)/node-v$(PKG_NODE_VERSION)/ \
|
||||
PREFIX="$(PKG_INSTALL_DIR)/usr/" \
|
||||
$(STAGING_DIR_HOST)/bin/npm install -g $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Package/node-hid/install
|
||||
mkdir -p $(1)/usr/lib/node/node-hid/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/node-hid/{index.js,package.json,build,node_modules} $(1)/usr/lib/node/node-hid/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,node-hid))
|
||||
|
2457
lang/node-hid/patches/000-compile.patch
Normal file
2457
lang/node-hid/patches/000-compile.patch
Normal file
File diff suppressed because it is too large
Load diff
60
lang/node-serialport/Makefile
Normal file
60
lang/node-serialport/Makefile
Normal file
|
@ -0,0 +1,60 @@
|
|||
#
|
||||
# Copyright (C) 2014 Arduino LLC
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NPM_NAME:=serialport
|
||||
PKG_NAME:=node-$(PKG_NPM_NAME)
|
||||
PKG_VERSION:=1.4.6
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NPM_NAME)-$(PKG_VERSION).tgz
|
||||
PKG_SOURCE_URL:=http://registry.npmjs.org/$(PKG_NPM_NAME)/-/
|
||||
PKG_MD5SUM:=1eb21082e0aa676b8350182a60230808
|
||||
|
||||
PKG_BUILD_DEPENDS:=node
|
||||
PKG_NODE_VERSION:=0.12.7
|
||||
|
||||
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/node-serialport
|
||||
DEPENDS:=+node
|
||||
SUBMENU:=Node.js
|
||||
SECTION:=lang
|
||||
CATEGORY:=Languages
|
||||
TITLE:=Node.js package to access serial ports for reading and writing
|
||||
URL:=https://www.npmjs.org/package/serialport
|
||||
endef
|
||||
|
||||
define Package/node-serialport/description
|
||||
Node.js package to access serial ports for reading and writing OR Welcome your robotic JavaScript overlords. Better yet, program them!
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
/bin/tar xzf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components 1
|
||||
$(Build/Patch)
|
||||
endef
|
||||
|
||||
EXTRA_LDFLAGS="-L$(TOOLCHAIN_DIR)/lib/ -Wl,-rpath-link $(TOOLCHAIN_DIR)/lib/" \
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE_FLAGS) \
|
||||
npm_config_arch=$(CONFIG_ARCH) \
|
||||
npm_config_nodedir=$(BUILD_DIR)/node-v$(PKG_NODE_VERSION)/ \
|
||||
PREFIX="$(PKG_INSTALL_DIR)/usr/" \
|
||||
$(STAGING_DIR_HOST)/bin/npm install -g $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Package/node-serialport/install
|
||||
mkdir -p $(1)/usr/lib/node/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/* $(1)/usr/lib/node/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,node-serialport))
|
||||
|
11
lang/node-serialport/patches/package.json.patch
Normal file
11
lang/node-serialport/patches/package.json.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/package.json 2014-05-02 12:02:02.940515727 +0200
|
||||
+++ b/package.json 2014-05-02 12:03:08.488512762 +0200
|
||||
@@ -69,7 +71,7 @@
|
||||
"serialportterm": "./bin/serialportTerminal.js"
|
||||
},
|
||||
"scripts": {
|
||||
- "install": "node-pre-gyp install --fallback-to-build",
|
||||
+ "install": "node-pre-gyp reinstall --build-from-source --target_arch=${npm_config_arch}",
|
||||
"test": "grunt --verbose"
|
||||
}
|
||||
}
|
71
lang/node/Makefile
Normal file
71
lang/node/Makefile
Normal file
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=node
|
||||
PKG_VERSION:=v0.12.7
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=node-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://nodejs.org/dist/${PKG_VERSION}
|
||||
|
||||
PKG_INSTALL:=1
|
||||
|
||||
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||
PKG_LICENSE:=
|
||||
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/node
|
||||
SECTION:=lang
|
||||
CATEGORY:=Languages
|
||||
SUBMENU:=Node.js
|
||||
TITLE:=Node.js is a platform built on Chrome's JavaScript runtime
|
||||
URL:=http://nodejs.org/
|
||||
DEPENDS:=+libpthread +librt +libstdcpp +libopenssl +libuv
|
||||
endef
|
||||
|
||||
define Package/node/description
|
||||
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses
|
||||
an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js'
|
||||
package ecosystem, npm, is the largest ecosystem of open source libraries in the world.
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS= \
|
||||
--dest-cpu=$(CONFIG_ARCH) \
|
||||
--dest-os=linux \
|
||||
--without-snapshot \
|
||||
--shared-zlib \
|
||||
--shared-openssl \
|
||||
--prefix=/usr
|
||||
|
||||
HOST_CONFIGURE_VARS:=
|
||||
HOST_CONFIGURE_ARGS:= \
|
||||
--dest-os=linux \
|
||||
--without-snapshot \
|
||||
--prefix=$(STAGING_DIR_HOST)/
|
||||
|
||||
HOST_CONFIGURE_CMD:=python ./configure
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
|
||||
endef
|
||||
|
||||
define Package/node/install
|
||||
mkdir -p $(1)/usr/bin $(1)/usr/lib/node_modules/npm/{bin,lib,node_modules}
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/bin/{node,npm} $(1)/usr/bin/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/{package.json,LICENSE,cli.js} $(1)/usr/lib/node_modules/npm
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/bin/npm-cli.js $(1)/usr/lib/node_modules/npm/bin
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/lib/* $(1)/usr/lib/node_modules/npm/lib/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/node_modules/npm/node_modules/* $(1)/usr/lib/node_modules/npm/node_modules/
|
||||
endef
|
||||
|
||||
$(eval $(call HostBuild))
|
||||
$(eval $(call BuildPackage,node))
|
15
lang/node/patches/001-mips-no-fpu.patch
Normal file
15
lang/node/patches/001-mips-no-fpu.patch
Normal file
|
@ -0,0 +1,15 @@
|
|||
--- a/deps/v8/build/toolchain.gypi
|
||||
+++ b/deps/v8/build/toolchain.gypi
|
||||
@@ -50,10 +50,10 @@
|
||||
'arm_test_noprobe%': 'off',
|
||||
|
||||
# Similar to vfp but on MIPS.
|
||||
- 'v8_can_use_fpu_instructions%': 'true',
|
||||
+ 'v8_can_use_fpu_instructions%': 'false',
|
||||
|
||||
# Similar to the ARM hard float ABI but on MIPS.
|
||||
- 'v8_use_mips_abi_hardfloat%': 'true',
|
||||
+ 'v8_use_mips_abi_hardfloat%': 'false',
|
||||
|
||||
# Default arch variant for MIPS.
|
||||
'mips_arch_variant%': 'r2',
|
10
lang/node/patches/002-addr_info.patch
Normal file
10
lang/node/patches/002-addr_info.patch
Normal file
|
@ -0,0 +1,10 @@
|
|||
--- a/deps/uv/src/unix/getaddrinfo.c
|
||||
+++ b/deps/uv/src/unix/getaddrinfo.c
|
||||
@@ -99,6 +99,7 @@
|
||||
int err;
|
||||
|
||||
req = container_of(w, uv_getaddrinfo_t, work_req);
|
||||
+ req->hints->ai_flags &= ~AI_V4MAPPED;
|
||||
err = getaddrinfo(req->hostname, req->service, req->hints, &req->addrinfo);
|
||||
req->retcode = uv__getaddrinfo_translate_error(err);
|
||||
}
|
12
lang/node/patches/003-path.patch
Normal file
12
lang/node/patches/003-path.patch
Normal file
|
@ -0,0 +1,12 @@
|
|||
--- a/lib/module.js
|
||||
+++ b/lib/module.js
|
||||
@@ -512,7 +512,8 @@
|
||||
var homeDir = process.env.HOME;
|
||||
}
|
||||
|
||||
- var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')];
|
||||
+ var paths = [path.resolve(process.execPath, '..', '..', 'lib', 'node'),
|
||||
+ path.resolve(process.execPath, '..', '..', 'lib', 'node_modules')];
|
||||
|
||||
if (homeDir) {
|
||||
paths.unshift(path.resolve(homeDir, '.node_libraries'));
|
Loading…
Reference in a new issue