From 1acbbce033ef7c8ea813e44e9ddec2d8aa631ac5 Mon Sep 17 00:00:00 2001 From: Bliblank Date: Wed, 21 Jan 2026 22:31:25 -0600 Subject: [PATCH] build scripts checkpoint --- CMakeLists.txt | 12 -------- README.md | 48 ++++++++++++++++++++++++----- scripts/build.ps1 | 53 ++++++++++++-------------------- scripts/install_dependencies.ps1 | 14 +++++++-- 4 files changed, 71 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de6e8cc..b80acd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,18 +111,6 @@ if (WIN32) RtMidi::RtMidi ) - add_custom_command(TARGET metabolus POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "C:/rtaudio/bin/rtaudio.dll" - $ - ) - - add_custom_command(TARGET metabolus POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "C:/rtmidi/bin/rtmidi.dll" - $ - ) - else() target_include_directories(metabolus PRIVATE ${RTAUDIO_INCLUDE_DIRS} ${RTMIDI_INCLUDE_DIRS}) target_link_libraries(metabolus PRIVATE Qt6::Widgets ${RTAUDIO_LIBRARIES} ${RTMIDI_LIBRARIES}) diff --git a/README.md b/README.md index 5afeade..31b3bf7 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,45 @@ This synthesizer isn't very good, but it's neat :3 - [ ] Noise - [ ] LFO modulation -## setup -TODO: instructions on build setup -TODO: add dependencies into lib -TODO: autobuild libs in build scripts -Package Dependencies: Qt 6, RtAudio, RtMidi +## Build Instructions -$ ./scripts/build.sh -PS ./scripts/build.bat +Prerequisites: +CMake: https://cmake.org/download/ +Ninja: https://github.com/ninja-build/ninja/releases + +Windows: MSVC +Linux: GCC + +Clone repository +```PowerShell +git clone https://github.com/Blitblank/metabalus.git --recursive +``` +or if you forgot to --recursive: +```PowerShell +git clone https://github.com/Blitblank/metabalus.git +git submodule update --init --recursive +``` +Build. The script will build and install dependencies automatically + +On Windows (MSVC): +```PowerShell +.\scripts\build.ps1 +``` + +On Linux (GCC): +```Bash +./scripts/build.sh +``` + +Configure the CMake/build script if you have issues + +To clean: +``` +.\scripts\clean.ps1 +./scripts/clean.sh +``` +Note: dependencies are built into build/lib, so don't delete that unless you want to rebuild qt which takes forever :) +Use the install_dependencies script to manually install dependencies. + +Build troubleshooting: +On windows, `bcdedit /set IncreaseUserVa 3072` solved cc1plus.exe: out of memory errors while building qt for me diff --git a/scripts/build.ps1 b/scripts/build.ps1 index a5ef320..a424e49 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -1,13 +1,15 @@ +$PROJECT_ROOT = $PWD + # config -$BUILD_DIR = "build" +$BUILD_DIR = "$PWD/build" $CONFIG = "Release" # change these to the build libs -$QT_ROOT = "C:\Qt\6.10.1\msvc2022_64" -$RTAUDIO_ROOT = "C:\rtaudio" -$RTMIDI_ROOT = "C:\rtmidi" +$QT_ROOT = "$BUILD_DIR\lib\qt\install" +$RTAUDIO_ROOT = "$BUILD_DIR\lib\rtaudio" +$RTMIDI_ROOT = "$BUILD_DIR\lib\rtmidi" # setup @@ -21,7 +23,7 @@ if (-not (Test-Path -Path $BUILD_DIR)) { # detect dependencies -$libraries = @("qt", "rtaudio", "rtmidi", "yaml-cpp") +$libraries = @("qt", "rtaudio", "rtmidi") $dependencies_found = 0 foreach ($lib in $libraries) { if (Test-Path -Path ".\build\lib\$lib") { @@ -34,44 +36,27 @@ foreach ($lib in $libraries) { if (-not ($dependencies_found -eq $libraries.Count)) { & "scripts\install_dependencies.ps1" +} else { + Write-Host "All dependencies detected, skipping depency install step..." } # configure - -<# -cmake -S . -B $BUILD_DIR ^ - -G Ninja ^ - -DCMAKE_BUILD_TYPE=$CONFIG ^ - -DRTAUDIO_ROOT=$RTAUDIO_ROOT ^ - -DRTMIDI_ROOT=$RTMIDI_ROOT - - -if errorlevel 1 goto error +Write-Host "Configuring metabolus..." +cmake -S . -B $BUILD_DIR -G Ninja -DCMAKE_BUILD_TYPE=$CONFIG -DQt6_ROOT="$QT_ROOT\lib\cmake\Qt6" -DRTAUDIO_ROOT=$RTAUDIO_ROOT -DRTMIDI_ROOT=$RTMIDI_ROOT # build +Write-Host "Building metabolus..." cmake --build $BUILD_DIR -if errorlevel 1 goto error - # link dlls +Write-Host "Deploying metabolus..." +cd $BUILD_DIR -cd %BUILD_DIR% +& "$QT_ROOT\bin\windeployqt.exe" metabolus.exe -windeployqt metabolus.exe +Copy-Item -Path "$RTAUDIO_ROOT\bin\rtaudio.dll" -Destination . +Copy-Item -Path "$RTMIDI_ROOT\bin\rtmidi.dll" -Destination . -copy "%RTAUDIO_ROOT%\bin\rtaudio.dll" . -copy "%RTMIDI_ROOT%\bin\rtmidi.dll" . -echo. -echo Build successful -goto end - -:error -echo. -echo Build failed -exit /b 1 - -:end -endlocal -pause -#> \ No newline at end of file +# TODO: allow input of an external qt install because this one is huge +# TODO: remove unnecessary qt modules bc why is this install like 80 gb diff --git a/scripts/install_dependencies.ps1 b/scripts/install_dependencies.ps1 index 776edd7..d502a52 100644 --- a/scripts/install_dependencies.ps1 +++ b/scripts/install_dependencies.ps1 @@ -2,12 +2,20 @@ echo "Installing dependencies ... " $project_root = $PWD + +if (-not (Test-Path -Path "$PWD\build\lib")) { + mkdir "$PWD\build\lib" +} + $build_lib_dir = "$PWD\build\lib" - # qt -mkdir "$build_lib_dir\qt" -cd $project_root\lib\qtbase +mkdir "$build_lib_dir\qt" -Force +#cd $project_root\lib\qt5 +cd $build_lib_dir\qt +& "$project_root\lib\qt5\configure.bat" -prefix .\install -submodules qttools,qtbase -widgets +cmake --build . --parallel +cmake --install . # rtaudio