Even more c make (#195)
* use Qt 6.3.1 * Let Cmake Set releaseInfo, remove unneeded qt5 if check Co-authored-by: Chris Rizzitello <crizzitello@ics.com>main
parent
c85f4ca237
commit
e28a6f5190
|
@ -8,7 +8,7 @@ on:
|
|||
pull_request:
|
||||
branches: [ main ]
|
||||
env:
|
||||
QT_VERSION: 6.3.0
|
||||
QT_VERSION: 6.3.1
|
||||
jobs:
|
||||
# This is a super hacky way to get this into a place that can actually be
|
||||
# used by downstream jobs because YAML values don't allow shell
|
||||
|
|
|
@ -30,26 +30,31 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.git)
|
|||
set(CMAKE_PROJECT_VERSION_PATCH ${PATCH})
|
||||
set(CMAKE_PROJECT_VERSION_TWEAK ${TWEAK})
|
||||
set(CMAKE_PROJECT_VERSION "${MAJOR}.${MINOR}.${PATCH}.${TWEAK}")
|
||||
add_definitions(-DVERSION_TAG="v${MAJOR}.${MINOR}.${PATCH}")
|
||||
set(VERSION_TAG "v${MAJOR}.${MINOR}.${PATCH}")
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE GITHASH
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
add_definitions(-DCOMMIT_HASH="${GITHASH}")
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${GIT_EXECUTABLE} remote get-url origin
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE GITORIGIN
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
add_definitions(-DSOURCE_CONTROL_REPO="${GITORIGIN}")
|
||||
string(REPLACE "https://github.com/" ":" GITORIGIN ${GITORIGIN})
|
||||
string(REPLACE "git@github.com" "" GITORIGIN ${GITORIGIN})
|
||||
string(REGEX MATCH [[:[A-Za-z0-9]+]] REPO_OWNER ${GITORIGIN})
|
||||
string(REPLACE ":" "" REPO_OWNER ${REPO_OWNER})
|
||||
string(REGEX MATCH [[/[A-Za-z0-9]+]] REPO_NAME ${GITORIGIN})
|
||||
string(REPLACE "/" "" REPO_NAME ${REPO_NAME})
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DCOMMIT_HASH="")
|
||||
add_definitions(-DVERSION_TAG="")
|
||||
add_definitions(-DSOURCE_CONTROL_REPO="")
|
||||
set(COMMIT_HASH "")
|
||||
set(REPO_NAME "ashirt")
|
||||
set(REPO_OWNER "theparanoids")
|
||||
set(VERSION_TAG "v0.0.0")
|
||||
endif()
|
||||
message(STATUS "VERSION: ${CMAKE_PROJECT_VERSION}")
|
||||
|
||||
|
|
|
@ -85,15 +85,8 @@ elseif(UNIX AND NOT APPLE)
|
|||
install(TARGETS ashirt BUNDLE DESTINATION bin)
|
||||
elseif(WIN32)
|
||||
install(TARGETS ashirt RUNTIME DESTINATION .)
|
||||
if(${QT_DEFAULT_MAJOR_VERSION} MATCHES "5")
|
||||
add_custom_command(
|
||||
TARGET ashirt POST_BUILD
|
||||
COMMAND ${PLATFORMDEPLOYQT} $<TARGET_FILE:ashirt> --no-compiler-runtime --no-system-d3d-compiler --no-quick-import --no-translations --no-angle --no-webkit2 --no-opengl-sw --dir ${CMAKE_BINARY_DIR}/qtDeploy --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ashirt POST_BUILD
|
||||
COMMAND ${PLATFORMDEPLOYQT} $<TARGET_FILE:ashirt> --no-compiler-runtime --no-system-d3d-compiler --no-quick-import --no-translations --no-opengl-sw --dir ${CMAKE_BINARY_DIR}/qtDeploy --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins
|
||||
)
|
||||
endif()
|
||||
add_custom_command(
|
||||
TARGET ashirt POST_BUILD
|
||||
COMMAND ${PLATFORMDEPLOYQT} $<TARGET_FILE:ashirt> --no-compiler-runtime --no-system-d3d-compiler --no-quick-import --no-translations --no-opengl-sw --dir ${CMAKE_BINARY_DIR}/qtDeploy --plugindir ${CMAKE_BINARY_DIR}/qtDeploy/plugins
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <QLabel>
|
||||
#include <QTextBrowser>
|
||||
|
||||
#include "helpers/constants.h"
|
||||
#include "helpers/netman.h"
|
||||
|
||||
Credits::Credits(QWidget* parent)
|
||||
|
@ -43,7 +42,7 @@ Credits::Credits(QWidget* parent)
|
|||
void Credits::updateRelease() {
|
||||
if (updateDigest.hasUpgrade()) {
|
||||
updateLabel->setVisible(true);
|
||||
updateLabel->setText(baseUpdateText.arg(Constants::releasePageUrl));
|
||||
updateLabel->setText(baseUpdateText.arg(ReleaseInfo::releasePageUrl));
|
||||
}
|
||||
else {
|
||||
updateLabel->setVisible(false);
|
||||
|
@ -55,7 +54,7 @@ void Credits::onReleasesUpdate(bool success, QList<dto::GithubRelease> releases)
|
|||
if (!success)
|
||||
return;
|
||||
|
||||
auto digest = dto::ReleaseDigest::fromReleases(Constants::releaseTag(), releases);
|
||||
auto digest = dto::ReleaseDigest::fromReleases(ReleaseInfo::version, releases);
|
||||
updateDigest = digest;
|
||||
updateRelease();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "ashirtdialog/ashirtdialog.h"
|
||||
#include "dtos/github_release.h"
|
||||
#include "helpers/constants.h"
|
||||
#include "releaseinfo.h" //Part of Helpers Generated by Cmake
|
||||
|
||||
class QLabel;
|
||||
|
||||
|
@ -47,12 +47,12 @@ class Credits : public AShirtDialog {
|
|||
"Licensed under the terms of %4\n\n"
|
||||
"A short user guide can be found %5\n\n"
|
||||
"Report issues %6\n\n")
|
||||
.arg(Constants::releaseTag()
|
||||
, Constants::commitHash
|
||||
.arg(ReleaseInfo::version
|
||||
, ReleaseInfo::commitHash
|
||||
, QStringLiteral("2020 - %1").arg(QDateTime::currentDateTime().date().year())
|
||||
, hyperlinkMd.arg(QStringLiteral("MIT"), QStringLiteral("https://github.com/theparanoids/ashirt/blob/master/LICENSE"))
|
||||
, hyperlinkMd.arg(QStringLiteral("here"), Constants::userGuideUrl)
|
||||
, hyperlinkMd.arg(QStringLiteral("here"), Constants::reportAnIssueUrl));
|
||||
, hyperlinkMd.arg(QStringLiteral("MIT"), ReleaseInfo::licenseUrl)
|
||||
, hyperlinkMd.arg(QStringLiteral("here"), ReleaseInfo::userGuideUrl)
|
||||
, hyperlinkMd.arg(QStringLiteral("here"), ReleaseInfo::reportAnIssueUrl));
|
||||
|
||||
static QString attributionMarkdown() {
|
||||
const QStringList attribs = attribBLOB.split(attribBLOB_splitChar);
|
||||
|
|
|
@ -5,6 +5,8 @@ if(APPLE)
|
|||
find_library(CARBON_LIBRARY Carbon)
|
||||
endif()
|
||||
|
||||
configure_file(releaseinfo.h.in releaseinfo.h @ONLY)
|
||||
|
||||
add_library (HELPERS STATIC
|
||||
constants.h
|
||||
file_helpers.h
|
||||
|
@ -21,6 +23,7 @@ add_library (HELPERS STATIC
|
|||
hotkeys/hotkeymap.h
|
||||
hotkeys/uglobalhotkeys.cpp hotkeys/uglobalhotkeys.h
|
||||
hotkeys/ukeysequence.cpp hotkeys/ukeysequence.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/releaseinfo.h
|
||||
)
|
||||
|
||||
add_library(ASHIRT::HELPERS ALIAS HELPERS)
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
|
||||
class Constants {
|
||||
public:
|
||||
inline static const auto dbLocation = QStringLiteral("%1/evidence.sqlite").arg(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
||||
inline static const auto defaultEvidenceRepo = QStringLiteral("%1/evidence").arg(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
||||
inline static const auto commitHash = QStringLiteral("%1").arg(COMMIT_HASH);
|
||||
inline static const auto userGuideUrl = QStringLiteral("https://www.github.com/theparanoids/ashirt/blob/master/README.md");
|
||||
inline static const auto reportAnIssueUrl = QStringLiteral("https://www.github.com/theparanoids/ashirt/issues");
|
||||
inline static const auto releasePageUrl = QStringLiteral("https://github.com/theparanoids/ashirt/releases");
|
||||
/// defaultDbName returns a string storing the "name" of the database for Qt identification
|
||||
/// purposes. This _value_ should not be reused for other db connections.
|
||||
inline static const auto defaultDbName = QStringLiteral("evidence");
|
||||
|
@ -21,44 +16,4 @@ class Constants {
|
|||
inline static const auto configLocation = QStringLiteral("%1/ashirt/config.json").arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
|
||||
inline static const auto codeFont = QStringLiteral("source code pro");
|
||||
#endif
|
||||
|
||||
static QString releaseOwner() {
|
||||
return parseRepo(RepoField::owner);
|
||||
}
|
||||
|
||||
static QString releaseRepo() {
|
||||
return parseRepo(RepoField::repo);
|
||||
}
|
||||
|
||||
static QString releaseTag() {
|
||||
static QString parsedReleaseTag;
|
||||
if (parsedReleaseTag.isEmpty()) {
|
||||
QRegularExpression compiledTagRegex(QStringLiteral("(?:tags/)?v(.*)"));
|
||||
auto rawVersion = QStringLiteral("%1").arg(VERSION_TAG);
|
||||
QRegularExpressionMatch match = compiledTagRegex.match(rawVersion);
|
||||
parsedReleaseTag = match.hasMatch() ? QStringLiteral("v") + match.captured(1) : QStringLiteral("v0.0.0-unversioned");
|
||||
}
|
||||
return parsedReleaseTag;
|
||||
}
|
||||
|
||||
private:
|
||||
enum RepoField {
|
||||
owner = 0,
|
||||
repo = 1,
|
||||
};
|
||||
|
||||
static QString parseRepo(RepoField field) {
|
||||
static QString parsedRepo;
|
||||
static QString parsedOwner;
|
||||
if (parsedRepo.isEmpty()) {
|
||||
auto rawRepo = QStringLiteral("%1").arg(SOURCE_CONTROL_REPO);
|
||||
QRegularExpression ownerRegex(QStringLiteral("^([^/]+)/(.*)"));
|
||||
QRegularExpressionMatch match = ownerRegex.match(rawRepo);
|
||||
// Note that the specific values for the error cases below don't matter
|
||||
// They are set to avoid rerunning the parsing (since these values won't change mid-run)
|
||||
parsedOwner = match.hasMatch() ? match.captured(1) : QString();
|
||||
parsedRepo = match.hasMatch() ? match.captured(2) : QString();
|
||||
}
|
||||
return field == RepoField::owner ? parsedOwner : parsedRepo;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "dtos/operation.h"
|
||||
#include "dtos/tag.h"
|
||||
#include "dtos/github_release.h"
|
||||
#include "helpers/constants.h"
|
||||
#include <helpers/multipartparser.h>
|
||||
#include "helpers/stopreply.h"
|
||||
#include "models/evidence.h"
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
class ReleaseInfo {
|
||||
inline static const auto _urlBase = QStringLiteral("https://www.github.com/theparanoids/ashirt/");
|
||||
public:
|
||||
inline static const auto commitHash = QStringLiteral("@COMMIT_HASH@");
|
||||
inline static const auto owner = QStringLiteral("@REPO_OWNER@");
|
||||
inline static const auto repo = QStringLiteral("@REPO_NAME@");
|
||||
inline static const auto licenseUrl = QStringLiteral("blob/main/LICENSE").prepend(_urlBase);
|
||||
inline static const auto userGuideUrl = QStringLiteral("blob/main/README.md").prepend(_urlBase);
|
||||
inline static const auto reportAnIssueUrl = QStringLiteral("issues").prepend(_urlBase);
|
||||
inline static const auto releasePageUrl = QStringLiteral("releases").prepend(_urlBase);
|
||||
inline static const auto version = QStringLiteral("@VERSION_TAG@");
|
||||
};
|
|
@ -22,7 +22,7 @@
|
|||
#include "forms/getinfo/getinfo.h"
|
||||
#include "helpers/netman.h"
|
||||
#include "helpers/screenshot.h"
|
||||
#include "helpers/constants.h"
|
||||
#include "helpers/releaseinfo.h"
|
||||
#include "helpers/system_helpers.h"
|
||||
#include "hotkeymanager.h"
|
||||
#include "models/codeblock.h"
|
||||
|
@ -300,7 +300,7 @@ void TrayManager::onOperationListUpdated(bool success,
|
|||
}
|
||||
|
||||
void TrayManager::checkForUpdate() {
|
||||
NetMan::checkForNewRelease(Constants::releaseOwner(), Constants::releaseRepo());
|
||||
NetMan::checkForNewRelease(ReleaseInfo::owner, ReleaseInfo::repo);
|
||||
}
|
||||
|
||||
void TrayManager::onReleaseCheck(bool success, const QList<dto::GithubRelease>& releases) {
|
||||
|
@ -308,7 +308,7 @@ void TrayManager::onReleaseCheck(bool success, const QList<dto::GithubRelease>&
|
|||
return; // doesn't matter if this fails -- another request will be made later.
|
||||
}
|
||||
|
||||
auto digest = dto::ReleaseDigest::fromReleases(Constants::releaseTag(), releases);
|
||||
auto digest = dto::ReleaseDigest::fromReleases(ReleaseInfo::version, releases);
|
||||
|
||||
if (digest.hasUpgrade()) {
|
||||
setTrayMessage(UPGRADE, tr("A new version is available!"), tr("Click for more info"));
|
||||
|
@ -342,7 +342,7 @@ QIcon TrayManager::getTrayIcon()
|
|||
void TrayManager::onTrayMessageClicked() {
|
||||
switch(currentTrayMessage) {
|
||||
case UPGRADE:
|
||||
QDesktopServices::openUrl(Constants::releasePageUrl);
|
||||
QDesktopServices::openUrl(ReleaseInfo::releasePageUrl);
|
||||
break;
|
||||
case OPEN_PATH:
|
||||
QDesktopServices::openUrl(openServicesPath);
|
||||
|
|
Loading…
Reference in New Issue