You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucy.apache.org by Nick Wellnhofer <we...@aevum.de> on 2014/01/20 21:09:33 UTC

[lucy-dev] Search path for .cfh files

Lucifers,

Now that we’re about to build Clownfish and Lucy separately, we have to find a way to point Lucy to the Clownfish .cfh files. I can see the following options:

    * Add a command-line option to Lucy’s build scripts which in
      turn gets passed to the Clownfish compiler.
    * Use an environment variable like CLOWNFISH_INCLUDE which
      contains a list of paths the Clownfish compiler should search.
    * Install .cfh files in some well-known locations like
      /usr/include/cfh, /usr/local/include/cfh and have CFC always
      search there.

We should probably provide a combination of these methods. I think we should use all three. Thoughts?

Nick


Re: [lucy-dev] Search path for .cfh files

Posted by Nick Wellnhofer <we...@aevum.de>.
On 21/01/2014 17:44, Marvin Humphrey wrote:
> I would tweak this to be specific per host.  Multiple, incompatible versions
> of Clownfish must be allowed to co-exist simultaneously on a given system, so
> that it is possible to upgrade them independently.  That means that the
> Clownfish which is installed with e.g. Python 3.3 should look here first:
>
>     $PYTHON_INSTALL/include/python3.3m/cfh
>
> I think the paths that you specify above make sense for the C Clownfish
> host bindings.  I'm not sure that Clownfish installed with other hosts should
> look there at all, though -- it seems like asking for trouble.  For example,
> a Python Clownfish might find header files for a library in
> /usr/local/include/cfh which does not have Python bindings installed.

Yes, these paths should only be used for the C bindings. Thinking more about 
it, $PREFIX/share/clownfish/include would be a better place.

We already worked out a path for Perl. See sub cf_system_include_dirs in 
Clownfish::CFC::Perl::Build. It currently searches

     $installsitearch/Clownfish/_include
     $installvendorarch/Clownfish/_include

Nick



Re: [lucy-dev] Search path for .cfh files

Posted by Marvin Humphrey <ma...@rectangular.com>.
On Mon, Jan 20, 2014 at 12:09 PM, Nick Wellnhofer <we...@aevum.de> wrote:
> Now that we’re about to build Clownfish and Lucy separately, we have to find a way to point Lucy to the Clownfish .cfh files. I can see the following options:
>
>     * Add a command-line option to Lucy’s build scripts which in
>       turn gets passed to the Clownfish compiler.

+1

>     * Use an environment variable like CLOWNFISH_INCLUDE which
>       contains a list of paths the Clownfish compiler should search.

+1

>     * Install .cfh files in some well-known locations like
>       /usr/include/cfh, /usr/local/include/cfh and have CFC always
>       search there.

I would tweak this to be specific per host.  Multiple, incompatible versions
of Clownfish must be allowed to co-exist simultaneously on a given system, so
that it is possible to upgrade them independently.  That means that the
Clownfish which is installed with e.g. Python 3.3 should look here first:

   $PYTHON_INSTALL/include/python3.3m/cfh

I think the paths that you specify above make sense for the C Clownfish
host bindings.  I'm not sure that Clownfish installed with other hosts should
look there at all, though -- it seems like asking for trouble.  For example,
a Python Clownfish might find header files for a library in
/usr/local/include/cfh which does not have Python bindings installed.

Marvin Humphrey

Re: [lucy-dev] Search path for .cfh files

Posted by Nick Wellnhofer <we...@aevum.de>.
On 21/01/2014 10:13, Nathan Kurz wrote:
> On Mon, Jan 20, 2014 at 12:09 PM, Nick Wellnhofer <we...@aevum.de> wrote:
>> Now that we’re about to build Clownfish and Lucy separately, we have to find a way to point Lucy to the Clownfish .cfh files. I can see the following options:
>
> Does the Lucy build process really need to know where they are, or can
> the CFC executable just have that knowledge internally?   I suppose it
> would be useful in odd cases to tell CFC to use alternate base
> headers, but this seems like a fairly rare issue.

