termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.29k stars 3.06k forks source link

[Package]: watchman #21478

Open wharacembell opened 1 month ago

wharacembell commented 1 month ago

Why is it worth to add this package?

Watchman is used to watch files and track changes made to those file. Since on termux we can't change the maximum limit of files tracked by inotify this would be of help

Home page URL

https://facebook.github.io/watchman/

Source code URL

https://github.com/facebook/watchman/

Packaging policy acknowledgement

Additional information

Install rust Download source code

Run ./install-system-packages.sh

+ python3 ./build/fbcode_builder/getdeps.py install-system-deps --recursive watchman
I don't know how to install any packages on this system None-none-none

If i try to skip it and run ./autogen.sh

+ python3 build/fbcode_builder/getdeps.py build --allow-system-packages --src-dir=. --project-install-prefix=watchman:/data/data/com.termux/files/usr watchman
Building on {distro=None, distro_vers=None, fb=off, fbsource=off, os=None, shared_libs=off, test=on}
Testing ENV[BOOST_ROOT_1_69_0]: None
Testing ENV[BOOST_ROOT_1_69_0]: None
Assessing boost...
Traceback (most recent call last):
  File "/data/data/com.termux/files/home/test/watchman-2024.09.09.00/build/fbcode_builder/getdeps.py", line 1422, in <module>
    sys.exit(main())
             ^^^^^^
  File "/data/data/com.termux/files/home/test/watchman-2024.09.09.00/build/fbcode_builder/getdeps.py", line 1405, in main
    return args.func(args)
           ^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/test/watchman-2024.09.09.00/build/fbcode_builder/getdeps.py", line 108, in run
    self.run_project_cmd(args, loader, manifest)
  File "/data/data/com.termux/files/home/test/watchman-2024.09.09.00/build/fbcode_builder/getdeps.py", line 616, in run_project_cmd
    cached_project = CachedProject(cache, loader, m)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/home/test/watchman-2024.09.09.00/build/fbcode_builder/getdeps.py", line 248, in __init__
    self.cache_file_name = "-".join(
                           ^^^^^^^^^
TypeError: sequence item 1: expected str instance, NoneType found
TomJo2000 commented 1 month ago

This looks like it mostly duplicates the functionality of watchexec. https://github.com/termux/termux-packages/blob/eb8c502731063bbfb903b41df82c1c896de99878/packages/watchexec/build.sh#L1-L6

wharacembell commented 1 month ago

Yes it is like it but not the same. Since the project i am using (react native expo) uses watchman by default and i dont think there is a way to use watchexec instead

rowend36 commented 3 weeks ago

This is not yet tested but you can modify /node_modules/metro-file-map/src/watchers/NodeWatchers.js to skip node_modules.

I got past this limitation on Termux by doing that.

_watchdir = (dir) => {
    if (this.watched[dir]) {
      return false;
    }
   if (!/.git|node_modules/.test(dir)){
    const watcher = fs.watch(
      dir,
      {
        persistent: true,
      },
      (event, filename) => this._normalizeChange(dir, event, filename)
    );
    this.watched[dir] = watcher;
    watcher.on("error", this._checkedEmitError);
    }
    if (this.root !== dir) {
      this._register(dir, "d");
    }
    return true;
  };
wharacembell commented 3 weeks ago

Thanks. It works in both expo go and expo dev build.

But i remember reading that metro needs to watch all files in order to work properly, as i tried to add the node_modules to metro ignore file but it didn't work then. Or does this just prevent metro from tracking changes in the directory but reads the directory as normal.