Commit Graph

27 Commits

Author SHA1 Message Date
Ryan Prichard
67a34b6c03 Build system: redo how version number tracking works
* Remove the "version suffix" and BUILD_INFO.txt mechanisms, which I
   believe no one uses except winpty itself.  Instead, a suffix can be
   added in the VERSION.txt file.

 * Instead of passing the version and commit info as a preprocessor macro
   when building every C++ file, write the info into a GenVersion.h
   header that is only included by WinptyVersion.cc.

 * Instead of writing a BUILD_INFO.txt in ship.py, pass COMMIT_HASH=<hash>
   to make.

These changes accomplish two things:

 * People who build a tag from source won't see a "<ver>-dev" suffix
   anymore.

 * Changing the version or the commit will correctly rebuild the version
   object files (and only those object files).  It will also relink every
   binary.

Fixes https://github.com/rprichard/winpty/issues/72
2017-01-17 23:39:14 -06:00
Ryan Prichard
3539b806e9 Build/package winpty for embedding using gyp and MSVC 2016-06-01 20:01:37 -05:00
Ryan Prichard
880c00c69e Replace the libwinpty API.
The new API improves upon the old API in a number of ways:

 * The old API provided a single data pipe for input and output, and it
   provided the pipe in the form of a HANDLE opened with
   FILE_FLAG_OVERLAPPED.  Using a bare HANDLE is difficult in higher-level
   languages, and overlapped/asynchronous I/O is hard to get right.
   winpty_close closed the data pipe, which also didn't help things, though
   I think the handle could have been duplicated.

   Using a single handle for input and output complicates shutdown.  When
   the child process exits, the agent scrapes the final output, then closes
   the data pipe once its written.  It's possible that a winpty client will
   first detect the closed pipe when it's writing *input* rather than
   reading output, which seems wrong.  (On the other hand, the agent
   doesn't implement "backpressure" for either input or output (yet), and
   if it did, it's possible that post-exit shutdown should interrupt a
   blocked write into the console input queue.  I need to think about it
   more.)

   The new API splits the data pipe into CONIN and CONOUT pipes, which are
   accessed by filename.  After `winpty_open` returns, the client queries
   pipe names using `winpty_conin_name` and `winpty_conout_name`, then
   opens them using any mechanism, low-level or high-level, blocking or
   overlapped.

 * The old libwinpty handled errors by killing the process.  The new
   libwinpty uses C++ exceptions internally and translates exceptions at
   API boundaries using:

    - a boolean error result (e.g. BOOL, NULL-vs-non-NULL)
    - a potentially heap-allocated winpty_error_t object returned via an
      optional winpty_error_ptr_t parameter.  That parameter can be NULL.
      If it isn't, then an error code and message can be queried from the
      error object.  The winpty_error_t object must be freed with
      winpty_error_free.

 * winpty_start_process is renamed to winpty_spawn.  winpty_open and
   winpty_spawn accept a "config" object which holds parameters.  New
   configuration options can be added without disturbing the source or
   binary API.

 * The winpty_get_exit_code and winpty_get_process_id APIs are removed.
   The winpty_spawn function has an out parameter providing the child's
   process and thread HANDLEs (duplicated from the agent via
   DuplicateHandle).  The winpty client can call GetExitCodeProcess and
   GetProcessId (as well as the WaitForXXX APIs to wait for child exit).
2016-05-26 20:56:01 -05:00
Ryan Prichard
cf380b39bc Output a line each time a directory is created.
This might be helpful in diagnosing the directory creation logic in the
Makefile, which is obscure.

*Might* be related to https://github.com/rprichard/winpty/issues/71
2016-04-06 18:53:31 -05:00
Ryan Prichard
d984413c0a Rename the UNIX adapter from console.exe to winpty.exe.
There are three reasons for this change:

 * It's consistent with MSYS2, which already renamed console.exe to
   winpty.exe.

 * winpty.exe is less likely to clash with another program.

 * winpty.exe is easier to search for online.  If someone unfamiliar with
   winpty is asked to run console.exe, they might have a hard time figuring
   out where console.exe comes from.

The old behavior can be restored by passing UNIX_ADAPTER_EXE=console.exe
to `make`, or by simply renaming the binary after-the-fact, or with
`alias`, etc.
2016-04-05 02:43:13 -05:00
Ryan Prichard
bb23f63b34 Install dev files (importlib, headers) and docs, localize PHONY deps 2016-04-05 02:43:12 -05:00
Ryan Prichard
adc1a5adbf Use precompiled headers when compiling with GCC.
The unix-adapter doesn't use PCH, because MSYS1's compiler doesn't support
them.
2016-02-29 04:33:42 -06:00
Ryan Prichard
fd270915c1 Compile each target's source files separately from other targets.
The gyp file already worked this way, but now the Makefile does too.

The motivation is to let the shared source files have different error
handling behavior (e.g. assert/ASSERT/stderr-print/abort/exception) in
winpty.dll and the other targets.
2016-02-29 04:16:04 -06:00
Ryan Prichard
bce511725a Add a clean-msvs target for cleaning up after gyp and VisualStudio/msbuild 2016-02-29 04:16:03 -06:00
Ryan Prichard
e390c8775c Try to fix an issue where make fails if a header file disappears
Currently, when a header file is removed (or renamed), there is a stale
dependency file still referring to the header, and GNU make aborts, because
the header is missing.  Attempt to work around this by adding a pattern
rule to generate any header in `src/`.  The rule prints a warning message.

The C source file whose header was missing will be recompiled because a
dependency was rebuilt.  Once it is, the removed header should be removed
from the dependency file.

