# HG changeset patch # User Chris Cannam # Date 1591718384 -3600 # Node ID 885960538dd47afda4525ee3ca6247262abe061f # Parent b081441c7970fe40e84ca75d736d9d62a8649a7f Build a static-ish binary diff -r b081441c7970 -r 885960538dd4 .hgignore --- a/.hgignore Tue Jun 09 14:55:19 2020 +0100 +++ b/.hgignore Tue Jun 09 16:59:44 2020 +0100 @@ -46,6 +46,7 @@ .notarization-uuid .notarization-status build_win64_debug +build_win64_static *.AppImage *.AppDir bundle diff -r b081441c7970 -r 885960538dd4 base.pro --- a/base.pro Tue Jun 09 14:55:19 2020 +0100 +++ b/base.pro Tue Jun 09 16:59:44 2020 +0100 @@ -42,3 +42,4 @@ for (file, SVCORE_SOURCES) { SOURCES += $$sprintf("svcore/%1", $$file) } for (file, SVCORE_HEADERS) { HEADERS += $$sprintf("svcore/%1", $$file) } + diff -r b081441c7970 -r 885960538dd4 deploy/clean-build-and-package.bat --- a/deploy/clean-build-and-package.bat Tue Jun 09 14:55:19 2020 +0100 +++ b/deploy/clean-build-and-package.bat Tue Jun 09 16:59:44 2020 +0100 @@ -14,18 +14,30 @@ @echo Proceeding -call .\deploy\win\build-both.bat +del /q /s build_win32 +del /q /s build_win64_static + +@echo Rebuilding 32-bit + +call .\deploy\win\build-32.bat +if %errorlevel% neq 0 exit /b %errorlevel% + +@echo Rebuilding 64-bit + +call .\deploy\win\build-64-static.bat if %errorlevel% neq 0 exit /b %errorlevel% @echo on +@echo Signing + set NAME=Open Source Developer, Christopher Cannam @echo Signing 32-bit executables and libraries signtool sign /v /n "%NAME%" /t http://time.certum.pl /fd sha1 /a build_win32\release\*.exe build_win32\release\*.dll @echo Signing 64-bit executables and libraries -signtool sign /v /n "%NAME%" /t http://time.certum.pl /fd sha1 /a build_win64\release\*.exe build_win64\release\*.dll +signtool sign /v /n "%NAME%" /t http://time.certum.pl /fd sha1 /a build_win64_static\release\*.exe build_win64_static\release\*.dll @echo Zipping up 32-bit package set pkg=sonic-annotator-%VERSION%-win32 @@ -40,10 +52,11 @@ copy build_win32\release\Qt5Network.dll %dir% copy build_win32\release\Qt5Xml.dll %dir% copy build_win32\release\libgcc_s_dw2-1.dll %dir% -copy build_win32\release\libstdc++-6.dll %dir% copy build_win32\release\libwinpthread-1.dll %dir% +copy build_win32\release\libstd*.dll %dir% copy build_win32\release\sonic-annotator.exe %dir% +del %pkg%.zip powershell -NoProfile -ExecutionPolicy Bypass -Command "& 'deploy\win\zip.ps1' %pkg%.zip %pkg%" del /q /s %pkg% @@ -56,18 +69,10 @@ copy CITATION %dir%\CITATION.txt copy COPYING %dir%\COPYING.txt copy README.md %dir%\README.txt -copy build_win64\release\Qt5Core.dll %dir% -copy build_win64\release\Qt5Network.dll %dir% -copy build_win64\release\Qt5Xml.dll %dir% -copy build_win64\release\libsndfile-1.dll %dir% -copy build_win64\release\sonic-annotator.exe %dir% +copy build_win64_static\release\libsndfile-1.dll %dir% +copy build_win64_static\release\sonic-annotator.exe %dir% -copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\x64\Microsoft.VC142.CRT\concrt140.DLL" %dir% -copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\x64\Microsoft.VC142.CRT\msvcp140.DLL" %dir% -copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\x64\Microsoft.VC142.CRT\vccorlib140.DLL" %dir% -copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\x64\Microsoft.VC142.CRT\vcruntime140.DLL" %dir% -copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Redist\MSVC\14.25.28508\x64\Microsoft.VC142.CRT\vcruntime140_1.DLL" %dir% - +del %pkg%.zip powershell -NoProfile -ExecutionPolicy Bypass -Command "& 'deploy\win\zip.ps1' %pkg%.zip %pkg%" del /q /s %pkg% diff -r b081441c7970 -r 885960538dd4 deploy/win/build-32.bat --- a/deploy/win/build-32.bat Tue Jun 09 14:55:19 2020 +0100 +++ b/deploy/win/build-32.bat Tue Jun 09 16:59:44 2020 +0100 @@ -39,4 +39,7 @@ .\release\test-svcore-base .\release\test-svcore-system +.\release\sonic-annotator -v + set PATH=%ORIGINALPATH% +cd %STARTPWD% diff -r b081441c7970 -r 885960538dd4 deploy/win/build-64-static.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deploy/win/build-64-static.bat Tue Jun 09 16:59:44 2020 +0100 @@ -0,0 +1,75 @@ + +rem Using Qt Base module thus: +rem .\configure -static -static-runtime -release -platform win32-msvc -no-opengl -no-angle -nomake examples -prefix C:\Qt\5.14.1-static + +set QTDIR=C:\Qt\5.14.1-static-msvc2015 +if not exist %QTDIR% ( +@ echo Could not find 64-bit Qt in %QTDIR% +@ exit /b 2 +) + +rem Not 2019! Its APIs are too new for use in our static build +rem set vcvarsall="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" +set vcvarsall="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" + +if not exist %vcvarsall% ( +@ echo "Could not find MSVC vars batch file" +@ exit /b 2 +) + +set SMLNJDIR=C:\Program Files (x86)\SMLNJ +if not exist "%SMLNJDIR%\bin" ( +@ echo Could not find SML/NJ, required for Repoint +@ exit /b 2 +) + +call %vcvarsall% amd64 +if %errorlevel% neq 0 exit /b %errorlevel% + +set ORIGINALPATH=%PATH% +set PATH=%PATH%;%SMLNJDIR%\bin;%QTDIR%\bin +set NAME=Open Source Developer, Christopher Cannam + +set ARG=%1 +shift +if "%ARG%" == "sign" ( +@ echo NOTE: sign option specified, will attempt to codesign exe and msi +@ echo NOTE: starting by codesigning an unrelated executable, so we know +@ echo NOTE: whether it'll work before doing the entire build +copy "%SMLNJDIR%\bin\.run\run.x86-win32.exe" signtest.exe +signtool sign /v /n "%NAME%" /t http://time.certum.pl /fd sha1 /a signtest.exe +if errorlevel 1 exit /b %errorlevel% +signtool verify /pa signtest.exe +if errorlevel 1 exit /b %errorlevel% +del signtest.exe +@ echo NOTE: success +) else ( +@ echo NOTE: sign option not specified, will not codesign anything +) + +cd %STARTPWD% + +call .\repoint install +if %errorlevel% neq 0 exit /b %errorlevel% + +mkdir build_win64_static +cd build_win64_static + +qmake -spec win32-msvc -r -tp vc ..\sonic-annotator.pro +if %errorlevel% neq 0 exit /b %errorlevel% + +mkdir o + +msbuild sonic-annotator.sln /t:Build /p:Configuration=Release +if %errorlevel% neq 0 exit /b %errorlevel% + +rem Sadly this static build is not totally static +copy ..\sv-dependency-builds\win64-msvc\lib\libsndfile-1.dll .\release + +.\release\test-svcore-base +.\release\test-svcore-system + +.\release\sonic-annotator -v + +set PATH=%ORIGINALPATH% +cd %STARTPWD% diff -r b081441c7970 -r 885960538dd4 deploy/win/build-64.bat --- a/deploy/win/build-64.bat Tue Jun 09 14:55:19 2020 +0100 +++ b/deploy/win/build-64.bat Tue Jun 09 16:59:44 2020 +0100 @@ -48,4 +48,7 @@ .\release\test-svcore-base .\release\test-svcore-system +.\release\sonic-annotator -v + set PATH=%ORIGINALPATH% +cd %STARTPWD% diff -r b081441c7970 -r 885960538dd4 deploy/win/build-both.bat --- a/deploy/win/build-both.bat Tue Jun 09 14:55:19 2020 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -rem Run this from within the top-level dir: deploy\win\build-and-package.bat - -set STARTPWD=%CD% - -if not exist "C:\Program Files (x86)\SMLNJ\bin" ( -@ echo Could not find SML/NJ, required for Repoint -@ exit /b 2 -) - -set ORIGINALPATH=%PATH% -set PATH=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin;%PATH% - -@echo "" -@echo Rebuilding 32-bit - -cd %STARTPWD% -del /q /s build_win32 -call .\deploy\win\build-32.bat -if %errorlevel% neq 0 exit /b %errorlevel% - -@echo Rebuilding 64-bit - -cd %STARTPWD% -del /q /s build_win64 -call .\deploy\win\build-64.bat -if %errorlevel% neq 0 exit /b %errorlevel% - -set PATH=%ORIGINALPATH% -cd %STARTPWD% - -@echo Done - diff -r b081441c7970 -r 885960538dd4 deploy/win/static-redirects.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/deploy/win/static-redirects.cpp Tue Jun 09 16:59:44 2020 +0100 @@ -0,0 +1,10 @@ + +#include + +extern "C" { + void __imp__assert(char const *msg, char const *fn, unsigned line) {} + void __imp__wassert(wchar_t const *msg, wchar_t const *fn, unsigned line) {} + void __imp_clearerr(FILE *f) { clearerr(f); } + void __imp_rewind(FILE *f) { rewind(f); } +} + diff -r b081441c7970 -r 885960538dd4 noconfig.pri --- a/noconfig.pri Tue Jun 09 14:55:19 2020 +0100 +++ b/noconfig.pri Tue Jun 09 16:59:44 2020 +0100 @@ -6,7 +6,8 @@ PREFIX_PATH = /usr/local -DEFINES += NDEBUG BUILD_RELEASE +#DEFINES += NDEBUG BUILD_RELEASE +DEFINES += BUILD_RELEASE DEFINES += NO_TIMING # Full set of defines expected for all platforms when we have the @@ -74,8 +75,8 @@ INCLUDEPATH += $$PWD/sv-dependency-builds/win64-msvc/include $$PWD/sv-dependency-builds/win64-msvc/include/opus CONFIG(release) { - LIBS += -NODEFAULTLIB:LIBCMT -Lrelease \ - -L$$PWD/sv-dependency-builds/win64-msvc/lib + SOURCES += deploy/win/static-redirects.cpp + LIBS += -Lrelease -L$$PWD/sv-dependency-builds/win64-msvc/lib } DEFINES += NOMINMAX _USE_MATH_DEFINES HAVE_MEDIAFOUNDATION AVOID_WINRT_DEPENDENCY