Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
EnvVars Plugin and PATH
stahta01:
--- Quote from: pkrcel on February 11, 2012, 10:47:06 pm ---Question: is there a way to see the value of PATH at any time inside C::B focus?
--- End quote ---
I have used "CMD /C echo %PATH%" without the quotes in the post build step; note it can lock up the build and requires the abort button to be pressed to stop it. I added the "/C" option and it no longer locked up for me.
Tim S.
pkrcel:
Thanks, this was indirectly useful...I defined a tools+ (named pathexpl) that invokes "cmd /c path" redirected to the C::B console.
If I call this upon launch of C::B I obtain the following:
--- Quote ---PATH=C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Fi
les\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Fil
es\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\Syste
m32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Comm
on Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Share
d\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\
;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program
Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\
Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\T
ortoiseSVN\bin;C:\Mingw32\bin;C:\Users\Provasi\_user\Coding\Libraries\allegro-5.
0.5-mingw-4.5.2\bin
Process returned 0 (0x0) execution time : 0.033 s
Press any key to continue.
--- End quote ---
and running Debug_Dyn target is (of course) successful.
I then hit build (and get the "target up to date" message)
and again invoke pathexpl, and obtain:
--- Quote ---PATH=C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Fi
les\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Fil
es\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\Syste
m32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Comm
on Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Share
d\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\
;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program
Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\
Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\T
ortoiseSVN\bin;C:\Mingw32\bin
Process returned 0 (0x0) execution time : 0.023 s
Press any key to continue.
--- End quote ---
and, quite expected, there is no longer the path to "$(#liballeg)\bin" in the end, so hitting run returns the "cannot find allegro dll" error.
I do not know why of course.... ???
Going to the Envvars panel in Environment settigns and pressing "set now", then
--- Quote ---PATH=C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Fi
les\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Fil
es\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\Syste
m32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Comm
on Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Share
d\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\
;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program
Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\
Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\T
ortoiseSVN\bin;C:\Mingw32\bin;C:\Users\Provasi\_user\Coding\Libraries\allegro-5.
0.5-mingw-4.5.2\bin
Process returned 0 (0x0) execution time : 0.021 s
Press any key to continue.
--- End quote ---
Any ideas? ???
MortenMacFly:
--- Quote from: pkrcel on February 12, 2012, 01:27:47 am ---Any ideas? ???
--- End quote ---
OK, I think I know why and this is not "nice". You said you compile C::B yourself. Can you do me a favour and search for the following in the compiler plugins's compilergcc.cpp file (should be in CompilerGCC::SetupEnvironment()):
--- Code: --- if (!m_OriginalPath.IsEmpty())
wxSetEnv(_T("PATH"), m_OriginalPath);
--- End code ---
...and replace it with:
--- Code: --- if (!m_OriginalPath.IsEmpty())
{
Manager::Get()->GetLogManager()->DebugLog(_T("Setting up compiler PATH environment..."));
wxSetEnv(_T("PATH"), m_OriginalPath);
}
--- End code ---
Then search for (should be in CompilerGCC::SetEnvironmentForCompiler()):
--- Code: --- envPath = envPath + GetStringFromArray(envPathArr, path_sep, false);
wxSetEnv(_T("PATH"), envPath);
--- End code ---
...and replace it with:
--- Code: --- envPath = envPath + GetStringFromArray(envPathArr, path_sep, false);
Manager::Get()->GetLogManager()->DebugLog(_T("Updating compiler PATH environment..."));
wxSetEnv(_T("PATH"), envPath);
--- End code ---
Then compile, run C::B with the debug console and inspect when C::B sets the PATH from the compiler and from the Envvars plugin respectively. I have the feeling that the compiler "resets" the PATH when you hit compile.
If that is the case, I need to think about a new concept for this (this applies to the PATH environment only!!!).
In the meantime, you have these work-arounds:
1.) In the project options, setup the "execution working dir" for your targets to the allegro bin folder.
2.) In the compiler setup, append the path to the allegro bin folder under "additional paths".
3.) Depending on your platform, adjust the PATH environment variable "globally" (per user).
EDIT: Oh and for testing, you can use a simple "command only" project as this (MyCmd.cbp):
--- Code: ---<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="MyCmd" />
<Option compiler="gcc" />
<Build>
<Target title="default">
<Option type="4" />
<Option compiler="gcc" />
<ExtraCommands>
<Add before="echo <PRE_BUILD>" />
<Add before="echo %PATH%" />
<Add before="echo </PRE_BUILD>" />
<Add after="echo <POST_BUILD>" />
<Add after="echo %PATH%" />
<Add after="echo </POST_BUILD>" />
<Mode after="always" />
</ExtraCommands>
</Target>
</Build>
<Extensions>
<envvars set="dummy" />
</Extensions>
</Project>
</CodeBlocks_project_file>
--- End code ---
pkrcel:
Of course I sticked for (3)for the time being. ;D
Anyway, I did as per your request, just rebuilt C::B and attached you can find the debug log for the same steps as before.
I think the additions you made me push in ended up in this:
--- Quote ---
[....]
EnvVars: Searching for envvars in path '/sets/default'.
EnvVars: Read 1/1 envvars in path '/sets/default'.
EnvVars: Trying to set environment variable 'PATH' to value 'C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\TortoiseSVN\bin;C:\Mingw32\bin;C:\Users\Provasi\_user\Coding\Libraries\allegro-5.0.5-mingw-4.5.2\bin'...
EnvVars: 1/1 envvars applied within C::B focus.
Passing list of files to batch-parser.
Header to parse with priority: 'C:\MinGW\lib\gcc\mingw32\4.6.1\include\c++\cstddef'
Header to parse with priority: 'C:\MinGW\include\w32api.h'
Add 2 priority parsing file(s) for project 'AllegText'...
Added 1 file(s) for project 'AllegText' to batch-parser...
Create new parser for project 'AllegText'
Updating class browser...
Class browser updated.
Starting batch parsing for project 'AllegText'...
Project 'AllegText' parsing stage done!
Project 'AllegText' parsing stage done (53 total parsed files, 1657 tokens in 0 minute(s), 0.589 seconds).
Updating class browser...
Class browser updated.
Setting up compiler PATH environment...
Updating compiler PATH environment...
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 47, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Setting up compiler PATH environment...
Updating compiler PATH environment...
Scanned 0 files for #includes, cache used 0, cache updated 0
Setting up compiler PATH environment...
Updating compiler PATH environment...
Scanned 0 files for #includes, cache used 0, cache updated 0
--- End quote ---
EDIT
using your testbed I get this in the build log
--- Quote ---Running target pre-build steps
cmd /c echo PRE_BUILD
PRE_BUILD
cmd /c echo C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\TortoiseSVN\bin;C:\Mingw32\bin
C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\TortoiseSVN\bin;C:\Mingw32\bin
-------------- Build: default in MyCmd ---------------
Linking stage skipped (build target has no object files to link)
Running target post-build steps
cmd /c echo POST_BUILD
POST_BUILD
cmd /c echo C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\TortoiseSVN\bin;C:\Mingw32\bin
C:\MinGW\bin;C:\Program Files (x86)\PC Connectivity Solution\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\DLLShared\;c:\Program Files (x86)\Common Files\Roxio Shared\OEM\12.0\DLLShared\;c:\Program Files (x86)\Roxio\OEM\AudioCore\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ZipGenius 6\;C:\Program Files\SlikSvn\bin;C:\Program Files\TortoiseSVN\bin;C:\Mingw32\bin
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings (0 minutes, 0 seconds)
--- End quote ---
[attachment deleted by admin]
MortenMacFly:
--- Quote from: pkrcel on February 12, 2012, 10:58:14 am ---I think the additions you made me push in ended up in this:
--- End quote ---
So, it seems I was right: Setting up the PATH envvar using the EnvVars plugin interferes with the compiler plugin that uses the PATH envvar, too for settings up additional path's as setup by the user in the compiler's tool chain settings. Unfortunately it uses a cached PATH anvvar - so the one before the EnvVars plugin updated it. Interesting to see: It depends on the priority of the plugin, so if you were able to setup a higher priority for the EnvVars plugin it would probably work...
Notice that this only applies to the PATH and probably LD_LIBRARY_PATH envvar, every other nested envvar should work just fine.
I see two solutions:
1.) Update the EnvVars plugin so it gets activated every time a file is compiled (which is after the compiler sets the PATH envvar) -> not nice, because of many calls to update the envvar when compiling large projects, OR
2.) Update the compiler plugin so it always caches the *current* PATH envvar when updating/restoring it.
I think solution 2.) is the better one, however, I don't know if it doesn't have side effects... ???
Any thoughts by any of the other devs?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version