Skip to content

Commit cc15fce

Browse files
authored
feat: update breakpad (#32)
1 parent c05cf7c commit cc15fce

File tree

10 files changed

+48
-82
lines changed

10 files changed

+48
-82
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "deps/breakpad"]
22
path = deps/breakpad
3-
url = https://github.com/electron/chromium-breakpad.git
3+
url = https://chromium.googlesource.com/breakpad/breakpad

.npmignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

bin/minidump_stackwalk

Lines changed: 0 additions & 9 deletions
This file was deleted.

binding.gyp

Lines changed: 0 additions & 17 deletions
This file was deleted.

build.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const {spawnSync} = require('child_process')
4+
5+
const buildDir = path.join(__dirname, 'build')
6+
if (!fs.existsSync(buildDir)) {
7+
fs.mkdirSync(buildDir, {recursive: true})
8+
}
9+
spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], {
10+
cwd: buildDir,
11+
env: {
12+
...process.env,
13+
CPPFLAGS: `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}`
14+
},
15+
stdio: 'inherit'
16+
})
17+
const targets = ['src/processor/minidump_stackwalk']
18+
if (process.platform === 'linux') {
19+
targets.push('src/tools/linux/dump_syms/dump_syms')
20+
}
21+
spawnSync('make', ['-C', buildDir, '-j', require('os').cpus().length, ...targets], {
22+
stdio: 'inherit'
23+
})

common.gypi

Lines changed: 0 additions & 21 deletions
This file was deleted.

deps/breakpad

Submodule breakpad updated from 64ee374 to b62101d

lib/minidump.js

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,21 @@ var fs = require('fs')
22
var path = require('path')
33
var spawn = require('child_process').spawn
44

5-
var searchPaths = [
6-
path.resolve(__dirname, '..', 'build', 'Release'),
7-
path.resolve(__dirname, '..', 'build', 'Debug'),
8-
path.resolve(__dirname, '..', 'bin')
9-
]
10-
11-
function searchCommand (command) {
12-
var binaryPath = null
13-
if (process.platform === 'win32') {
14-
command += '.exe'
15-
binaryPath = path.join(__dirname, '..', 'deps', 'breakpad', command)
16-
if (fs.existsSync(binaryPath)) {
17-
return binaryPath
18-
}
19-
} else {
20-
for (var i in searchPaths) {
21-
binaryPath = path.join(searchPaths[i], command)
22-
if (fs.existsSync(binaryPath)) {
23-
return binaryPath
24-
}
5+
const exe = process.platform === 'win32' ? '.exe' : ''
6+
const commands = {
7+
minidump_stackwalk: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_stackwalk') + exe,
8+
dump_syms: (() => {
9+
if (process.platform === 'darwin') {
10+
return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms_mac')
11+
} else if (process.platform === 'linux') {
12+
return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms')
2513
}
26-
}
14+
})()
2715
}
2816

2917
function execute (command, args, callback) {
30-
var stdout = new Buffer(0)
31-
var stderr = new Buffer(0)
18+
var stdout = Buffer.alloc(0)
19+
var stderr = Buffer.alloc(0)
3220
var child = spawn(command, args)
3321
child.stdout.on('data', function (chunk) {
3422
stdout = Buffer.concat([stdout, chunk])
@@ -54,7 +42,7 @@ module.exports.walkStack = function (minidump, symbolPaths, callback, commandArg
5442
symbolPaths = []
5543
}
5644

57-
var stackwalk = searchCommand('minidump_stackwalk')
45+
var stackwalk = commands.minidump_stackwalk
5846
if (!stackwalk) {
5947
callback(new Error('Unable to find "minidump_stackwalk"'))
6048
return
@@ -66,7 +54,7 @@ module.exports.walkStack = function (minidump, symbolPaths, callback, commandArg
6654
}
6755

6856
module.exports.dumpSymbol = function (binary, callback) {
69-
var dumpsyms = searchCommand('dump_syms')
57+
var dumpsyms = commands.dump_syms
7058
if (!dumpsyms) {
7159
callback(new Error('Unable to find "dump_syms"'))
7260
return

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,20 @@
1515
"url": "https://github.com/electron/node-minidump/issues"
1616
},
1717
"scripts": {
18-
"test": "mocha test && standard"
18+
"test": "mocha test && standard",
19+
"install": "node build.js"
1920
},
2021
"devDependencies": {
2122
"electron-download": "^3.0.1",
2223
"extract-zip": "^1.5.0",
2324
"mocha": "^3.1.2",
2425
"standard": "^8.4.0",
2526
"temp": "^0.8.3"
26-
}
27+
},
28+
"files": [
29+
"LICENSE.md",
30+
"README.md",
31+
"/bin",
32+
"/lib"
33+
]
2734
}

test/minidump-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ describe('minidump', function () {
7474

7575
describe('dumpSymbol()', function () {
7676
it('calls back with a minidump', function (done) {
77-
if (process.platform === 'win32') return this.skip()
77+
if (process.platform !== 'linux') return this.skip()
7878

7979
downloadElectron(function (error, binaryPath) {
8080
if (error) return done(error)

0 commit comments

Comments
 (0)