Re: Get Compile Errors - Command Line
On Sunday, 16 March 2014 at 18:45:30 UTC, Adam D. Ruppe wrote: On Sunday, 16 March 2014 at 13:57:42 UTC, Bauss wrote: Actually I was doing it through C#. I have tried getting the output of the window but it doesn't seem to redirect it. Did you try the startup info there too? Here's a link with a .net example: http://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output Notice that the answer itself only redirects the output, but dmd I believe uses the error stream for it. The comments discuss it: add to the ctor: RedirectStandardError = true, and read from proc.StandardError afterward. Thank you! That was the issue. I was reading from the standardoutput and not standarderror
Re: Get Compile Errors - Command Line
On Saturday, 15 March 2014 at 22:48:52 UTC, Adam D. Ruppe wrote: On Saturday, 15 March 2014 at 19:11:38 UTC, Bauss wrote: Note I am not typing the arguments, but rather starting the process. Skip to the bottom of this message if you are doing it in D and don't care how it is done in the lower level api. The CreateProcess API call takes a STARTUPINFO argument which has handles you can use to redirect the output. 2somefile.txt in cmd.exe does something like this: HANDLE hFile = CreateFile(somefile.txt, GENERIC_WRITE, 0, null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, null); if(hFile == INVALID_HANDLE_VALUE) throw new Exception(couldn't open file); scope(exit) CloseHandle(hFile); STARTUPINFO si; si.cb = si.sizeof; si.dwFlags = STARTF_USESTDHANDLES; si.hStdError = hFile; // redirect to our file si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); // Now, we'll create the process with the file set up and wait for it to finish PROCESS_INFORMATION pi; if(CreateProcessA(dmd.exe, dmd.exe yourfile.d, null, null, true, 0, null, null, si, pi) == 0) throw new Exception(createProcess failed); WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); // At this point, we could check out somefile.txt to see what is there Of course, if we wanted to see the content in our program, instead of going through a regular file, we could use CreatePipe() to make a pair, passing the write handle to it as the hStdOutput, then reading from the read side to collect all the program's output in memory. There's similar Posix functions if you want to do this kind of thing on linux, etc., too. If you're writing this program in D, the standard library contains a nice little function to make this a lot shorter: http://dlang.org/phobos/std_process.html#.execute the example there calls dmd too! So if you wanna try it from D, copy/paste that example and it should get you started. Actually I was doing it through C#. I have tried getting the output of the window but it doesn't seem to redirect it.
Re: Get Compile Errors - Command Line
On Sunday, 16 March 2014 at 13:57:42 UTC, Bauss wrote: Actually I was doing it through C#. I have tried getting the output of the window but it doesn't seem to redirect it. Did you try the startup info there too? Here's a link with a .net example: http://stackoverflow.com/questions/4291912/process-start-how-to-get-the-output Notice that the answer itself only redirects the output, but dmd I believe uses the error stream for it. The comments discuss it: add to the ctor: RedirectStandardError = true, and read from proc.StandardError afterward.
Re: Get Compile Errors - Command Line
On Saturday, 15 March 2014 at 02:05:26 UTC, Chris Williams wrote: On Friday, 14 March 2014 at 17:10:46 UTC, Bauss wrote: I'm using dmd.exe and not cmd.exe dmd.exe doesn't have a GUI. You're probably running dmd.exe inside cmd.exe. dmd foo.d mylog.txt dmd.exe is a console application. And I running dmd.exe with arguments not cmd.exe with arguments, just wanted to know if there perhaps was an alternative than using cmd.exe.
Re: Get Compile Errors - Command Line
On 03/15/2014 03:04 AM, Bauss wrote: On Saturday, 15 March 2014 at 02:05:26 UTC, Chris Williams wrote: On Friday, 14 March 2014 at 17:10:46 UTC, Bauss wrote: I'm using dmd.exe and not cmd.exe dmd.exe doesn't have a GUI. You're probably running dmd.exe inside cmd.exe. dmd foo.d mylog.txt dmd.exe is a console application. And every console supports what you need. And I running dmd.exe with arguments not cmd.exe with arguments, Sorry but that has nothing to do with the solution that has already been proposed. just wanted to know if there perhaps was an alternative than using cmd.exe. All you need to do is to try the solution. :) Once again: dmd foo.d 2 error.log Ali
Re: Get Compile Errors - Command Line
On Saturday, 15 March 2014 at 16:08:06 UTC, Ali Çehreli wrote: On 03/15/2014 03:04 AM, Bauss wrote: On Saturday, 15 March 2014 at 02:05:26 UTC, Chris Williams wrote: On Friday, 14 March 2014 at 17:10:46 UTC, Bauss wrote: I'm using dmd.exe and not cmd.exe dmd.exe doesn't have a GUI. You're probably running dmd.exe inside cmd.exe. dmd foo.d mylog.txt dmd.exe is a console application. And every console supports what you need. And I running dmd.exe with arguments not cmd.exe with arguments, Sorry but that has nothing to do with the solution that has already been proposed. just wanted to know if there perhaps was an alternative than using cmd.exe. All you need to do is to try the solution. :) Once again: dmd foo.d 2 error.log Ali Doesn't work. Note I am not typing the arguments, but rather starting the process. Tried both with cmd.exe and dmd.exe and neither seem to work.
Re: Get Compile Errors - Command Line
On 03/15/2014 12:11 PM, Bauss wrote: On Saturday, 15 March 2014 at 16:08:06 UTC, Ali Çehreli wrote: dmd foo.d 2 error.log Doesn't work. What happens? Note I am not typing the arguments, but rather starting the process. Your first sentence had compiling manual through command line in it and that made us think that you were typing the arguments. You had said: When compiling manual through command line is there anyway to get the compiling errors? Ali
Re: Get Compile Errors - Command Line
On Saturday, 15 March 2014 at 19:11:38 UTC, Bauss wrote: Note I am not typing the arguments, but rather starting the process. Skip to the bottom of this message if you are doing it in D and don't care how it is done in the lower level api. The CreateProcess API call takes a STARTUPINFO argument which has handles you can use to redirect the output. 2somefile.txt in cmd.exe does something like this: HANDLE hFile = CreateFile(somefile.txt, GENERIC_WRITE, 0, null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, null); if(hFile == INVALID_HANDLE_VALUE) throw new Exception(couldn't open file); scope(exit) CloseHandle(hFile); STARTUPINFO si; si.cb = si.sizeof; si.dwFlags = STARTF_USESTDHANDLES; si.hStdError = hFile; // redirect to our file si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); // Now, we'll create the process with the file set up and wait for it to finish PROCESS_INFORMATION pi; if(CreateProcessA(dmd.exe, dmd.exe yourfile.d, null, null, true, 0, null, null, si, pi) == 0) throw new Exception(createProcess failed); WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hProcess); // At this point, we could check out somefile.txt to see what is there Of course, if we wanted to see the content in our program, instead of going through a regular file, we could use CreatePipe() to make a pair, passing the write handle to it as the hStdOutput, then reading from the read side to collect all the program's output in memory. There's similar Posix functions if you want to do this kind of thing on linux, etc., too. If you're writing this program in D, the standard library contains a nice little function to make this a lot shorter: http://dlang.org/phobos/std_process.html#.execute the example there calls dmd too! So if you wanna try it from D, copy/paste that example and it should get you started.
Re: Get Compile Errors - Command Line
Bauss: When compiling manual through command line is there anyway to get the compiling errors? Something like an error.log file or whatever. Perhaps an argument for the compiler? I checked the documents but didn't seem like there was anything. Thanks. Probably you have to use redirect to file, with or even 2 on Windows. Bye, bearophile
Get Compile Errors - Command Line
When compiling manual through command line is there anyway to get the compiling errors? Something like an error.log file or whatever. Perhaps an argument for the compiler? I checked the documents but didn't seem like there was anything. Thanks.
Re: Get Compile Errors - Command Line
On Friday, 14 March 2014 at 16:58:09 UTC, bearophile wrote: Bauss: When compiling manual through command line is there anyway to get the compiling errors? Something like an error.log file or whatever. Perhaps an argument for the compiler? I checked the documents but didn't seem like there was anything. Thanks. Probably you have to use redirect to file, with or even 2 on Windows. Bye, bearophile I'm using dmd.exe and not cmd.exe
Re: Get Compile Errors - Command Line
On Friday, 14 March 2014 at 17:10:46 UTC, Bauss wrote: I'm using dmd.exe and not cmd.exe dmd.exe doesn't have a GUI. You're probably running dmd.exe inside cmd.exe. dmd foo.d mylog.txt