| 1 | n/a | #include <windows.h> |
|---|
| 2 | n/a | #include <sys/types.h> |
|---|
| 3 | n/a | #include <sys/stat.h> |
|---|
| 4 | n/a | #include <stdio.h> |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | /* This file creates the getbuildinfo.o object, by first |
|---|
| 7 | n/a | invoking subwcrev.exe (if found), and then invoking cl.exe. |
|---|
| 8 | n/a | As a side effect, it might generate PC\VS7.1\getbuildinfo2.c |
|---|
| 9 | n/a | also. If this isn't a subversion checkout, or subwcrev isn't |
|---|
| 10 | n/a | found, it compiles ..\\..\\Modules\\getbuildinfo.c instead. |
|---|
| 11 | n/a | |
|---|
| 12 | n/a | Currently, subwcrev.exe is found from the registry entries |
|---|
| 13 | n/a | of TortoiseSVN. |
|---|
| 14 | n/a | |
|---|
| 15 | n/a | No attempt is made to place getbuildinfo.o into the proper |
|---|
| 16 | n/a | binary directory. This isn't necessary, as this tool is |
|---|
| 17 | n/a | invoked as a pre-link step for pythoncore, so that overwrites |
|---|
| 18 | n/a | any previous getbuildinfo.o. |
|---|
| 19 | n/a | |
|---|
| 20 | n/a | */ |
|---|
| 21 | n/a | |
|---|
| 22 | n/a | int make_buildinfo2() |
|---|
| 23 | n/a | { |
|---|
| 24 | n/a | struct _stat st; |
|---|
| 25 | n/a | HKEY hTortoise; |
|---|
| 26 | n/a | char command[500]; |
|---|
| 27 | n/a | DWORD type, size; |
|---|
| 28 | n/a | if (_stat(".svn", &st) < 0) |
|---|
| 29 | n/a | return 0; |
|---|
| 30 | n/a | /* Allow suppression of subwcrev.exe invocation if a no_subwcrev file is present. */ |
|---|
| 31 | n/a | if (_stat("no_subwcrev", &st) == 0) |
|---|
| 32 | n/a | return 0; |
|---|
| 33 | n/a | if (RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS && |
|---|
| 34 | n/a | RegOpenKey(HKEY_CURRENT_USER, "Software\\TortoiseSVN", &hTortoise) != ERROR_SUCCESS) |
|---|
| 35 | n/a | /* Tortoise not installed */ |
|---|
| 36 | n/a | return 0; |
|---|
| 37 | n/a | command[0] = '"'; /* quote the path to the executable */ |
|---|
| 38 | n/a | size = sizeof(command) - 1; |
|---|
| 39 | n/a | if (RegQueryValueEx(hTortoise, "Directory", 0, &type, command+1, &size) != ERROR_SUCCESS || |
|---|
| 40 | n/a | type != REG_SZ) |
|---|
| 41 | n/a | /* Registry corrupted */ |
|---|
| 42 | n/a | return 0; |
|---|
| 43 | n/a | strcat(command, "bin\\subwcrev.exe"); |
|---|
| 44 | n/a | if (_stat(command+1, &st) < 0) |
|---|
| 45 | n/a | /* subwcrev.exe not part of the release */ |
|---|
| 46 | n/a | return 0; |
|---|
| 47 | n/a | strcat(command, "\" ..\\.. ..\\..\\Modules\\getbuildinfo.c getbuildinfo2.c"); |
|---|
| 48 | n/a | puts(command); fflush(stdout); |
|---|
| 49 | n/a | if (system(command) < 0) |
|---|
| 50 | n/a | return 0; |
|---|
| 51 | n/a | return 1; |
|---|
| 52 | n/a | } |
|---|
| 53 | n/a | |
|---|
| 54 | n/a | int main(int argc, char*argv[]) |
|---|
| 55 | n/a | { |
|---|
| 56 | n/a | char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; |
|---|
| 57 | n/a | int do_unlink, result; |
|---|
| 58 | n/a | if (argc != 2) { |
|---|
| 59 | n/a | fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); |
|---|
| 60 | n/a | return EXIT_FAILURE; |
|---|
| 61 | n/a | } |
|---|
| 62 | n/a | if (strcmp(argv[1], "Release") == 0) { |
|---|
| 63 | n/a | strcat(command, "-MD "); |
|---|
| 64 | n/a | } |
|---|
| 65 | n/a | else if (strcmp(argv[1], "Debug") == 0) { |
|---|
| 66 | n/a | strcat(command, "-D_DEBUG -MDd "); |
|---|
| 67 | n/a | } |
|---|
| 68 | n/a | else if (strcmp(argv[1], "ReleaseItanium") == 0) { |
|---|
| 69 | n/a | strcat(command, "-MD /USECL:MS_ITANIUM "); |
|---|
| 70 | n/a | } |
|---|
| 71 | n/a | else if (strcmp(argv[1], "ReleaseAMD64") == 0) { |
|---|
| 72 | n/a | strcat(command, "-MD "); |
|---|
| 73 | n/a | strcat(command, "-MD /USECL:MS_OPTERON "); |
|---|
| 74 | n/a | } |
|---|
| 75 | n/a | else { |
|---|
| 76 | n/a | fprintf(stderr, "unsupported configuration %s\n", argv[1]); |
|---|
| 77 | n/a | return EXIT_FAILURE; |
|---|
| 78 | n/a | } |
|---|
| 79 | n/a | |
|---|
| 80 | n/a | if ((do_unlink = make_buildinfo2())) |
|---|
| 81 | n/a | strcat(command, "getbuildinfo2.c -DSUBWCREV "); |
|---|
| 82 | n/a | else |
|---|
| 83 | n/a | strcat(command, "..\\..\\Modules\\getbuildinfo.c"); |
|---|
| 84 | n/a | strcat(command, " -Fogetbuildinfo.o -I..\\..\\Include -I..\\..\\PC"); |
|---|
| 85 | n/a | puts(command); fflush(stdout); |
|---|
| 86 | n/a | result = system(command); |
|---|
| 87 | n/a | if (do_unlink) |
|---|
| 88 | n/a | unlink("getbuildinfo2.c"); |
|---|
| 89 | n/a | if (result < 0) |
|---|
| 90 | n/a | return EXIT_FAILURE; |
|---|
| 91 | n/a | return 0; |
|---|
| 92 | n/a | } |
|---|