Tuesday, June 17, 2008

setenv for Windows

Jim:

I have the misfortune of needing both the 9.1 and 9.2 versions of the Xilinx Platform Studio (XPS) development tools in Windows XP. They're not compatible, but I have designs that require IP and software from each version.

Both versions of XPS are installed on my workstation, and I need an easy way to switch between them without manually changing the path and environmental settings to work with either version.

I found one archived undocumented "setenv.exe" program on the web, but hesitated to use it without knowing what was really going on...

Rory wrote the following C# console application in a few minutes. You can build it yourself as a Console Application using Visual Studio.

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
try {
if (args.Length > 0){

Environment.SetEnvironmentVariable(args[0], args[1],
EnvironmentVariableTarget.Machine);
Console.WriteLine("Set command executed; open a new shell to verify");
}
else{
Console.WriteLine("USE:");
Console.WriteLine(" ");
}
}//try
catch (Exception e){
Console.WriteLine("Does this shell have admin permissions?");
Console.WriteLine(e);
}
}//Main
}//class
}//ns

Once built, put the resulting .exe in a directory contained in your path (i.e. Windows\System32).
The format from the command shell is "setenv attribute value"


Caveats / Notes:

Be careful!
- This code will modify registry entries for your environmental variables. Make sure to back up your environment first! (i.e "set > setBackup.txt")...

Also note:
- For some reason, I encountered an interaction between the cygwin installation and this setenv program; I had to manually include the path to cygwin\bin in the .bat files used in conjunction with the program before Xilinx XPS could be launched.

- You have to open another console window and type "set" to verify that your change has been made; the change will not be reflected in your current console window.

- This applies to XP, not Vista. I'm not using 10.1 yet...

I created a couple of .bat files that can be invoked from the cmd line, to swap back & forth between the two Xilinx development environments:

- typing "set > setenv9x.bat" will create a .bat file that you can modify to point to 9.1 variables; here's what the Xilinx portions of that batch file look like based on my installation:

setenv91.bat (excluding complete path info):

setenv LMC_HOME C:\Xil\Xil91\smartmodel\nt\installed_nt
setenv Path C:\Xil\Xil91edk\bin\nt;C:\Xil\XIl91edk\cygwin\bin;C:\Xil\Xil91\bin\nt; .....
setenv XILINX C:\Xil\Xil91
setenv XILINX_EDK C:\Xil\Xil91edk

Likewise for my 9.2 installation:

setenv92.bat (excluding complete path info):

setenv LMC_HOME C:\Xil\Xil92\smartmodel\nt\installed_nt
setenv Path C:\Xil\Xil92edk\bin\nt;C:\Xil\XIl92edk\cygwin\bin;C:\Xil\Xil92\bin\nt; ......
setenv XILINX C:\Xil\Xil92
setenv XILINX_EDK C:\Xil\Xil92edk