olofk / fusesoc

Package manager and build abstraction tool for FPGA/ASIC development
BSD 2-Clause "Simplified" License
1.16k stars 242 forks source link

Support per-project config files #314

Open imphil opened 4 years ago

imphil commented 4 years ago

It would be nice to have a per-project config file for fusesoc which allows setting default options, like cores root and build directory. (1)

Implementation idea: Extend the config file search algorithm to go up the directory hierarchy starting from the current working directory until a valid fusesoc.conf file is found. (Current search algo: https://fusesoc.readthedocs.io/en/master/fusesoc.html#core-libraries)

(1) I don't think setting the build directory in the config file is possibly currently, but that's for another issue.

olofk commented 4 years ago

This is mostly already existing. cores_root is deprecated in favor of the core library sections, but still work if you prefer that. build_root can be set in the config file as well

The only thing lacking is the recursive discovery of a fusesoc.conf but I'm not sure I think that's a good idea as it would be unpredictable to know which file it will pick. You can however specify a file explicitly with --config=path/to/fusesoc.conf

imphil commented 4 years ago

The "pick a config file up the tree" is reasonably common these days (think git/svn to find their repository root, editorconfig, and many other project config files).

The --config option is less nice for two reasons:

I agree that we need to document this behavior well, and that we need to make sure that we give suitable warnings/debug output if conflicts are detected to avoid surprising behavior.

olofk commented 4 years ago

Oh, I see what you mean now. I thought you meant down the tree. Up the tree makes more sense. There are probably still some things to work out, but let's deal with those when we come across them

imphil commented 4 years ago

I'm not sure we're having the same definition of up and down in mind :-)

What I mean:

sriyerg commented 4 years ago

I would assume that any option set on the command line would override the 'default' set in the fusesoc.conf file if/when this is implemented.