Example #1
0
int main(int argc, char*argv[])
{
	char command[500] = "";
	int svn;
	/* Get getbuildinfo.c from svn as getbuildinfo2.c */
	svn = make_buildinfo2();
	if (svn) {
		puts("subcwrev succeeded, generated getbuildinfo.c");
	} else {
		puts("Couldn't run subwcrev.exe on getbuildinfo.c.  Copying it");
		strcat_s(command, sizeof(command), "copy /Y ..\\Modules\\getbuildinfo.c getbuildinfo.c");
		puts(command); fflush(stdout);
		if (system(command) < 0)
			return EXIT_FAILURE;
	}
	return 0;
}
Example #2
0
int main(int argc, char*argv[])
{
    char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL ";
    int do_unlink, result;
    if (argc != 2) {
        fprintf(stderr, "make_buildinfo $(ConfigurationName)\n");
        return EXIT_FAILURE;
    }
    if (strcmp(argv[1], "Release") == 0) {
        strcat_s(command, CMD_SIZE, "-MD ");
    }
    else if (strcmp(argv[1], "Debug") == 0) {
        strcat_s(command, CMD_SIZE, "-D_DEBUG -MDd ");
    }
    else if (strcmp(argv[1], "ReleaseItanium") == 0) {
        strcat_s(command, CMD_SIZE, "-MD /USECL:MS_ITANIUM ");
    }
    else if (strcmp(argv[1], "ReleaseAMD64") == 0) {
        strcat_s(command, CMD_SIZE, "-MD ");
        strcat_s(command, CMD_SIZE, "-MD /USECL:MS_OPTERON ");
    }
    else {
        fprintf(stderr, "unsupported configuration %s\n", argv[1]);
        return EXIT_FAILURE;
    }

    if ((do_unlink = make_buildinfo2()))
        strcat_s(command, CMD_SIZE, "getbuildinfo2.c -DSUBWCREV ");
    else
        strcat_s(command, CMD_SIZE, "..\\..\\Modules\\getbuildinfo.c");
    strcat_s(command, CMD_SIZE, " -Fogetbuildinfo.o -I..\\..\\Include -I..\\..\\PC");
    puts(command); fflush(stdout);
    result = system(command);
    if (do_unlink)
        _unlink("getbuildinfo2.c");
    if (result < 0)
        return EXIT_FAILURE;
    return 0;
}
Example #3
0
int main(int argc, char*argv[])
{
    char command[CMD_SIZE] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL ";
    char tmppath[CMD_SIZE] = "";
    int do_unlink, result;
    char *tmpdir = NULL;
    if (argc <= 2 || argc > 3) {
        fprintf(stderr, "make_buildinfo $(ConfigurationName) [tmpdir]\n");
        return EXIT_FAILURE;
    }
    if (strcmp(argv[1], "Release") == 0) {
        strcat_s(command, CMD_SIZE, "-MD ");
    }
    else if (strcmp(argv[1], "Debug") == 0) {
        strcat_s(command, CMD_SIZE, "-D_DEBUG -MDd ");
    }
    else if (strcmp(argv[1], "ReleaseItanium") == 0) {
        strcat_s(command, CMD_SIZE, "-MD /USECL:MS_ITANIUM ");
    }
    else if (strcmp(argv[1], "ReleaseAMD64") == 0) {
        strcat_s(command, CMD_SIZE, "-MD ");
        strcat_s(command, CMD_SIZE, "-MD /USECL:MS_OPTERON ");
    }
    else {
        fprintf(stderr, "unsupported configuration %s\n", argv[1]);
        return EXIT_FAILURE;
    }
    if (argc > 2) {
        tmpdir = argv[2];
        strcat_s(tmppath, _countof(tmppath), tmpdir);
        /* Hack fix for bad command line:  If the command is issued like this:
         * $(SolutionDir)make_buildinfo.exe" Debug "$(IntDir)"
         * we will get a trailing quote because IntDir ends with a backslash that then
         * escapes the final ".  To simplify the life for developers, catch that problem
         * here by cutting it off.
         * The proper command line, btw is:
         * $(SolutionDir)make_buildinfo.exe" Debug "$(IntDir)\"
         * Hooray for command line parsing on windows.
         */
        if (strlen(tmppath) > 0 && tmppath[strlen(tmppath)-1] == '"')
            tmppath[strlen(tmppath)-1] = '\0';
        strcat_s(tmppath, _countof(tmppath), "\\");
    }

    if ((do_unlink = make_buildinfo2(tmppath))) {
        strcat_s(command, CMD_SIZE, "\"");
        strcat_s(command, CMD_SIZE, tmppath);
        strcat_s(command, CMD_SIZE, "getbuildinfo2.c\" -DSUBWCREV ");
    }
    else {
        char hgtag[CMD_SIZE];
        char hgbranch[CMD_SIZE];
        char hgrev[CMD_SIZE];

        if (get_mercurial_info(hgbranch, hgtag, hgrev, CMD_SIZE)) {
            strcat_s(command, CMD_SIZE, "-DHGBRANCH=\\\"");
            strcat_s(command, CMD_SIZE, hgbranch);
            strcat_s(command, CMD_SIZE, "\\\"");

            strcat_s(command, CMD_SIZE, " -DHGTAG=\\\"");
            strcat_s(command, CMD_SIZE, hgtag);
            strcat_s(command, CMD_SIZE, "\\\"");

            strcat_s(command, CMD_SIZE, " -DHGVERSION=\\\"");
            strcat_s(command, CMD_SIZE, hgrev);
            strcat_s(command, CMD_SIZE, "\\\" ");
        }
        strcat_s(command, CMD_SIZE, "..\\..\\Modules\\getbuildinfo.c");
    }
    strcat_s(command, CMD_SIZE, " -Fo\"");
    strcat_s(command, CMD_SIZE, tmppath);
    strcat_s(command, CMD_SIZE, "getbuildinfo.o\" -I..\\..\\Include -I..\\..\\PC");
    puts(command); fflush(stdout);
    result = system(command);
    if (do_unlink) {
        command[0] = '\0';
        strcat_s(command, CMD_SIZE, "\"");
        strcat_s(command, CMD_SIZE, tmppath);
        strcat_s(command, CMD_SIZE, "getbuildinfo2.c\"");
        _unlink(command);
    }
    if (result < 0)
        return EXIT_FAILURE;
    return 0;
}