Skip to content

Commit 7a94b69

Browse files
Matt Broadstonembroadst
authored andcommitted
fix(osx): fix build on OSX
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
1 parent 65337f2 commit 7a94b69

27 files changed

+495
-615
lines changed

binding.gyp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
'-std=c++11',
3434
'<!@(pkg-config --cflags libvirt)'
3535
],
36+
}],
37+
['OS=="mac"', {
38+
'xcode_settings': {
39+
'GCC_ENABLE_CPP_RTTI': 'YES'
40+
}
3641
}]
3742
]
3843
}

lib/index.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
'use strict';
22

33
var libvirt = require('bindings')('libvirt'),
4-
Promise = require("bluebird");
4+
Promise = require("bluebird"),
5+
EventEmitter = require('events').EventEmitter;
6+
7+
// extend prototype
8+
function inherits(target, source) {
9+
for (var k in source.prototype) {
10+
target.prototype[k] = source.prototype[k];
11+
}
12+
}
513

614
Promise.promisifyAll(libvirt.Hypervisor.prototype);
715
Promise.promisifyAll(libvirt.Domain.prototype);
@@ -13,6 +21,8 @@ Promise.promisifyAll(libvirt.Secret.prototype);
1321
Promise.promisifyAll(libvirt.StoragePool.prototype);
1422
Promise.promisifyAll(libvirt.StorageVolume.prototype);
1523

24+
inherits(libvirt.Domain, EventEmitter);
25+
1626
/*
1727
* A helper method returning an 'all domains' promise.
1828
*/
@@ -33,12 +43,21 @@ libvirt.Hypervisor.prototype.getAllDomains = function() {
3343
.then(function(domains) {
3444
return domains.concat(defined);
3545
});
36-
}
46+
};
3747

38-
module.exports = {
39-
Promise: Promise,
40-
startEventLoop: libvirt.setupEvent,
41-
createHypervisor: function(uri, options) {
42-
return new libvirt.Hypervisor(uri, options);
43-
}
48+
libvirt.Promise = Promise;
49+
libvirt.startEventLoop = libvirt.setupEvent,
50+
libvirt.createHypervisor = function(uri, options) {
51+
return new libvirt.Hypervisor(uri, options);
4452
};
53+
54+
module.exports = libvirt;
55+
56+
// module.exports = {
57+
// libvirt: libvirt,
58+
// Promise: Promise,
59+
// startEventLoop: libvirt.setupEvent,
60+
// createHypervisor: function(uri, options) {
61+
// return new libvirt.Hypervisor(uri, options);
62+
// }
63+
// };

0 commit comments

Comments
 (0)