Guest User

Untitled

a guest
May 27th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include "pd/pragma.h"
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "dirty/dm/file.h"
  6. #include <string>
  7.  
  8. #include <fstream>
  9.  
  10. using namespace std;
  11. void fileToString(string& str, FILE *f)
  12. {
  13. char psBuffer[1024*16]; //16k should be big enough for any single line gcc and other apps throw at us
  14. while( !feof(f) )
  15. {
  16. if( fgets( psBuffer, sizeof(psBuffer), f ) != NULL )
  17. str += ( psBuffer );
  18. }
  19. }
  20.  
  21. long getRevionNumber(const string& s)
  22. {
  23. const char revStr []= "At revision ";
  24. size_t l, v;
  25. l = s.rfind(revStr);
  26. if (l == -1) return 0;
  27. l += sizeof(revStr)-1;
  28. v = atoi( &s.c_str()[l] );
  29. return v;
  30. }
  31.  
  32. int main(int argc, char *argv[])
  33. {
  34. /*
  35. STARTUPINFO siStartupInfo;
  36. PROCESS_INFORMATION piProcessInfo;
  37. memset(&siStartupInfo, 0, sizeof(siStartupInfo));
  38. memset(&piProcessInfo, 0, sizeof(piProcessInfo));
  39. siStartupInfo.cb = sizeof(siStartupInfo);
  40. siStartupInfo.hStdError =
  41. CreateProcess("C:/nightly/autobuild.bat ", 0, NULL, NULL, FALSE, 0, NULL, NULL, &siStartupInfo, &piProcessInfo);
  42. */
  43. #ifdef _DEBUG
  44. fs_chdir("C:/nightly/targetdir");
  45. #endif
  46. long doClean=0, i;
  47. for (i=1; i<argc; i++)
  48. {
  49. if (argv[i] == '-r') //rebuild/clean
  50. doClean = 1;
  51. else if (argv[i] == '-d')
  52. {
  53. if (i+1 >= argc)
  54. printf("-d but missing directory?\r\n")
  55. if (argv[i+1][0] == '-')
  56. printf("-d with option after it?\r\n")
  57. fs_chdir(argv[i+1]);
  58. }
  59. }
  60.  
  61.  
  62. string log, text;
  63. FILE *pipe;
  64.  
  65. pipe = _popen("svn update 2>&1", "r");
  66. text = "";
  67. fileToString(text, pipe);
  68. _pclose(pipe);
  69. long revNo = getRevionNumber(text);
  70. log += text;
  71.  
  72. pipe = _popen("make clean 2>&1", "r");
  73. fileToString(log, pipe);
  74. _pclose(pipe);
  75.  
  76. pipe = _popen("make 2>&1", "r");
  77. fileToString(log, pipe);
  78. _pclose(pipe);
  79.  
  80. printf("%s", log.c_str());
  81.  
  82. ofstream fs;
  83. fs.open ("log.txt");
  84. fs << log;
  85. fs.close();
  86.  
  87. //call upload media to server func
  88. //call upload binary to server func (along with logs)
  89. //call update rss func
  90. return 0;
  91. }
  92.  
  93. #include "../dm/filesystem_win32.c"
Add Comment
Please, Sign In to add comment