|
@@ -23,6 +23,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
connect(&mProc,SIGNAL(readyReadStandardError()),this,SLOT(onReadStandardError()));
|
|
|
connect(&mProc,SIGNAL(finished(int)),this,SLOT(onfinish()));
|
|
|
Checkqmakesh();
|
|
|
+ Checkdeploysh();
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
@@ -91,6 +92,70 @@ void MainWindow::Checkqmakesh()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void MainWindow::Checkdeploysh()
|
|
|
+{
|
|
|
+ QFile xFile;
|
|
|
+ xFile.setFileName("./maketool_deploy.sh");
|
|
|
+ if(xFile.exists())
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<"not found maketool_deploy.sh. so use res file creat one."<<std::endl;
|
|
|
+ QFile xFileres;
|
|
|
+ xFileres.setFileName(":/maketool_deploy.sh");
|
|
|
+ if(xFileres.open(QIODevice::ReadOnly))
|
|
|
+ {
|
|
|
+ QByteArray ba = xFileres.readAll();
|
|
|
+ if(xFile.open(QIODevice::ReadWrite))
|
|
|
+ {
|
|
|
+ xFile.write(ba);
|
|
|
+ xFile.close();
|
|
|
+ std::cout<<" create maketool_deploy.sh success. "<<std::endl;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" can't create maketool_deploy.sh."<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" open rc file maketool_deploy.sh fail."<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ xFile.setFileName("./maketool_deploylib.sh");
|
|
|
+ if(xFile.exists())
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<"not found maketool_deploylib.sh. so use res file creat one."<<std::endl;
|
|
|
+ QFile xFileres;
|
|
|
+ xFileres.setFileName(":/maketool_deploylib.sh");
|
|
|
+ if(xFileres.open(QIODevice::ReadOnly))
|
|
|
+ {
|
|
|
+ QByteArray ba = xFileres.readAll();
|
|
|
+ if(xFile.open(QIODevice::ReadWrite))
|
|
|
+ {
|
|
|
+ xFile.write(ba);
|
|
|
+ xFile.close();
|
|
|
+ std::cout<<" create maketool_deploylib.sh success. "<<std::endl;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" can't create maketool_deploylib.sh."<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" open rc file maketool_deploylib.sh fail."<<std::endl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::onfinish()
|
|
|
{
|
|
|
ui->pushButton_findqmake->setEnabled(true);
|
|
@@ -141,6 +206,7 @@ void MainWindow::BuildProgram(QString & strpropath)
|
|
|
|
|
|
QString MainWindow::MakeBuildSH(QString & strpropath)
|
|
|
{
|
|
|
+ QString strqmake = ui->lineEdit_qmakepath->text();
|
|
|
int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
|
|
|
char strpath[1000];
|
|
|
snprintf(strpath,1000,"%lld.sh",nnow);
|
|
@@ -154,6 +220,77 @@ QString MainWindow::MakeBuildSH(QString & strpropath)
|
|
|
QString strprodir = strpropath.left(npos);
|
|
|
std::cout<<" dir path: "<<strprodir.toLatin1().data()<<std::endl;
|
|
|
|
|
|
+ QString strproname = strpropath.right(strpropath.size() - npos -1);
|
|
|
+ std::cout<<" pro name: "<<strproname.toLatin1().data()<<std::endl;
|
|
|
+
|
|
|
+ QString strprogramname = strproname.left(strproname.size() -4);
|
|
|
+ std::cout<<" program name: "<<strprogramname.toLatin1().data()<<std::endl;
|
|
|
+
|
|
|
+ int ninfomax = 100000;
|
|
|
+ char * strshinfo = new char[ninfomax];
|
|
|
+ char strline[1000];
|
|
|
+ snprintf(strshinfo,ninfomax,"\n");
|
|
|
+ snprintf(strline,1000,"exemode=0 # 0 no file 1 so 2 exe\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"exefile=\"\"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"curdir=%s\n",QCoreApplication::applicationDirPath().toLatin1().data());strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"cpu_num=`cat /proc/stat | grep cpu[0-9] -c`\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"qtmake=%s\n",strqmake.toLatin1().data());strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"proname=%s\n",strprogramname.toLatin1().data());strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"cd %s\n",strprodir.toLatin1().data());strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"$qtmake %s\n",strproname.toLatin1().data());strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"make -j${cpu_num}\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"make clean\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"rm Makefile\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"rm .qmake.stash\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"if [ -f lib$proname.so ]; then\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," exemode=1\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," exefile=\"lib$proname.so\"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," else\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," if [ -f $proname ]; then\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," exemode=2\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," exefile=\"$proname\"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000," fi\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"fi\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"if ! [ $exemode == 0 ]; then\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"cp $exefile $curdir\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"rm $exefile\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"cd $curdir\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"else\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"echo \"build fail.\"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"exit 1\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"fi\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"if ! [ -d deploy ]; then\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"mkdir deploy\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"fi\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"if [ $exemode == 1 ]; then\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"/bin/bash maketool_deploylib.sh $exefile\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"fi\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"if [ $exemode == 2 ]; then\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"/bin/bash maketool_deploy.sh $exefile\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+ snprintf(strline,1000,"fi\n");strncat(strshinfo,strline,ninfomax);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ QFile xFile;
|
|
|
+ xFile.setFileName(strshpath);
|
|
|
+ if(xFile.open(QIODevice::ReadWrite))
|
|
|
+ {
|
|
|
+ xFile.write(strshinfo,strnlen(strshinfo,ninfomax));
|
|
|
+ xFile.close();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<" open buildsh file fail. file name: "<<strshpath.toLatin1().data()<<std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
+ delete[] strshinfo;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|