ยปCore Development>Code coverage>PC/VS7.1/make_buildinfo.c

Python code coverage for PC/VS7.1/make_buildinfo.c

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