Merge pull request #5602 from electron/static-linking-vs-runtime
Link with VS2015 libraries statically for Release build
This commit is contained in:
commit
53d0db0a28
9 changed files with 65 additions and 15 deletions
|
@ -4,10 +4,6 @@
|
||||||
|
|
||||||
#include "atom/common/asar/archive.h"
|
#include "atom/common/asar/archive.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -20,6 +16,10 @@
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "atom/node/osfhandle.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace asar {
|
namespace asar {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -118,7 +118,7 @@ Archive::Archive(const base::FilePath& path)
|
||||||
: path_(path),
|
: path_(path),
|
||||||
file_(path_, base::File::FLAG_OPEN | base::File::FLAG_READ),
|
file_(path_, base::File::FLAG_OPEN | base::File::FLAG_READ),
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
fd_(_open_osfhandle(
|
fd_(node::open_osfhandle(
|
||||||
reinterpret_cast<intptr_t>(file_.GetPlatformFile()), 0)),
|
reinterpret_cast<intptr_t>(file_.GetPlatformFile()), 0)),
|
||||||
#elif defined(OS_POSIX)
|
#elif defined(OS_POSIX)
|
||||||
fd_(file_.GetPlatformFile()),
|
fd_(file_.GetPlatformFile()),
|
||||||
|
@ -131,7 +131,7 @@ Archive::Archive(const base::FilePath& path)
|
||||||
Archive::~Archive() {
|
Archive::~Archive() {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
if (fd_ != -1) {
|
if (fd_ != -1) {
|
||||||
_close(fd_);
|
node::close(fd_);
|
||||||
// Don't close the handle since we already closed the fd.
|
// Don't close the handle since we already closed the fd.
|
||||||
file_.TakePlatformFile();
|
file_.TakePlatformFile();
|
||||||
}
|
}
|
||||||
|
|
19
atom/node/osfhandle.cc
Normal file
19
atom/node/osfhandle.cc
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) 2016 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "osfhandle.h"
|
||||||
|
|
||||||
|
#include <io.h>
|
||||||
|
|
||||||
|
namespace node {
|
||||||
|
|
||||||
|
int open_osfhandle(intptr_t osfhandle, int flags) {
|
||||||
|
return _open_osfhandle(osfhandle, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
int close(int fd) {
|
||||||
|
return _close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace node
|
28
atom/node/osfhandle.h
Normal file
28
atom/node/osfhandle.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright (c) 2016 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_NODE_OSFHANDLE_H_
|
||||||
|
#define ATOM_NODE_OSFHANDLE_H_
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "node_extern.h"
|
||||||
|
|
||||||
|
namespace node {
|
||||||
|
|
||||||
|
// The _open_osfhandle and _close functions on Windows are provided by the
|
||||||
|
// Visual C++ library, so the fd returned by them can only be used in the
|
||||||
|
// same instance of VC++ library.
|
||||||
|
// However Electron is linking with VC++ library statically, so electron.exe
|
||||||
|
// shares a different instance of VC++ library with node.exe. This results
|
||||||
|
// in fd created in electron.exe not usable in node.dll, so we have to ensure
|
||||||
|
// we always create fd in one instance of VC++ library.
|
||||||
|
// Followings wrappers are compiled in node.dll, and all code in electron.exe
|
||||||
|
// should call these wrappers instead of calling _open_osfhandle directly.
|
||||||
|
NODE_EXTERN int open_osfhandle(intptr_t osfhandle, int flags);
|
||||||
|
NODE_EXTERN int close(int fd);
|
||||||
|
|
||||||
|
} // namespace node
|
||||||
|
|
||||||
|
#endif // ATOM_NODE_OSFHANDLE_H_
|
10
common.gypi
10
common.gypi
|
@ -130,7 +130,17 @@
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
['OS=="win"', {
|
['OS=="win"', {
|
||||||
|
# Fix passing fd across modules, see |osfhandle.h| for more.
|
||||||
|
'sources': [
|
||||||
|
'<(DEPTH)/atom/node/osfhandle.cc',
|
||||||
|
'<(DEPTH)/atom/node/osfhandle.h',
|
||||||
|
],
|
||||||
|
'include_dirs': [
|
||||||
|
'<(DEPTH)/atom/node',
|
||||||
|
],
|
||||||
|
# Node is using networking API but linking with this itself.
|
||||||
'libraries': [ '-lwinmm.lib' ],
|
'libraries': [ '-lwinmm.lib' ],
|
||||||
|
# Fix the linking error with icu.
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['libchromiumcontent_component==0', {
|
['libchromiumcontent_component==0', {
|
||||||
'variables': {
|
'variables': {
|
||||||
|
|
|
@ -157,9 +157,6 @@
|
||||||
'<(libchromiumcontent_dir)/snapshot_blob.bin',
|
'<(libchromiumcontent_dir)/snapshot_blob.bin',
|
||||||
'external_binaries/d3dcompiler_47.dll',
|
'external_binaries/d3dcompiler_47.dll',
|
||||||
'external_binaries/xinput1_3.dll',
|
'external_binaries/xinput1_3.dll',
|
||||||
'external_binaries/msvcp140.dll',
|
|
||||||
'external_binaries/vccorlib140.dll',
|
|
||||||
'external_binaries/vcruntime140.dll',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -36,7 +36,6 @@ TARGET_BINARIES = {
|
||||||
'icudtl.dat',
|
'icudtl.dat',
|
||||||
'libEGL.dll',
|
'libEGL.dll',
|
||||||
'libGLESv2.dll',
|
'libGLESv2.dll',
|
||||||
'msvcp140.dll',
|
|
||||||
'ffmpeg.dll',
|
'ffmpeg.dll',
|
||||||
'node.dll',
|
'node.dll',
|
||||||
'content_resources_200_percent.pak',
|
'content_resources_200_percent.pak',
|
||||||
|
@ -44,8 +43,6 @@ TARGET_BINARIES = {
|
||||||
'xinput1_3.dll',
|
'xinput1_3.dll',
|
||||||
'natives_blob.bin',
|
'natives_blob.bin',
|
||||||
'snapshot_blob.bin',
|
'snapshot_blob.bin',
|
||||||
'vccorlib140.dll',
|
|
||||||
'vcruntime140.dll',
|
|
||||||
],
|
],
|
||||||
'linux': [
|
'linux': [
|
||||||
PROJECT_NAME, # 'electron'
|
PROJECT_NAME, # 'electron'
|
||||||
|
|
|
@ -8,7 +8,7 @@ import sys
|
||||||
|
|
||||||
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
|
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
|
||||||
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
|
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
|
||||||
LIBCHROMIUMCONTENT_COMMIT = 'e5ddff3e0d277703e2c1adc363d49709cf1bc56a'
|
LIBCHROMIUMCONTENT_COMMIT = '7509afe48dbb438e921e5fccf08603340b41c308'
|
||||||
|
|
||||||
PLATFORM = {
|
PLATFORM = {
|
||||||
'cygwin': 'win32',
|
'cygwin': 'win32',
|
||||||
|
|
|
@ -30,7 +30,6 @@ def main():
|
||||||
download_and_unzip('Squirrel')
|
download_and_unzip('Squirrel')
|
||||||
elif sys.platform in ['cygwin', 'win32']:
|
elif sys.platform in ['cygwin', 'win32']:
|
||||||
download_and_unzip('directxsdk-' + get_target_arch())
|
download_and_unzip('directxsdk-' + get_target_arch())
|
||||||
download_and_unzip('vs2015-crt-' + get_target_arch())
|
|
||||||
|
|
||||||
with open(version_file, 'w') as f:
|
with open(version_file, 'w') as f:
|
||||||
f.write(VERSION)
|
f.write(VERSION)
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit d5ddb834fe5bc7d914e098ecf7c35b10b5322f54
|
Subproject commit bf56e3a38f50a2b12d28f8b3bf8adb7dc628f671
|
Loading…
Reference in a new issue