Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) QmakeWatcher

 

QmakeWatcher is a tool to show which qmake does with with the makefile it creates.

 

 

 

 

 

Downloads

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolQmakeWatcher/ToolQmakeWatcherConsole.pro

 

# Go ahead and use Qt.Core: it is about as platform-independent as
# the STL and Boost
QT += core

# Go ahead and use Qt.Gui: it is about as platform-independent as
# the STL and Boost. It is needed for QImage
QT += gui

# Don't define widgets: it would defy the purpose of this console
# application to work non-GUI
#greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

include(../../Classes/CppAbout/CppAbout.pri)
include(../../Classes/CppHelp/CppHelp.pri)
include(../../Classes/CppMenuDialog/CppMenuDialog.pri)
include(../../Classes/CppRichelBilderbeekProgram/CppRichelBilderbeekProgram.pri)
include(../../Classes/CppTrace/CppTrace.pri)
include(ToolQmakeWatcherConsole.pri)

#
#
# Type of compile
#
#

CONFIG(release, debug|release) {
  DEFINES += NDEBUG NTRACE_BILDERBIKKEL
}

QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra -Weffc++

unix {
  QMAKE_CXXFLAGS += -Werror
}

#
#
# Boost
#
#

win32 {
  INCLUDEPATH += \
    ../../Libraries/boost_1_54_0
}

 

 

 

 

 

Qt project file: ./ToolQmakeWatcher/ToolQmakeWatcherDesktop.pro

 

include(../../DesktopApplication.pri)
include(../../Libraries/Boost.pri)
include(../../Libraries/GeneralConsole.pri)
include(../../Libraries/GeneralDesktop.pri)

include(ToolQmakeWatcherDesktop.pri)

SOURCES += qtmain.cpp

 

 

 

 

 

./ToolQmakeWatcher/ToolQmakeWatcherConsole.pri

 

INCLUDEPATH += \
    ../../Tools/ToolQmakeWatcher

SOURCES += \
    ../../Tools/ToolQmakeWatcher/qmakewatchermenudialog.cpp

HEADERS += \
    ../../Tools/ToolQmakeWatcher/qmakewatchermenudialog.h

OTHER_FILES += \
    ../../Tools/ToolQmakeWatcher/Licence.txt

 

 

 

 

 

./ToolQmakeWatcher/ToolQmakeWatcherDesktop.pri

 

include(ToolQmakeWatcherConsole.pri)

INCLUDEPATH += \
    ../../Tools/ToolQmakeWatcher

SOURCES += \
    ../../Tools/ToolQmakeWatcher/qtqmakewatchermaindialog.cpp \
    ../../Tools/ToolQmakeWatcher/qtqmakewatchermenudialog.cpp

HEADERS += \
    ../../Tools/ToolQmakeWatcher/qtqmakewatchermaindialog.h \
    ../../Tools/ToolQmakeWatcher/qtqmakewatchermenudialog.h

FORMS    += \
    ../../Tools/ToolQmakeWatcher/qtqmakewatchermaindialog.ui \
    ../../Tools/ToolQmakeWatcher/qtqmakewatchermenudialog.ui

 

 

 

 

 

./ToolQmakeWatcher/ToolQmakeWatcherWebsite.pri

 

include(../../Tools/ToolQmakeWatcher/ToolQmakeWatcherConsole.pri)
SOURCES +=
HEADERS +=

 

 

 

 

 

./ToolQmakeWatcher/main.cpp

 

