redoconf suggestion

51 views
Skip to first unread message

stanley...@gmail.com

unread,
Jun 20, 2020, 4:42:47 PM6/20/20
to redo
     I have been playing around with redoconf and trying to integrate it into a small project that is already using redo, but based on examples from the wiki from a couple of years ago.  One thing I noticed immediately was that redoconf hardcodes the "source directory" to $PWD/src.  This does not play well with projects like mine which put their c/c++ source files in a subdirectory named src.  I worked around this by changing the path from src to src_dir in redoconf/configure.sh and redoconf/default.do.sh.  Many tutorials still suggest putting source code files in src.  I think that either making this directory configurable and documenting this on the wiki, or choosing a less likely to clash name will help with adoption.

     The redoconf example on the wiki is nice and covers a lot of basic things that can be done in a C/C++ project, but it doesn't cover more interesting cases like how to deal with in-tree dependencies and submodules.  It also doesn't show how to work with dependencies that are neither readily accessible in standard search paths like libm nor registered with pkg-config.

     CMake offers the ability to add_subdirectory(my/dependency) for CMake ready dependencies, and it allows you to write custom findMyDependency.cmake files for interfacing with those which are not CMake ready.  In my project I currently just put a dependency on the required object files of my dependencies into the various do files of my project's executable and libraries where they are needed for linking.  This works for my case, but I am not sure that this is scalable.  I would be interested to see if you have any suggestions for dealing with dependencies that are not pre-installed and findable with pkg-config.

     For a pre-installed 3rd-party non-pkg-config library I wrote a somelib.rc.od  script to check the existence of it's header file and library file and then appended the appropriate compile and linking flags to CPPFLAGS, LINK and LIBSOME.  I was able to write a small test program and then on the condition of that compiling successfully, set HAVE_LIBSOME to 1 and ran rc_save.  If the detection fails, I print a helpmsg indicating failure and call rc_undo.

     When I tried to do something similar for one of my in-tree dependencies, I ran into some difficulties.  Because the dependency is provided as a git submodule in an uncompiled state, I would like to check to see if the dependency's header is available.  Its absence probably means that the user did not initialize the submodule correctly and I would like to give them a help message suggesting this.  Although this may be the wrong approach, I feel like I should compile the library using whatever requirements are previously specified in the all.rc.  I could then theoretically set CPPFLAGS, LINK, and LIBMYDEPENDENCY appropriately.  However, when I tried to redo-ifchange path/to/mydepencency.o from within my detection script, I get the error from redo

Traceback (most recent call last):
  File "/usr/local/bin/redo-ifchange", line 10, in <module>
    redo.cmd_ifchange.main()
  File "/usr/local/bin/../lib/redo/cmd_ifchange.py", line 48, in main
    rv = builder.run(targets, should_build)
  File "/usr/local/bin/../lib/redo/builder.py", line 556, in run
    lock.trylock()
  File "/usr/local/bin/../lib/redo/state.py", line 512, in trylock
    self.check()
  File "/usr/local/bin/../lib/redo/state.py", line 508, in check
    cycles.check(self.fid)
  File "/usr/local/bin/../lib/redo/cycles.py", line 24, in check
    raise CyclicDependencyError()
redo.cycles.CyclicDependencyError

This is probably because I am trying to use the default.do to build the object file.  The default.do is probably dependent on all.rc being finalized, but my in_tree_dependency.rc.od is a dependency in all.rc.od.  Maybe I could work around this by having a base all.rc that does not contain my in_tree_dependency.rc that is used when redo-ifchange is called in my in-tree dependency.  Then after the in-tree-object file is built, it could be safely added to the true all.rc.  The details of doing this seem a little bit murky to me.

Am I just needlessly complicating things?

My broken libfmt.rc.od for https://github.com/fmtlib/fmt cloned into $S/extern/fmt
#------------------------------
rc_include rc/CXX.rc

prog='
#include <fmt/format.h>

void f() { fmt::format(""); }
'

if [ -e "$S/extern/fmt/include/fmt/format.h" ]; then
    if (redo-ifchange extern/fmt/src/format.o); then
        rc_appendln LIBFMT "extern/fmt/src/format.o"
        rc_appendln CPPFLAGS -I"$S"/extern/fmt/include
    fi
fi
if (rc_compile cxx link $prog); then
    rc_helpmsg "LIBFMT" "Found LIBFMT at extern/fmt"
    rc_replaceln HAVE_LIBFMT 1
    rc_save
else
    rc_helpmsg "LIBFMT" "LIBFMT NOT Found"
    rc_undo
fi
#------------------------------

Thanks for your thoughts on these matters.

Clémence lopez

unread,
Feb 25, 2021, 7:20:07 AM2/25/21
to redo
Hello, we are individuals and we offer loans to all serious and honest people able to repay us honestly. For your financial needs and further information on the loan, contact us at the following email: clemenc...@gmail.com
   you can also contact us WhatsApp: +33 7 52 14 47.

Reply all
Reply to author
Forward
0 new messages