From 4b9b12bf3053c2616c70f5bf55a4f532112b47d2 Mon Sep 17 00:00:00 2001 From: jacques Date: Wed, 6 Nov 2024 20:50:05 -0800 Subject: [PATCH] (chore) create windows binary --- .github/workflows/build.yml | 35 +++++++++++- Hedgehog.pro | 4 +- build.bat | 36 ++++++++++++ .../topological-sorting.js | 4 +- qml/LoginPage.qml | 56 +++++++++---------- src/main.cpp | 6 +- 6 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 build.bat diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bea5c6..09f5202 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,6 +7,33 @@ on: pull_request: jobs: + build-windows: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Qt5 on Windows + run: | + choco install qt5-default -y + $env:PATH += ";C:\Qt\5.15.2\mingw81_64\bin" + ls + + - name: Set architecture for build + run: echo "Building for Windows x64 architecture" + + - name: Build application + run: | + $env:PATH += ";C:\Qt\5.15.2\mingw81_64\bin" + .\build.bat windows-latest-x64-binary # Ensure your build.bat script exists and is configured for Windows + + - name: Upload binary + uses: actions/upload-artifact@v3 + with: + name: Hedgehog-windows-latest-x64-binary.exe + path: Hedgehog-windows-latest-x64-binary.exe + build-linux: runs-on: ubuntu-latest @@ -61,7 +88,7 @@ jobs: release: runs-on: ubuntu-latest - needs: [build-linux, build-macos] + needs: [build-linux, build-macos, build-windows] steps: - name: Checkout code @@ -78,6 +105,12 @@ jobs: with: name: Hedgehog-macos-latest-arm64-binary path: ./ + + - name: Download Windows x64 binary + uses: actions/download-artifact@v3 + with: + name: Hedgehog-windows-latest-x64-binary.exe + path: ./ - name: Create Draft Release id: create_release diff --git a/Hedgehog.pro b/Hedgehog.pro index 7b98810..41d6c3f 100644 --- a/Hedgehog.pro +++ b/Hedgehog.pro @@ -9,8 +9,8 @@ DESTDIR = ./build CONFIG += c++11 -QT += core gui qml widgets -QT += webengine +QT += core gui qml widgets quick +# QT += webengine DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..a6bfe15 --- /dev/null +++ b/build.bat @@ -0,0 +1,36 @@ +@echo off + +REM Function to replace destination binary path in Makefile (Windows equivalent) +setlocal +set "file=Makefile.Release" +set "string_to_replace=\\Hedgehog" +set "replacement_string=/Hedgehog" + +REM Run qmake and make +qmake +REM Use PowerShell to replace the string +powershell -Command "(Get-Content %file%) -replace '%string_to_replace%', '%replacement_string%' | Set-Content %file%" +echo Replaced "%string_to_replace%" with "%replacement_string%" in "%file%". + +set "file=Makefile.Release" +set "string_to_replace=Hedgehog\\" +set "replacement_string=Hedgehog/" + +REM Use PowerShell to replace the string +powershell -Command "(Get-Content %file%) -replace '%string_to_replace%', '%replacement_string%' | Set-Content %file%" +echo Replaced "%string_to_replace%" with "%replacement_string%" in "%file%". + +REM Clean previous builds +if exist build rmdir /S /Q build +mkdir build + +make + +REM Copy the final binary +if "%~1"=="" ( + copy "build\Hedgehog.exe" "Hedgehog.exe" +) else ( + copy "build\Hedgehog.exe" "Hedgehog-%~1.exe" +) + +endlocal diff --git a/logic/topological-sorting/topological-sorting.js b/logic/topological-sorting/topological-sorting.js index 45752cc..3d4c1a6 100644 --- a/logic/topological-sorting/topological-sorting.js +++ b/logic/topological-sorting/topological-sorting.js @@ -3,7 +3,7 @@ var question = [ id: "Topological sort", category: "Topo. Sort", placeHolderCpp: `void dfs(int node, map& visited, stack& stk, vector graph[]) {\n ...\n}\n\nvoid topoSortGraph(int V, vector adj[]) {\n ...\n}\n\n\n\n\n\n\n\n`, - placeHolderGo: `func dfs(node int, visited []bool, stack *[]int, graph [][]int) {\n ...\n}\n\nfunc topoSortGraph(V int, adj [][]int) {\n ...\n}\n\n\n\n\n\n\n`, + placeHolderGo: `func dfs(node int, visited []bool, stack *[]int, graph [][]int) {\n ...\n}\n\nvoid topoSortGraph(vector nodes, vector graph[]) {\n ...\n}\n\n\n\n\n\n\n`, difficulty: "Hard", question: "Topological Sort.", answerImage: "", @@ -18,7 +18,7 @@ var question = [ stk.push(node); } -void topoSortGraph(vector nodes, vector graph[]) { +void topoSortGraph(int V, vector nodes, vector graph[]) { map visited(V, false); stack stk; diff --git a/qml/LoginPage.qml b/qml/LoginPage.qml index 6637dc4..41f151a 100644 --- a/qml/LoginPage.qml +++ b/qml/LoginPage.qml @@ -1,8 +1,8 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 -import QtWebView 1.1 -import QtWebEngine 1.7 +// import QtWebView 1.1 +// import QtWebEngine 1.7 Rectangle { id: categoryPage @@ -15,35 +15,35 @@ Rectangle { property string redirectUri: "urn:ietf:wg:oauth:2.0:oob" property string authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth" - WebEngineView { - id: webView - anchors.fill: parent + // WebEngineView { + // id: webView + // anchors.fill: parent - // Step 1: Open Google's OAuth 2.0 login page - onUrlChanged: { - // Step 2: Detect redirect after successful login and extract authorization code - if (webView.url.indexOf(redirectUri) !== -1) { - var url = webView.url; - var authorizationCode = url.split("code=")[1]; - if (authorizationCode) { - console.log("Authorization Code: " + authorizationCode); + // // Step 1: Open Google's OAuth 2.0 login page + // onUrlChanged: { + // // Step 2: Detect redirect after successful login and extract authorization code + // if (webView.url.indexOf(redirectUri) !== -1) { + // var url = webView.url; + // var authorizationCode = url.split("code=")[1]; + // if (authorizationCode) { + // console.log("Authorization Code: " + authorizationCode); - // Step 3: Exchange authorization code for access token (via REST API call) - getAccessToken(authorizationCode); - } - } - } + // // Step 3: Exchange authorization code for access token (via REST API call) + // getAccessToken(authorizationCode); + // } + // } + // } - // Step 1: Load the Google login page with OAuth parameters - Component.onCompleted: { - var url = authorizationUrl + - "?client_id=" + clientId + - "&redirect_uri=" + redirectUri + - "&response_type=code" + - "&scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"; - webView.url = url; - } - } + // // Step 1: Load the Google login page with OAuth parameters + // Component.onCompleted: { + // var url = authorizationUrl + + // "?client_id=" + clientId + + // "&redirect_uri=" + redirectUri + + // "&response_type=code" + + // "&scope=https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"; + // webView.url = url; + // } + // } Button { text: "Exit" diff --git a/src/main.cpp b/src/main.cpp index 08a140f..6b998a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,15 @@ #include #include #include -#include +// #include + +#include #include "includes/documenthandler.h" #include "includes/highlighter.h" int main(int argc, char *argv[]) { - QtWebEngine::initialize(); + // QtWebEngine::initialize(); QGuiApplication app(argc, argv);