From c6f375f3d287e9ee36a04fbe12dbb85ed97927f7 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 10 Dec 2020 16:12:40 -0600 Subject: [PATCH 01/13] fix: submodule not being instantiated --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9e9d005..5ab4369 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,9 @@ }, "scripts": { "test": "mocha test && standard", - "preinstall": "node build.js" + "build": "node build.js", + "submodule": "git submodule update --recursive --init", + "prepare": "npm run submodule && npm run build" }, "devDependencies": { "electron-download": "^3.0.1", From 06e16017a5360c1e2581aa735f30312b0e70fc43 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 10 Dec 2020 17:44:58 -0600 Subject: [PATCH 02/13] fix: use postinstall to make sure the script runs on installation as a dependency --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5ab4369..1cab500 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "test": "mocha test && standard", "build": "node build.js", "submodule": "git submodule update --recursive --init", - "prepare": "npm run submodule && npm run build" + "prepare": "npm run submodule && npm run build", + "postinstall": "npm run build" }, "devDependencies": { "electron-download": "^3.0.1", From ab6210c1152e34eb4739ab9bf9c3868995d5b61d Mon Sep 17 00:00:00 2001 From: Amin Yahyaabaadi Date: Tue, 15 Dec 2020 12:17:46 -0600 Subject: [PATCH 03/13] fix: support macos - add new target and exe path --- build.js | 4 ++++ lib/minidump.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index 37959f2..8b71615 100644 --- a/build.js +++ b/build.js @@ -18,6 +18,10 @@ const targets = ['src/processor/minidump_stackwalk', 'src/processor/minidump_dum if (process.platform === 'linux') { targets.push('src/tools/linux/dump_syms/dump_syms') } +if (process.platform === 'darwin') { + targets.push('src/tools/mac/dump_syms/dump_syms_tool') +} + spawnSync('make', ['-C', buildDir, '-j', require('os').cpus().length, ...targets], { stdio: 'inherit' }) diff --git a/lib/minidump.js b/lib/minidump.js index e949b46..b93f740 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -9,7 +9,7 @@ const commands = { minidump_dump: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_dump') + exe, dump_syms: (() => { if (process.platform === 'darwin') { - return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms_mac') + return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms') } else if (process.platform === 'linux') { return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms') } From a0583179357d9cb8f454b3937cb25415b08a8432 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabaadi Date: Tue, 15 Dec 2020 12:23:11 -0600 Subject: [PATCH 04/13] fix: add includes needed for mac target --- build.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build.js b/build.js index 8b71615..259a6bc 100644 --- a/build.js +++ b/build.js @@ -6,11 +6,18 @@ const buildDir = path.join(__dirname, 'build') if (!fs.existsSync(buildDir)) { fs.mkdirSync(buildDir, { recursive: true }) } + +let includes = `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}` +if (process.platform === 'darwin') { + // needed for `#include "common/*.h"` in `src/tools/mac/dump_syms/dump_syms_tool` + includes = includes + ` -I${path.relative(buildDir, path.join(__dirname, 'deps', 'breakpad', 'src'))}` +} + spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], { cwd: buildDir, env: { ...process.env, - CPPFLAGS: `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}` + CPPFLAGS: includes }, stdio: 'inherit' }) @@ -22,6 +29,6 @@ if (process.platform === 'darwin') { targets.push('src/tools/mac/dump_syms/dump_syms_tool') } -spawnSync('make', ['-C', buildDir, '-j', require('os').cpus().length, ...targets], { +spawnSync('make', [includes, '-C', buildDir, '-j', require('os').cpus().length, ...targets], { stdio: 'inherit' }) From f93e26e216c5399ed6a7d3bb15193f9b2daa2a8c Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Tue, 15 Dec 2020 12:19:54 -0800 Subject: [PATCH 05/13] use xcodebuild to build dump_syms on mac --- build.js | 13 ++++++------- lib/minidump.js | 2 +- test/minidump-test.js | 2 -- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/build.js b/build.js index 259a6bc..ee15132 100644 --- a/build.js +++ b/build.js @@ -8,10 +8,6 @@ if (!fs.existsSync(buildDir)) { } let includes = `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}` -if (process.platform === 'darwin') { - // needed for `#include "common/*.h"` in `src/tools/mac/dump_syms/dump_syms_tool` - includes = includes + ` -I${path.relative(buildDir, path.join(__dirname, 'deps', 'breakpad', 'src'))}` -} spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], { cwd: buildDir, @@ -25,10 +21,13 @@ const targets = ['src/processor/minidump_stackwalk', 'src/processor/minidump_dum if (process.platform === 'linux') { targets.push('src/tools/linux/dump_syms/dump_syms') } -if (process.platform === 'darwin') { - targets.push('src/tools/mac/dump_syms/dump_syms_tool') -} spawnSync('make', [includes, '-C', buildDir, '-j', require('os').cpus().length, ...targets], { stdio: 'inherit' }) + +if (process.platform === 'darwin') { + spawnSync('xcodebuild', ['-project', path.join(__dirname, 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms.xcodeproj'), 'build'], { + stdio: 'inherit' + }) +} diff --git a/lib/minidump.js b/lib/minidump.js index b93f740..9483b26 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -9,7 +9,7 @@ const commands = { minidump_dump: path.resolve(__dirname, '..', 'build', 'src', 'processor', 'minidump_dump') + exe, dump_syms: (() => { if (process.platform === 'darwin') { - return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'mac', 'dump_syms', 'dump_syms') + return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms') } else if (process.platform === 'linux') { return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms') } diff --git a/test/minidump-test.js b/test/minidump-test.js index 61ca4d5..1e15fd2 100644 --- a/test/minidump-test.js +++ b/test/minidump-test.js @@ -74,8 +74,6 @@ describe('minidump', function () { describe('dumpSymbol()', function () { it('calls back with a minidump', function (done) { - if (process.platform !== 'linux') return this.skip() - downloadElectron(function (error, binaryPath) { if (error) return done(error) minidump.dumpSymbol(binaryPath, function (error, minidump) { From 88f85afc373e8bd7d351a3eef73cbe2f09985e13 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Tue, 15 Dec 2020 12:21:31 -0800 Subject: [PATCH 06/13] exit non-0 when build fails --- build.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.js b/build.js index ee15132..f804a52 100644 --- a/build.js +++ b/build.js @@ -1,6 +1,13 @@ const fs = require('fs') const path = require('path') -const { spawnSync } = require('child_process') +const childProcess = require('child_process') + +function spawnSync(...args) { + const result = childProcess.spawnSync(...args) + if (result.status !== 0) { + process.exit(result.status) + } +} const buildDir = path.join(__dirname, 'build') if (!fs.existsSync(buildDir)) { From e3d7d62022163d2a24704e8b95ccf4d7ad781075 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Tue, 15 Dec 2020 12:29:03 -0800 Subject: [PATCH 07/13] fix lint --- build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.js b/build.js index f804a52..1ecaca5 100644 --- a/build.js +++ b/build.js @@ -2,7 +2,7 @@ const fs = require('fs') const path = require('path') const childProcess = require('child_process') -function spawnSync(...args) { +function spawnSync (...args) { const result = childProcess.spawnSync(...args) if (result.status !== 0) { process.exit(result.status) From 8bddbe7759016fedf9c33dffa3515ddf6073b24d Mon Sep 17 00:00:00 2001 From: Amin Yahyaabaadi Date: Tue, 15 Dec 2020 14:45:09 -0600 Subject: [PATCH 08/13] fix: add dump_syms support on windows --- lib/minidump.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/minidump.js b/lib/minidump.js index 9483b26..82fea80 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -12,6 +12,8 @@ const commands = { return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms') } else if (process.platform === 'linux') { return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms') + } else if (process.platform === 'win32') { + return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'windows', 'binaries', 'dump_syms.exe') } })() } From c7ab644567aa00f2c7fcbcb09d2e646cf43645f5 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabaadi Date: Tue, 15 Dec 2020 14:59:27 -0600 Subject: [PATCH 09/13] fix: change prepare to prepublishOnly + update readme --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b191927..99097f1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ npm install minidump ``` -## Building +## Building (for development) * `git clone --recurse-submodules https://github.com/electron/node-minidump` * `npm install` diff --git a/package.json b/package.json index 1cab500..c2fdaa6 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test": "mocha test && standard", "build": "node build.js", "submodule": "git submodule update --recursive --init", - "prepare": "npm run submodule && npm run build", + "prepublishOnly": "npm run submodule && npm run build", "postinstall": "npm run build" }, "devDependencies": { From 0089bcc8efb782ebc97853af78d5070bb136a7fd Mon Sep 17 00:00:00 2001 From: Amin Yahyaabaadi Date: Tue, 15 Dec 2020 15:06:29 -0600 Subject: [PATCH 10/13] Revert "fix: add dump_syms support on windows" This reverts commit 8bddbe7759016fedf9c33dffa3515ddf6073b24d. --- lib/minidump.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/minidump.js b/lib/minidump.js index 82fea80..9483b26 100644 --- a/lib/minidump.js +++ b/lib/minidump.js @@ -12,8 +12,6 @@ const commands = { return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'mac', 'dump_syms', 'build', 'Release', 'dump_syms') } else if (process.platform === 'linux') { return path.resolve(__dirname, '..', 'build', 'src', 'tools', 'linux', 'dump_syms', 'dump_syms') - } else if (process.platform === 'win32') { - return path.resolve(__dirname, '..', 'deps', 'breakpad', 'src', 'tools', 'windows', 'binaries', 'dump_syms.exe') } })() } From 38c7bb3e3aac5797082aabb3897336f6fab0e666 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Wed, 16 Dec 2020 14:22:00 -0800 Subject: [PATCH 11/13] Update package.json --- package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/package.json b/package.json index c2fdaa6..9e9d005 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,7 @@ }, "scripts": { "test": "mocha test && standard", - "build": "node build.js", - "submodule": "git submodule update --recursive --init", - "prepublishOnly": "npm run submodule && npm run build", - "postinstall": "npm run build" + "preinstall": "node build.js" }, "devDependencies": { "electron-download": "^3.0.1", From 1c683404b5686ba52e3b9d549fba20a73e6d49e6 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Wed, 16 Dec 2020 14:22:36 -0800 Subject: [PATCH 12/13] Update build.js --- build.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.js b/build.js index 1ecaca5..02e68bc 100644 --- a/build.js +++ b/build.js @@ -14,13 +14,11 @@ if (!fs.existsSync(buildDir)) { fs.mkdirSync(buildDir, { recursive: true }) } -let includes = `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}` - spawnSync(path.join(__dirname, 'deps', 'breakpad', 'configure'), [], { cwd: buildDir, env: { ...process.env, - CPPFLAGS: includes + CPPFLAGS: `-I${path.relative(buildDir, path.join(__dirname, 'deps'))}` }, stdio: 'inherit' }) From f5f9ace634cec178bc5bacf317d3a3852c5088ea Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Wed, 16 Dec 2020 14:23:11 -0800 Subject: [PATCH 13/13] Update build.js --- build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.js b/build.js index 02e68bc..df06052 100644 --- a/build.js +++ b/build.js @@ -27,7 +27,7 @@ if (process.platform === 'linux') { targets.push('src/tools/linux/dump_syms/dump_syms') } -spawnSync('make', [includes, '-C', buildDir, '-j', require('os').cpus().length, ...targets], { +spawnSync('make', ['-C', buildDir, '-j', require('os').cpus().length, ...targets], { stdio: 'inherit' })