-
Notifications
You must be signed in to change notification settings - Fork 445
WSL wrapper
The WSL wrapper lets you run Linux applications on Windows computers using WSL.
BOINC provides a WSL wrapper executable.
A WSL app version must include
- The WSL wrapper, marked as the app version's main program.
- A 'control script', the top-level executable that runs in WSL.
Its logical name must be
main
and it must have the<copy_file/>
attribute. - Additional files, data or 'worker' executables.
The control script 'main' must
- Resolve input and output link files as needed, and connect the resulting paths to worker executables.
- Execute the worker executable(s).
Typically 'main' is a bash or perl script, since those are the languages present in stock WSL distros.
In bash, you can resolve link files with this function:
resolve () {
sed 's/<soft_link>//; s/<\/soft_link>//' $1 | tr -d '\r\n'
}
This takes a logical file name (the name of a link file) and returns the path of the physical file in the project directory.
For example, suppose your application has a binary with
logical name worker
that takes input and output filenames as command-line arguments.
These files have logical names in
and out
.
The control script might look like:
#! /bin/bash
resolve () {
sed 's/<soft_link>//; s/<\/soft_link>//' $1 | tr -d '\r\n'
}
$(resolve worker) --nsecs 60 $(resolve in) $(resolve out)
If instead the work reads from stdin and writes to stdout, the last line might be
$(resolve worker) --nsecs 60 < $(resolve in) > $(resolve out)
If the job involves several executables run in sequence, the control script might look like
#! /bin/bash
...
if [ ! -f prog1_done ]; then
prog1; touch prog1_done
fi
if [ ! -f prog2_done ]; then
prog2; touch prog2_done
fi
...
This prevents rerunning steps that have already been completed.
If none of the above features are needed
(input and output files all use <copy_file/>
,
and there's only one computing step)
then main
can simply be the (binary) worker executable.