Skip to content

Commit

Permalink
Build script updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wgergely committed Nov 6, 2023
1 parent 008728e commit 2fe549d
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 57 deletions.
2 changes: 1 addition & 1 deletion docs/src/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if errorlevel 9009 (
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
exit /b %ERRORLEVEL%
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
Expand Down
18 changes: 14 additions & 4 deletions package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ get_qt_version()
set(QT_LIST_FILE ${PACKAGES_DIR}/vcpkg/installed/vcpkg/info/qt${QT_VERSION_MAJOR}-base_${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}_${VCPKG_TRIPLET}.list)
add_custom_command(
OUTPUT ${QT_LIST_FILE}
COMMAND echo "Building QT..."
COMMAND echo.
COMMAND echo "vcpkg is building Qt"
COMMAND ${PACKAGES_DIR}/vcpkg/vcpkg.exe install qt5[core,imageformats]:${VCPKG_TRIPLET} --overlay-ports=${VCPKG_OVERLAYS_DIR}
COMMAND echo "vcpkg finished building Qt"
COMMAND echo.
)
add_custom_target(
vcpkg-qt ALL
Expand All @@ -80,8 +83,11 @@ get_ffmpeg_version()
set(FFMPEG_LIST_FILE ${PACKAGES_DIR}/vcpkg/installed/vcpkg/info/ffmpeg_${FFMPEG_VERSION_MAJOR}.${FFMPEG_VERSION_MINOR}.${FFMPEG_VERSION_PATCH}_${VCPKG_TRIPLET}.list)
add_custom_command(
OUTPUT ${FFMPEG_LIST_FILE}
COMMAND echo "Building FFMPEG..."
COMMAND echo.
COMMAND echo "vcpkg is building FFMpeg"
COMMAND ${PACKAGES_DIR}/vcpkg/vcpkg.exe install ffmpeg[avcodec,avdevice,avfilter,avformat,avresample,bzip2,ffmpeg,fontconfig,freetype,lzma,opengl,swresample,swscale,x264,x265,zlib]:${VCPKG_TRIPLET} --overlay-ports=${VCPKG_OVERLAYS_DIR}
COMMAND echo "vcpkg finished building FFMpeg"
COMMAND echo.
)
add_custom_target(
vcpkg-ffmpeg ALL
Expand All @@ -94,8 +100,12 @@ get_oiio_version()
set(OIIO_LIST_FILE ${PACKAGES_DIR}/vcpkg/installed/vcpkg/info/openimageio_${OIIO_VERSION_MAJOR}.${OIIO_VERSION_MINOR}.${OIIO_VERSION_PATCH}.${OIIO_VERSION_TWEAK}_${VCPKG_TRIPLET}.list)
add_custom_command(
OUTPUT ${OIIO_LIST_FILE}
COMMAND echo "Building OpenImageIO..."
COMMAND echo.
COMMAND echo "vcpkg is building OpenImageIO"
COMMAND ${PACKAGES_DIR}/vcpkg/vcpkg.exe install openimageio[ffmpeg,freetype,gif,libheif,libraw,opencolorio,openjpeg,pybind11,tools,webp]:${VCPKG_TRIPLET} --overlay-ports=${VCPKG_OVERLAYS_DIR}
COMMAND echo "vcpkg finished building OpenImageIO"
COMMAND echo.

)
add_custom_target(
vcpkg-oiio ALL
Expand All @@ -113,7 +123,7 @@ elseif(QT_VERSION_MAJOR STREQUAL 6)
set(PYSIDE_VERSION_MAJOR "6")
set(SHIBOKEN "shiboken6")
else()
message(FATAL_ERROR "PySide only supports Qt5 and Qt6")
message(FATAL_ERROR "Build script only supports Qt5 or Qt6")
endif()

string(TOLOWER ${PYSIDE} PYSIDE_LOWER)
Expand Down
16 changes: 12 additions & 4 deletions package/build-imageutil.bat.in
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
@echo off

set "CMAKE_TOOLCHAIN_FILE=${PACKAGES_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake"

if not exist "%CMAKE_TOOLCHAIN_FILE%" (
echo "%CMAKE_TOOLCHAIN_FILE% not found"
exit /b 1
exit /b %ERRORLEVEL%
)

set "PATH=${PACKAGES_DIR}\python;${PACKAGES_DIR}\python\bin;%PATH%"

"${CMAKE_COMMAND}" ^
-S "${PROJECT_SOURCE_DIR}/imageutil" ^
-B "${PROJECT_BINARY_DIR}/imageutil" ^
-G "${CMAKE_GENERATOR}" ^
-A ${CMAKE_GENERATOR_PLATFORM} ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_TOOLCHAIN_FILE="${PACKAGES_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake" ^
-DBUILD_TEST:BOOL=OFF
-DBUILD_TESTS=OFF

if ERRORLEVEL 1 (
echo Failed to configure imageutil
exit /b %ERRORLEVEL%
)

cd "${PROJECT_BINARY_DIR}/imageutil"
if not exist "${PROJECT_BINARY_DIR}/imageutil/imageutil.sln" (
echo "imageutil.sln not found"
exit /b 1
exit /b %ERRORLEVEL%
)

msbuild.exe "${PROJECT_BINARY_DIR}/imageutil/imageutil.sln" /t:Build /p:Configuration=Release /p:Platform=${CMAKE_GENERATOR_PLATFORM} /m /nologo
cmd /c msbuild.exe "${PROJECT_BINARY_DIR}/imageutil/imageutil.sln" /t:Build /p:Configuration=Release /p:Platform=${CMAKE_GENERATOR_PLATFORM} /m /nologo
40 changes: 35 additions & 5 deletions package/build-pyside.bat.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,36 @@ mkdir "${PYTHON_DIR}/libs"
robocopy "${PACKAGES_DIR}/vcpkg/installed/${VCPKG_TRIPLET}/lib" "${PYTHON_DIR}/libs" python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}.lib /IS /IT /NFL /NDL /NJH /NJS /R:0 /W:0
robocopy "${PACKAGES_DIR}/vcpkg/installed/${VCPKG_TRIPLET}/debug/lib" "${PYTHON_DIR}/libs" python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib /IS /IT /NFL /NDL /NJH /NJS /R:0 /W:0

@REM Clone qt-for-python
@REM Clone PySide/qt-for-python
cd /d "${PACKAGES_DIR}"
if EXIST "${PACKAGES_DIR}/pyside-setup" rmdir "${PACKAGES_DIR}/pyside-setup" /S /Q
git clone git://code.qt.io/pyside/pyside-setup.git "${PACKAGES_DIR}/pyside-setup"
cd pyside-setup

@REM Checkout our Qt version
git checkout ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}

IF ERRORLEVEL 1 (
git checkout ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.2
)

IF ERRORLEVEL 1 (
git checkout ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.1
)

IF ERRORLEVEL 1 (
git checkout ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.0
)

IF ERRORLEVEL 1 (
git checkout ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}
)

IF ERRORLEVEL 1 (
echo Failed to find a suitable branch
exit /b %ERRORLEVEL%
)

git submodule update --init
git submodule foreach git fetch --all

Expand All @@ -48,10 +72,10 @@ set "Qt${QT_VERSION_MAJOR}Widgets_DIR=${PACKAGES_DIR}/vcpkg/installed/${VCPKG_TR
set "LLVM_INSTALL_DIR=${LLVM_INSTALL_DIR}"
set PATH=^
${PYTHON_DIR};^
${PYTHON_DIR}/Scripts;^
${PYTHON_DIR}\Scripts;^
${LLVM_INSTALL_DIR};^
${PACKAGES_DIR}/vcpkg/installed/${VCPKG_TRIPLET}/tools/qt${QT_VERSION_MAJOR}/bin;^
${PACKAGES_DIR}/vcpkg/installed/${VCPKG_TRIPLET}/bin;^
${PACKAGES_DIR}\vcpkg\installed\${VCPKG_TRIPLET}\tools\qt${QT_VERSION_MAJOR}\bin;^
${PACKAGES_DIR}\vcpkg\installed\${VCPKG_TRIPLET}\bin;^
%PATH%

@REM Build using cmake
Expand All @@ -77,11 +101,17 @@ ${PACKAGES_DIR}/vcpkg/installed/${VCPKG_TRIPLET}/bin;^
-DPYTHON_DEBUG_LIBRARY:FILEPATH="${PYTHON_DIR}/libs/python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}_d.lib" ^
-DQUIET_BUILD=1

IF ERRORLEVEL 1 (
echo Could not configure PySide
exit /b %ERRORLEVEL%
)


@REM Build solution
set "SOLUTION=${PACKAGES_DIR}/pyside-setup/build/${PYSIDE_LOWER}_super_project.sln"
if not exist "%SOLUTION%" (
echo Error: Could not find %SOLUTION%
exit /b 1
exit /b %ERRORLEVEL%
)

@REM Build pyside
Expand Down
79 changes: 64 additions & 15 deletions package/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SET VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.ex
:: Check if vswhere is available
IF NOT EXIST %VSWHERE% (
echo Error: "vswhere.exe" not found. Please ensure you have Visual Studio 2017 or newer installed.
exit /b 1
exit /b %ERRORLEVEL%
)

:: Use vswhere to find the latest VS installation with VC tools
Expand All @@ -16,7 +16,7 @@ FOR /F "tokens=*" %%i IN ('%VSWHERE% -latest -products * -requires Microsoft.Vis

IF NOT DEFINED VSPATH (
echo Error: Suitable Visual Studio installation not found.
exit /b 1
exit /b %ERRORLEVEL%
)

:: Construct path to vcvars64.bat using the found VS path
Expand All @@ -25,7 +25,7 @@ SET VCVARS64="%VSPATH%\VC\Auxiliary\Build\vcvars64.bat"
:: Check for vcvars64.bat existence
IF NOT EXIST %VCVARS64% (
echo Error: "vcvars64.bat" not found in detected Visual Studio path.
exit /b 1
exit /b %ERRORLEVEL%
)

call %VCVARS64%
Expand All @@ -34,31 +34,31 @@ call %VCVARS64%
where cmake >nul 2>nul
IF ERRORLEVEL 1 (
echo Error: cmake is not installed or not in the PATH.
exit /b 1
exit /b %ERRORLEVEL%
)

:: Get the Visual Studio version
if defined VisualStudioVersion (
set VS_VERSION=%VisualStudioVersion%
) else (
echo Visual Studio environment not set up!
exit /b 1
exit /b %ERRORLEVEL%
)

:: Get the Visual Studio name for CMake
if "%VS_VERSION%"=="16.0" (
set VS_NAME="Visual Studio 16 2019"
) else (
echo Unsupported Visual Studio version!
exit /b 1
exit /b %ERRORLEVEL%
)

:: Get the architecture
if defined VSCMD_ARG_TGT_ARCH (
set VS_ARCH=%VSCMD_ARG_TGT_ARCH%
) else (
echo Architecture not set!
exit /b 1
exit /b %ERRORLEVEL%
)

:: Print the values
Expand All @@ -70,34 +70,83 @@ set "_script_dir=%~dp0"
set "_script_dir=%_script_dir:~0,-1%"
echo The directory of the script is: %_script_dir%


:: Make sure we're using short paths for the build
subst B: "%_script_dir%/build"

:: Get the parent directory
for %%i in ("%_script_dir%") do set "_parent_dir=%%~dpi"

cmake ^
-S "%_script_dir%" ^
-B "%_script_dir%/build" ^
-B "B:" ^
-G %VS_NAME% ^
-A %VS_ARCH% ^
-DCMAKE_BUILD_TYPE=Release

IF ERRORLEVEL 1 (
echo Failed to configure build project.
subst B: /D
exit /b %ERRORLEVEL%
)


@REM @REM Build dependencies
cmd /c msbuild.exe "%_script_dir%/build/Bookmarks.sln" -target:Build -property:Configuration=Release -property:Platform=%VS_ARCH% /m /nologo
cmd /c msbuild.exe "B:/Bookmarks.sln" -target:Build -property:Configuration=Release -property:Platform=%VS_ARCH% /m /nologo

IF ERRORLEVEL 1 (
echo Failed to build Bookmarks.sln
subst B: /D
exit /b %ERRORLEVEL%
)


@REM @REM Build pyside
cmd /c "%_script_dir%/build/packages/build-pyside.bat"
cmd /c "B:/packages/build-pyside.bat"

IF ERRORLEVEL 1 (
echo PySide encountered errors
echo %ERRORLEVEL%
echo Continuing build...
)

@REM @REM Build image util
cmd /c "%_script_dir%/build/build-imageutil.bat"
cmd /c "B:/build-imageutil.bat"

IF ERRORLEVEL 1 (
echo Failed to build imageutil
subst B: /D
exit /b %ERRORLEVEL%
)

@REM Build application package
cmd /c "%_script_dir%/build/packages/build-package.bat"
cmd /c "B:/packages/build-package.bat"

IF ERRORLEVEL 1 (
echo Failed to build package
subst B: /D
exit /b %ERRORLEVEL%
)

@REM Build installer
mkdir "%_script_dir%/build/install"
for /d /r "%_script_dir%/build/package" %%G in (__pycache__) do (
mkdir "B:/install"
for /d /r "B:/package" %%G in (__pycache__) do (
if exist "%%G" (
echo Removing "%%G"
rd /s /q "%%G"
)
)
"%_script_dir%/build/packages/inno/ISCC.exe" /O"%_script_dir%/build/install" "%_script_dir%/build/install/installer.iss"
"B:/packages/inno/ISCC.exe" /O"B:/install" "B:/install/installer.iss"

IF ERRORLEVEL 1 (
echo Failed to build installer
subst B: /D
exit /b %ERRORLEVEL%
)

subst B: /D

echo.
echo Build completed.
echo Installer saved to:
echo %_script_dir%/build/install
Loading

0 comments on commit 2fe549d

Please sign in to comment.