Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

0 comments on commit ff2e535

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