Skip to content

Commit

Permalink
fix(osx): fix build on OSX
Browse files Browse the repository at this point in the history
OSX uses clang by default, and there were a number of changes in
order to get things building there. As an added bonus, I've cleaned
up a bunch of things given that clang is somewhat stricter out of
the box. In particular these changes are included:

  - switch to using constructor functions rather than constructor
    templates where appropriate

  - a few bug fixes with signed vs unsigned integer comparison

  - switched event support to use an EventEmitter implementation
    rather than callbacks
  • Loading branch information
Matt Broadstone authored and mbroadst committed Apr 22, 2015
1 parent 65337f2 commit 7a94b69
Show file tree
Hide file tree
Showing 27 changed files with 495 additions and 615 deletions.
5 changes: 5 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
'-std=c++11',
'<!@(pkg-config --cflags libvirt)'
],
}],
['OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_RTTI': 'YES'
}
}]
]
}
Expand Down
35 changes: 27 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
'use strict';

var libvirt = require('bindings')('libvirt'),
Promise = require("bluebird");
Promise = require("bluebird"),
EventEmitter = require('events').EventEmitter;

// extend prototype
function inherits(target, source) {
for (var k in source.prototype) {
target.prototype[k] = source.prototype[k];
}
}

Promise.promisifyAll(libvirt.Hypervisor.prototype);
Promise.promisifyAll(libvirt.Domain.prototype);
Expand All @@ -13,6 +21,8 @@ Promise.promisifyAll(libvirt.Secret.prototype);
Promise.promisifyAll(libvirt.StoragePool.prototype);
Promise.promisifyAll(libvirt.StorageVolume.prototype);

inherits(libvirt.Domain, EventEmitter);

/*
* A helper method returning an 'all domains' promise.
*/
Expand All @@ -33,12 +43,21 @@ libvirt.Hypervisor.prototype.getAllDomains = function() {
.then(function(domains) {
return domains.concat(defined);
});
}
};

module.exports = {
Promise: Promise,
startEventLoop: libvirt.setupEvent,
createHypervisor: function(uri, options) {
return new libvirt.Hypervisor(uri, options);
}
libvirt.Promise = Promise;
libvirt.startEventLoop = libvirt.setupEvent,
libvirt.createHypervisor = function(uri, options) {
return new libvirt.Hypervisor(uri, options);
};

module.exports = libvirt;

// module.exports = {
// libvirt: libvirt,
// Promise: Promise,
// startEventLoop: libvirt.setupEvent,
// createHypervisor: function(uri, options) {
// return new libvirt.Hypervisor(uri, options);
// }
// };
Loading

0 comments on commit 7a94b69

Please sign in to comment.