Re: [dev] requirements of build systems

From: Petros Pateros <petratman_AT_gmail.com>
Date: Mon, 31 Jan 2022 22:52:36 +0200

On Mon, Jan 31, 2022 at 09:34:52AM -0500, LM wrote:
Dear Laura,

> This looks like a very interesting project. I've been looking for some
> alternatives to GNU make.

I hope you find something to fit your needs.

> I do use a few GNU make features that I'm not sure about porting to other
> alternatives. I use wildcards a lot for specifying files. I use the
> substitute features. I also use static pattern rules a lot:
> https://www.gnu.org/software/make/manual/make.html#Static-Pattern Was
> wondering if redo has functionality to replace those features. How hard
> would it be to target .po files and generate .mo files with the proper
> naming conventions using redo? So, en.po generates
> en/LC_MESSAGES/programname.mo. I currently use GNU make and wildcards to
> figure out what .po files there are and generate the .mo files placed in
> applicably named directories.

By default, /bin/sh is called to interpret the .do files, like
/bin/sh -e /path/to/script.do args.., unless they are executables, in which
case they are just executed. So expanding a wildcard is trivial.

all.do: (contents of all.do)
        redo listofmo # always (re)generate it
        redo-ifchange $(cat listofmo) # IFS is relevant here
listofmo.do:
        # create/update the list of .mo's
        # stdout is captured and will atomically (re)place listofmo,
        # unless an error occurs

        ls *.po |
                while read -r po
                do
                        printf '%s\n' "${po%.po}/LC_MESSAGES/programname.mo"
                done
default.mo.do:
        # $1: the name of the file this .do file is called to produce,
              as a path relative to $0 ($0 is /path/to/default.mo.do)
        # $2: $1 but without the .mo suffix
        # $3: see below
        po=${1%/*/*}.po

        redo-ifchange "$po" # declare that $1 depends on $po

        # now generate .mo from .po, either by creating $3 or by writing
        # to stdout. Doing both is or affecting $1 directly is an error.
        #po2mo "$po" > "$3"
        #po2mo "$po" -o "$3"
        #po2mo "$po" # if po2mo writes to stdout

With the above, running
        $ redo all
will generate listofmo and the */LC_MESSAGES/programname.mo files
from the *.po files.

With this approach, however, listofmo is generated every time so that they are
up to date (in case of adding/removing a .po file).

Some redo implementations, like goredo [0], also store a hash of the created
file so nothing that depends on them gets rebuild when its content hasn't changed.

> Any pointers to documentation on how to use
> redo in a project in place of GNU make?

You can find a lot in:
https://redo.readthedocs.io/en/latest/
http://www.goredo.cypherpunks.ru/Usage-rules.html

I also plan to write manual pages for baredo.

Cheers!

[0] http://www.goredo.cypherpunks.ru/index.html
Received on Mon Jan 31 2022 - 21:52:36 CET

This archive was generated by hypermail 2.3.0 : Tue Feb 01 2022 - 11:36:07 CET