Blame README.md

Packit b5b901
![libuv][libuv_banner]
Packit b5b901
Packit b5b901
## Overview
Packit b5b901
Packit b5b901
libuv is a multi-platform support library with a focus on asynchronous I/O. It
Packit b5b901
was primarily developed for use by [Node.js][], but it's also
Packit b5b901
used by [Luvit](http://luvit.io/), [Julia](http://julialang.org/),
Packit b5b901
[pyuv](https://github.com/saghul/pyuv), and [others](https://github.com/libuv/libuv/wiki/Projects-that-use-libuv).
Packit b5b901
Packit b5b901
## Feature highlights
Packit b5b901
Packit b5b901
 * Full-featured event loop backed by epoll, kqueue, IOCP, event ports.
Packit b5b901
Packit b5b901
 * Asynchronous TCP and UDP sockets
Packit b5b901
Packit b5b901
 * Asynchronous DNS resolution
Packit b5b901
Packit b5b901
 * Asynchronous file and file system operations
Packit b5b901
Packit b5b901
 * File system events
Packit b5b901
Packit b5b901
 * ANSI escape code controlled TTY
Packit b5b901
Packit b5b901
 * IPC with socket sharing, using Unix domain sockets or named pipes (Windows)
Packit b5b901
Packit b5b901
 * Child processes
Packit b5b901
Packit b5b901
 * Thread pool
Packit b5b901
Packit b5b901
 * Signal handling
Packit b5b901
Packit b5b901
 * High resolution clock
Packit b5b901
Packit b5b901
 * Threading and synchronization primitives
Packit b5b901
Packit b5b901
## Versioning
Packit b5b901
Packit b5b901
Starting with version 1.0.0 libuv follows the [semantic versioning](http://semver.org/)
Packit b5b901
scheme. The API change and backwards compatibility rules are those indicated by
Packit b5b901
SemVer. libuv will keep a stable ABI across major releases.
Packit b5b901
Packit b5b901
The ABI/API changes can be tracked [here](http://abi-laboratory.pro/tracker/timeline/libuv/).
Packit b5b901
Packit b5b901
## Licensing
Packit b5b901
Packit b5b901
libuv is licensed under the MIT license. Check the [LICENSE file](LICENSE).
Packit b5b901
The documentation is licensed under the CC BY 4.0 license. Check the [LICENSE-docs file](LICENSE-docs).
Packit b5b901
Packit b5b901
## Community
Packit b5b901
Packit b5b901
 * [Support](https://github.com/libuv/help)
Packit b5b901
 * [Mailing list](http://groups.google.com/group/libuv)
Packit b5b901
 * [IRC chatroom (#libuv@irc.freenode.org)](http://webchat.freenode.net?channels=libuv&uio=d4)
Packit b5b901
Packit b5b901
## Documentation
Packit b5b901
Packit b5b901
### Official documentation
Packit b5b901
Packit b5b901
Located in the docs/ subdirectory. It uses the [Sphinx](http://sphinx-doc.org/)
Packit b5b901
framework, which makes it possible to build the documentation in multiple
Packit b5b901
formats.
Packit b5b901
Packit b5b901
Show different supported building options:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ make help
Packit b5b901
```
Packit b5b901
Packit b5b901
Build documentation as HTML:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ make html
Packit b5b901
```
Packit b5b901
Packit b5b901
Build documentation as HTML and live reload it when it changes (this requires
Packit b5b901
sphinx-autobuild to be installed and is only supported on Unix):
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ make livehtml
Packit b5b901
```
Packit b5b901
Packit b5b901
Build documentation as man pages:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ make man
Packit b5b901
```
Packit b5b901
Packit b5b901
Build documentation as ePub:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ make epub
Packit b5b901
```
Packit b5b901
Packit b5b901
NOTE: Windows users need to use make.bat instead of plain 'make'.
Packit b5b901
Packit b5b901
Documentation can be browsed online [here](http://docs.libuv.org).
Packit b5b901
Packit b5b901
The [tests and benchmarks](https://github.com/libuv/libuv/tree/master/test)
Packit b5b901
also serve as API specification and usage examples.
Packit b5b901
Packit b5b901
### Other resources
Packit b5b901
Packit b5b901
 * [LXJS 2012 talk](http://www.youtube.com/watch?v=nGn60vDSxQ4)
Packit b5b901
   — High-level introductory talk about libuv.
Packit b5b901
 * [libuv-dox](https://github.com/thlorenz/libuv-dox)
Packit b5b901
   — Documenting types and methods of libuv, mostly by reading uv.h.
Packit b5b901
 * [learnuv](https://github.com/thlorenz/learnuv)
Packit b5b901
   — Learn uv for fun and profit, a self guided workshop to libuv.
Packit b5b901
Packit b5b901
These resources are not handled by libuv maintainers and might be out of
Packit b5b901
date. Please verify it before opening new issues.
Packit b5b901
Packit b5b901
## Downloading
Packit b5b901
Packit b5b901
libuv can be downloaded either from the
Packit b5b901
[GitHub repository](https://github.com/libuv/libuv)
Packit b5b901
or from the [downloads site](http://dist.libuv.org/dist/).
Packit b5b901
Packit b5b901
Starting with libuv 1.7.0, binaries for Windows are also provided. This is to
Packit b5b901
be considered EXPERIMENTAL.
Packit b5b901
Packit b5b901
Before verifying the git tags or signature files, importing the relevant keys
Packit b5b901
is necessary. Key IDs are listed in the
Packit b5b901
[MAINTAINERS](https://github.com/libuv/libuv/blob/master/MAINTAINERS.md)
Packit b5b901
file, but are also available as git blob objects for easier use.
Packit b5b901
Packit b5b901
Importing a key the usual way:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ gpg --keyserver pool.sks-keyservers.net --recv-keys AE9BC059
Packit b5b901
```
Packit b5b901
Packit b5b901
Importing a key from a git blob object:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ git show pubkey-saghul | gpg --import
Packit b5b901
```
Packit b5b901
Packit b5b901
### Verifying releases
Packit b5b901
Packit b5b901
Git tags are signed with the developer's key, they can be verified as follows:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ git verify-tag v1.6.1
Packit b5b901
```
Packit b5b901
Packit b5b901
Starting with libuv 1.7.0, the tarballs stored in the
Packit b5b901
[downloads site](http://dist.libuv.org/dist/) are signed and an accompanying
Packit b5b901
signature file sit alongside each. Once both the release tarball and the
Packit b5b901
signature file are downloaded, the file can be verified as follows:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ gpg --verify libuv-1.7.0.tar.gz.sign
Packit b5b901
```
Packit b5b901
Packit b5b901
## Build Instructions
Packit b5b901
Packit b5b901
For GCC there are two build methods: via autotools or via [GYP][].
Packit b5b901
GYP is a meta-build system which can generate MSVS, Makefile, and XCode
Packit b5b901
backends. It is best used for integration into other projects.
Packit b5b901
Packit b5b901
To build with autotools:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ sh autogen.sh
Packit b5b901
$ ./configure
Packit b5b901
$ make
Packit b5b901
$ make check
Packit b5b901
$ make install
Packit b5b901
```
Packit b5b901
Packit b5b901
To build with [CMake](https://cmake.org/):
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ mkdir -p out/cmake ; cd out/cmake ; cmake -DBUILD_TESTING=ON ../..
Packit b5b901
$ make all test
Packit b5b901
# Or manually:
Packit b5b901
$ ./uv_run_tests    # shared library build
Packit b5b901
$ ./uv_run_tests_a  # static library build
Packit b5b901
```
Packit b5b901
Packit b5b901
To build with GYP, first run:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ git clone https://chromium.googlesource.com/external/gyp build/gyp
Packit b5b901
```
Packit b5b901
Packit b5b901
### Windows
Packit b5b901
Packit b5b901
Prerequisites:
Packit b5b901
Packit b5b901
* [Python 2.6 or 2.7][] as it is required
Packit b5b901
  by [GYP][].
Packit b5b901
  If python is not in your path, set the environment variable `PYTHON` to its
Packit b5b901
  location. For example: `set PYTHON=C:\Python27\python.exe`
Packit b5b901
* One of:
Packit b5b901
  * [Visual C++ Build Tools][]
Packit b5b901
  * [Visual Studio 2015 Update 3][], all editions
Packit b5b901
    including the Community edition (remember to select
Packit b5b901
    "Common Tools for Visual C++ 2015" feature during installation).
Packit b5b901
  * [Visual Studio 2017][], any edition (including the Build Tools SKU).
Packit b5b901
    **Required Components:** "MSbuild", "VC++ 2017 v141 toolset" and one of the
Packit b5b901
    Windows SDKs (10 or 8.1).
Packit b5b901
* Basic Unix tools required for some tests,
Packit b5b901
  [Git for Windows][] includes Git Bash
Packit b5b901
  and tools which can be included in the global `PATH`.
Packit b5b901
Packit b5b901
To build, launch a git shell (e.g. Cmd or PowerShell), run `vcbuild.bat`
Packit b5b901
(to build with VS2017 you need to explicitly add a `vs2017` argument),
Packit b5b901
which will checkout the GYP code into `build/gyp`, generate `uv.sln`
Packit b5b901
as well as the necesery related project files, and start building.
Packit b5b901
Packit b5b901
```console
Packit b5b901
> vcbuild
Packit b5b901
```
Packit b5b901
Packit b5b901
Or:
Packit b5b901
Packit b5b901
```console
Packit b5b901
> vcbuild vs2017
Packit b5b901
```
Packit b5b901
Packit b5b901
To run the tests:
Packit b5b901
Packit b5b901
```console
Packit b5b901
> vcbuild test
Packit b5b901
```
Packit b5b901
Packit b5b901
To see all the options that could passed to `vcbuild`:
Packit b5b901
Packit b5b901
```console
Packit b5b901
> vcbuild help
Packit b5b901
vcbuild.bat [debug/release] [test/bench] [clean] [noprojgen] [nobuild] [vs2017] [x86/x64] [static/shared]
Packit b5b901
Examples:
Packit b5b901
  vcbuild.bat              : builds debug build
Packit b5b901
  vcbuild.bat test         : builds debug build and runs tests
Packit b5b901
  vcbuild.bat release bench: builds release build and runs benchmarks
Packit b5b901
```
Packit b5b901
Packit b5b901
Packit b5b901
### Unix
Packit b5b901
Packit b5b901
For Debug builds (recommended) run:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./gyp_uv.py -f make
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
For Release builds run:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./gyp_uv.py -f make
Packit b5b901
$ BUILDTYPE=Release make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
Run `./gyp_uv.py -f make -Dtarget_arch=x32` to build [x32][] binaries.
Packit b5b901
Packit b5b901
### OS X
Packit b5b901
Packit b5b901
Run:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./gyp_uv.py -f xcode
Packit b5b901
$ xcodebuild -ARCHS="x86_64" -project uv.xcodeproj \
Packit b5b901
     -configuration Release -target All
Packit b5b901
```
Packit b5b901
Packit b5b901
Using Homebrew:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ brew install --HEAD libuv
Packit b5b901
```
Packit b5b901
Packit b5b901
Note to OS X users:
Packit b5b901
Packit b5b901
Make sure that you specify the architecture you wish to build for in the
Packit b5b901
"ARCHS" flag. You can specify more than one by delimiting with a space
Packit b5b901
(e.g. "x86_64 i386").
Packit b5b901
Packit b5b901
### Android
Packit b5b901
Packit b5b901
Run:
Packit b5b901
Packit b5b901
For arm
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ source ./android-configure-arm NDK_PATH gyp [API_LEVEL]
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
or for arm64
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ source ./android-configure-arm64 NDK_PATH gyp [API_LEVEL]
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
or for x86
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ source ./android-configure-x86 NDK_PATH gyp [API_LEVEL]
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
or for x86_64
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ source ./android-configure-x86_64 NDK_PATH gyp [API_LEVEL]
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
The default API level is 24, but a different one can be selected as follows:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ source ./android-configure ~/android-ndk-r15b gyp 21
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
Note for UNIX users: compile your project with `-D_LARGEFILE_SOURCE` and
Packit b5b901
`-D_FILE_OFFSET_BITS=64`. GYP builds take care of that automatically.
Packit b5b901
Packit b5b901
### Using Ninja
Packit b5b901
Packit b5b901
To use ninja for build on ninja supported platforms, run:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./gyp_uv.py -f ninja
Packit b5b901
$ ninja -C out/Debug     #for debug build OR
Packit b5b901
$ ninja -C out/Release
Packit b5b901
```
Packit b5b901
Packit b5b901
Packit b5b901
### Running tests
Packit b5b901
Packit b5b901
#### Build
Packit b5b901
Packit b5b901
Build (includes tests):
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./gyp_uv.py -f make
Packit b5b901
$ make -C out
Packit b5b901
```
Packit b5b901
Packit b5b901
#### Run all tests
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./out/Debug/run-tests
Packit b5b901
```
Packit b5b901
Packit b5b901
#### Run one test
Packit b5b901
Packit b5b901
The list of all tests is in `test/test-list.h`.
Packit b5b901
Packit b5b901
This invocation will cause the `run-tests` driver to fork and execute `TEST_NAME` in a child process:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./out/Debug/run-tests TEST_NAME
Packit b5b901
```
Packit b5b901
Packit b5b901
This invocation will cause the `run-tests` driver to execute the test within the `run-tests` process:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ ./out/Debug/run-tests TEST_NAME TEST_NAME
Packit b5b901
```
Packit b5b901
Packit b5b901
#### Debugging tools
Packit b5b901
Packit b5b901
When running the test from within the `run-tests` process (`run-tests TEST_NAME TEST_NAME`), tools like gdb and valgrind work normally.
Packit b5b901
When running the test from a child of the `run-tests` process (`run-tests TEST_NAME`), use these tools in a fork-aware manner.
Packit b5b901
Packit b5b901
##### Fork-aware gdb
Packit b5b901
Packit b5b901
Use the [follow-fork-mode](https://sourceware.org/gdb/onlinedocs/gdb/Forks.html) setting:
Packit b5b901
Packit b5b901
```
Packit b5b901
$ gdb --args out/Debug/run-tests TEST_NAME
Packit b5b901
Packit b5b901
(gdb) set follow-fork-mode child
Packit b5b901
...
Packit b5b901
```
Packit b5b901
Packit b5b901
##### Fork-aware valgrind
Packit b5b901
Packit b5b901
Use the `--trace-children=yes` parameter:
Packit b5b901
Packit b5b901
```bash
Packit b5b901
$ valgrind --trace-children=yes -v --tool=memcheck --leak-check=full --track-origins=yes --leak-resolution=high --show-reachable=yes --log-file=memcheck.log out/Debug/run-tests TEST_NAME
Packit b5b901
```
Packit b5b901
Packit b5b901
### Running benchmarks
Packit b5b901
Packit b5b901
See the section on running tests.
Packit b5b901
The benchmark driver is `out/Debug/run-benchmarks` and the benchmarks are listed in `test/benchmark-list.h`.
Packit b5b901
Packit b5b901
## Supported Platforms
Packit b5b901
Packit b5b901
Check the [SUPPORTED_PLATFORMS file](SUPPORTED_PLATFORMS.md).
Packit b5b901
Packit b5b901
### AIX Notes
Packit b5b901
Packit b5b901
AIX support for filesystem events requires the non-default IBM `bos.ahafs`
Packit b5b901
package to be installed.  This package provides the AIX Event Infrastructure
Packit b5b901
that is detected by `autoconf`.
Packit b5b901
[IBM documentation](http://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/)
Packit b5b901
describes the package in more detail.
Packit b5b901
Packit b5b901
AIX support for filesystem events is not compiled when building with `gyp`.
Packit b5b901
Packit b5b901
### z/OS Notes
Packit b5b901
Packit b5b901
z/OS creates System V semaphores and message queues. These persist on the system
Packit b5b901
after the process terminates unless the event loop is closed.
Packit b5b901
Packit b5b901
Use the `ipcrm` command to manually clear up System V resources.
Packit b5b901
Packit b5b901
## Patches
Packit b5b901
Packit b5b901
See the [guidelines for contributing][].
Packit b5b901
Packit b5b901
[node.js]: http://nodejs.org/
Packit b5b901
[GYP]: http://code.google.com/p/gyp/
Packit b5b901
[guidelines for contributing]: https://github.com/libuv/libuv/blob/master/CONTRIBUTING.md
Packit b5b901
[libuv_banner]: https://raw.githubusercontent.com/libuv/libuv/master/img/banner.png
Packit b5b901
[x32]: https://en.wikipedia.org/wiki/X32_ABI
Packit b5b901
[Python 2.6 or 2.7]: https://www.python.org/downloads/
Packit b5b901
[Visual C++ Build Tools]: https://visualstudio.microsoft.com/visual-cpp-build-tools/
Packit b5b901
[Visual Studio 2015 Update 3]: https://www.visualstudio.com/vs/older-downloads/
Packit b5b901
[Visual Studio 2017]: https://www.visualstudio.com/downloads/
Packit b5b901
[Git for Windows]: http://git-scm.com/download/win