Skip to content

Releases: e-dant/watcher

0.12.1

09 Oct 00:47
Compare
Choose a tag to compare

0.12.1

Meson learned how to install the header files for the C library, thank you @toge (in #56)

Fixed an automatic version bump in the release script for some of our newer build files.

0.12.0

07 Oct 21:41
Compare
Choose a tag to compare

0.12.0

Various documentation improvements in the readme, especially around new features.
The readme for the C project was contributed by @AlliBalliBaba in #53

Added (heavily optimized) builds in CI for our "important" artifacts:

  • The "minimal" CLI: tw
  • The "full" CLI: wtr.watcher
  • The new C (currently built as a shared) library: watcher.so.<version> and watcher-c.h
  • Python wheels

These artifacts are available for a wide range of platforms. The CLI and C
shared library are built for these triplets:

  • aarch64-apple-darwin
  • aarch64-pc-windows-msvc
  • aarch64-unknown-linux-gnu
  • aarch64-unknown-linux-musl
  • armv7-unknown-linux-gnueabihf
  • armv7-unknown-linux-musleabihf
  • x86_64-pc-windows-msvc
  • x86_64-unknown-linux-gnu
  • x86_64-unknown-linux-musl

The Python wheels are built for these platforms Linux and Apple on Python 3.8 and up.
On Linux, the musl and gnu libcs, and the architectures x86_64 and aarch64, are supported.
On Apple, only aarch64 is supported (because of a bug on intel runners; see the workflow).

Added support for using this project in C, Python and Node.js:

  • C support as a shared or static library (one with a C-ABI)
  • Node.js support as an NPM package for a "native addon"
  • Python support as a Wheel for an FFI bridge to the C shared library

Each of the new bindings have a basic test suite.

Some examples for these new languages.
Each of the examples has similar behavior:

  • Watch for and display all events
  • Watch for events on every filesystem under the root directory /
  • Stop when any terminal input is received

C

#include "wtr/watcher-c.h"
#include <stdio.h>

void callback(struct wtr_watcher_event event, void* _ctx) {
    printf(
        "path name: %s, effect type: %d path type: %d, effect time: %lld, associated path name: %s\n",
        event.path_name,
        event.effect_type,
        event.path_type,
        event.effect_time,
        event.associated_path_name ? event.associated_path_name : ""
    );
}

int main() {
    void* watcher = wtr_watcher_open("/", callback, NULL);
    getchar();
    return ! wtr_watcher_close(watcher);
}

Python

from watcher import Watch

with Watch("/", print):
    input()

Node.js/TypeScript/JavaScript

import * as watcher from 'watcher';

var w = watcher.watch('/', (event) => {
  console.log(event);
});

process.stdin.on('data', () => {
  w.close();
  process.exit();
});