From 11130150f638b9f8e94c1d9807219db58b8dd0dc Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 23 Mar 2021 17:43:15 +0100 Subject: [PATCH 1/3] Add github actions for MSVC --- .github/workflows/build.yml | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5a650477..9bbe985d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -133,6 +133,70 @@ jobs: name: MOD devices tarball path: ${{runner.workspace}}/build/${{env.install_name}}.tar.gz + build_for_win32: + runs-on: windows-2019 + steps: + - name: Set install name + run: | + echo platform=x86 >> "${Env:GITHUB_ENV}" + echo release_arch=Win32 >> "${Env:GITHUB_ENV}" + echo "install_ref=$(${Env:GITHUB_REF}.split('/')[-1])" >> "${Env:GITHUB_ENV}" + echo "install_name=sfizz-$(${Env:GITHUB_REF}.split('/')[-1])-win32" >> "${Env:GITHUB_ENV}" + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Create Build Environment + working-directory: ${{runner.workspace}} + run: cmake -E make_directory build + - name: Configure CMake + working-directory: ${{runner.workspace}}/build + run: | + cmake "${Env:GITHUB_WORKSPACE}" -G"Visual Studio 16 2019" -A"${Env:release_arch}" -DCMAKE_BUILD_TYPE="${Env:BUILD_TYPE}" -DCMAKE_CXX_STANDARD=17 -DSFIZZ_TESTS=ON -DSFIZZ_VST=ON -DSFIZZ_LV2=ON + - name: Build + working-directory: ${{runner.workspace}}/build + run: cmake --build . --config "${Env:BUILD_TYPE}" -j 2 + - name: Test + run: ${{runner.workspace}}/build/tests/Release/sfizz_tests + - name: Create installer + working-directory: ${{runner.workspace}}/build + run: iscc /O"." /F"${Env:install_name}" /dARCH="${Env:platform}" innosetup.iss + - uses: actions/upload-artifact@v2 + with: + name: Win32 installer + path: ${{runner.workspace}}/build/${{env.install_name}}.exe + + build_for_win64: + runs-on: windows-2019 + steps: + - name: Set install name + run: | + echo platform=x64 >> "${Env:GITHUB_ENV}" + echo release_arch=x64 >> "${Env:GITHUB_ENV}" + echo "install_ref=$(${Env:GITHUB_REF}.split('/')[-1])" >> "${Env:GITHUB_ENV}" + echo "install_name=sfizz-$(${Env:GITHUB_REF}.split('/')[-1])-win64" >> "${Env:GITHUB_ENV}" + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Create Build Environment + working-directory: ${{runner.workspace}} + run: cmake -E make_directory build + - name: Configure CMake + working-directory: ${{runner.workspace}}/build + run: | + cmake "${Env:GITHUB_WORKSPACE}" -G"Visual Studio 16 2019" -A"${Env:release_arch}" -DCMAKE_BUILD_TYPE="${Env:BUILD_TYPE}" -DCMAKE_CXX_STANDARD=17 -DSFIZZ_TESTS=ON -DSFIZZ_VST=ON -DSFIZZ_LV2=ON + - name: Build + working-directory: ${{runner.workspace}}/build + run: cmake --build . --config "${Env:BUILD_TYPE}" -j 2 + - name: Test + run: ${{runner.workspace}}/build/tests/Release/sfizz_tests + - name: Create installer + working-directory: ${{runner.workspace}}/build + run: iscc /O"." /F"${Env:install_name}" /dARCH="${Env:platform}" innosetup.iss + - uses: actions/upload-artifact@v2 + with: + name: Win64 installer + path: ${{runner.workspace}}/build/${{env.install_name}}.exe + build_for_mingw32: runs-on: ubuntu-18.04 container: From ce1f11abec42871809ce1b8e0ce289531e89f9a2 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 23 Mar 2021 17:44:21 +0100 Subject: [PATCH 2/3] Remove MSVC from Appveyor --- .appveyor.yml | 38 +------------------------------ scripts/appveyor/after_build.cmd | 4 ---- scripts/appveyor/before_build.cmd | 15 ------------ scripts/appveyor/build.cmd | 5 ---- scripts/appveyor/install.cmd | 9 -------- 5 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 scripts/appveyor/after_build.cmd delete mode 100644 scripts/appveyor/before_build.cmd delete mode 100644 scripts/appveyor/build.cmd delete mode 100644 scripts/appveyor/install.cmd diff --git a/.appveyor.yml b/.appveyor.yml index b60ec401..e0f92e8d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -7,18 +7,6 @@ environment: appveyor_build_worker_image: macos INSTALL_DIR: sfizz-$(APPVEYOR_REPO_TAG_NAME)-macos - - job_name: Windows x86 - appveyor_build_worker_image: Visual Studio 2019 - platform: x86 - VCPKG_TRIPLET: x86-windows-static - PATH: C:\Program Files (x86)\Inno Setup 6;%PATH% - - - job_name: Windows x64 - appveyor_build_worker_image: Visual Studio 2019 - platform: x64 - VCPKG_TRIPLET: x64-windows-static - PATH: C:\Program Files (x86)\Inno Setup 6;%PATH% - # Made with https://github.com/sfztools/code-signing CODESIGN_IDENTITY: codesign.sfz.tools CODESIGN_P12: @@ -54,35 +42,11 @@ for: - name: macOS DMG path: "sfizz-*.dmg" -- matrix: - only: - - job_name: Windows x86 - cache: c:\tools\vcpkg\installed\ -> appveyor.yml - install: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\install.cmd - before_build: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\before_build.cmd - build_script: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\build.cmd - after_build: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\after_build.cmd - artifacts: - - name: x86 Setup - path: "sfizz-*.exe" - -- matrix: - only: - - job_name: Windows x64 - cache: c:\tools\vcpkg\installed\ -> appveyor.yml - install: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\install.cmd - before_build: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\before_build.cmd - build_script: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\build.cmd - after_build: call %APPVEYOR_BUILD_FOLDER%\scripts\appveyor\after_build.cmd - artifacts: - - name: x64 Setup - path: "sfizz-*.exe" - deploy: - provider: GitHub auth_token: secure: xOugGAynvnZdc0DXaL3rlgMf4CICFLkdO8JxoRfLQMKJhkj/kZ4d8h7NCFneDzXG - artifact: macOS DMG,x86 Setup,x64 Setup + artifact: macOS DMG draft: false prerelease: false force_update: true diff --git a/scripts/appveyor/after_build.cmd b/scripts/appveyor/after_build.cmd deleted file mode 100644 index 069a079d..00000000 --- a/scripts/appveyor/after_build.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo off - -iscc.exe /dARCH=%platform% innosetup.iss -move *.exe ../ diff --git a/scripts/appveyor/before_build.cmd b/scripts/appveyor/before_build.cmd deleted file mode 100644 index 0b7804cd..00000000 --- a/scripts/appveyor/before_build.cmd +++ /dev/null @@ -1,15 +0,0 @@ -git submodule update --init --recursive - -mkdir build && cd build - -if %platform%==x86 set RELEASE_ARCH=Win32 -if %platform%==x64 set RELEASE_ARCH=x64 - -cmake .. -G"Visual Studio 16 2019" -A"%RELEASE_ARCH%"^ - -DSFIZZ_BENCHMARKS=OFF^ - -DSFIZZ_TESTS=ON^ - -DSFIZZ_LV2=ON^ - -DSFIZZ_VST=ON^ - -DCMAKE_BUILD_TYPE=Release^ - -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET%^ - -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake diff --git a/scripts/appveyor/build.cmd b/scripts/appveyor/build.cmd deleted file mode 100644 index 94838421..00000000 --- a/scripts/appveyor/build.cmd +++ /dev/null @@ -1,5 +0,0 @@ -cmake --build . --target sfizz_tests --config Release -j2 -.\tests\Release\sfizz_tests.exe -cmake --build . --target sfizz_lv2 --config Release -j2 -cmake --build . --target sfizz_lv2_ui --config Release -j2 -cmake --build . --target sfizz_vst3 --config Release -j2 diff --git a/scripts/appveyor/install.cmd b/scripts/appveyor/install.cmd deleted file mode 100644 index 3f7b2cc0..00000000 --- a/scripts/appveyor/install.cmd +++ /dev/null @@ -1,9 +0,0 @@ -choco install -y innosetup - -REM Uncomment the next 4 lines to force vcpkg update -REM cd c:\tools\vcpkg\ -REM git pull -REM .\bootstrap-vcpkg.bat -REM cd %APPVEYOR_BUILD_FOLDER% - -REM vcpkg install libsndfile:%VCPKG_TRIPLET% From 1ca1e1d4436ea88a390ac71f6f936e7ac1e9e6cb Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 23 Mar 2021 19:14:11 +0100 Subject: [PATCH 3/3] Fix the Buffer-related issue --- src/sfizz/Buffer.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/sfizz/Buffer.h b/src/sfizz/Buffer.h index 0fd8dc29..1f2dd2d3 100644 --- a/src/sfizz/Buffer.h +++ b/src/sfizz/Buffer.h @@ -156,8 +156,12 @@ public: return true; } - auto tempSize = newSize + 2 * AlignmentMask; // To ensure that we have leeway at the beginning and at the end - auto* newData = std::realloc(paddedData.get(), tempSize * sizeof(value_type)); + Type* oldData = paddedData.get(); + Type* oldNormalData = normalData; + std::size_t oldSize = alignedSize; + + std::size_t tempSize = newSize + 2 * AlignmentMask; // To ensure that we have leeway at the beginning and at the end + Type* newData = reinterpret_cast(std::calloc(tempSize, sizeof(value_type))); if (newData == nullptr) { return false; } @@ -173,12 +177,15 @@ public: paddedData.reset(static_cast(newData)); normalData = static_cast(align(Alignment, alignedSize, newData, tempSize)); normalEnd = normalData + alignedSize; - auto endMisalignment = (alignedSize & TypeAlignmentMask); + std::size_t endMisalignment = (alignedSize & TypeAlignmentMask); if (endMisalignment != 0) _alignedEnd = normalEnd + Alignment - endMisalignment; else _alignedEnd = normalEnd; + std::memcpy(normalData, oldNormalData, std::min(newSize, oldSize) * sizeof(Type)); + std::free(oldData); + return true; } @@ -307,14 +314,14 @@ private: static_assert(Alignment == 0 || Alignment == 4 || Alignment == 8 || Alignment == 16 || Alignment == 32, "Bad alignment value"); static_assert(TypeAlignment * sizeof(value_type) == Alignment || !std::is_arithmetic::value, "The alignment does not appear to be divided by the size of the arithmetic Type"); - void* align(std::size_t alignment, std::size_t size, void *&ptr, std::size_t &space ) + void* align(std::size_t alignment, std::size_t size, void *ptr, std::size_t &space) { - std::uintptr_t pn = reinterpret_cast< std::uintptr_t>( ptr ); - std::uintptr_t aligned = ( pn + alignment - 1 ) & - alignment; + std::uintptr_t pn = reinterpret_cast(ptr); + std::uintptr_t aligned = (pn + alignment - 1) & - alignment; std::size_t padding = aligned - pn; - if ( space < size + padding ) return nullptr; + if (space < size + padding) return nullptr; space -= padding; - return ptr = reinterpret_cast< void * >( aligned ); + return reinterpret_cast(aligned); } struct deleter {