Skip to content

Commit

Permalink
Merge pull request #47 from oblivioncth/dev
Browse files Browse the repository at this point in the history
Merge to master for v0.2.2
  • Loading branch information
oblivioncth authored Dec 17, 2023
2 parents 048f984 + 489a03e commit 39610d4
Show file tree
Hide file tree
Showing 30 changed files with 1,037 additions and 387 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/build-starpp-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
compiler: [gcc, clang]
compiler: [clang]
lib_linkage: [shared, static]
include:
- os: ubuntu-20.04
compiler: gcc
c_comp: gcc-10
cxx_comp: g++-10
qt_comp: clang12
- os: ubuntu-20.04
compiler: clang
c_comp: clang-12
Expand All @@ -36,6 +31,13 @@ jobs:
c_comp: gcc-12
cxx_comp: g++-12
qt_comp: clang14
lib_linkage: shared
- os: ubuntu-22.04
compiler: gcc
c_comp: gcc-12
cxx_comp: g++-12
qt_comp: clang14
lib_linkage: static
- os: ubuntu-22.04
compiler: clang
c_comp: clang-14
Expand All @@ -58,16 +60,25 @@ jobs:
- name: Install Qt (custom build)
uses: oblivioncth/actions/general/install-and-cache-qt-from-ffynnon@dev
with:
version: 6.4.2
version: 6.6.0
os: linux
compiler: ${{ matrix.qt_comp }}
linkage: ${{ matrix.lib_linkage }}
path: ${{ env.qt_install_dir }}
credentials: ${{ secrets.qt_ffynnon_cred }}
- name: Update package index
run: sudo apt-get update
- name: WORKAROUND FOR https://github.com/actions/runner-images/issues/8659
if: matrix.os == 'ubuntu-22.04'
run: |
echo "TEMPORARY WORKAROUND FOR GITHUB RUNNER BUG #8659\n\nRemoving GCC 13 as it breaks Clang14"
sudo rm -f /etc/apt/sources.list.d/ubuntu-toolchain-r-ubuntu-test-jammy.list
sudo apt-get update
sudo apt-get install -y --allow-downgrades libc6=2.35-0ubuntu3.5 libc6-dev=2.35-0ubuntu3.5 libstdc++6=12.3.0-1ubuntu1~22.04 libgcc-s1=12.3.0-1ubuntu1~22.04
- name: Install Doxygen
uses: oblivioncth/actions/ubuntu/install-doxygen-from-sourceforge@dev
with:
version: 1.9.4
version: 1.9.8
- name: Install Graphviz
run: sudo apt-get install graphviz
- name: Install Ninja
Expand All @@ -78,6 +89,9 @@ jobs:
run: sudo apt-get install libxkbcommon-x11-dev libxcb-*-dev
- name: Install OpenGL lib
run: sudo apt-get install libglu1-mesa-dev # TODO: See if this can be avoided, for some reason qhelpgenerator needs this, maybe its because it was available during compilation
- name: Install EGL [22.04]
if: matrix.os == 'ubuntu-22.04'
run: sudo apt-get install libegl1-mesa-dev
- name: Checkout STARpp
uses: actions/checkout@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-starpp-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install Qt (custom build)
uses: oblivioncth/actions/general/install-and-cache-qt-from-ffynnon@dev
with:
version: 6.4.2
version: 6.6.0
os: windows
compiler: msvc2022
linkage: ${{ matrix.lib_linkage }}
Expand All @@ -52,7 +52,7 @@ jobs:
- name: Install Doxygen
uses: oblivioncth/actions/general/cache-and-install-doxygen-from-ffynnon@dev
with:
version: 1.9.4
version: 1.9.8
os: windows
credentials: ${{ secrets.qt_ffynnon_cred }}
- name: Install Graphviz
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#================= Project Setup ==========================

# CMake
cmake_minimum_required(VERSION 3.23.0...3.25.0)
cmake_minimum_required(VERSION 3.23.0...3.26.0)

# Project
# NOTE: DON'T USE TRAILING ZEROS IN VERSIONS
project(STARpp
VERSION 0.2.1
VERSION 0.2.2
LANGUAGES CXX
DESCRIPTION "C++ implementation of STAR voting"
)

