From 41ee481080d4c9d4f5697cde4ceb1cc051b6f80f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Mon, 28 Feb 2000 19:15:43 -0800 Subject: [PATCH] initial cygwin support, still requires VC++ or Watcom, experimental Rev: NT/init_nt:1.24 Rev: NT/tools/bash-fixup:1.2 Rev: NT/tools/lib.pike:1.10 Rev: lib/master.pike.in:1.102 --- NT/init_nt | 26 ++++++++++-- NT/tools/bash-fixup | 17 +++++--- NT/tools/lib.pike | 100 ++++++++++++++++++++++++++++++++++++++++++-- lib/master.pike.in | 17 +++++++- 4 files changed, 147 insertions(+), 13 deletions(-) diff --git a/NT/init_nt b/NT/init_nt index 0e4047368d..130007b5e9 100755 --- a/NT/init_nt +++ b/NT/init_nt @@ -1,6 +1,6 @@ #!/bin/sh -#This can be 'sprsh' or 'wine' +#This can be 'sprsh', 'wine' or 'cygwin' REMOTE_METHOD=sprsh # Choose 'rntcc' for Watcom or 'rntcl' for Microsoft VC++ @@ -57,7 +57,7 @@ lib=$watcom\\lib386;$local\\lib esac -# Don't edit +# Don't edit anything below this point.. case /$0 in */init_nt) @@ -72,7 +72,26 @@ case /$0 in ;; esac -NT_TOOL_PATH=$base/tools +if [ "x$OSTYPE" = xcygwin32 ]; then + REMOTE_METHOD=cygwin + driveletter=`echo $base | sed -e 's@^//\(.\)/.*@\1@` + if [ "x$driveletter" != "x" ]; then + NTDRIVE=${driveletter}: + NTMOUNT="//$driveletter" + fi + mkdir $base/cygtools 2>/dev/null || : + ( + cd $base/tools + cp rntcc rntcl ar nm ranlib uname bash-fixup sprsh lib lib.pike $base/cygtools || : + ) + SHELL=bash + + NT_TOOL_PATH=$base/cygtools +else + NT_TOOL_PATH=$base/tools +fi + + export NT_TOOL_PATH @@ -89,6 +108,7 @@ esac NTTOOLS=$NT_TOOL_PATH/lib + if [ "x$NTMOUNT" = x ]; then MNTREPLACE="" PIKE_PATH_TRANSLATE="" diff --git a/NT/tools/bash-fixup b/NT/tools/bash-fixup index 6b3f37e708..5aaef69ab2 100644 --- a/NT/tools/bash-fixup +++ b/NT/tools/bash-fixup @@ -2,11 +2,18 @@ if [ -f $HOME/.bashrc ]; then . $HOME/.bashrc fi -if [ $REMOTE_METHOD = sprsh ]; then - PS1="NT $NTHOST \\$ " -else - PS1="WINE \\$ " -fi +case "$REMOTE_METHOD" in + sprsh) + PS1="NT $NTHOST \\$ " + ;; + wine) + PS1="WINE \\$ " + ;; + cygwin) + PS1="Pike-cygwin \\$ " + ;; +esac + export PS1 case $TERM in diff --git a/NT/tools/lib.pike b/NT/tools/lib.pike index 75e0f071cc..bd2bd5b8c9 100644 --- a/NT/tools/lib.pike +++ b/NT/tools/lib.pike @@ -2,6 +2,13 @@ #define strerror(X) X #endif +#ifdef __NT__ +void exece(string cmd, array(string) args) +{ + exit(Process.create_process( ({ cmd }) + args )->wait()); +} +#endif + string fixpath(string s) { string mnt=getenv("NTMOUNT"); @@ -15,6 +22,12 @@ string fixabspath(string s) return replace(s,"/","\\"); } +string opt_path(string p1, string p2) +{ + return ( ( ((p1||"") + ";" + (p2||"")) / ";" ) - ({""}) ) * ";"; +} + + int silent_do_cmd(string *cmd, mixed|void filter, int|void silent) { string ret=""; @@ -39,12 +52,85 @@ int silent_do_cmd(string *cmd, mixed|void filter, int|void silent) object o=f->pipe(Stdio.PROP_BIDIRECTIONAL | Stdio.PROP_IPC); cmd=({"wine", "-winver","win95", - "-debugmsg","fixme-all", + "-debugmsg","fixme-all", "-debugmsg","trace+all", "-debugmsg","+relay", cmd*" "}); // werror("WINE %O\n",cmd); - object proc=Process.create_process(cmd,(["stdout":o])); + object proc=Process.create_process(cmd, (["stdout":o]) ); + destruct(o); + while(1) + { + string s=f->read(8192,1); + if(!s || !strlen(s)) break; + s=replace(s,"\r\n","\n"); + if(!silent) write(s); + ret+=s; + } + if(filter) filter(ret); + destruct(f); + return proc->wait(); + } + + case "cygwin": + case "CYGWIN": + { + mapping env=copy_value(getenv()); + if(string tmp=getenv("REMOTE_VARIABLES")) + { + foreach(tmp/"\n",string var) + { + if(search(var,"=")!=-1 && sscanf(var,"%s=%s",string key, string val)) + { + // Magic + if(!env[key]) + { + if(env[lower_case(key)]) + key=lower_case(key); + else if(env[upper_case(key)]) + key=upper_case(key); + else + { + foreach(indices(env), string x) + { + if(lower_case(x) == lower_case(key)) + { + key=x; + break; + } + } + } + } + if(val[0]==';') + { + env[key]=opt_path(env[key], val); + } + else if(val[-1]==';') + { + env[key]=opt_path(val, env[key]); + } + else + { + env[key]=val; + } +// werror("%s = %s\n",key,env[key]); + } + } + } + + string mnt=getenv("NTMOUNT"); +#if 1 + /* Experimental */ + if(mnt && strlen(mnt)>1) + { + for(int e=1;e<sizeof(cmd);e++) + cmd[e]=replace(cmd[e],mnt,getenv("NTDRIVE")); + } +#endif + + object o=f->pipe(Stdio.PROP_IPC); + object proc=Process.create_process(cmd, + (["stdout":o,"env":env])); destruct(o); while(1) { @@ -72,8 +158,14 @@ int silent_do_cmd(string *cmd, mixed|void filter, int|void silent) } string tmp=getcwd(); string mnt=getenv("NTMOUNT"); - if(mnt && strlen(mnt)) tmp=replace(tmp,mnt,""); - cmd=({getenv("NTDRIVE")+replace(tmp,"/","\\")})+cmd; + if(mnt && strlen(mnt)) + tmp=replace(tmp,mnt,getenv("NTDRIVE")); + else + tmp=getenv("NTDRIVE")+tmp; + + tmp=replace(tmp,"/","\\"); + + cmd=({ tmp })+cmd; #if 1 /* Experimental */ diff --git a/lib/master.pike.in b/lib/master.pike.in index 29db7a6ac1..818bb51064 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -1,6 +1,6 @@ /* -*- Pike -*- * - * $Id: master.pike.in,v 1.101 2000/02/19 21:30:28 nilsson Exp $ + * $Id: master.pike.in,v 1.102 2000/02/29 03:15:43 hubbe Exp $ * * Master-file for Pike. * @@ -278,6 +278,21 @@ static program low_findprog(string pname, string ext, object|void handler) if(!zero_type (ret=programs[fname])) return ret; } +#ifdef __NT__ + // Ugly kluge to work better with cygwin32 + if(getenv("OSTYPE")=="cygwin32") + { + string tmp=fname[..1]; + if((tmp=="//" || tmp=="\\\\") && (fname[3]=='/' || fname[3]=='\\')) + { + if(!master_file_stat(fname)) + { + fname=fname[2..2]+":"+fname[3..]; + } + } + } +#endif + if( (s=master_file_stat(fname)) && s[1]>=0 ) { AUTORELOAD_BEGIN(); -- GitLab