Skip to content
Browse files

Added debug compiler options

* Default "make" target now does compile without debugging information.
Debugging information can be turned on by "make debug" or "node-waf clean configure --debug=true build".

* Added check for ENABLE_DEBUG define
  • Loading branch information...
1 parent 10e4962 commit ff2e535e094b73c965ac08889e5895439d1e78fc Christopher Klein committed Nov 15, 2010
Showing with 30 additions and 6 deletions.
  1. +3 −0 Makefile
  2. +11 −3 README
  3. +0 −1 TODO
  4. +1 −1 src/bindings.cc
  5. +8 −1 src/bindings.h
  6. +1 −0 usb.js
  7. +6 −0 wscript
View
3 Makefile
@@ -1,5 +1,8 @@
make:
node-waf configure clean build; node tests/node-usb-test.js
+debug:
+ node-waf configure --debug=true clean build; node tests/node-usb-test.js
+
create-usb-ids:
rm usb_ids.js; node util/create_usb_ids.js >> usb_ids.js
View
14 README
@@ -8,20 +8,28 @@ Tested with Node version 0.2.4
Installation
==============================
Make sure you have installed libusb-1.0-0-dev (Ubuntu: sudo apt-get install libusb-1.0-0-dev).
+
Just run
- make setup
-in current directory and wait. "Unit tests" can be executed with
+ make
+in current directory and wait. "Unit tests" are automatically executed by default target.
+
+You can although execute the tests by typing:
node tests/node-usb-test.js
If you want to use the USB vendor ids, execute
make create-usb-ids
+For creating debug output you have to compile node-usb with
+ make debug
+or
+ node-waf clean configure --debug=true build
+
+
Examples
=============================
A simple version of lsusb can be executed by typing
node examples/lsusb.js
-
More information
==============================
Christopher Klein <ckl[at]ecw[dot]de>
View
1 TODO
@@ -1,6 +1,5 @@
* Move to asynchronous calls
* read/write streams
-* add debug option as compiler setting
* check for undefined LIBUSB_CLASS_* enums (WIRELESS/APPLICATION)
* finish create_usb_ids.js
* add endpoint and interface descriptor detection
View
2 src/bindings.cc
@@ -373,7 +373,7 @@ namespace NodeUsb {
}
/**
- * @return integer DEBUG("Before init");
+ * @return integer
*/
Handle<Value> Device::DeviceAddressGetter(Local<String> property, const AccessorInfo &info) {
View
9 src/bindings.h
@@ -7,7 +7,14 @@
// Taken from node-libmysqlclient
#define OBJUNWRAP ObjectWrap::Unwrap
#define V8STR(str) String::New(str)
-#define DEBUG(str) fprintf(stderr, "node-usb [%s:%s() %d]: %s", __FILE__, __FUNCTION__, __LINE__, str); fprintf(stderr, "\n");
+
+#ifdef ENABLE_DEBUG
+ #define DEBUG(str) fprintf(stderr, "node-usb [%s:%s() %d]: %s", __FILE__, __FUNCTION__, __LINE__, str); fprintf(stderr, "\n");
+#endif
+
+#ifndef ENABLE_DEBUG
+ #define DEBUG(str)
+#endif
namespace NodeUsb {
class Usb : public EventEmitter {
View
1 usb.js
@@ -6,6 +6,7 @@ var binding = require("./usb_bindings");
exports.create = function() {
var usbInstance = new binding.Usb();
+ // prototype method for finding devices by vendor and product id
usbInstance.find_by_vid_and_pid = function(vid, pid) {
var r = new Array();
var devices = this.getDevices();
View
6 wscript
@@ -6,9 +6,12 @@ srcdir = '.'
blddir = 'build'
VERSION = '0.1'
+# def options(ctx):
+
def set_options(opt):
opt.tool_options("compiler_cxx")
opt.tool_options("compiler_cc")
+ opt.add_option('--debug', action='store', default=False, help='Enable debugging output')
def configure(conf):
conf.check_tool('compiler_cxx')
@@ -32,6 +35,9 @@ def build(bld):
obj.lib = ["usb-1.0"]
obj.name = "node-usb"
obj.linklags = ['/usr/lib/libusb-1.0a']
+
+ if (Options.options.debug != False) and (Options.options.debug == 'true'):
+ obj.defines = ['ENABLE_DEBUG=1']
def shutdown():
t = 'usb_bindings.node';

0 comments on commit ff2e535

Please sign in to comment.
Something went wrong with that request. Please try again.