diff --git a/.gitmodules b/.gitmodules index 3c56b23..cb75910 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "deps/breakpad"] path = deps/breakpad - url = https://github.com/electron/chromium-breakpad.git + url = https://chromium.googlesource.com/breakpad/breakpad diff --git a/.npmignore b/.npmignore deleted file mode 100644 index fb13d04..0000000 --- a/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -.gitmodules -.npmignore -.travis.yml -npm-debug.log -test diff --git a/bin/minidump_stackwalk b/bin/minidump_stackwalk deleted file mode 100755 index ee83d1f..0000000 --- a/bin/minidump_stackwalk +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env node -var path = require('path'); -var spawn = require('child_process').spawn; - -var stackwalk = path.resolve(__dirname, '..', 'build', 'Release', 'minidump_stackwalk'); -var args = process.argv.slice(2); -var child = spawn(stackwalk, args); -child.stdout.pipe(process.stdout); -child.stderr.pipe(process.stderr); diff --git a/binding.gyp b/binding.gyp deleted file mode 100644 index dc655b3..0000000 --- a/binding.gyp +++ /dev/null @@ -1,17 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'minidump', - 'type': 'none', - 'conditions': [ - ['OS=="win"', { - }, { - 'dependencies': [ - 'deps/breakpad/breakpad.gyp:minidump_stackwalk', - 'deps/breakpad/breakpad.gyp:dump_syms#host', - ], - }], - ], - } - ] -} diff --git a/build.js b/build.js new file mode 100644 index 0000000..b65a49d --- /dev/null +++ b/build.js @@ -0,0 +1,23 @@ +const fs = require('fs') +const path = require('path') +const {spawnSync} = require('child_process') + +const buildDir = path.join(__dirname, 'build') +if (!fs.existsSync(buildDir)) { + fs.mkdirSync(buildDir, {recursive: true}) +} +spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], { + cwd: buildDir, + env: { + ...process.env, + CPPFLAGS: `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}` + }, + stdio: 'inherit' +}) +const targets = ['src/processor/minidump_stackwalk'] +if (process.platform === 'linux') { + targets.push('src/tools/linux/dump_syms/dump_syms') +} +spawnSync('make', ['-C', buildDir, '-j', require('os').cpus().length, ...targets], { + stdio: 'inherit' +}) diff --git a/common.gypi b/common.gypi deleted file mode 100644 index e74d9e6..0000000 --- a/common.gypi +++ /dev/null @@ -1,21 +0,0 @@ -{ - 'variables': { - 'chromeos%': 0, - 'os_bsd%': 0, - 'mac_deployment_target%': '10.9', - }, - 'target_defaults': { - 'conditions': [ - ['OS=="linux"', { - 'cflags': ['-w', '-std=c++0x'], - }], - ['OS=="mac"', { - 'xcode_settings': { - 'OTHER_CFLAGS': ['-w'], - 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', - 'CLANG_CXX_LIBRARY': 'libc++', - } - }] - ] - } -} diff --git a/deps/breakpad b/deps/breakpad index 64ee374..b62101d 160000 --- a/deps/breakpad +++ b/deps/breakpad @@ -1 +1 @@ -Subproject commit 64ee3743b4dd5e34220e2b47701be7be927ebd1f +Subproject commit b62101dead2e9dd10e14252e8b68fbdf56bb40d2 diff --git a/lib/minidump.js b/lib/minidump.js index 4322cc0..e2eb3e3 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -2,33 +2,21 @@ var fs = require('fs') var path = require('path') var spawn = require('child_process').spawn -var searchPaths = [ - path.resolve(__dirname, '..', 'build', 'Release'), - path.resolve(__dirname, '..', 'build', 'Debug'), - path.resolve(__dirname, '..', 'bin') -] - -function searchCommand (command) { - var binaryPath = null - if (process.platform === 'win32') { - command += '.exe' - binaryPath = path.join(__dirname, '..', 'deps', 'breakpad', command) - if (fs.existsSync(binaryPath)) { - return binaryPath - } - } else { - for (var i in searchPaths) { - binaryPath = path.join(searchPaths[i], command) - if (fs.existsSync(binaryPath)) { - return binaryPath - } +const exe = process.platform === 'win32' ? '.exe' : '' +const commands = { + minidump_stackwalk: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_stackwalk') + exe, + dump_syms: (() => { + if (process.platform === 'darwin') { + return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms_mac') + } else if (process.platform === 'linux') { + return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms') } - } + })() } function execute (command, args, callback) { - var stdout = new Buffer(0) - var stderr = new Buffer(0) + var stdout = Buffer.alloc(0) + var stderr = Buffer.alloc(0) var child = spawn(command, args) child.stdout.on('data', function (chunk) { stdout = Buffer.concat([stdout, chunk]) @@ -54,7 +42,7 @@ module.exports.walkStack = function (minidump, symbolPaths, callback, commandArg symbolPaths = [] } - var stackwalk = searchCommand('minidump_stackwalk') + var stackwalk = commands.minidump_stackwalk if (!stackwalk) { callback(new Error('Unable to find "minidump_stackwalk"')) return @@ -66,7 +54,7 @@ module.exports.walkStack = function (minidump, symbolPaths, callback, commandArg } module.exports.dumpSymbol = function (binary, callback) { - var dumpsyms = searchCommand('dump_syms') + var dumpsyms = commands.dump_syms if (!dumpsyms) { callback(new Error('Unable to find "dump_syms"')) return diff --git a/package.json b/package.json index 3de40fd..4041ae4 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "url": "https://github.com/electron/node-minidump/issues" }, "scripts": { - "test": "mocha test && standard" + "test": "mocha test && standard", + "install": "node build.js" }, "devDependencies": { "electron-download": "^3.0.1", @@ -23,5 +24,11 @@ "mocha": "^3.1.2", "standard": "^8.4.0", "temp": "^0.8.3" - } + }, + "files": [ + "LICENSE.md", + "README.md", + "/bin", + "/lib" + ] } diff --git a/test/minidump-test.js b/test/minidump-test.js index bb8a1ef..34e2a37 100644 --- a/test/minidump-test.js +++ b/test/minidump-test.js @@ -74,7 +74,7 @@ describe('minidump', function () { describe('dumpSymbol()', function () { it('calls back with a minidump', function (done) { - if (process.platform === 'win32') return this.skip() + if (process.platform !== 'linux') return this.skip() downloadElectron(function (error, binaryPath) { if (error) return done(error)