Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3150a27

Browse files
committed
Add missing make_buildinfo.c.
1 parent d078e40 commit 3150a27

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

PCbuild/make_buildinfo.c

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

0 commit comments

Comments
 (0)