# Get helper scripts
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchOBCMake.cmake)
fetch_ob_cmake("v0.3")
fetch_ob_cmake("v0.3.4")

# Initialize project according to standard rules
include(OB/Project)
Expand Down Expand Up @@ -65,14 +65,14 @@ set(STARPP_QX_COMPONENTS

include(OB/FetchQx)
ob_fetch_qx(
REF "v0.5"
REF "v0.5.6"
COMPONENTS
${STARPP_QX_COMPONENTS}
)

# Fetch Neargye's Magic Enum
include(OB/FetchMagicEnum)
ob_fetch_magicenum("v0.8.0")
ob_fetch_magicenum("v0.9.5")

# Process Targets
set(LIB_TARGET_NAME ${PROJECT_NAMESPACE_LC}_base)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Using no calculator options will result in the application following the recomme

## Pre-built Releases/Artifacts

Releases and some workflows currently provide builds of libsquish in various combinations of platforms and compilers. View the repository [Actions](https://github.com/oblivioncth/STARpp/actions) or [Releases](https://github.com/oblivioncth/STARpp/releases) to see examples
Releases and some workflows currently provide builds of STARpp in various combinations of platforms and compilers. View the repository [Actions](https://github.com/oblivioncth/STARpp/actions) or [Releases](https://github.com/oblivioncth/STARpp/releases) to see examples

### Details
The source for this project is managed by a sensible CMake configuration that allows for straightforward compilation and consumption of its target(s), either as a sub-project or as an imported package. All required dependencies except for Qt6 and Doxygen are automatically acquired via CMake's FetchContent mechanism.
Expand Down
3 changes: 1 addition & 2 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ ob_add_standard_executable(${APP_TARGET_NAME}
SOURCE
core.h
core.cpp
errorcode.h
referenceelectionconfig.h
resultspresenter.h
resultspresenter.cpp
Expand All @@ -38,5 +37,5 @@ ob_add_cpp_vars(${APP_TARGET_NAME}
VARS
VERSION_STR "\"${PROJECT_VERSION}\""
SHORT_NAME "\"${PROJECT_NAME}\""
APP_NAME "\"${APP_NAME}\""
APP_NAME "\"${PROJECT_NAME_FORMAL}\""
)
69 changes: 49 additions & 20 deletions app/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,30 @@
// Macros
#define ENUM_NAME(eenum) QString(magic_enum::enum_name(eenum).data())

//===============================================================================================================
// CoreError
//===============================================================================================================

//-Constructor-------------------------------------------------------------
//Private:
CoreError::CoreError(Type t, const QString& s, Qx::Severity sv) :
mType(t),
mSpecific(s),
mSeverity(sv)
{}

//-Instance Functions-------------------------------------------------------------
//Public:
bool CoreError::isValid() const { return mType != NoError; }
QString CoreError::specific() const { return mSpecific; }
CoreError::Type CoreError::type() const { return mType; }

//Private:
Qx::Severity CoreError::deriveSeverity() const { return mSeverity; }
quint32 CoreError::deriveValue() const { return mType; }
QString CoreError::derivePrimary() const { return ERR_STRINGS.value(mType); }
QString CoreError::deriveSecondary() const { return mSpecific; }

//===============================================================================================================
// CORE
//===============================================================================================================
Expand All @@ -31,13 +55,13 @@ Core::Core(QCoreApplication* app) :

//-Instance Functions-------------------------------------------------------------
//Private:
void Core::handleLogError(Qx::IoOpReport error)
void Core::handleLogError(const Qx::IoOpReport& error)
{
// Note error
mLogErrorOccurred = true;

// Post error
static Qx::GenericError errorMsg(Qx::GenericError::Warning, ERR_LOG_ERROR, error.outcomeInfo());
static CoreError errorMsg(CoreError::LogError, error.outcomeInfo(), Qx::Warning);
Qx::cout << errorMsg;
}

Expand Down Expand Up @@ -75,18 +99,18 @@ void Core::showVersion()
postMessage(CL_VERSION_MESSAGE);
}

void Core::logElectionData(const ReferenceElectionConfig data)
void Core::logElectionData(const ReferenceElectionConfig& data)
{
logEvent(NAME, LOG_EVENT_ELECTION_DATA_PROVIDED.arg(data.bbPath, data.ccPath));
}

//Public:
ErrorCode Core::initialize()
Qx::Error Core::initialize()
{
// Open log
Qx::IoOpReport logOpen = mLogger.openLog();
if(logOpen.isFailure())
postError(NAME, Qx::GenericError(Qx::GenericError::Warning, logOpen.outcome(), logOpen.outcomeInfo()));
postError(NAME, Qx::Error(logOpen).setSeverity(Qx::Warning));

// Log initialization step
logEvent(NAME, LOG_EVENT_INIT);
Expand All @@ -100,9 +124,10 @@ ErrorCode Core::initialize()
// Parse
if(!clParser.parse(mArguments))
{
postError(NAME, Qx::GenericError(Qx::GenericError::Error, LOG_ERR_INVALID_ARGS, clParser.errorText()));
CoreError err(CoreError::InvalidArgs, clParser.errorText());
postError(NAME, err);
showHelp();
return ErrorCode::INVALID_ARGS;
return err;
}

// Handle arguments
Expand Down Expand Up @@ -141,8 +166,9 @@ ErrorCode Core::initialize()
}
else
{
postError(NAME, Qx::GenericError(Qx::GenericError::Error, LOG_ERR_INVALID_CALC_OPTION, optStr));
return ErrorCode::INVALID_CALC_OPT;
CoreError err(CoreError::InvalidCalcOption, optStr);
postError(NAME, err);
return err;
}
}

Expand All @@ -160,12 +186,13 @@ ErrorCode Core::initialize()
}
else
{
logError(NAME, Qx::GenericError(Qx::GenericError::Error, LOG_ERR_INVALID_ARGS, ERR_MISSING_REF_PATHS));
return ErrorCode::INVALID_ARGS;
CoreError err(CoreError::InvalidArgs, ERR_MISSING_REF_PATHS);
postError(NAME, err);
return err;
}

// Return success
return ErrorCode::NO_ERR;
return CoreError();
}

