Example #1
0
void ModelsimGenerator::generateMakefile(QString outputPath) {

	Q_ASSERT_X(handler_, "ModelsimGenerator::generateMakefile()",
			"Invalid LibraryHandler pointer");

	// if the outputPath is not defined
	if (outputPath.isEmpty()) {
		emit errorMessage(tr("No output path specified"));
		return;
	}

	QFile file(outputPath);

	// if previous file exists then remove it.
	if (file.exists()) {
		file.remove();
	}

	// open the file and erase all old contents if any exists

	// if file could not be opened
	if (!file.open(QIODevice::Truncate | QIODevice::WriteOnly)) {

		// throw an exception that file couldn't be opened
		QString message(tr("File: "));
		message += outputPath;
		message += tr(" couldn't be opened for writing");
		emit errorMessage(message);

		return;
	}
	// now file has been opened for writing

	QTextStream stream(&file);

	writeMakefile(stream);

	return;

}
Example #2
0
int main(int ac, char **av)
{
    int fake = 0;
    for(int i=0; i<ac; i++) {
        cmdline.cat(av[i]);
        cmdline.cat(" ");
    }
    for(int i=1; i<ac; i++)
    {
        const char *arg = av[i];
        if(strcmp(av[i],"-o") == 0)
        {
            i++;
            fmake = av[i];
        }
        else if(strcmp(av[i],"-builddir") == 0)
        {
            i++;
            builddir = av[i];
            if(strlen(builddir) + 4 < sizeof(destination))
            {
                strcpy(destination, builddir);
                strcat(destination,"/");
            }
        }
        else if(*arg != '-')
        {
            fname = av[i];
        }
        else if(strcmp(av[i],"-fake") == 0)
        {
            fake = 1;
        }
        else
        {
            printf("fake_qmake is a fake of qmake from qt with a very reduced set of features.\n");
            printf("but sufficient to build a pvserver or other simple commandline tools with MinGW.\n");
            printf("if you need all the qmake functions install the qt development package.\n");
            printf("usage:   fake_qmake <-fake> <name.pro> <-o makefile>   <-builddir directory>\n");
#ifdef RLWIN32
            printf("default: fake_qmake          name.pro   -o Makefile.win -builddir release\n");
#else
            printf("default: fake_qmake          name.pro   -o Makefile\n");
#endif
            return -1;
        }
    }

    if(fake == 0)
    {
        perhapsRunQmake(ac,av);
    }
    printf("running fake_qmake\n");

    if(fpro.load(fname.text()) >= 0)
    {
        if(interpretProFile() >= 0)
        {
            fout = fopen(fmake.text(),"w");
            if(fout == NULL)
            {
                printf("could not write makefile=%s\n",fmake.text());
                return -1;
            }
            if(writeMakefile() < 0)
            {
                printf("error writeing makefile=%s\n", fmake.text());
            }
            fclose(fout);
        }
        else
        {
            printf("error interpreting file=%s line=%s\n", fname.text(), line.text());
        }
    }
    else
    {
        printf("could not load project_file=%s\n", fname.text());
    }

    return 0;
}