Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/project/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,13 @@ set(COMMON_SRCS
../cli/script.h)

if(COMMAND qt_add_executable)
qt_add_executable(${APP_NAME} WIN32 MACOSX_BUNDLE ${COMMON_SRCS})
qt_add_executable(${APP_NAME} WIN32 MACOSX_BUNDLE ${COMMON_SRCS} $<$<PLATFORM_ID:Windows>:${app_icon_resource_windows}>)
else()
add_executable(${APP_NAME}
$<$<PLATFORM_ID:Windows>:WIN32>
$<$<PLATFORM_ID:Darwin>:MACOSX_BUNDLE>
${COMMON_SRCS}
$<$<PLATFORM_ID:Windows>:${app_icon_resource_windows}>
)
endif()

Expand Down
54 changes: 51 additions & 3 deletions src/project/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,61 @@ param (
)

if ($IsWindows) {
cmake . -DCMAKE_PREFIX_PATH=C:/Qt/6.9.0/msvc2022_64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS="/Zc:__cplusplus /permissive-" -B build
cmake --build build --config Release --parallel 32
# Check if Ninja is installed
if (-not (Get-Command ninja -ErrorAction SilentlyContinue)) {
Write-Error "Ninja build system is not installed. Please install Ninja."
Write-Error "Install via: choco install ninja (or download from https://github.com/ninja-build/ninja/releases)"
exit 1
}

# Check if Visual Studio is installed (including preview versions) for compiler
$vsPath = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -property installationPath 2>$null
if (-not $vsPath) {
Write-Error "Visual Studio is not installed. Please install Visual Studio 2022 with C++ development tools."
Write-Error "Download from: https://visualstudio.microsoft.com/downloads/"
exit 1
}

Write-Host "Using Visual Studio at: $vsPath"

# Use Ninja generator
$generator = "Ninja"
Write-Host "Using CMake generator: $generator"

# Check if Qt is installed
if (-not (Test-Path "C:\Qt\6.9.0\msvc2022_64")) {
Write-Error "Qt 6.9.0 MSVC2022 64-bit is not installed at C:\Qt\6.9.0\msvc2022_64"
Write-Error "Please install Qt 6.9.0 for MSVC 2022 64-bit from: https://www.qt.io/download"
exit 1
}
Comment thread
christianhelle marked this conversation as resolved.

# Find vcvars64.bat to setup Visual Studio environment
$vcvars = "$vsPath\VC\Auxiliary\Build\vcvars64.bat"
if (-not (Test-Path $vcvars)) {
Write-Error "Visual Studio C++ tools not found. Please install C++ development workload."
exit 1
}

# Setup Visual Studio environment and run CMake with Ninja generator
& cmd /c "`"$vcvars`" && cmake . -G `"$generator`" -DCMAKE_PREFIX_PATH=C:\Qt\6.9.0\msvc2022_64 -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_FLAGS=`"/Zc:__cplusplus /permissive-`" -DCMAKE_BUILD_TYPE=Release -B build"
if ($LASTEXITCODE -ne 0) {
Write-Error "CMake configuration failed"
exit $LASTEXITCODE
}

& cmd /c "`"$vcvars`" && cmake --build build --parallel 32"
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed"
exit $LASTEXITCODE
}

if ($Package) {
mkdir .\build\Release

Copilot AI Nov 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mkdir command can fail if the directory already exists. Add -Force parameter to prevent errors on subsequent builds: mkdir .\build\Release -Force

Suggested change
mkdir .\build\Release
mkdir .\build\Release -Force

Copilot uses AI. Check for mistakes.
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
Comment on lines +56 to +57

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Add error handling and safe directory creation.

The packaging steps lack error handling and may fail if the directory already exists.

Apply this diff to improve robustness:

-        mkdir .\build\Release
+        if (-not (Test-Path .\build\Release)) {
+            New-Item -ItemType Directory -Path .\build\Release -Force | Out-Null
+        }
+        
+        if (-not (Test-Path .\build\SQLiteQueryAnalyzer.exe)) {
+            Write-Error "Build output not found: .\build\SQLiteQueryAnalyzer.exe"
+            exit 1
+        }
+        
         Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mkdir .\build\Release
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
if (-not (Test-Path .\build\Release)) {
New-Item -ItemType Directory -Path .\build\Release -Force | Out-Null
}
if (-not (Test-Path .\build\SQLiteQueryAnalyzer.exe)) {
Write-Error "Build output not found: .\build\SQLiteQueryAnalyzer.exe"
exit 1
}
Copy-Item .\build\SQLiteQueryAnalyzer.exe .\build\Release\SQLiteQueryAnalyzer.exe
🤖 Prompt for AI Agents
In src/project/build.ps1 around lines 56 to 57, the script unconditionally calls
mkdir and Copy-Item which will fail if the directory already exists or if copy
errors occur; update to create the Release folder safely (use Test-Path or
New-Item -ItemType Directory -Force) and wrap the directory creation and
Copy-Item in a try/catch with -ErrorAction Stop so failures are caught; on
error, write a clear error message to stderr (Write-Error or Write-Host with
red) and exit with a non-zero code to fail the build.

C:\Qt\6.9.0\msvc2022_64\bin\windeployqt.exe .\build\Release\SQLiteQueryAnalyzer.exe
../../deps/innosetup/ISCC.exe setup.iss
}
Comment thread
christianhelle marked this conversation as resolved.
}
}

if ($IsLinux) {
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./linux/
Expand Down
Binary file modified src/resources/icon.ico
Binary file not shown.
Loading