Browse Source

Build on windows again

v0.7.4-release
Bert Belder 14 years ago
parent
commit
406f44a86b
  1. 12
      src/node.cc
  2. 5
      src/node.js
  3. 8
      src/node_child_process.h
  4. 23
      src/node_child_process_win32.cc
  5. 6
      src/node_extensions.h
  6. 17
      src/node_file.cc
  7. 11
      src/node_stdio_win32.cc
  8. 19
      wscript

12
src/node.cc

@ -52,14 +52,18 @@
#include <platform.h>
#include <node_buffer.h>
#include <node_io_watcher.h>
#ifdef __POSIX__
# include <node_io_watcher.h>
#endif
#include <node_net.h>
#include <node_events.h>
#include <node_cares.h>
#include <node_file.h>
#include <node_http_parser.h>
#include <node_signal_watcher.h>
#include <node_stat_watcher.h>
#ifdef __POSIX__
# include <node_signal_watcher.h>
# include <node_stat_watcher.h>
#endif
#include <node_child_process.h>
#include <node_constants.h>
#include <node_stdio.h>
@ -1865,10 +1869,12 @@ static Handle<Value> Binding(const Arguments& args) {
DefineConstants(exports);
binding_cache->Set(module, exports);
#ifdef __POSIX__
} else if (!strcmp(*module_v, "io_watcher")) {
exports = Object::New();
IOWatcher::Initialize(exports);
binding_cache->Set(module, exports);
#endif
} else if (!strcmp(*module_v, "natives")) {
exports = Object::New();

5
src/node.js

@ -194,7 +194,10 @@
startup.processStdio = function() {
var binding = process.binding('stdio'),
net = NativeModule.require('net'),
// FIXME Remove conditional when net is supported again on windows.
net = (process.platform !== "win32")
? NativeModule.require('net')
: undefined,
fs = NativeModule.require('fs'),
tty = NativeModule.require('tty');

8
src/node_child_process.h

@ -26,7 +26,11 @@
#include <node_object_wrap.h>
#include <v8.h>
#include <ev.h>
#include <uv.h>
#ifdef __POSIX__
# include <ev.h>
#endif
#ifdef __MINGW32__
# include <platform_win32.h> // HANDLE type
@ -120,7 +124,7 @@ class ChildProcess : ObjectWrap {
static void watch(ChildProcess *child);
static void CALLBACK watch_wait_callback(void *data, BOOLEAN didTimeout);
static void notify_spawn_failure(ChildProcess *child);
static void notify_exit(EV_P_ ev_async *ev, int revent);
static void notify_exit(uv_handle_t* watcher, int status);
static int do_kill(ChildProcess *child, int sig);static void close_stdio_handles(ChildProcess *child);
int pid_;

23
src/node_child_process_win32.cc

@ -24,10 +24,11 @@
#include <node_child_process.h>
#include <v8.h>
#include <ev.h>
#include <uv.h>
#include <eio.h>
#include <assert.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@ -51,7 +52,7 @@ static Persistent<String> onexit_symbol;
static struct watcher_status_struct {
ev_async async_watcher;
uv_async_t async_watcher;
ChildProcess *child;
HANDLE lock;
int num_active;
@ -350,15 +351,10 @@ void ChildProcess::close_stdio_handles(ChildProcess *child) {
// Called from the main thread
void ChildProcess::notify_exit(EV_P_ ev_async *ev, int revent) {
void ChildProcess::notify_exit(uv_handle_t* watcher, int status) {
// Get the child process, then release the lock
ChildProcess *child = watcher_status.child;
// Stop the watcher if appropriate
if (!--watcher_status.num_active) {
ev_async_stop(EV_DEFAULT_UC_ &watcher_status.async_watcher);
}
ReleaseSemaphore(watcher_status.lock, 1, NULL);
DWORD exit_code = -127;
@ -398,7 +394,7 @@ void ChildProcess::notify_spawn_failure(ChildProcess *child) {
watcher_status.child = child;
ev_async_send(EV_DEFAULT_UC_ &watcher_status.async_watcher);
uv_async_send(&watcher_status.async_watcher);
}
@ -418,7 +414,7 @@ void CALLBACK ChildProcess::watch_wait_callback(void *data,
assert(result == WAIT_OBJECT_0);
watcher_status.child = child;
ev_async_send(EV_DEFAULT_UC_ &watcher_status.async_watcher);
uv_async_send(&watcher_status.async_watcher);
}
@ -810,11 +806,6 @@ Handle<Value> ChildProcess::Spawn(const Arguments& args) {
// Grab a reference so it doesn't get GC'ed
child->Ref();
// Start the async watcher
if (!watcher_status.num_active++) {
ev_async_start(EV_DEFAULT_UC_ &watcher_status.async_watcher);
}
eio_custom(do_spawn, EIO_PRI_DEFAULT, after_spawn, (void*)child);
return scope.Close(result);
@ -892,7 +883,7 @@ void ChildProcess::Initialize(Handle<Object> target) {
target->Set(String::NewSymbol("ChildProcess"), t->GetFunction());
ev_async_init(EV_DEFAULT_UC_ &watcher_status.async_watcher, notify_exit);
uv_async_init(&watcher_status.async_watcher, notify_exit, NULL, NULL);
watcher_status.lock = CreateSemaphore(NULL, 1, 1, NULL);
}

6
src/node_extensions.h

@ -22,16 +22,22 @@
NODE_EXT_LIST_START
NODE_EXT_LIST_ITEM(node_buffer)
#ifdef __POSIX__
NODE_EXT_LIST_ITEM(node_cares)
#endif
NODE_EXT_LIST_ITEM(node_child_process)
#ifdef HAVE_OPENSSL
NODE_EXT_LIST_ITEM(node_crypto)
#endif
NODE_EXT_LIST_ITEM(node_evals)
NODE_EXT_LIST_ITEM(node_fs)
#ifdef __POSIX__
NODE_EXT_LIST_ITEM(node_net)
#endif
NODE_EXT_LIST_ITEM(node_http_parser)
#ifdef __POSIX__
NODE_EXT_LIST_ITEM(node_signal_watcher)
#endif
NODE_EXT_LIST_ITEM(node_stdio)
NODE_EXT_LIST_ITEM(node_os)
NODE_EXT_LIST_ITEM(node_timer_wrap)

17
src/node_file.cc

@ -22,7 +22,9 @@
#include <node.h>
#include <node_file.h>
#include <node_buffer.h>
#include <node_stat_watcher.h>
#ifdef __POSIX__
# include <node_stat_watcher.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
@ -816,6 +818,7 @@ static Handle<Value> Chmod(const Arguments& args) {
}
#ifdef __POSIX__
/* fs.fchmod(fd, mode);
* Wrapper for fchmod(1) / EIO_FCHMOD
*/
@ -836,6 +839,7 @@ static Handle<Value> FChmod(const Arguments& args) {
return Undefined();
}
}
#endif // __POSIX__
#ifdef __POSIX__
@ -909,6 +913,7 @@ static inline void ToTimevals(eio_tstamp atime,
}
#ifdef __POSIX__
static Handle<Value> UTimes(const Arguments& args) {
HandleScope scope;
@ -937,6 +942,7 @@ static Handle<Value> UTimes(const Arguments& args) {
return Undefined();
}
#endif // __POSIX__
static Handle<Value> FUTimes(const Arguments& args) {
@ -1002,16 +1008,16 @@ void File::Initialize(Handle<Object> target) {
NODE_SET_METHOD(target, "write", Write);
NODE_SET_METHOD(target, "chmod", Chmod);
NODE_SET_METHOD(target, "fchmod", FChmod);
#ifdef __POSIX__
NODE_SET_METHOD(target, "fchmod", FChmod);
//NODE_SET_METHOD(target, "lchmod", LChmod);
NODE_SET_METHOD(target, "chown", Chown);
NODE_SET_METHOD(target, "fchown", FChown);
//NODE_SET_METHOD(target, "lchown", LChown);
#endif // __POSIX__
NODE_SET_METHOD(target, "utimes", UTimes);
#endif // __POSIX__
NODE_SET_METHOD(target, "futimes", FUTimes);
errno_symbol = NODE_PSYMBOL("errno");
@ -1026,9 +1032,12 @@ void InitFs(Handle<Object> target) {
stats_constructor_template = Persistent<FunctionTemplate>::New(stat_templ);
target->Set(String::NewSymbol("Stats"),
stats_constructor_template->GetFunction());
StatWatcher::Initialize(target);
File::Initialize(target);
#ifdef __POSIX__
StatWatcher::Initialize(target);
#endif
#ifdef __MINGW32__
// Open files in binary mode by default
_fmode = _O_BINARY;

11
src/node_stdio_win32.cc

@ -422,7 +422,7 @@ void *tty_keypress_callback;
void *tty_resize_callback;
static bool tty_watcher_initialized = false;
static bool tty_watcher_active = false;
static uv_handle_t tty_avail_notifier;
static uv_async_t tty_avail_notifier;
static void CALLBACK tty_want_poll(void *context, BOOLEAN didTimeout) {
@ -469,6 +469,7 @@ static void tty_watcher_start() {
assert(tty_watcher_initialized);
if (!tty_watcher_active) {
tty_watcher_active = true;
uv_ref();
tty_watcher_arm();
}
}
@ -477,6 +478,7 @@ static void tty_watcher_start() {
static void tty_watcher_stop() {
if (tty_watcher_active) {
tty_watcher_active = false;
uv_unref();
tty_watcher_disarm();
}
}
@ -492,7 +494,7 @@ static inline void tty_emit_error(Handle<Value> err) {
static void tty_poll(uv_handle_t* handle, int status) {
assert(handle == &tty_avail_notifier);
assert((uv_async_t*) handle == &tty_avail_notifier);
assert(status == 0);
HandleScope scope;
@ -609,8 +611,6 @@ static Handle<Value> InitTTYWatcher(const Arguments& args) {
? cb_persist(args[3])
: NULL;
uv_async_init(&tty_avail_notifier, tty_poll, NULL, NULL);
tty_watcher_initialized = true;
tty_wait_handle = NULL;
@ -658,6 +658,9 @@ static Handle<Value> StopTTYWatcher(const Arguments& args) {
void Stdio::Initialize(v8::Handle<v8::Object> target) {
init_scancode_table();
uv_async_init(&tty_avail_notifier, tty_poll, NULL, NULL);
uv_unref();
name_symbol = NODE_PSYMBOL("name");
shift_symbol = NODE_PSYMBOL("shift");
ctrl_symbol = NODE_PSYMBOL("ctrl");

19
wscript

@ -599,7 +599,7 @@ def build_v8(bld):
bld.install_files('${PREFIX}/include/node/', 'deps/v8/include/*.h')
def sh_escape(s):
return s.replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
return s.replace("\\", "\\\\").replace("(","\\(").replace(")","\\)").replace(" ","\\ ")
def uv_cmd(bld, variant):
srcdeps = join(bld.path.abspath(), "deps")
@ -610,8 +610,11 @@ def uv_cmd(bld, variant):
# build directory before each compile. This could be much improved by
# modifying libuv's build to send object files to a separate directory.
#
cmd = 'cp -r ' + sh_escape(srcdir) + '/* ' + sh_escape(blddir) + \
' && if [[ -z "$NODE_MAKE" ]]; then NODE_MAKE=make; fi; $NODE_MAKE -C ' + sh_escape(blddir)
cmd = 'cp -r ' + sh_escape(srcdir) + '/* ' + sh_escape(blddir)
if not sys.platform.startswith('win32'):
cmd += ' && if [[ -z "$NODE_MAKE" ]]; then NODE_MAKE=make; fi; $NODE_MAKE -C ' + sh_escape(blddir)
else:
cmd += ' && make -C ' + sh_escape(blddir)
return cmd
@ -834,14 +837,9 @@ def build(bld):
src/node_javascript.cc
src/node_extensions.cc
src/node_http_parser.cc
src/node_net.cc
src/node_io_watcher.cc
src/node_constants.cc
src/node_cares.cc
src/node_events.cc
src/node_file.cc
src/node_signal_watcher.cc
src/node_stat_watcher.cc
src/node_script.cc
src/node_os.cc
src/node_dtrace.cc
@ -853,6 +851,11 @@ def build(bld):
node.source += " src/node_stdio_win32.cc "
node.source += " src/node_child_process_win32.cc "
else:
node.source += " src/node_cares.cc "
node.source += " src/node_net.cc "
node.source += " src/node_signal_watcher.cc "
node.source += " src/node_stat_watcher.cc "
node.source += " src/node_io_watcher.cc "
node.source += " src/node_stdio.cc "
node.source += " src/node_child_process.cc "

Loading…
Cancel
Save