Clownfish can be installed in different directories so we can't hardcode the 
exact location of the .cfh files. Maybe we could install a config file 
together with Clownfish which contains the location of the .cfh files. But 
then the question is how to find the config file. For UNIX systems, I think it 
should be enough to hardcode some locations in /usr and /usr/local.

I'd also like to find a solution which works for more complex dependency 
chains, for example a Lucy extension which has to find the Lucy and Clownfish 
headers.

>  From the point of view of the interface to CFC, a well-known location
> plus a command-line override seems sufficient.  I suppose CFC could
> allow an environment variable to override the compiled default
> location in the absence of a command line arg, but feels like
> overkill.   Is there a frequent case where the command line wouldn't
> be adequate?

For development, I'd like to make it easy to include .cfh files from an 
external source tree which hasn't been installed yet. I think an environment 
variable would be ideal for this use case. I'd like to have a shell script 
like devel/bin/setup_clownfish_env.sh in the Lucy source tree which can be 
called like this:

     devel/bin/setup_clownfish_env.sh /path/to/cfish/source

This script would add the Clownfish compiler/c directory to PATH, the 
Clownfish runtime/c directory to LIBRARY_PATH (and LD_LIBRARY_PATH on ELF 
systems), and the Clownfish core directory to CLOWNFISH_INCLUDE. Then you can 
hack on Lucy pretty much like before without having to care about the location 
of the Clownfish source tree.

> But for my own version of overkill, you might consider adding a
> "well-known name" within the current working directory or the
> executable's directory at the head of the list of places that CFC
> searches.  It's often nice for new users to be able to test things
> from a single directory before they are required to install them.

This would make sense for the .cfh files of the current project which we call 
"source directories". For example, we could always search "core" and 
"../core". But I can't think of a relative path that would make sense for 
"include directories".

Nick


Re: [lucy-dev] Search path for .cfh files

Posted by Nathan Kurz <na...@verse.com>.
On Mon, Jan 20, 2014 at 12:09 PM, Nick Wellnhofer <we...@aevum.de> wrote:
> Lucifers,

I love the appellation!

> Now that we’re about to build Clownfish and Lucy separately, we have to find a way to point Lucy to the Clownfish .cfh files. I can see the following options:

Does the Lucy build process really need to know where they are, or can
the CFC executable just have that knowledge internally?   I suppose it
would be useful in odd cases to tell CFC to use alternate base
headers, but this seems like a fairly rare issue.

>     * Add a command-line option to Lucy’s build scripts which in
>       turn gets passed to the Clownfish compiler.
>     * Use an environment variable like CLOWNFISH_INCLUDE which
>       contains a list of paths the Clownfish compiler should search.
>     * Install .cfh files in some well-known locations like
>       /usr/include/cfh, /usr/local/include/cfh and have CFC always
>       search there.
>
> We should probably provide a combination of these methods.
> I think we should use all three. Thoughts?

>From the point of view of the interface to CFC, a well-known location
plus a command-line override seems sufficient.  I suppose CFC could
allow an environment variable to override the compiled default
location in the absence of a command line arg, but feels like
overkill.   Is there a frequent case where the command line wouldn't
be adequate?

But for my own version of overkill, you might consider adding a
"well-known name" within the current working directory or the
executable's directory at the head of the list of places that CFC
searches.  It's often nice for new users to be able to test things
from a single directory before they are required to install them.

Both working and executable relative have some advantages.  Working
directory may be simplest, but executable relative can be helpful for
a permanent non-root install.  Finding the executable's directory on
Linux and other Unix systems is shown here, with the implication that
it's possible on Windows as well:
http://stackoverflow.com/questions/606041/how-do-i-get-the-path-of-a-process-in-unix-linux

--nate