From 1af090c7b3a56b24851712a1ae41321358a8aac4 Mon Sep 17 00:00:00 2001 From: don bright Date: Mon, 21 Jan 2013 14:25:14 +0100 Subject: add wrapper code from nop head, mod build scripts diff --git a/openscad.pro b/openscad.pro index b11f45b..a7088ec 100644 --- a/openscad.pro +++ b/openscad.pro @@ -344,3 +344,8 @@ INSTALLS += applications icons.path = $$PREFIX/share/pixmaps icons.files = icons/openscad.png INSTALLS += icons + +CONFIG(winconsole) { + include(winconsole.pri) +} + diff --git a/scripts/installer.nsi b/scripts/installer.nsi index 87ec18d..1841431 100644 --- a/scripts/installer.nsi +++ b/scripts/installer.nsi @@ -6,6 +6,7 @@ DirText "This will install OpenSCAD on your computer. Choose a directory" Section "install" SetOutPath $INSTDIR File openscad.exe +File openscad.com File /r /x mingw-cross-env examples File /r /x mingw-cross-env libraries ${registerExtension} "$INSTDIR\openscad.exe" ".scad" "OpenSCAD_File" diff --git a/scripts/release-common.sh b/scripts/release-common.sh index ae856df..de14cb1 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -166,7 +166,14 @@ fi case $OS in LINXWIN) # dont use paralell builds, it can error-out on parser_yacc. + + # make main openscad.exe cd $DEPLOYDIR && make $TARGET + + # make console pipe-able openscad.com - see winconsole.pri for info + i686-pc-mingw32-qmake CONFIG+=winconsole ../openscad.pro + make + cd $OPENSCADDIR ;; *) @@ -232,6 +239,7 @@ case $OS in #package cp win32deps/* openscad-$VERSION cp $TARGET/openscad.exe openscad-$VERSION + cp $TARGET/openscad.com openscad-$VERSION rm -f openscad-$VERSION.zip "$ZIP" $ZIPARGS openscad-$VERSION.zip openscad-$VERSION rm -rf openscad-$VERSION @@ -242,6 +250,7 @@ case $OS in echo "Creating binary package" cd $DEPLOYDIR cp $TARGET/openscad.exe openscad-$VERSION + cp $TARGET/openscad.com openscad-$VERSION rm -f OpenSCAD-$VERSION.zip "$ZIP" $ZIPARGS OpenSCAD-$VERSION.zip openscad-$VERSION cd $OPENSCADDIR diff --git a/src/winconsole.c b/src/winconsole.c new file mode 100644 index 0000000..2180e19 --- /dev/null +++ b/src/winconsole.c @@ -0,0 +1,146 @@ +// enable easy piping under windows command line, using the 'devenv' method +// http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app +// http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx +// http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx +// http://www.i18nguy.com/unicode/c-unicode.html + +/* + +Based on inkscapec by Jos Hirth work at http://kaioa.com +and Nop Head's OpenSCAD_cl at github.com + +Zero-clause BSD-style license (DGAF) + +Redistribution and use in source and binary forms, with or without +modification, are permitted. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include +void HandleOutput(HANDLE hPipeRead); +DWORD WINAPI RedirThread(LPVOID lpvThreadParam); + +HANDLE hChildProcess=NULL; +HANDLE hStdIn=NULL; +BOOL bRunThread=TRUE; + +int main(int argc,char *argv[]){ + HANDLE hOutputReadTemp,hOutputRead,hOutputWrite; + HANDLE hInputWriteTemp,hInputRead,hInputWrite; + HANDLE hErrorWrite; + HANDLE hThread; + DWORD ThreadId; + SECURITY_ATTRIBUTES sa; + + sa.nLength=sizeof(SECURITY_ATTRIBUTES); + sa.lpSecurityDescriptor=NULL; + sa.bInheritHandle=TRUE; + + int i; + wchar_t cmd[32000]; + wcscat( cmd,L"\0" ); + wcscat( cmd,L"openscad.exe" ); + int wargc; + LPWSTR *wargv; + wargv = CommandLineToArgvW(GetCommandLineW(), &wargc); + if ( !wargv ) { + printf(" error in CommandLineToArgvW\n"); + return 1; + } + for(i=1;i Date: Tue, 22 Jan 2013 03:43:55 +0100 Subject: rewrite wrapper using popen. add 1 name to abt dialog diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 34e8127..47493bb 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -115,7 +115,7 @@ Brett Sutton, hmnapier, Eero af Heurlin, caliston, 5263, ghost, 42loop, uniqx, Michael Thomson, Michael Ivko, Pierre Doucet, myglc2, Alan Cox, Peter Falke, Michael Ambrus, Gordon Wrigley, Ed Nisley, Stony Smith, Pasca Andrei, David Goodenough, William A Adams, mrrobinson, 1i7, -benhowes ... and many others +benhowes, Craig Trader, Miro Hrončok, ... and many others

