environment variable and workspace generation

Added by Kevin Thacker over 5 years ago

I have an environment variable which I want to pass through when generating a workspace, so that when the solution is loaded, this environment variable is set for jam to use.

I tried to pass it on the command-line with -jamflags and I tried to put it into the config file, but I can't see how to make this work.

So in jam command-line it sees this environment variable automatically and uses it.
When the solution is built with --workspace, it doesn't see it.

What is the correct way to do this?

thanks.


Replies (5)

RE: environment variable and workspace generation - Added by Joshua Jensen about 5 years ago

Sorry for the late response.

Can you give me an example of what you are passing in and what you expect to happen?

Thanks.

Josh

RE: environment variable and workspace generation - Added by Kevin Thacker about 5 years ago

Joshua Jensen wrote:

Sorry for the late response.

Can you give me an example of what you are passing in and what you expect to happen?

Thanks.

Josh

Here is an example:

set CODE_ROOT = c:\tool

Then in Jam files I use:

$(CODE_ROOT)/Libraries
and
$(CODE_ROOT)/ExternalDependencies

The idea being that the CODE_ROOT could be in a different place for each person, and could be in a different place if the code was branched in a source control tool like Perforce.

Then something like this:

jam --workspace -gen=vs2010 -sCODE_ROOT=%CODE_ROOT% jamfile.jam

So that when the workspace is opened without the var set, it remembers it from the time it was generated.

It is probably possible to do this already.

RE: environment variable and workspace generation - Added by Joshua Jensen about 5 years ago

Are you implying you want to hardcode CODE_ROOT at workspace generation time?

If so, you could use:

jam --workspace -gen=vs2010 -jamflags=CODE_ROOT=%CODE_ROOT% Jamfile.jam build

Unfortunately, this won't quite work, as the %CODE_ROOT% expands with a backslash in it, and that backslash acts as an escape in Jam.

Upon examining the workspace generation code, I can see no way to expand an environment variable at workspace generation time.

I think this could be added, but it isn't there now.

If you can use CODE_ROOT when you run Jam, then you can just use $(CODE_ROOT) within your Jam scripts, and it will use the environment variable.

Any further thoughts?

-Josh

RE: environment variable and workspace generation - Added by Kevin Thacker about 5 years ago

Ok, this is the main reason:

In the config file I can specify the JamModulesUserPath. It uses this to find my c-compiler jam files and a special jam file with all the rules in it.
It uses that to build workspace fine.

This value doesn't appear to get propagated through to the files it generates, so that when the visual studio project is opened, and a build is done, it fails to find the rules in that location.

To get around that, the JAM_MODULES_USER_PATH environment variable needs to be set so that the rules can be found.

In this case, this variable could be put into the jam.bat that is created so that it finds them?

The CODE_ROOT environment variable is there so that the code can be branched to another perforce depot and the common engine/library files accessed through it.

RE: environment variable and workspace generation - Added by Kevin Thacker about 5 years ago

Can environment variables be used in the config file?

e.g.?

CODE_DIR is the environment variable.

Config = {
Platforms = {"win32"},
Configurations = {"debug"},
JamModulesUserPath="%CODE_DIR%/jam"

};

EDIT: I see how the JamModulesUserPath makes it to the generated jambase.jam with JAM_MODULES_USER_PATH+=.
I also see that there are 2 variables, sourceRootPath and destinationRootPath that can be used.

(1-5/5)