Ejemplo n.º 1
0
        public static Process CreateXilinxEnvironmentProcess()
        {
            Process process = new Process();

            process.StartInfo.UseShellExecute = false;

            Logger.Instance.WriteDebug("Setting up a process to run inside a Xilinx Environment on a {0} platform.", SystemHelper.GetSystemType());

            List <string> binPaths = new List <string>(XilinxHelper.GetXilinxBinaryPaths());
            List <string> libPaths = new List <string>(XilinxHelper.GetXilinxLibraryPaths());

            // Binary Paths on the PATH environment
            process.StartInfo.EnvironmentVariables["PATH"] =
                SystemHelper.EnvironmentPathPrepend(process.StartInfo.EnvironmentVariables["PATH"], binPaths);

            Logger.Instance.WriteDebug("PATH Environment = '{0}'", process.StartInfo.EnvironmentVariables["PATH"]);

            // Specific the LD_LIBRARY_PATH aswell for *nix systems
            if (SystemHelper.GetSystemType() == SystemHelper.SystemType.Linux)
            {
                Logger.Instance.WriteDebug("Appending Xilinx lib paths to the LD_LIBRARY_PATH");
                process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"] =
                    SystemHelper.EnvironmentPathPrepend(process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"], libPaths);

                Logger.Instance.WriteDebug("LD_LIBRARY_PATH Environment = '{0}'", process.StartInfo.EnvironmentVariables["LD_LIBRARY_PATH"]);
            }

            // Xilinx Specific Environment Variables
            process.StartInfo.EnvironmentVariables["XILINX"]           = PathHelper.Combine(XilinxHelper.GetRootXilinxPath(), "ISE");
            process.StartInfo.EnvironmentVariables["XILINX_DSP"]       = PathHelper.Combine(XilinxHelper.GetRootXilinxPath(), "ISE");
            process.StartInfo.EnvironmentVariables["XILINX_EDK"]       = PathHelper.Combine(XilinxHelper.GetRootXilinxPath(), "EDK");
            process.StartInfo.EnvironmentVariables["XILINX_PLANAHEAD"] = PathHelper.Combine(XilinxHelper.GetRootXilinxPath(), "PlanAhead");

            Logger.Instance.WriteDebug("XILINX Environment = '{0}'", process.StartInfo.EnvironmentVariables["XILINX"]);

            return(process);
        }
Ejemplo n.º 2
0
        public virtual void Start()
        {
            // Check to see if process is already busy
            if (Running)
            {
                throw new Exception("Process is already running.");
            }

            Dispose();

            // Get the tool executable
            string toolPath = Tool;

            if (!Path.IsPathRooted(toolPath))
            {
                toolPath = XilinxHelper.GetXilinxToolPath(Tool);
                if (toolPath == null)
                {
                    throw new Exception(string.Format("Unable to location the executable for the tool '{0}'", Tool));
                }
            }

            // Create the process with special Xilinx Environment
            CurrentProcess = CreateXilinxEnvironmentProcess();
            CurrentProcess.StartInfo.FileName = toolPath;

            string args = "";

            foreach (string arg in Arguments)
            {
                if (!string.IsNullOrEmpty(args))
                {
                    args += " ";
                }
                args += arg;
            }
            CurrentProcess.StartInfo.Arguments        = args;
            CurrentProcess.StartInfo.WorkingDirectory = WorkingDirectory;

            CurrentProcess.StartInfo.UseShellExecute = false;
            if (RedirectOutput)
            {
                CurrentProcess.StartInfo.RedirectStandardError  = true;
                CurrentProcess.StartInfo.RedirectStandardOutput = true;

                listener = new ProcessHelper.ProcessListener(CurrentProcess);
                listener.StdOutNewLineReady += delegate(string line) { if (line != null)
                                                                       {
                                                                           ProcessLine(line);
                                                                       }
                };
                listener.StdErrNewLineReady += delegate(string line) { if (line != null)
                                                                       {
                                                                           ProcessErrorLine(line);
                                                                       }
                };
            }
            if (RedirectInput)
            {
                CurrentProcess.StartInfo.RedirectStandardInput = true;
            }

            // Start the process
            CurrentProcess.Start();

            if (RedirectOutput)
            {
                // Start the listener
                listener.Begin();
            }
        }