win: Register msdia80.dll automatically when dumping symbols.
authorCheng Zhao <zcbenz@gmail.com>
Tue, 26 Nov 2013 14:05:32 +0000 (22:05 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 26 Nov 2013 14:05:32 +0000 (22:05 +0800)
docs/development/build-instructions-windows.md
package.json
tools/win/generate_breakpad_symbols.py
tools/win/register_msdia80_dll.js [new file with mode: 0644]

index 4a9613c..cfa2e65 100644 (file)
@@ -18,14 +18,6 @@ softwares:
 * [Windows 7 SDK](http://www.microsoft.com/en-us/download/details.aspx?id=8279)
   * `Windows Headers` and `Visual C++ Compilers` are required.
 
-If you want to dump breakpad symbols you also need to do this (you are free to
-skip this step if you don't know what it is):
-
-1. Get a copy of `msdia80.dll` and put it in
-   `C:\Program Files\Common Files\Microsoft Shared\VC\`.
-2. As Administrator, run:
-   `regsvr32 "C:\Program Files\Common Files\Microsoft Shared\VC\msdia80.dll"`.
-
 The instructions bellow are executed under [cygwin](http://www.cygwin.com),
 but it's not a requirement, you can also build atom-shell under Windows's
 console or other terminals.
index fcdba23..81f9c61 100644 (file)
@@ -7,6 +7,7 @@
     "coffeelint": "~0.6.1",
     "mocha": "~1.13.0",
     "walkdir": "~0.0.7",
+    "runas": "~0.2.0",
 
     "formidable": "~1.0.14",
     "unzip": "~0.1.9",
index 2e0c07c..254b359 100644 (file)
@@ -47,6 +47,13 @@ def mkdir_p(path):
     else: raise
 
 
+def RegisterRequiredDll():
+  register = os.path.join(os.path.dirname(__file__), 'register_msdia80_dll.js')
+  node = os.path.join(SOURCE_ROOT, 'out', 'Release', 'atom.exe')
+  os.environ['ATOM_SHELL_INTERNAL_RUN_AS_NODE'] = '1'
+  subprocess.check_call([node, register]);
+
+
 def GenerateSymbols(options, binaries):
   """Dumps the symbols of binary and places them in the given directory."""
 
@@ -118,6 +125,7 @@ def main():
   for directory in directories:
     pdbs += glob.glob(os.path.join(directory, '*.pdb'))
 
+  RegisterRequiredDll();
   GenerateSymbols(options, pdbs)
 
   return 0
diff --git a/tools/win/register_msdia80_dll.js b/tools/win/register_msdia80_dll.js
new file mode 100644 (file)
index 0000000..a5a0508
--- /dev/null
@@ -0,0 +1,12 @@
+var fs = require('fs');
+var path = require('path');
+var runas = require('runas');
+
+var source = path.resolve(__dirname, '..', '..', 'vendor', 'breakpad', 'msdia80.dll');
+var target = 'C:\\Program Files\\Common Files\\Microsoft Shared\\VC\\msdia80.dll';
+if (fs.existsSync(target))
+  return;
+
+var copy = 'copy "' + source + '" "' + target + '"';
+var register = 'regsvr32 "' + target + '"';
+runas('cmd', ['/K', copy + ' & ' + register + ' & exit']);