[cli-users] build2 Module for CLI

lyrahgames lyrahgames at mailbox.org
Fri Jun 30 21:45:55 EDT 2023


Hello,

a few days ago, I learned about CLI and have to say that I really much 
like it so far.
Thank you so much for your hard work!

I wanted to use CLI in conjunction with build2 and created the 
following test repository:
https://github.com/lyrahgames/build2-cli-test

Hereby, I have included CLI as build-time dependency and used an ad hoc 
recipe
to automatically transform CLI specification files into their 
respective C++ files.
Similar to the standard process in build2 for generating version header 
files.

exe{build2-cli-test}: {hxx ixx txx cxx}{** -options} {hxx ixx 
cxx}{options}

<{hxx ixx cxx}{options}>: cli{options}
{
  dist = true
  clean = ($src_root != $out_root)
}

As a more general approach, I then used a regex-based ad hoc recipe in 
the 'root.build' file.

# Define file type and its extension for CLI specifications.
#
define cli: file
cli{*}: extension = cli

# Immediately import the CLI compiler.
#
import! [metadata] clic = cli%exe{cli}

# Provide a regex-based ad hoc rule to run the CLI compiler.
#
<{hxx ixx cxx}{~'/(.*)/'}>: cli{~'/\1/'} $clic
{{
  diag cli $>
  $clic \
    --output-dir $out_base \
    --hxx-suffix .hpp \
    --ixx-suffix .ipp \
    --cxx-suffix .cpp \
    $path($<[0])
}}

Would this be the way to go?

Furthermore, thinking of the `in` module of build2 and the ability to 
create custom modules,
is there already a build2 module for CLI that I might have overseen?
Otherwise, would it even be possible to create a build2 module for CLI?
I think build2 depends on CLI, doesn't it?

Greetings
Markus




More information about the cli-users mailing list