From ce8c86362f434ce2bb21115860f48d176477506b Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 1 Aug 2016 17:22:30 +0200 Subject: [PATCH] Dump symbols and make them build artifacts --- build/build.js | 3 ++- build/config.js | 3 ++- build/lib/dump-symbols.js | 36 ++++++++++++++++++++++++++++++++++++ build/package.json | 1 + circle.yml | 6 ++++-- 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 build/lib/dump-symbols.js diff --git a/build/build.js b/build/build.js index 3d60c7e0c..7761f0eb7 100755 --- a/build/build.js +++ b/build/build.js @@ -6,6 +6,7 @@ require('coffee-script/register') const cleanOutputDirectory = require('./lib/clean-output-directory') const copyAssets = require('./lib/copy-assets') +const dumpSymbols = require('./lib/dump-symbols') const generateMetadata = require('./lib/generate-metadata') const generateModuleCache = require('./lib/generate-module-cache') const packageApplication = require('./lib/package-application') @@ -25,5 +26,5 @@ transpilePegJsPaths() generateModuleCache() prebuildLessCache() generateMetadata() -packageApplication() writeFingerprint() +dumpSymbols().then(packageApplication) diff --git a/build/config.js b/build/config.js index c81aea757..81064309a 100644 --- a/build/config.js +++ b/build/config.js @@ -13,12 +13,13 @@ const channel = getChannel() const repositoryRootPath = path.resolve(__dirname, '..') const buildOutputPath = path.join(repositoryRootPath, 'out') const intermediateAppPath = path.join(buildOutputPath, 'app') +const symbolsPath = path.join(buildOutputPath, 'symbols') const cachePath = path.join(repositoryRootPath, 'cache') const homeDirPath = process.env.HOME || process.env.USERPROFILE module.exports = { appMetadata, apmMetadata, channel, - repositoryRootPath, buildOutputPath, intermediateAppPath, + repositoryRootPath, buildOutputPath, intermediateAppPath, symbolsPath, cachePath, homeDirPath } diff --git a/build/lib/dump-symbols.js b/build/lib/dump-symbols.js new file mode 100644 index 000000000..76971b6bb --- /dev/null +++ b/build/lib/dump-symbols.js @@ -0,0 +1,36 @@ +const fs = require('fs-extra') +const glob = require('glob') +const minidump = require('minidump') +const path = require('path') + +const CONFIG = require('../config') + +module.exports = function () { + console.log(`Dumping symbols in ${CONFIG.symbolsPath}...`) + const binaryPaths = glob.sync(path.join(CONFIG.intermediateAppPath, 'node_modules', '**', '*.node')) + return Promise.all(binaryPaths.map(dumpSymbol)) +} + +function dumpSymbol (binaryPath) { + return new Promise(function (resolve, reject) { + minidump.dumpSymbol(binaryPath, function (error, content) { + if (error) { + reject(error) + throw new Error(error) + } else { + const moduleLine = /MODULE [^ ]+ [^ ]+ ([0-9A-F]+) (.*)\n/.exec(content) + if (moduleLine.length !== 3) { + reject() + throw new Error(`Invalid output when dumping symbol for ${binaryPath}`) + } else { + const filename = moduleLine[2] + const symbolDirPath = path.join(CONFIG.symbolsPath, filename, moduleLine[1]) + const symbolFilePath = path.join(symbolDirPath, `${filename}.sym`) + fs.mkdirpSync(symbolDirPath) + fs.writeFileSync(symbolFilePath) + resolve() + } + } + }) + }) +} diff --git a/build/package.json b/build/package.json index 9c72e4a0c..1b610b1e9 100644 --- a/build/package.json +++ b/build/package.json @@ -10,6 +10,7 @@ "fs-extra": "0.30.0", "glob": "7.0.3", "legal-eagle": "0.13.0", + "minidump": "0.9.0", "mkdirp": "0.5.1", "normalize-package-data": "2.3.5", "npm": "3.10.5", diff --git a/circle.yml b/circle.yml index a7e5eb2b2..215f2120c 100644 --- a/circle.yml +++ b/circle.yml @@ -9,7 +9,8 @@ machine: general: artifacts: - - out/Atom.zip + - out/atom-mac.zip + - out/atom-mac-symbols.zip dependencies: pre: @@ -23,7 +24,8 @@ dependencies: - build/build.js post: - - zip -r out/Atom.zip out/Atom-darwin-x64 + - cd out/Atom-darwin-x64 && zip -r ../atom-mac.zip ./Atom.app && cd - + - cd out && zip -r ./atom-mac-symbols.zip ./symbols && cd - cache_directories: - cache