Skip to content

Support libraries stored in parent directory #172

@est31

Description

@est31

I'm doing something like:

let mut cfg = gcc::Config::new();
cfg.file("../libfoo/file.c");
cfg.compile("libfoo.a");

And it also works, but I noticed that it doesn't store stuff into the out directory any more but one level above the out directory. This might not be an issue as its still inside the target dir, but its not really nice IMO. This is probably due to this line.

I have that layout because I have a submodule at the top level, and use a workspace, and don't want to move the submodule into one of the crates because multiple crates use it.

How can this be fixed? I imagine two ways:

  • Adding some "prefix" option to the config where you can specify a common prefix that gets prepended to the source location only, but not to the object location. Here it'd be also a good idea to prevent any .. to be put into the path passed to file().
  • Stripping any .. prefixed for the object file path, but not stripping them for the source file path.

The first option requires more concious cooperation from the user, while the second option is potentially more surprising and doesn't help if you have libfoo/../../../libbar/file.c but I guess that doesn't happen often.

This issue is low priority to me as stuff continues working, even though I wanted to write it down somewhere because I think its a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions