Skip to content

Commit

Permalink
C++ Qt Hello C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
PyjaErskell committed Jan 10, 2020
1 parent e64cdfa commit d2b4d33
Show file tree
Hide file tree
Showing 10 changed files with 568 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@ECHO OFF

SET SC_KAPA_HM=%ProgramData%\Bichon Frise\Kapa

SET SC_QT_HM=C:\Qt\Qt5.14.0\5.14.0\mingw73_64
SET SC_QM_X_FN=%SC_QT_HM%\bin\qmake.exe
SET QT_PLUGIN_PATH=%SC_QT_HM%\plugins
SET PATH=%SC_QT_HM%\bin;%PATH%

SET SC_PERL_HM=%SC_KAPA_HM%\19.01.22\Vindue\x64\Strawberry\5.28.1\perl
SET SC_PERL_X_FN=%SC_PERL_HM%\bin\perl5.28.1.exe

SET SC_MINGW_HM=C:\Qt\Qt5.14.0\Tools\mingw730_64
SET SC_MAKE_X_FN=%SC_MINGW_HM%\bin\mingw32-make.exe
SET PATH=%SC_MINGW_HM%\bin;%PATH%

PUSHD "%~DP0"
CD "%~DP0"

SET SC_MILO_PN=%CD%
CD "%SC_MILO_PN%\.."
SET SC_OLIM_PN=%CD%

CD "%SC_MILO_PN%\..\..\..\.."
SET SC_PYJA_HM=%CD%
FOR %%F IN (%SC_PYJA_HM%\..) DO SET SC_PYJA_NM=%%~NXF
FOR %%F IN (%SC_PYJA_HM%) DO SET SC_PYJA_VR=%%~NXF

SET SC_ECU_PN=%SC_MILO_PN%\ecu

POPD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

export SC_KAPA_HM="/Library/Application Support/Bichon Frise/Kapa"

export SC_QT_HM=$SC_KAPA_HM/19.01.22/Mushama/x64/Anaconda/5.1.0
export SC_QM_X_FN=$SC_QT_HM/bin/qmake
export QT_PLUGIN_PATH=$SC_QT_HM/plugins
export DYLD_FRAMEWORK_PATH=$SC_QT_HM/lib

export SC_PERL_X_FN=/opt/local/bin/perl5.26.3

export SC_MAKE_X_FN=/usr/bin/make

export SC_MILO_PN=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
export SC_OLIM_PN=$( cd "$SC_MILO_PN/.." && pwd )

export SC_PYJA_HM=$( cd "$SC_MILO_PN/../../../.." && pwd )
export SC_PYJA_NM=$( basename "$( cd "$SC_PYJA_HM/.." && pwd )" )
export SC_PYJA_VR=$( basename "${SC_PYJA_HM}" )

export SC_ECU_PN=$SC_MILO_PN/ecu

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF
SETLOCAL

CALL "%~DP0\SCommon.bat"
"%SC_PERL_X_FN%" -CS -I "%SC_MILO_PN%\src\k-09001-perl" "%SC_MILO_PN%\src\k-01001-compile\SToa.pl" %*
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/SCommon.sh"

"$SC_PERL_X_FN" -CS -I "$SC_MILO_PN/src/k-09001-perl" "$SC_MILO_PN/src/k-01001-compile/SToa.pl" "$@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@ECHO OFF
SETLOCAL

CALL "%~DP0\SCommon.bat"
"%SC_ECU_PN%\SToa" %*
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/SCommon.sh"

"$SC_ECU_PN/SToa" "$@"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//---------------------------------------------------------------
// Global
//---------------------------------------------------------------

#include <QApplication>
#include <QFileInfo>

namespace Global {
QApplication * GTL_QAPP;
const long GC_STD_VR = __cplusplus;
const QString GC_COMPILER_VR = __VERSION__;
const QString GC_QT_VR = QT_VERSION_STR;
QString gf_os_env ( const QString & xru_key ) {
const auto fu_r = std::getenv ( xru_key .toStdString () .c_str () );
if ( fu_r == NULL ) { throw std::runtime_error ( QString ( "Can't find environment variable => %1 !!!" ) .arg (xru_key) .toStdString () ); }
return QString (fu_r);
}
QString gf_bn ( const QString & xru_it ) { return QFileInfo (xru_it) .fileName (); }
}

//---------------------------------------------------------------
// Your Source
//---------------------------------------------------------------

#include <QListWidget>
#include <QMainWindow>
#include <QScreen>
#include <QTimer>
#include <QVBoxLayout>

using namespace Global;

auto sf_hello ( const QString & xru_str, const int x_no ) { return QString ( "Hello %1" ) .arg ( xru_str .repeated (x_no) ); }

template < typename ... TArgs >
auto sf_sum ( TArgs ... x_args ) { return ( 0 + ... + x_args ); }

