Environment var expansion error?
I'm having a problem using environment vars that contain spaces. For some reason they seem to expand incorrectly with space being replaced with the path section that follows the var.
C.IncludeDirectories core : "$(DXSDK_DIR)include/" ;
With DXSDK_DIR set to "C:/Program Files/Microsoft DirectX SDK (November 2008)/", I'd expect the above to expand to"C:/Program Files/Microsoft DirectX SDK (November 2008)/include/". But instead when I Echo it out it expands to:
C:/Programinclude/ Files/Microsoftinclude/ DirectXinclude/ SDKinclude/ (Novemberinclude/ 2008)/include/
Or am I using it wrong?
RE: Environment var expansion error? - Added by Joshua Jensen over 8 years ago
Environment variables that do not have 'path' in some part of their name are split by space into a string list. What you want to do is join the variable back together:
DXSDK_DIR = $(DXSDK_DIR:J=$(SPACE)) ;
You can also use the supplied c/directx module.
IncludeModule c/directx ;
- For libraries.
C.UseDirectX yourlibrary ;
- For the executable.
C.UseDirectX yourapp : link ;
RE: Environment var expansion error? - Added by Richie Turner over 8 years ago
Thanks for the fast responce Josh.
I take it thats because env vars are expanded before the list is split and makes sense in general. However we're working across multiple platforms and have a load of $(PLATFORMX_LIBS), $(PLATFORMY_SDK) etc. that are bound to have spaces in them.
I'm actually generating my jam files from vcproj's using a python script so I've worked around it by pre-expanding them out before I generate the file. They are re-generated each rebuild right now so its ok in the short term. However that makes it a little less portable so I'd like to find a solutiuon that doesnt require pre-expansion or any specialist knowledge of the var type, like late expansion of env vars?