bazelbuild / bazel-watcher

Tools for building Bazel targets when source files change.
Apache License 2.0
441 stars 118 forks source link

Send Refresh Signal #408

Closed dmadisetti closed 4 years ago

dmadisetti commented 4 years ago

Context: I just started using bazel as a build system for my thesis in latex with pandoc. I'll normally start a new chapter or note in a new file, which is then globbed in a filegroup and then processed by my rules. ibazel doesn't seem to detect these new files, just changes to the files already globbed. Watching filegroups sounds super non-trivial, so I'm not asking about that.

Request: Could we rig up some key binding like Ctrl-R that will force ibazel to refresh?

achew22 commented 4 years ago

Please ignore this, I got lost in tabs

achew22 commented 4 years ago

Oops, I had too many tabs open and replied into the wrong one.

Request: Could we rig up some key binding like Ctrl-R that will force ibazel to refresh?

This is an interesting proposal and I appreciate you recognize the non-triviality of handling globs. Is this a thing you would be interested in taking on as a task?

dmadisetti commented 4 years ago

Sure! I just wanted to open the issue to make sure this isn't against some core philosophy.

Looks like there's already a routine that handles signals: https://github.com/bazelbuild/bazel-watcher/blob/01507ccf687542774bec86a38949a82a1089f47c/ibazel/ibazel.go#L124 We could add PSUSR1 instead of a key press that restarts.

Alternatively, we could have some keyboard watcher routine. Benefit of this is that it could be extended, and is potentially more user friendly. Looks like https://github.com/eiannone/keyboard provides a nice channel

It also might be slow going since I have other work outside of my workflow 😄

achew22 commented 4 years ago

Just spitballing here, is there a signal you can send to CLI tools other than SIGTERM with your keyboard or something? Is it possible to do ctrl-@ or something to send SIGUSR1? If so there is a 2 line fix that would be able to add this

dmadisetti commented 4 years ago

Yeah, if I was just doing this for myself, I'd add a vim keybinding. Normally you'd send: killall -SIGUSR1 ibazel But it's totally a hack. I think BSD systems have Ctrl-T for SIGINFO, but outside of finding some work around I don't think there's an out of the box solution.

dmadisetti commented 4 years ago

Here's my hack in https://github.com/bazelbuild/bazel-watcher/compare/master...AnotherGroupChat:hack

I started another branch with that keyboard module. Digging into the lib, I realized it's not tested, and there's some global stuff happening that makes me not think it's not that great. I had something working, but writing unit tests looked like they would be a pain. I might revisit it since I'd like a solution upstream. Relevant XKCD

in my .vimrc

<C-e> :AsyncRun killall -SIGUSR1 ibazel

Which seems to be working great

achew22 commented 4 years ago

TBH, regardless of if you want to keep working forward to map some key combo directly to trigger a refresh, I would be happy to merge that PR.

github-actions[bot] commented 4 years ago

Stale issue message

achew22 commented 4 years ago

@dmadisetti, I would be happy to merge your PR if you send it over. Cheers!