class WMain : public QMainWindow {
Q_OBJECT
public :
explicit WMain (void) : QMainWindow (Q_NULLPTR) {
__wan_init ();
QTimer::singleShot ( 0, [this] { __wan_body (); } );
}
void wn_say ( const QString & xru_line ) {
__watl_lw -> addItem (xru_line);
__watl_lw -> setCurrentRow ( __watl_lw -> count () - 1 );
}
private :
QListWidget * __watl_lw;
void __wan_init (void) {
setWindowTitle ( QString ( "%1 : %2" ) .arg ( gf_bn ( gf_os_env ("SC_OLIM_PN") ) ) .arg ( gf_bn ( gf_os_env ("SC_MILO_PN") ) ) );
auto ntl_cw = new QWidget ();
auto ntl_lo = new QVBoxLayout ();
__watl_lw = new QListWidget ();
ntl_lo -> addWidget (__watl_lw);
ntl_cw -> setLayout (ntl_lo);
setCentralWidget (ntl_cw);
resize ( 660, 330 );
show ();
raise ();
__wan_center_on_screen ();
}
void __wan_body (void) {
wn_say ( QString ( "C++ standard version => %1" ) .arg (GC_STD_VR) );
wn_say ( QString ( "Compiler version => %1" ) .arg (GC_COMPILER_VR) );
wn_say ( QString ( "Qt version => %1" ) .arg (GC_QT_VR) );
wn_say ( QString ( "C++ Qt hello => %1" ) .arg ( sf_hello ( "CPP-Qt-", 7 ) ) );
wn_say ( QString ( "C++17 sum of numbers => %1" ) .arg ( QString ("%L1") .arg ( sf_sum ( 700000000, 12, 49, 15, 51, 94, 21, 63 ) ) ) );
}
void __wan_center_on_screen (void) {
const auto nu_cp = QGuiApplication::primaryScreen () -> geometry () .center (); // center point
move ( nu_cp .x () - width () / 2, nu_cp .y () - height () / 2 );
}
};

#include "SToa.moc"

void sp_body (void) {
new WMain ();
GTL_QAPP -> exec ();
}

void sp_main (void) {
sp_body ();
}

int main ( int xl_argc, char ** xtl_argv ) {
GTL_QAPP = new QApplication ( xl_argc, xtl_argv );
sp_main ();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#---------------------------------------------------------------
# Global
#---------------------------------------------------------------

use v5.26;
use strict;
use warnings;

use File::Basename;

BEGIN { $ENV {'SC_DUCK_PN'} = dirname __FILE__; }

use i191210::G010;

#---------------------------------------------------------------
# Your Source
#---------------------------------------------------------------

use File::Copy;
use File::Slurp;
use File::Temp;

my $su_tmp_pn = File::Temp -> newdir;

sub sp_body {
GC_LOG -> info ( "Temporary path (${\ GC_TEMP_PN_SYM }) => $su_tmp_pn" );
gp_mp GC_ECU_PN;
gp_ep GC_ECU_PN;
gp_log_header undef, 'Making executable from C++ source ...', undef;

my $pu_src_pn = gf_pj GC_MILO_PN, 'src', 'k-00701-ya';
my $pu_src_fn = gf_pj $pu_src_pn, 'SToa.cpp';
GC_LOG -> info ( "C++ source file => ${\ gf_to_mps $pu_src_fn }" );
my $pu_src_jn = gf_jn $pu_src_fn;
my $pu_pro_fn = gf_pj $su_tmp_pn, "$pu_src_jn.pro";
my @pu_inc_paths = (GC_ECU_PN);
write_file $pu_pro_fn, <<~PASH_EOS;
TARGET = $pu_src_jn
TEMPLATE = app
macx {
CONFIG -= app_bundle
}
QMAKE_CXXFLAGS += -std=gnu++1z
CONFIG += release
QT += core gui widgets network
${\ join ( "\n ", map { "INCLUDEPATH += \"$_\"" } @pu_inc_paths ) }
DEFINES += QT_DEPRECATED_WARNINGS
VPATH += "$pu_src_pn"
SOURCES += ${\ gf_bn $pu_src_fn }
PASH_EOS
gp_log_array undef, "Generating Qt pro file => ${\ gf_to_tps $pu_pro_fn, $su_tmp_pn }", read_file $pu_pro_fn;

my $pu_qm_x_fn = gf_os_env 'SC_QM_X_FN';
GC_LOG -> info ( "Qt qmake executable file => ${\ gf_to_khs $pu_qm_x_fn }" );
my $pu_mk_fn = gf_pj $su_tmp_pn, 'Makefile';
GC_LOG -> info ( "Generating ${\ gf_to_tps $pu_mk_fn, $su_tmp_pn } ..." );
my $pu_qm_rxc = gf_rxc [ $pu_qm_x_fn, '-o', $pu_mk_fn, $pu_pro_fn ];
gp_log_array undef, undef, @{$pu_qm_rxc->ru_soe};
die 'Cannot generate Makefile ... !!!' if $pu_qm_rxc->ru_ce >> 8;

my $pu_make_x_fn = gf_os_env 'SC_MAKE_X_FN';
GC_LOG -> info ( "Make executable file => ${\ gf_to_khs $pu_make_x_fn }" );
GC_LOG -> info ( "Compiling C++ ${\ gf_to_mps $pu_src_fn } ..." );
my $pu_mk_rxc = gf_rxc [ $pu_make_x_fn, '-C', $su_tmp_pn ];
gp_log_array undef, undef, @{$pu_mk_rxc->ru_soe};
die 'Cannot compile ... !!!' if $pu_mk_rxc->ru_ce >> 8;

my $pv_x_bn = $pu_src_jn;
$pv_x_bn .= '.exe' if $^O eq 'MSWin32';
my $pu_x_fn = gf_pj $su_tmp_pn, $pv_x_bn;
GC_LOG -> info ( "Moving generated executable ${\ gf_to_tps $pu_x_fn, $su_tmp_pn } to ${\ gf_to_mps GC_ECU_PN } ..." );
die 'Cannot move ... !!!' unless move $pu_x_fn, GC_ECU_PN;
}

sub sp_main {
gp_run \&sp_body;
}

sp_main;
Loading

0 comments on commit d2b4d33

Please sign in to comment.