//---------------------------------------------------------------------------
/*
PrimeExpert, tool to test if a number is prime
Copyright (C) 2008-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolPrimeExpert.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "qmakewatchermenudialog.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  const std::vector<std::string> args { ribi::MenuDialog::ConvertArguments(argc,argv) };
  ribi::QmakeWatcherMenuDialog d;
  return d.Execute(args);
}

 

 

 

 

 

./ToolQmakeWatcher/qmakewatchermenudialog.h

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#ifndef QMAKEWATCHERMENUDIALOG_H
#define QMAKEWATCHERMENUDIALOG_H

#include "menudialog.h"

namespace ribi {

struct QmakeWatcherMenuDialog final : public MenuDialog
{
  About GetAbout() const noexcept override;
  Help GetHelp() const noexcept override;
  boost::shared_ptr<const Program> GetProgram() const noexcept override;
  std::string GetVersion() const noexcept override;
  std::vector<std::string> GetVersionHistory() const noexcept override;

  private:
  int ExecuteSpecific(const std::vector<std::string>& argv) noexcept override;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif
};

} //~namespace ribi

#endif // QMAKEWATCHERMENUDIALOG_H

 

 

 

 

 

./ToolQmakeWatcher/qmakewatchermenudialog.cpp

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#include "qmakewatchermenudialog.h"

#include <iostream>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "richelbilderbeekprogram.h"
#include "testtimer.h"
#include "trace.h"
#pragma GCC diagnostic pop

int ribi::QmakeWatcherMenuDialog::ExecuteSpecific(const std::vector<std::string>& argv) noexcept
{
  #ifndef NDEBUG
  Test();
  #endif
  const int argc = static_cast<int>(argv.size());
  if (argc == 1)
  {
    std::cout << GetHelp() << '\n';
    return 1;
  }
  assert(!"TODO");
  return 1;
}

ribi::About ribi::QmakeWatcherMenuDialog::GetAbout() const noexcept
{
  ribi::About a {
    "Richel Bilderbeek",
    "QmakeWatcher",
    "tool to watch qmake's .pro to Makefile conversion",
    "the 20th of September 2013",
    "2010-2015",
    "http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm",
    GetVersion(),
    GetVersionHistory()
  };
  a.AddLibrary("TestTimer version: " + TestTimer::GetVersion());
  a.AddLibrary("Trace version: " + Trace::GetVersion());
  return a;
}

ribi::Help ribi::QmakeWatcherMenuDialog::GetHelp() const noexcept
{
  return Help(
    this->GetAbout().GetFileTitle(),
    this->GetAbout().GetFileDescription(),
    {

    },
    {

    }
  );
}

boost::shared_ptr<const ribi::Program> ribi::QmakeWatcherMenuDialog::GetProgram() const noexcept
{
  const boost::shared_ptr<const Program> p {
    new ProgramQmakeWatcher
  };
  assert(p);
  return p;
}

std::string ribi::QmakeWatcherMenuDialog::GetVersion() const noexcept
{
  return "1.0";
}

std::vector<std::string> ribi::QmakeWatcherMenuDialog::GetVersionHistory() const noexcept
{
  return {
    "2013-09-20: version 1.0: initial version, conformized for ProjectRichelBilderbeek"
    "2013-11-04: version 1.1: conformized for ProjectRichelBilderbeekConsole"
  };
}

#ifndef NDEBUG
void ribi::QmakeWatcherMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolQmakeWatcher/qtmain.cpp

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <QApplication>
#include "qtqmakewatchermenudialog.h"
#pragma GCC diagnostic pop

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  ribi::QtQmakeWatcherMenuDialog w;
  w.show();
  return a.exec();
}

 

 

 

 

 

./ToolQmakeWatcher/qtqmakewatchermaindialog.h

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#ifndef QTQMAKEWATCHERMAINDIALOG_H
#define QTQMAKEWATCHERMAINDIALOG_H

#include <string>
#include <vector>

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
  class QtQmakeWatcherMainDialog;
}

namespace ribi {

class QtQmakeWatcherMainDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtQmakeWatcherMainDialog(QWidget *parent = 0);
  QtQmakeWatcherMainDialog(const QtQmakeWatcherMainDialog&) = delete;
  QtQmakeWatcherMainDialog& operator=(const QtQmakeWatcherMainDialog&) = delete;
  ~QtQmakeWatcherMainDialog() noexcept;

private:
  Ui::QtQmakeWatcherMainDialog *ui;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif

private slots:
  void OnQmake() noexcept;
};

} //~namespace ribi

#endif // QTQMAKEWATCHERMAINDIALOG_H

 

 

 

 

 

./ToolQmakeWatcher/qtqmakewatchermaindialog.cpp

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include "qtqmakewatchermaindialog.h"

#include <cassert>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <string>

#include <QDesktopWidget>
#include <QFile>

#include "fileio.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qtqmakewatchermaindialog.h"
#pragma GCC diagnostic pop

ribi::QtQmakeWatcherMainDialog::QtQmakeWatcherMainDialog(QWidget *parent)
  : QtHideAndShowDialog(parent),
    ui(new Ui::QtQmakeWatcherMainDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
  ui->edit_pro->setWordWrapMode(QTextOption::NoWrap);
  ui->edit_makefile->setWordWrapMode(QTextOption::NoWrap);
  ui->edit_diff->setWordWrapMode(QTextOption::NoWrap);

  QObject::connect(ui->button_qmake,&QPushButton::clicked,
    this,&ribi::QtQmakeWatcherMainDialog::OnQmake
  );



  //Put the dialog in the screen center
  const QRect screen = QApplication::desktop()->screenGeometry();
  this->setGeometry(0,0,screen.width() * 8 / 10,screen.height() * 8 / 10);
  this->move( screen.center() - this->rect().center() );
}

ribi::QtQmakeWatcherMainDialog::~QtQmakeWatcherMainDialog() noexcept
{
  delete ui;
}

void ribi::QtQmakeWatcherMainDialog::OnQmake() noexcept
{
  //Save text to file
  {
    const std::string s = ui->edit_pro->document()->toPlainText().toStdString();
    std::ofstream f("tmp.pro");
    f << s << '\n';
  }
  //Execute commands
  {
    const bool has_error = std::system("cp Makefile oldmake");
    assert(!has_error);
    if (has_error) throw std::runtime_error("'cp Makefile oldmake' failed");
  }
  {
    const bool has_error = std::system("qmake tmp.pro");
    assert(!has_error);
    if (has_error) throw std::runtime_error("'qmake tmp.pro' failed");
  }
  {
    const bool has_error = std::system("diff Makefile oldmake > tmp.txt");
    assert(!has_error);
    if (has_error) throw std::runtime_error("'diff Makefile oldmake > tmp.txt' failed");
  }
  //Display Makefile
  {
    ui->edit_makefile->clear();
    const std::vector<std::string> v(ribi::fileio::FileIo().FileToVector("Makefile"));
    for(const std::string& s: v)
    {
      ui->edit_makefile->appendPlainText(QString(s.c_str()));
    }
  }
  //Display diff
  {
    ui->edit_diff->clear();
    const std::vector<std::string> v(ribi::fileio::FileIo().FileToVector("tmp.txt"));
    for(const std::string& s: v)
    {
      std::string t = s;
      if (!s.empty() && s[0] == '>')
      {
        //Old
        t = "<font color=#0000FF>&lt;"
          + s.substr(1,s.size()-1)
          + "</font>";
      }
      if (!s.empty() && s[0] == '<')
      {
        //New
        t = "<b><font color=#FF0000>&gt;"
          + s.substr(1,s.size()-1)
          + "</font></b>";
      }
      ui->edit_diff->appendHtml(QString(t.c_str()));
    }
  }
}

#ifndef NDEBUG
void ribi::QtQmakeWatcherMainDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

./ToolQmakeWatcher/qtqmakewatchermenudialog.h

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#ifndef QTQMAKEWATCHERMENUDIALOG_H
#define QTQMAKEWATCHERMENUDIALOG_H

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qthideandshowdialog.h"
#pragma GCC diagnostic pop

namespace Ui {
  class QtQmakeWatcherMenuDialog;
}

namespace ribi {

class QtQmakeWatcherMenuDialog : public QtHideAndShowDialog
{
  Q_OBJECT

public:
  explicit QtQmakeWatcherMenuDialog(QWidget *parent = 0) noexcept;
  QtQmakeWatcherMenuDialog(const QtQmakeWatcherMenuDialog&) = delete;
  QtQmakeWatcherMenuDialog& operator=(const QtQmakeWatcherMenuDialog&) = delete;
  ~QtQmakeWatcherMenuDialog() noexcept;

protected:
  void keyPressEvent(QKeyEvent * event) noexcept;

private:
  Ui::QtQmakeWatcherMenuDialog *ui;

  #ifndef NDEBUG
  static void Test() noexcept;
  #endif

private slots:
  void on_button_about_clicked() noexcept;
  void on_button_quit_clicked() noexcept;
  void on_button_start_clicked() noexcept;
};

} //~namespace ribi

#endif // QTQMAKEWATCHERMENUDIALOG_H

 

 

 

 

 

./ToolQmakeWatcher/qtqmakewatchermenudialog.cpp

 

//---------------------------------------------------------------------------
/*
QmakeWatcher, tool to watch qmake's .pro to Makefile conversion
Copyright (C) 2010-2015 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolQmakeWatcher.htm
//---------------------------------------------------------------------------
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include "qtqmakewatchermenudialog.h"

#include <QDesktopWidget>
#include <QKeyEvent>

#include "qmakewatchermenudialog.h"
#include "qtaboutdialog.h"
#include "qtqmakewatchermaindialog.h"
#include "qthideandshowdialog.h"
#include "testtimer.h"
#include "trace.h"
#include "ui_qtqmakewatchermenudialog.h"
#pragma GCC diagnostic pop

ribi::QtQmakeWatcherMenuDialog::QtQmakeWatcherMenuDialog(QWidget *parent) noexcept :
    QtHideAndShowDialog(parent),
    ui(new Ui::QtQmakeWatcherMenuDialog)
{
  #ifndef NDEBUG
  Test();
  #endif
  ui->setupUi(this);
}

ribi::QtQmakeWatcherMenuDialog::~QtQmakeWatcherMenuDialog() noexcept
{
  delete ui;
}

void ribi::QtQmakeWatcherMenuDialog::keyPressEvent(QKeyEvent * event) noexcept
{
  if (event->key() == Qt::Key_Escape) { close(); return; }
}

void ribi::QtQmakeWatcherMenuDialog::on_button_about_clicked() noexcept
{
  ribi::About a = ribi::QmakeWatcherMenuDialog().GetAbout();
  a.AddLibrary("QtHideAndShowDialog version: " + QtHideAndShowDialog::GetVersion());
  ribi::QtAboutDialog d(a);
  d.setWindowIcon(this->windowIcon());
  d.setStyleSheet(this->styleSheet());
  this->ShowChild(&d);
}

void ribi::QtQmakeWatcherMenuDialog::on_button_quit_clicked() noexcept
{
  close();
}

void ribi::QtQmakeWatcherMenuDialog::on_button_start_clicked() noexcept
{
  QtQmakeWatcherMainDialog d;
  ShowChild(&d);
}

#ifndef NDEBUG
void ribi::QtQmakeWatcherMenuDialog::Test() noexcept
{
  {
    static bool is_tested{false};
    if (is_tested) return;
    is_tested = true;
  }
  QtQmakeWatcherMainDialog();
  const TestTimer test_timer(__func__,__FILE__,1.0);
}
#endif

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml