I would like to configure a C/C++ project with some environment variables:
- Path to the compiler
- Product to build
- C/C++ defines
- ...
I currently have a custom script that I called ./configure
which has nothing to do with autotools. I used it like with arguments:
$ cd project
$ ./configure --product=foo --compiler=new
This configure will setup a C header file, and some Makefiles files that will be included with the -include
directive.
I've recently found a somehow better solution involving a .env
script that needs to be sourced:
$ cd project
$ echo All is done with autoenv
The autoenv script does the trick. Unfortunately I am not sure this way is the correct way to work. Especially that I will need to remove all the environment variables that I put on my $PATH
when I leave the project.
What is the common way to deal with that issue?
Some hints about my configuration:
- Running on Git
- Using a proprietary compiler
- Using make and Python
One possible solution that I've come across is to instanciate a new shell with the environnment set on it. A problem may appear if I forgot to exit
the environment when I leave the project.
Aucun commentaire:
Enregistrer un commentaire