conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.95k stars 951 forks source link

[feature] Option to suppress generation of script files #16547

Closed vijay8i closed 4 days ago

vijay8i commented 5 days ago

Option to suppress generation of script files

For context, I am using gn + ninja + conan for my build system. I am using conan only to fetch, build and intall third-party dependencies and use them from either the shared cache location or using direct_deploy, by utilizing PkgConfigDeps to provide pkgconfig info to gn. This works well (so far).

I like to keep my third-party folder clean containing only artefacts related to my dependencies. Currently conan also generates and saves script files to manage the environment. This is how my third-party folder looks for a shared install:

$ conan install . --output-folder=third-party  --build=missing
$ tree third-party.shared-deploy/
third-party.shared-deploy/
├── conanbuild.sh
├── conanbuildenv-release-x86_64.sh
├── conanrun.sh
├── conanrunenv-release-x86_64.sh
├── deactivate_conanbuild.sh
├── deactivate_conanrun.sh
├── libuv-static.pc
└── uvw.pc

1 directory, 8 files

The *.sh files are being generated by various generators that eventually invoke save_script method in conan/tools/env/environment.py:

$ ack save_script
...
conan/tools/microsoft/nmakedeps.py
75:        self.vars(scope).save_script("conannmakedeps")

conan/tools/microsoft/nmaketoolchain.py
117:        env.vars(self._conanfile, scope=scope).save_script("conannmaketoolchain")

conan/tools/gnu/autotoolstoolchain.py
259:        env.save_script("conanautotoolstoolchain")

conan/tools/gnu/autotoolsdeps.py
84:        self.vars(scope).save_script("conanautotoolsdeps")

conan/tools/gnu/gnutoolchain.py
257:        env_vars.save_script("conanautotoolstoolchain")

conan/tools/env/virtualrunenv.py
100:        run_env.vars(self._conanfile, scope=scope).save_script(self._filename)

conan/tools/env/environment.py
523:    def save_script(self, filename):

conan/tools/env/virtualbuildenv.py
92:        build_env.vars(self._conanfile, scope=scope).save_script(self._filename)

I would like to have an option to skip the generation of script files so that my third-party folder looks more like this:

$ conan install . --output-folder=third-party --build=missing
$  tree third-party
third-party
├── libuv-static.pc
└── uvw.pc

1 directory, 2 files

OR like this:

$ conan install . --output-folder=third-party --deployer=direct_deploy --deployer-folder=third-party --build=missing
$ tree third-party -L 3
third-party
├── direct_deploy
│   ├── libuv
│   │   ├── conaninfo.txt
│   │   ├── conanmanifest.txt
│   │   ├── include
│   │   ├── lib
│   │   └── licenses
│   └── uvw
│       ├── conaninfo.txt
│       ├── conanmanifest.txt
│       ├── include
│       └── licenses
├── libuv-static.pc
└── uvw.pc

9 directories, 6 files

Looking into the code I don't think there is an option to skip generation of the script files. The feature request is to have an option that would allow this to be possible. The motivation is to reduce the cognitive load by staying as much as possible in one domain (gn for dealing with environment) and use conan for a very specific task of managing external dependencies.

If any one of the maintainers of conan can guide me I would be happy to submit a PR for this feature request.

TIA.

Have you read the CONTRIBUTING guide?

memsharded commented 4 days ago

Hi @vijay8i

Thanks for your suggestion. I think this might be a duplicate of https://github.com/conan-io/conan/issues/13751, which is assigned for 2.X milestone (meaning that it is planned to try it, just it hasn't become enough high priority yet).

Please track and comment that other ticket instead, and close this one if indeed a duplicate. Thanks!

vijay8i commented 4 days ago

Hi @memsharded

Indeed my request seems related to #13751. Closing my request and will track it instead. Thanks!