(Aside: FWIW, the "ninja" build tool knows directly about depfiles, and it
does not have this problem.)
2016-02-29 02:58:30 -06:00
Ryan Prichard
483aeffee6 Makefile: stop reading environ variables and avoid spawning processes
The variables can be specified on the make command-line instead, and the
user could have unrelated variables that happen to have the name winpty
is using.

I verified that MSYS2 is passing UNIX_ADAPTER_EXE and PREFIX on the
command-line.  ship/ship.py already passes PREFIX on the command-line.

Previously, for each object file, the Makefile spawned a subprocess for
each of: echo, mkdir, dirname, and git.  Most of these can be eliminated:

 - echo: The gmake function $(info ...) is mostly good enough -- it
   affects the --dry-run/-n output, which might be undesired.

 - mkdir: We only need to invoke mkdir once per directory.  It's tricky
   to get the optimal behavior, but it's possible to do better than before.

 - dirname: The gmake function $(dir ...) is good enough.

 - git: only needed once per build, to get the commit hash.
2016-02-26 04:21:22 -06:00
Ryan Prichard
97e1bd2661 Enable C++11 mode and re-enable C++ exception handling. 2016-02-26 01:20:31 -06:00
Ryan Prichard
0fb98c03fa Recompile everything if VERSION.txt changes
The contents of that file are included on the compiler command-line for
every file.
2015-12-28 21:57:11 -06:00
Ryan Prichard
95aff6bc69 Move source files into a src subdirectory.
Fixes https://github.com/rprichard/winpty/issues/51
2015-11-29 03:50:06 -06:00
Ryan Prichard
d21d0d0598 Add an "implicit copyright grant" notice; update copyright notices 2015-11-08 00:37:25 -06:00
Ryan Prichard
7b7192e441 Add version tracking. Add a --version arg to console and winpty-agent.
There is a "version suffix" that defaults to "-dev".  A maintainer could
change the suffix (or remove it) by invoking make:

    make BUILD_SUFFIX=-foo
    make BUILD_SUFFIX=

It can also be changed in gyp builds:

    gyp winpty.gyp --depth=1 -D BUILD_SUFFIX=-foo
    gyp winpty.gyp --depth=1 -D BUILD_SUFFIX=

If git cannot be executed, the string "none" is used for the commit hash.
2015-11-07 21:19:03 -06:00
Ryan Prichard
52b11bfba9 Convert the makefiles from recursive to non-recursive
* This change reduces the total build time from about 14 seconds to about
   9 seconds on my computer.

Also:

 * Consolidate all the intermediate files into the build directory to
   reduces clutter.

 * Allow specifying UNIX_ADAPTER_EXE to make.  Perhaps this will be helpful
   to the MSYS2 fork, which renames console.exe to winpty.exe.  (I like
   the renaming, but I don't know about the other winpty users.  Maybe
   I'll make the change after I've put out another stable release...)

 * Rename the WINPTY define to COMPILING_WINPTY_DLL define.  The longer
   name is clearer.  I define the macro inside libwinpty/winpty.cc, so the
   build system no longer needs to.  (I removed the define from
   winpty.gyp.)

 * Consolidate config-unix.mk and config-mingw.mk into config.mk.  The
   separation was previously necessary because each file had a conflicting
   definition of CXX.

 * Rename the UNIX_LDFLAGS_STATIC_LIBSTDCXX macro to UNIX_LDFLAGS_STATIC,
   because libstdc++ isn't the only thing I'm linking statically.
2015-11-06 22:08:24 -06:00
Ryan Prichard
4fbda64b7e List "make install" files explicitly and use install tool
* Previously, "make tests install" would also copy trivial_test.exe and
   trivial_test.d to /usr/local/bin.

 * The `install` tool seems to be the conventional way of installing files.
   Setting permissions when copying to /usr/local/bin seems like a good
   idea.

 * Invoke install with -s to strip the symbol tables when they're
   installed.
2015-10-15 16:47:00 -05:00
Ryan Prichard
db12b07706 Add winpty-debugserver.exe and document debugging environment variables. 2015-10-01 03:17:38 -05:00
Ryan Prichard
e123a4e7c8 Add a test program. 2015-08-23 16:02:23 -07:00
Josh Holtrop
31798422d2 add "install" Makefile target 2012-07-11 14:50:51 -04:00
Ryan Prichard
9b66d2cb9c Add a distclean target that removes the files configure creates. 2012-04-17 09:50:19 -07:00
Ryan Prichard
71aa4a59bb Rename pconsole to winpty.
* This avoids a name conflict with an existing unrelated project.

 * I think winpty is a better name anyway.  (i) It's more obviously
   Windows-related.  (ii) I think it more accurately describes what it
   does.  A "pseudo-console" ought to mirror the console API and allow
   replacing the implementation built-in to Windows.  This project is only
   trying to provide functionality similar to using the master interface of
   a Unix pty, but for native console programs.
2012-03-25 02:29:37 -07:00
Ryan Prichard
44554d5e9d Add an MIT copyright notice to all the source files. 2012-03-23 03:11:34 -07:00
Ryan Prichard
19d9c1832c Add a Unix pty<->pconsole adapter. 2012-01-28 14:23:31 -08:00
Ryan Prichard
7e4c06c2e1 Rename Agent to agent. 2012-01-21 17:32:26 -08:00
Ryan Prichard
a4df196ed4 Work on switching from qmake to makefiles and reorganize code a little.
My plan now is to integrate the PseudoConsole with Cygwin and MSYS ptys,
with initial focus on Cygwin.  I think I'll keep the separate Agent and DLL
binaries, and they'll continue to be native Win32 binaries.  I don't want
to have two build systems (qmake vs whatever MSYS/Cygwin uses), and since
I'd like to remove the Qt dependency anyway, I'm trying to switch to
makefiles.
2012-01-21 17:30:41 -08:00