Browse Source

change adciv_maketool, not complete.

yuchuli 1 year ago
parent
commit
2b792dc51e

+ 41 - 4
src/tool/adciv_maketool/findqmake.sh

@@ -1,12 +1,12 @@
 qtmake=" "
 
+
 if [ ${#qtmake} -lt 5 ]; then
-  echo "now need find qmake "
-  optfiles=`find /opt -name 'qmake'` 
+  optfiles=`find /usr/lib/x86_64-linux-gnu -name 'qmake'` 
   for entry in $optfiles
   do
-     x=${entry:0-17:17}
-     if [ "$x" == "/gcc_64/bin/qmake" ];  then
+     x=${entry:0-14:14}
+     if [ "$x" == "/qt5/bin/qmake" ];  then
         qtmake="$entry"
 	echo "  -----find qmake"
 	echo "$qtmake"
@@ -16,6 +16,20 @@ fi
 
 if [ ${#qtmake} -lt 5 ]; then
   echo "maybe agx,find qmake in usr folder "
+  optfiles=`find /usr/lib/aarch64-linux-gnu -name 'qmake'` 
+  for entry in $optfiles
+  do
+     x=${entry:0-14:14}
+     if [ "$x" == "/qt5/bin/qmake" ];  then
+        qtmake="$entry"
+	echo "  -----find qmake"
+	echo "$qtmake"
+     fi
+  done
+fi
+
+if [ ${#qtmake} -lt 5 ]; then
+  echo "find in /usr folder "
   optfiles=`find /usr -name 'qmake'` 
   for entry in $optfiles
   do
@@ -27,3 +41,26 @@ if [ ${#qtmake} -lt 5 ]; then
      fi
   done
 fi
+
+if [ ${#qtmake} -lt 5 ]; then
+  echo "find in /opt folder "
+  optfiles=`find /opt -name 'qmake'` 
+  for entry in $optfiles
+  do
+     x=${entry:0-17:17}
+     if [ "$x" == "/gcc_64/bin/qmake" ];  then
+        qtmake="$entry"
+	echo "  -----find qmake"
+	echo "$qtmake"
+     fi
+  done
+fi
+
+if [ ${#qtmake} -lt 5 ]; then
+	echo "fail to find qmake.No qmake in /usr or /opt directory. You can munual set qmake."
+	
+else
+	echo "---qmake---:""$qtmake"
+fi
+
+

+ 134 - 1
src/tool/adciv_maketool/mainwindow.cpp

@@ -1,6 +1,9 @@
 #include "mainwindow.h"
 #include "ui_mainwindow.h"
 
+#include <QFile>
+#include <iostream>
+#include <QFileDialog>
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
@@ -10,7 +13,16 @@ MainWindow::MainWindow(QWidget *parent)
 
     setWindowTitle("IV Make Tool");
 
-    ThreadFindQMake * px = new ThreadFindQMake();
+    ui->lineEdit_qmakepath->setText("qmake");
+
+    mstrqmakepath = "./findqmake.sh";
+    QStringList arg;
+    arg.append(mstrqmakepath);
+    marg_proc = arg;
+    connect(&mProc,SIGNAL(readyReadStandardOutput()),this,SLOT(onReadStandardOutput()));
+    connect(&mProc,SIGNAL(readyReadStandardError()),this,SLOT(onReadStandardError()));
+    connect(&mProc,SIGNAL(finished(int)),this,SLOT(onfinish()));
+    Checkqmakesh();
 }
 
 MainWindow::~MainWindow()
@@ -22,5 +34,126 @@ MainWindow::~MainWindow()
 void MainWindow::on_pushButton_findqmake_clicked()
 {
     ui->pushButton_findqmake->setEnabled(false);
+    mProc.start("/bin/bash",marg_proc);
+    mstrfindqmake = "";
+}
+
+void MainWindow::onReadStandardOutput()
+{
+    QProcess * proc = (QProcess *)sender();
+    QByteArray ba = proc->readAllStandardOutput();
+ //   qDebug("out:");
+    mstrfindqmake = mstrfindqmake + QString(ba);
+//    qDebug("%s",ba.toStdString().data());
+}
+
+void MainWindow::onReadStandardError()
+{
+ //   QProcess * proc = (QProcess *)sender();
+ //   QByteArray ba = proc->readAllStandardError();
+ //   QString str = QString(ba);
+ //   qDebug("error: %s",str.toLatin1().data());
+}
+
+void MainWindow::Checkqmakesh()
+{
+    QFile xFile;
+    xFile.setFileName(mstrqmakepath);
+    if(xFile.exists())
+    {
+
+    }
+    else
+    {
+  //      qDebug("not found findqmake.sh.");
+        std::cout<<"not found findqmake.sh. so use res file creat one."<<std::endl;
+        QFile xFileres;
+        xFileres.setFileName(":/findqmake.sh");
+        if(xFileres.open(QIODevice::ReadOnly))
+        {
+            std::cout<<" open file success."<<std::endl;
+            QByteArray ba = xFileres.readAll();
+            if(xFile.open(QIODevice::ReadWrite))
+            {
+                xFile.write(ba);
+                xFile.close();
+                std::cout<<" create findqmake.sh success. "<<std::endl;
+            }
+            else
+            {
+                std::cout<<" can't create findqmake.sh."<<std::endl;
+            }
+        }
+        else
+        {
+            std::cout<<" open rc file findqmake.sh fail."<<std::endl;
+        }
+    }
+}
+
+void MainWindow::onfinish()
+{
+    ui->pushButton_findqmake->setEnabled(true);
+//    qDebug("outputs:\n  %s",mstrfindqmake.toLatin1().data());
+
+    QByteArray ba = QByteArray(mstrfindqmake.toLatin1().data());
+    QList<QByteArray> balist =  ba.split('\n');
+//    qDebug("ba len %d",balist.size());
+
+    int nsize = static_cast<int>(balist.size());
+    int i;
+    for(i=0;i<nsize;i++)
+    {
+        QString strline = QString(balist[i]);
+        if(strline.indexOf("---qmake---:")>=0)
+        {
+            std::cout<<" find qmake."<<std::endl;
+            QString strqmake = strline.mid(12);
+            std::cout<<" qmake path: "<<strqmake.toLatin1().data()<<std::endl;
+            ui->lineEdit_qmakepath->setText(strqmake);
+            break;
+        }
+    }
+}
+
+
+
+void MainWindow::on_pushButton_SelectPro_clicked()
+{
+    QString str = QFileDialog::getOpenFileName(this,tr("Please Select .pro file"),".","*.pro");
+
+    if(str.isEmpty())return;
+
+
+    ui->pushButton_SelectPro->setEnabled(false);
+
+
+    BuildProgram(str);
+}
+
+void MainWindow::BuildProgram(QString & strpropath)
+{
+    MakeBuildSH(strpropath);
+    //make build sh
+
+    //build
+}
+
+QString MainWindow::MakeBuildSH(QString & strpropath)
+{
+    int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
+    char strpath[1000];
+    snprintf(strpath,1000,"%lld.sh",nnow);
+    QString strshpath = QString(strpath);
+    int npos = strpropath.lastIndexOf('/');
+    if(npos < 0)
+    {
+        std::cout<<" find folder fail."<<std::endl;
+        return QString("");
+    }
+    QString strprodir = strpropath.left(npos);
+    std::cout<<" dir path: "<<strprodir.toLatin1().data()<<std::endl;
+
+
 }
 

+ 22 - 0
src/tool/adciv_maketool/mainwindow.h

@@ -2,6 +2,7 @@
 #define MAINWINDOW_H
 
 #include <QMainWindow>
+#include <QProcess>
 
 #include "threadfindqmake.h"
 
@@ -17,10 +18,31 @@ public:
     MainWindow(QWidget *parent = nullptr);
     ~MainWindow();
 
+private slots:
+    void onReadStandardOutput();
+    void onReadStandardError();
+    void onfinish();
+
 private slots:
     void on_pushButton_findqmake_clicked();
 
+    void on_pushButton_SelectPro_clicked();
+
 private:
     Ui::MainWindow *ui;
+
+    QProcess mProc;
+    QStringList marg_proc;
+
+    QString mstrqmakepath;
+    QString mstrfindqmake;
+
+private:
+    void Checkqmakesh();
+
+    void BuildProgram(QString & strpropath);
+
+    QString MakeBuildSH(QString & strpropath);
+
 };
 #endif // MAINWINDOW_H

+ 13 - 0
src/tool/adciv_maketool/mainwindow.ui

@@ -50,6 +50,19 @@
      <string>qmake  path:</string>
     </property>
    </widget>
+   <widget class="QPushButton" name="pushButton_SelectPro">
+    <property name="geometry">
+     <rect>
+      <x>160</x>
+      <y>170</y>
+      <width>141</width>
+      <height>41</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>Select pro</string>
+    </property>
+   </widget>
   </widget>
   <widget class="QMenuBar" name="menubar">
    <property name="geometry">