bool Core::hasActionableArguments() const { return mRefElectionCfg.has_value(); }
Expand All @@ -181,7 +208,7 @@ bool Core::isMinimalPresentation() const { return mMinimal; }

//-Signals & Slots------------------------------------------------------------------------------------------------------------
//Public slots:
void Core::logError(QString src, Qx::GenericError error)
void Core::logError(const QString& src, const Qx::Error& error)
{
if(!mLogErrorOccurred)
{
Expand All @@ -191,7 +218,7 @@ void Core::logError(QString src, Qx::GenericError error)
}
}

void Core::logEvent(QString src, QString event)
void Core::logEvent(const QString& src, const QString& event)
{
if(!mLogErrorOccurred)
{
Expand All @@ -201,27 +228,29 @@ void Core::logEvent(QString src, QString event)
}
}

void Core::logCalculatorDetail(QString detail) { logEvent("Calculator", detail); }
void Core::logCalculatorDetail(const QString& detail) { logEvent("Calculator", detail); }

ErrorCode Core::logFinish(ErrorCode exitCode)
ErrorCode Core::logFinish(const Qx::Error& errorState)
{
ErrorCode code = errorState.typeCode();

if(!mLogErrorOccurred)
{
Qx::IoOpReport lr = mLogger.finish(exitCode);
Qx::IoOpReport lr = mLogger.finish(code);
if(lr.isFailure())
handleLogError(lr);
}

return exitCode;
return code;
}

void Core::postError(QString src, Qx::GenericError error)
void Core::postError(const QString& src, const Qx::Error& error)
{
Qx::cout << error << Qt::endl;
logError(src, error);
}

void Core::postMessage(QString msg)
void Core::postMessage(const QString& msg)
{
Qx::cout << msg << Qt::endl;
}
Loading

0 comments on commit 39610d4

Please sign in to comment.