Refine self update build options

This commit is contained in:
woblight
2024-08-12 21:08:22 +02:00
parent 3bf728ffff
commit ac8fc70a4e
6 changed files with 51 additions and 21 deletions
+3 -2
View File
@@ -9,6 +9,7 @@ winepwd:=$(shell $(wine) winepath -w $(pwd))
WINEPREFIX=WINEPREFIX="$(pwd)/wine"
WINEPATH=WINEPATH='C:\Program Files (x86)\CMake\bin;$(shell $(winepath) -w "$(pwd)/mingw64/bin");$(shell $(winepath) -w "$(pwd)/Qt/6.7.2/mingw_64/bin")' QTDIR="Z:$(pwd)/Qt/6.7.2/mingw_64/"
branch:=$(CI_COMMIT_BRANCH)
gam_opts:=-DDGitAddonsManager_SELF_UPDATE=ON -DGitAddonsManager_GIT_DESCRIBE="$(shell git describe --tags --long)" -DGitAddonsManager_BUILD_NAME=$(CI_JOB_NAME) -DGitAddonsManager_BRANCH_NAME=$(branch)
ifeq ($(branch),)
branch:=$(CI_DEFAULT_BRANCH)
endif
@@ -19,7 +20,7 @@ finalize:
cd GitAddonsManager && echo "# DO NOT EDIT" > .installedFiles && find ! -path . >> .installedFiles
build:
mkdir -p build && cd build && cmake ../ -DGitAddonsManager_BUILD_NAME=$(CI_JOB_NAME) -DGitAddonsManager_BRANCH_NAME=$(branch) -G"Ninja" -DCMAKE_BUILD_TYPE=Release --install-prefix="$(pwd)/release" && ninja && ninja install
mkdir -p build && cd build && cmake ../ $(gam_opts) -G"Ninja" -DCMAKE_BUILD_TYPE=Release --install-prefix="$(pwd)/release" && ninja && ninja install
linuxdeploy: build
mkdir GitAddonsManager
@@ -111,7 +112,7 @@ quazip/release/bin/libquazip1-qt6.dll: quazip/CMakeLists.txt
$(wine) mingw32-make -C quazip/build install
build_win64/GitAddonsManager.exe: Qt libgit2-0.27.2/release/bin/libgit2.dll zlib/build/libzlib.dll quazip/release/bin/libquazip1-qt6.dll
mkdir -p build_win64 && cd build_win64 && $(wine) cmake ../ -DGitAddonsManager_GIT_DESCRIBE="$(shell git describe --tags --long)" -DGitAddonsManager_BUILD_NAME=$(CI_JOB_NAME) -DGitAddonsManager_BRANCH_NAME=$(branch) -G"MinGW Makefiles" -DQuaZip-Qt6_DIR=$(pwd)/quazip/release/lib/cmake/QuaZip-Qt6-1.4/ -DLIBGIT2_LIBRARY=$(pwd)/libgit2-0.27.2/release/bin/libgit2.dll -DLIBGIT2_INCLUDE_DIR=$(pwd)/libgit2-0.27.2/release/include -DZLIB_LIBRARY=$(pwd)/zlib/build/libzlib.dll.a -DZLIB_INCLUDE_DIR=$(pwd)/zlib -DCMAKE_BUILD_TYPE=Release --install-prefix="$(winepwd)/release"
mkdir -p build_win64 && cd build_win64 && $(wine) cmake ../ $(gam_opts) -G"MinGW Makefiles" -DQuaZip-Qt6_DIR=$(pwd)/quazip/release/lib/cmake/QuaZip-Qt6-1.4/ -DLIBGIT2_LIBRARY=$(pwd)/libgit2-0.27.2/release/bin/libgit2.dll -DLIBGIT2_INCLUDE_DIR=$(pwd)/libgit2-0.27.2/release/include -DZLIB_LIBRARY=$(pwd)/zlib/build/libzlib.dll.a -DZLIB_INCLUDE_DIR=$(pwd)/zlib -DCMAKE_BUILD_TYPE=Release --install-prefix="$(winepwd)/release"
$(wine) mingw32-make -C build_win64 -j $(shell nproc)
$(wine) mingw32-make -C build_win64 install
+11 -4
View File
@@ -55,6 +55,8 @@ set(${PROJECT_NAME}_BUILD_NAME "" CACHE STRING "name of the build pipeline for s
set(${PROJECT_NAME}_BRANCH_NAME "" CACHE STRING "name of the branch for self updates")
option(${PROJECT_NAME}_SELF_UPDATE "Enable the self-update feature")
qt_add_executable(GitAddonsManager
addon.h control.h utils.h
main.cpp addon.cpp control.cpp
@@ -70,11 +72,16 @@ add_compile_definitions(
GAM_EXEC="GitAddonsManager${CMAKE_EXECUTABLE_SUFFIX}"
)
if (NOT ${PROJECT_NAME}_BUILD_NAME STREQUAL "")
add_compile_definitions(GAM_BUILD_NAME="${${PROJECT_NAME}_BUILD_NAME}")
endif()
if (NOT ${PROJECT_NAME}_BRANCH_NAME STREQUAL "")
if (${PROJECT_NAME}_SELF_UPDATE)
if (${PROJECT_NAME}_BUILD_NAME STREQUAL "")
message(FATAL_ERROR "${PROJECT_NAME}_SELF_UPDATE is enabled but ${PROJECT_NAME}_BUILD_NAME is not set" )
endif()
if (${PROJECT_NAME}_BRANCH_NAME STREQUAL "")
message(FATAL_ERROR "${PROJECT_NAME}_SELF_UPDATE is enabled but ${PROJECT_NAME}_BRANCH_NAME is not set" )
endif()
add_compile_definitions(GAM_BRANCH_NAME="${${PROJECT_NAME}_BRANCH_NAME}")
add_compile_definitions(GAM_BUILD_NAME="${${PROJECT_NAME}_BUILD_NAME}")
add_compile_definitions(GAM_SELF_UPDATE)
endif()
target_link_libraries(GitAddonsManager PUBLIC Qt6::Core)
+16 -2
View File
@@ -520,7 +520,7 @@ void Control::setAvailableStyles(QStringList availableStyles)
void Control::checkForUpdates()
{
#if defined(GAM_BUILD_NAME) && defined(GAM_BRANCH_NAME)
#ifdef GAM_SELF_UPDATE
QNetworkRequest req(QUrl(QString("https://gitlab.com/woblight/GitAddonsManager/-/jobs/artifacts/%1/download?job=%2").arg(GAM_BRANCH_NAME).arg(GAM_BUILD_NAME)));
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
connect(nam, &QNetworkAccessManager::finished, [](auto reply){
@@ -542,7 +542,7 @@ void Control::checkForUpdates()
void Control::downloadUpdate()
{
#if defined(GAM_BUILD_NAME) && defined(GAM_BRANCH_NAME)
#ifdef GAM_SELF_UPDATE
QFile *zip = new QFile(QApplication::applicationDirPath() + "/GitAddonsManager.zip");
if (!zip->open(QFile::WriteOnly)) {
setUpdateStatus(UpdateStatus::UpdateError);
@@ -689,3 +689,17 @@ void Control::exportAddonList(const QUrl &path)
out << addon->path() << " " << addon->name() << " " << remotes.join(" ") << " " << addon->currentBranch() << Qt::endl;
}
}
QString Control::version() const
{
return m_version;
}
bool Control::selfUpdates() const
{
#ifdef GAM_SELF_UPDATE
return true;
#else
return false;
#endif
}
+19
View File
@@ -55,6 +55,8 @@ class Control : public QObject
QList<Addon *> m_addons;
public:
Q_PROPERTY(QString version READ version CONSTANT)
Q_PROPERTY(bool selfUpdates READ selfUpdates CONSTANT)
Q_PROPERTY(QList<Addon *> addons READ addons WRITE setAddons NOTIFY addonsChanged)
Q_PROPERTY(int progress READ progress WRITE setProgress NOTIFY progressChanged)
Q_PROPERTY(int total READ total WRITE setTotal NOTIFY totalChanged)
@@ -132,6 +134,10 @@ public:
Q_INVOKABLE void exportAddonList(const QUrl &path);
QString version() const;
bool selfUpdates() const;
private:
static Control *m_instance;
explicit Control(QObject *parent = nullptr);
@@ -161,6 +167,19 @@ private:
bool m_useRepoDirectory;
QString m_version = QString("%1 (%2 %3)").arg(GIT_DESCRIBE)
#ifdef GAM_BUILD_NAME
.arg(GAM_BUILD_NAME)
#else
.arg(QSysInfo::productType())
#endif
#ifdef GAM_BANCH_NAME
.arg(GAM_BANCH_NAME)
#else
.arg(QSysInfo::buildCpuArchitecture())
#endif
;
signals:
void addonsChanged(QList<Addon *> addons);
-12
View File
@@ -71,18 +71,6 @@ int main(int argc, char *argv[])
} else {
Control::instance()->init();
qmlRegisterUncreatableType<Addon>("GitAddonsManager.engine",1,0,"Addon","");
engine.rootContext()->setContextProperty("gitVersion", QString("%1 (%2 %3)").arg(GIT_DESCRIBE)
#ifdef GAM_BUILD_NAME
.arg(GAM_BUILD_NAME)
#else
.arg(QSysInfo::productType())
#endif
#ifdef GAM_BANCH_NAME
.arg(GAM_BANCH_NAME)
#else
.arg(QSysInfo::buildCpuArchitecture())
#endif
);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
}
if (engine.rootObjects().isEmpty())
+2 -1
View File
@@ -154,12 +154,13 @@ ApplicationWindow {
}
TextArea {
readOnly: true
text: gitVersion
text: Engine.version
selectByMouse: true
onFocusChanged: if (focus) selectAll()
}
Button {
id: updateButton
visible: Engine.selfUpdates
contentItem: RowLayout {
BusyIndicator {
implicitHeight: parent.height