Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Merge branch 'v0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Aug 13, 2012
2 parents ac0d468 + 2c3e8b6 commit 9d7e300
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
20 changes: 0 additions & 20 deletions build/gcc_version.py

This file was deleted.

7 changes: 3 additions & 4 deletions common.gypi
Expand Up @@ -6,6 +6,8 @@
'library%': 'static_library', # allow override to 'shared_library' for DLL/.so builds
'component%': 'static_library', # NB. these names match with what V8 expects
'msvs_multi_core_compile': '0', # we do enable multicore compiles, but not using the V8 way
'gcc_version%': 'unknown',
'clang%': 0,
},

'target_defaults': {
Expand Down Expand Up @@ -117,9 +119,6 @@
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
'variables': {
'gcc_version%': '<!(python build/gcc_version.py)>)',
},
'cflags': [ '-Wall' ],
'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
'conditions': [
Expand All @@ -137,7 +136,7 @@
'cflags': [ '-pthread' ],
'ldflags': [ '-pthread' ],
}],
[ 'visibility=="hidden" and gcc_version >= "4.0.0"', {
[ 'visibility=="hidden" and (clang==1 or gcc_version >= 40)', {
'cflags': [ '-fvisibility=hidden' ],
}],
],
Expand Down
23 changes: 16 additions & 7 deletions gyp_uv
@@ -1,11 +1,14 @@
#!/usr/bin/env python

import glob
import os
import shlex
import subprocess
import sys

CC = os.environ.get('CC', 'cc')
script_dir = os.path.dirname(__file__)
uv_root = os.path.normpath(script_dir)
output_dir = os.path.join(os.path.abspath(uv_root), 'out')

sys.path.insert(0, os.path.join(uv_root, 'build', 'gyp', 'pylib'))
try:
Expand All @@ -14,16 +17,22 @@ except ImportError:
print('You need to install gyp in build/gyp first. See the README.')
sys.exit(42)

# Directory within which we want all generated files (including Makefiles)
# to be written.
output_dir = os.path.join(os.path.abspath(uv_root), 'out')

def compiler_version():
proc = subprocess.Popen(CC.split() + ['--version'], stdout=subprocess.PIPE)
is_clang = 'clang' in proc.communicate()[0].split('\n')[0]
proc = subprocess.Popen(CC.split() + ['-dumpversion'], stdout=subprocess.PIPE)
version = tuple(map(int, proc.communicate()[0].split('.')))
return (version, is_clang)


def run_gyp(args):
rc = gyp.main(args)
if rc != 0:
print 'Error running GYP'
sys.exit(rc)


if __name__ == '__main__':
args = sys.argv[1:]

Expand All @@ -49,12 +58,12 @@ if __name__ == '__main__':

# There's a bug with windows which doesn't allow this feature.
if sys.platform != 'win32':
# Tell gyp to write the Makefiles into output_dir
args.extend(['--generator-output', output_dir])
# Tell make to write its output into the same dir
args.extend(['-Goutput_dir=' + output_dir])
# Create Makefiles, not XCode projects
args.extend('-f make'.split())
(major, minor), is_clang = compiler_version()
args.append('-Dgcc_version=%d' % (10 * major + minor))
args.append('-Dclang=%d' % int(is_clang))

args.append('-Dtarget_arch=ia32')
args.append('-Dcomponent=static_library')
Expand Down
18 changes: 16 additions & 2 deletions src/win/process-stdio.c
Expand Up @@ -181,6 +181,20 @@ static int uv__create_stdio_pipe_pair(uv_loop_t* loop, uv_pipe_t* server_pipe,
static int uv__duplicate_handle(uv_loop_t* loop, HANDLE handle, HANDLE* dup) {
HANDLE current_process;


/* _get_osfhandle will sometimes return -2 in case of an error. This seems */
/* to happen when fd <= 2 and the process' corresponding stdio handle is */
/* set to NULL. Unfortunately DuplicateHandle will happily duplicate /*
/* (HANDLE) -2, so this situation goes unnoticed until someone tries to */
/* use the duplicate. Therefore we filter out known-invalid handles here. */
if (handle == INVALID_HANDLE_VALUE ||
handle == NULL ||
handle == (HANDLE) -2) {
*dup = INVALID_HANDLE_VALUE;
uv__set_artificial_error(loop, UV_EBADF);
return -1;
}

current_process = GetCurrentProcess();

if (!DuplicateHandle(current_process,
Expand Down Expand Up @@ -208,7 +222,7 @@ static int uv__duplicate_fd(uv_loop_t* loop, int fd, HANDLE* dup) {
return -1;
}

handle = (HANDLE)_get_osfhandle(fd);
handle = (HANDLE) _get_osfhandle(fd);
return uv__duplicate_handle(loop, handle, dup);
}

Expand Down Expand Up @@ -355,7 +369,7 @@ int uv__stdio_create(uv_loop_t* loop, uv_process_options_t* options,
break;

case FILE_TYPE_UNKNOWN:
if (GetLastError != 0) {
if (GetLastError() != 0) {
uv__set_sys_error(loop, GetLastError());
CloseHandle(child_handle);
goto error;
Expand Down

0 comments on commit 9d7e300

Please sign in to comment.