Hosting & resources diff --git a/src/winconsole.c b/src/winconsole.c index 2180e19..296bb31 100644 --- a/src/winconsole.c +++ b/src/winconsole.c @@ -1,146 +1,71 @@ -// enable easy piping under windows command line, using the 'devenv' method -// http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app -// http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx -// http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx -// http://www.i18nguy.com/unicode/c-unicode.html - /* - -Based on inkscapec by Jos Hirth work at http://kaioa.com -and Nop Head's OpenSCAD_cl at github.com - -Zero-clause BSD-style license (DGAF) - -Redistribution and use in source and binary forms, with or without -modification, are permitted. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + enable easy piping under windows command line, using the 'devenv' method + http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app + http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx + http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx + http://msdn.microsoft.com/en-us/library/aa298534%28v=vs.60%29.aspx + http://www.i18nguy.com/unicode/c-unicode.html + http://cournape.wordpress.com/2008/07/29/redirecting-stderrstdout-in-cmdexe/ + Open Group popen() documentation + See Also: inkscapec by Jos Hirth work at http://kaioa.com + and Nop Head's OpenSCAD_cl at github.com */ -#include -#include -#include -void HandleOutput(HANDLE hPipeRead); -DWORD WINAPI RedirThread(LPVOID lpvThreadParam); - -HANDLE hChildProcess=NULL; -HANDLE hStdIn=NULL; -BOOL bRunThread=TRUE; - -int main(int argc,char *argv[]){ - HANDLE hOutputReadTemp,hOutputRead,hOutputWrite; - HANDLE hInputWriteTemp,hInputRead,hInputWrite; - HANDLE hErrorWrite; - HANDLE hThread; - DWORD ThreadId; - SECURITY_ATTRIBUTES sa; - - sa.nLength=sizeof(SECURITY_ATTRIBUTES); - sa.lpSecurityDescriptor=NULL; - sa.bInheritHandle=TRUE; - - int i; - wchar_t cmd[32000]; - wcscat( cmd,L"\0" ); - wcscat( cmd,L"openscad.exe" ); - int wargc; - LPWSTR *wargv; - wargv = CommandLineToArgvW(GetCommandLineW(), &wargc); - if ( !wargv ) { - printf(" error in CommandLineToArgvW\n"); - return 1; - } - for(i=1;i +#include +#include +#define MAXCMDLEN 64000 +#define BUFFSIZE 42 + +int main( int argc, char * argv[] ) +{ + FILE *cmd_stdout; + char cmd[MAXCMDLEN]; + char buffer[BUFFSIZE]; + char *fgets_result; + int eof = 0; + int pclose_result; + int i; + int result = 0; + + strcat( cmd, "\0" ); + strcat( cmd, "openscad.exe" ); + for ( i = 1 ; i < argc ; ++i ) { + strcat( cmd, " " ); + strcat( cmd, argv[i] ); + } + strcat( cmd, " "); + strcat( cmd, " 2>&1"); // capture stderr and stdout + + cmd_stdout = _popen( cmd, "rt" ); + if ( cmd_stdout == NULL ) { + printf( "Error opening _popen for command: %s", cmd ); + perror( "Error message:" ); + return 1; + } + + while ( !eof ) + { + fgets_result = fgets( buffer, BUFFSIZE, cmd_stdout ); + if ( fgets_result == NULL ) { + if ( ferror( cmd_stdout ) ) { + printf("Error reading from stdout of %s\n", cmd); + result = 1; + } + if ( feof( cmd_stdout ) ) { + eof = 1; + } + } else { + fprintf( stdout, "%s", buffer ); + } + } + + pclose_result = _pclose( cmd_stdout ); + if ( pclose_result < 0 ) { + perror("Error while closing stdout for command:"); + result = 1; + } + + return result; } -- cgit v0.10.1 From 3eb13949975fe30c2bd5f66384ae8b3ad597900d Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 22 Jan 2013 03:57:27 +0100 Subject: documentation fixup diff --git a/src/winconsole.c b/src/winconsole.c index 296bb31..de8e682 100644 --- a/src/winconsole.c +++ b/src/winconsole.c @@ -1,14 +1,27 @@ /* - enable easy piping under windows command line, using the 'devenv' method + Enable easy piping under Windows(TM) command line. + + We use the 'devenv'(TM) method, which means we have two binary files: + + openscad.com, with IMAGE_SUBSYSTEM_WINDOWS_CUI flag set + openscad.exe, with IMAGE_SUBSYSTEM_WINDOWS_GUI flag set + + The .com version is a 'wrapper' for the .exe version. If you call + 'openscad' with no extension from a script or shell, the .com version + is prioritized by the OS and feeds the GUI stdout to the console. We use + pure C to minimize binary size when cross-compiling (~10kbytes). See Also: + http://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-app http://blogs.msdn.com/b/oldnewthing/archive/2009/01/01/9259142.aspx http://blogs.msdn.com/b/junfeng/archive/2004/02/06/68531.aspx http://msdn.microsoft.com/en-us/library/aa298534%28v=vs.60%29.aspx - http://www.i18nguy.com/unicode/c-unicode.html http://cournape.wordpress.com/2008/07/29/redirecting-stderrstdout-in-cmdexe/ Open Group popen() documentation - See Also: inkscapec by Jos Hirth work at http://kaioa.com - and Nop Head's OpenSCAD_cl at github.com + inkscapec by Jos Hirth work at http://kaioa.com + Nop Head's OpenSCAD_cl at github.com + + TODO: + Work with unicode: http://www.i18nguy.com/unicode/c-unicode.html */ -- cgit v0.10.1 From ddebb3991cc9fa183841d64ba43c3768e5be03a8 Mon Sep 17 00:00:00 2001 From: don bright Date: Tue, 22 Jan 2013 05:25:42 +0100 Subject: add another to About dialog diff --git a/src/AboutDialog.html b/src/AboutDialog.html index 47493bb..6203e83 100644 --- a/src/AboutDialog.html +++ b/src/AboutDialog.html @@ -115,7 +115,7 @@ Brett Sutton, hmnapier, Eero af Heurlin, caliston, 5263, ghost, 42loop, uniqx, Michael Thomson, Michael Ivko, Pierre Doucet, myglc2, Alan Cox, Peter Falke, Michael Ambrus, Gordon Wrigley, Ed Nisley, Stony Smith, Pasca Andrei, David Goodenough, William A Adams, mrrobinson, 1i7, -benhowes, Craig Trader, Miro Hrončok, ... and many others +benhowes, 5263, Craig Trader, Miro Hrončok, ... and many others

Hosting & resources -- cgit v0.10.1