Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup environment variable for Debug/Run configuration from scripts #464

Open
PengZheng opened this issue Jul 15, 2023 · 5 comments
Open
Labels
build Build components of CDT, anything to do with running the compiler, using Make, CMake, or any builder debug The debug components of CDT, anything to do with running or debugging the target. featurerequest A new feature or enhancement

Comments

@PengZheng
Copy link

PengZheng commented Jul 15, 2023

When using Conan package manager, various dependencies are managed by Conan, and shared libraries are stored in Conan's cache of mysterious path like /home/peng/.conan/data/gtest/1.10.0/_/_/package/e3949dc4f4b1aedb09a080372c49d53e7ce5c305/lib. To find these shared libraries, Conan's virtualrunenv generator generates scripts like the following:

DYLD_LIBRARY_PATH="/home/peng/.conan/data/gtest/1.10.0/_/_/package/e3949dc4f4b1aedb09a080372c49d53e7ce5c305/lib":"/home/peng/.conan/data/cpputest/4.0/_/_/package/cb76d877e1f71f6b4aef5a76437cec8178a987c7/lib":"/home/peng/.conan/data/libzip/1.9.2/_/_/package/6facee69b6b036ae5af63f4864caf8f0b3e81475/lib":"/home/peng/.conan/data/libcurl/7.87.0/_/_/package/57c3848689d663a01034b084669fcd2b1420ce9f/lib":"/home/peng/.conan/data/libxml2/2.10.3/_/_/package/f2181e72b5b28214e4fbb9b20d2d48aa8f8beeb1/lib":"/home/peng/.conan/data/czmq/4.2.0/_/_/package/e7eec5f8bf69573d490b58cf804a4ce56a131b02/lib":"/home/peng/.conan/data/civetweb/1.15/_/_/package/3594b6cdd9b4f46ba7b9b7e241ac8edff95165ce/lib":"/home/peng/.conan/data/libffi/3.4.3/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/lib":"/home/peng/.conan/data/jansson/2.14/_/_/package/7a6238b5a9497fe427989ca15a75e29419bc8c64/lib":"/home/peng/.conan/data/mdnsresponder/1310.140.1/_/_/package/aa7031966f171e2e0e020f7f0b98c6336ede16ad/lib":"/home/peng/.conan/data/zlib/1.2.13/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/lib":"/home/peng/.conan/data/bzip2/1.0.8/_/_/package/966805b1fe79a20c1455c582752b3b35386ff384/lib":"/home/peng/.conan/data/xz_utils/5.2.5/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/zstd/1.5.2/_/_/package/939a303d4130929069cfe8b977e8f2e62d5ade4a/lib":"/home/peng/.conan/data/openssl/1.1.1q/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/libuuid/1.0.3/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/lib":"/home/peng/.conan/data/libiconv/1.17/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/zeromq/4.3.4/_/_/package/6f860545503770f818a0a9b4714df33d9c66a70f/lib":"/home/peng/.conan/data/lz4/1.9.4/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/libsodium/1.0.18/_/_/package/db8eb877125e6492461d482466987ac7ba4ff516/lib"${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}
LD_LIBRARY_PATH="/home/peng/.conan/data/gtest/1.10.0/_/_/package/e3949dc4f4b1aedb09a080372c49d53e7ce5c305/lib":"/home/peng/.conan/data/cpputest/4.0/_/_/package/cb76d877e1f71f6b4aef5a76437cec8178a987c7/lib":"/home/peng/.conan/data/libzip/1.9.2/_/_/package/6facee69b6b036ae5af63f4864caf8f0b3e81475/lib":"/home/peng/.conan/data/libcurl/7.87.0/_/_/package/57c3848689d663a01034b084669fcd2b1420ce9f/lib":"/home/peng/.conan/data/libxml2/2.10.3/_/_/package/f2181e72b5b28214e4fbb9b20d2d48aa8f8beeb1/lib":"/home/peng/.conan/data/czmq/4.2.0/_/_/package/e7eec5f8bf69573d490b58cf804a4ce56a131b02/lib":"/home/peng/.conan/data/civetweb/1.15/_/_/package/3594b6cdd9b4f46ba7b9b7e241ac8edff95165ce/lib":"/home/peng/.conan/data/libffi/3.4.3/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/lib":"/home/peng/.conan/data/jansson/2.14/_/_/package/7a6238b5a9497fe427989ca15a75e29419bc8c64/lib":"/home/peng/.conan/data/mdnsresponder/1310.140.1/_/_/package/aa7031966f171e2e0e020f7f0b98c6336ede16ad/lib":"/home/peng/.conan/data/zlib/1.2.13/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/lib":"/home/peng/.conan/data/bzip2/1.0.8/_/_/package/966805b1fe79a20c1455c582752b3b35386ff384/lib":"/home/peng/.conan/data/xz_utils/5.2.5/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/zstd/1.5.2/_/_/package/939a303d4130929069cfe8b977e8f2e62d5ade4a/lib":"/home/peng/.conan/data/openssl/1.1.1q/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/libuuid/1.0.3/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/lib":"/home/peng/.conan/data/libiconv/1.17/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/zeromq/4.3.4/_/_/package/6f860545503770f818a0a9b4714df33d9c66a70f/lib":"/home/peng/.conan/data/lz4/1.9.4/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/lib":"/home/peng/.conan/data/libsodium/1.0.18/_/_/package/db8eb877125e6492461d482466987ac7ba4ff516/lib"${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
PATH="/home/peng/.conan/data/libzip/1.9.2/_/_/package/6facee69b6b036ae5af63f4864caf8f0b3e81475/bin":"/home/peng/.conan/data/libcurl/7.87.0/_/_/package/57c3848689d663a01034b084669fcd2b1420ce9f/bin":"/home/peng/.conan/data/libxml2/2.10.3/_/_/package/f2181e72b5b28214e4fbb9b20d2d48aa8f8beeb1/bin":"/home/peng/.conan/data/civetweb/1.15/_/_/package/3594b6cdd9b4f46ba7b9b7e241ac8edff95165ce/bin":"/home/peng/.conan/data/libffi/3.4.3/_/_/package/72c3a5400caa3c74f317fbdd305b834cf9aac301/bin":"/home/peng/.conan/data/mdnsresponder/1310.140.1/_/_/package/aa7031966f171e2e0e020f7f0b98c6336ede16ad/bin":"/home/peng/.conan/data/bzip2/1.0.8/_/_/package/966805b1fe79a20c1455c582752b3b35386ff384/bin":"/home/peng/.conan/data/xz_utils/5.2.5/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/bin":"/home/peng/.conan/data/openssl/1.1.1q/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/bin":"/home/peng/.conan/data/libiconv/1.17/_/_/package/0727c3981f0a1c4b9374f8b83e4a93cbd4ab42fe/bin"${PATH:+:$PATH}

CLion/VScode supports setting environment variables using these scripts.
Check https://github.com/apache/celix/blob/master/documents/building/dev_celix_with_clion.md#configuring-clion for an example.
Correction: for new version of Conan, environment_run.sh.env rather than activate_run.sh should be used.

It would be nice if Eclipse CDT could do the same.

@jonahgraham
Copy link
Member

Thanks @PengZheng for this enhancement request. I suppose for now your workaround is to run/source these scripts before starting Eclipse?

@betamaxbandit This is very similar to the work you have recently been working on. I wonder if there would be a benefit of making this standard that a script can be provided to source/run before launching make/gdb/etc. WDYT?

@jonahgraham jonahgraham added debug The debug components of CDT, anything to do with running or debugging the target. build Build components of CDT, anything to do with running the compiler, using Make, CMake, or any builder featurerequest A new feature or enhancement labels Jul 19, 2023
@betamaxbandit
Copy link
Contributor

@betamaxbandit This is very similar to the work you have recently been working on. I wonder if there would be a benefit of making this standard that a script can be provided to source/run before launching make/gdb/etc. WDYT?

Yes that seems like a good idea.
I'm not sure where you would "put" it though. If it were in the Launch Configuration, it would affect launches only and it seems it would be useful for building too. If it was put in the project properties (eg C/C++ General) then that would work, but it wouldn't be clear what the precedence of it and any other toolchain path logic was. Perhaps it could be an either/or. Or perhaps it just follows a similar approach to other environment variables where you can specify whether the environment is appended or replaced.
I guess to get things started it could put in the workspace environment preferences (Preference >C/C++ >Build > Environment).

@jld01
Copy link
Contributor

jld01 commented Jul 19, 2023

How could we make scripting for environment setup portable across all host operating systems without installing extra native tools? I wonder if the Eclipse properties file format would be most appropriate here rather than a shell script since all we need are key/value pairs.

@jonahgraham
Copy link
Member

I'm now aware of at least three tool chains that use the source (on bash) or run bat file (on Windows) to setup environment. So the idea is to integrate with what the tool chains already produce.

FTR the tool chains are:

  • Conan (OP's case)
  • QNX
  • EmSDK

@PengZheng
Copy link
Author

I suppose for now your workaround is to run/source these scripts before starting Eclipse?

Thanks for suggesting this workaround. It works for my case.

Previously I was too worried about affecting the dynamic library loading of the entire development environment. Thus I setup Debug/Run configuration manually, using a script to extract LD_LIBRARY_PATH from the script into xclip, with all double quotation marks removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build components of CDT, anything to do with running the compiler, using Make, CMake, or any builder debug The debug components of CDT, anything to do with running or debugging the target. featurerequest A new feature or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants