Skip to content

chore: use nushell as a task runner#1038

Merged
2bndy5 merged 13 commits intomasterfrom
add-task-runner
May 26, 2025
Merged

chore: use nushell as a task runner#1038
2bndy5 merged 13 commits intomasterfrom
add-task-runner

Conversation

@2bndy5
Copy link
Copy Markdown
Member

@2bndy5 2bndy5 commented May 24, 2025

This is completely optional. It allows simplifying (local) dev workflow by using nushell (isolated) as a task runner via nur.

Requirements

nur needs to be installed locally.

Note

nushell is compiled as the backend implementation of nur.
Therefore, nushell does not need to be installed.

Windows

It is easier to just install nur from the github release assets.

Linux

Unfortunately, nur needs to be built from it's rust sources.

  1. Install rust with rustup and follow the prompts. If installing on a RPi, then I recommend selecting a "minimal" install configuration (instead of the "default" configuration) to avoid wasting disk space. The minimal configuration can also be set later with rustup set profile minimal, but the std lib docs will still exist on disk until upgrading to the next rust release.
  2. Install nur from source using cargo install nur --locked. The --locked option is important (uses the nur project's cargo.locked manifest).

Using nur

Once nur is installed you can list the tasks defined in the file named "nurfile".

task name what it does
nur docs Builds docs with doxygen. This task also accepts an --open (or -o) option (switch) to open the built docs in your default browser.
nur examples Builds the Linux examples. Built binaries will reside in examples_linux/build directory.
nur fmt Runs clang-format (v14) on changed C++ sources. This task also accepts an --all (or -a) option (switch) to run clang-format on all C++ sources.
nur lib Builds and installs the RF24 library using cmake
nur pico Builds the Pico SDK examples. Built binaries will reside in examples_pico/build directory.
nur py Install the python wrapper. Requires the lib (& boost.python) to be installed.

Tip

All tasks except nur fmt accept a --dirty (or -d) flag to reuse an existing build env. If no build env exists, then one will be configured.

The tasks that use CMake (nur lib, nur examples, and nur pico) also forward any additional arguments passed (except -d, --dirty) in to cmake. This allows further configuring the build as needed.

# build Pico SDK examples for the Adafruit QtPy board
nur pico -DPICO_BOARD=adafruit_qtpy_rp2040

Reminder

All tasks have their own --help (-h) option.

nur fmt -h

nur version 0.16.0+0.104.0
Project path: C:\dev\RF24
Executing task: fmt

Run clang-format on C++ files.

By default, only changed C++ sources are formatted (uses `git status`).
The clang-format version is expected to be v14.
If v14 is not found, then an error is thrown.

Usage:
  > nur fmt {flags}

Flags:
  -a, --all: Format all C++ sources
  -h, --help: Display the help message for this command

Input/output types:
  ╭───┬───────┬────────╮
  │ # │ input │ output │
  ├───┼───────┼────────┤
  │ 0 │ any   │ any    │
  ╰───┴───────┴────────╯


Task execution successful

@2bndy5 2bndy5 marked this pull request as ready for review May 24, 2025 20:28
Copy link
Copy Markdown
Member

@TMRh20 TMRh20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand this but approving anyway. :p

@2bndy5
Copy link
Copy Markdown
Member Author

2bndy5 commented May 24, 2025

I admit, the syntax of the nurfile is not easy to comprehend. But basically, you install nur and use it anywhere within the repo.

Instead of doing this to build the lib and examples (from scratch)

mkdir build && cd build
cmake ..
make
sudo make install
cd ../examples_linux
mkdir build && cd build
cmake ..
make
./gettingStarted

You can just use nur:

nur lib -d
nur examples -d
./examples_linux/build/gettingStarted

I added the optional -d (or --dirty) switches to speed up consecutive builds, but -d is ignored if there is no previous build directory to use.

Run clang-format on any changed C++ files:

nur fmt

Run clang-format on every C++ file (regardless of git status info):

nur fmt -a

2bndy5 added 7 commits May 24, 2025 17:49
when no changed files re detected.
print elapsed time for most external commands.
`git status` can't be timed because we are using it's output.
@2bndy5
Copy link
Copy Markdown
Member Author

2bndy5 commented May 25, 2025

I just found out nushell has early support for running parallel jobs. Using this feature I'm able to clang-format 100 files in about 1 sec (was over 2 sec without parallelism before). 💯

2bndy5 added a commit to nRF24/RF24Network that referenced this pull request May 25, 2025
2bndy5 added a commit to nRF24/RF24Mesh that referenced this pull request May 25, 2025
2bndy5 added a commit to nRF24/RF24Gateway that referenced this pull request May 25, 2025
2bndy5 added a commit to nRF24/RF24Ethernet that referenced this pull request May 25, 2025
Same as  nRF24/RF24#1038 except this repo only has the following tasks:
- `nur docs`
- `nur  fmt`

All others tasks in nRF24/RF24#1038 are only applicable to Linux or the Pico SDK.
@2bndy5 2bndy5 merged commit 2df8418 into master May 26, 2025
2 checks passed
@2bndy5 2bndy5 deleted the add-task-runner branch May 26, 2025 09:00
2bndy5 added a commit to nRF24/RF24Network that referenced this pull request May 26, 2025
2bndy5 added a commit to nRF24/RF24Mesh that referenced this pull request May 26, 2025
2bndy5 added a commit to nRF24/RF24Gateway that referenced this pull request May 26, 2025
2bndy5 added a commit to nRF24/RF24Ethernet that referenced this pull request May 26, 2025
Same as  nRF24/RF24#1038 except this repo only has the following tasks:
- `nur docs`
- `nur  fmt`

All others tasks in nRF24/RF24#1038 are only applicable to Linux or the Pico SDK.

* ran `nur fmt -a`

* disable clang-format on 1 line

avoids adding the wrong indentation to a line.
2bndy5 added a commit to nRF24/RF24Mesh that referenced this pull request May 26, 2025
2bndy5 added a commit to nRF24/RF24Network that referenced this pull request May 26, 2025
2bndy5 added a commit to nRF24/RF24Gateway that referenced this pull request May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants