Adding support for windows viewer build. # Conflicts: # .gitignore # skia/viewer/src/main.cpp
diff --git a/.gitignore b/.gitignore index 72dd777..8a123a3 100644 --- a/.gitignore +++ b/.gitignore
@@ -81,3 +81,19 @@ /build/android /skia/dependencies/skia_rive_optimized /skia/dependencies/skia-experimental +build/windows/obj +dev/test +skia/renderer/build +skia/viewer/build/windows/dependencies/imgui +skia/viewer/build/windows/dependencies/gl3w +skia/viewer/build/windows/dependencies/skia +skia/viewer/build/windows/dependencies/glfw +skia/viewer/build/windows/dependencies/glfw_build +skia/viewer/build/windows/obj +skia/viewer/build/windows/*.sln +skia/viewer/build/windows/*.vcxproj +skia/viewer/build/windows/*.vcxproj.filters +skia/viewer/build/*.sln +skia/viewer/build/*.vcxproj +skia/viewer/build/*.vcxproj.filters +*.pdb
diff --git a/skia/viewer/build/windows/build.bat b/skia/viewer/build/windows/build.bat new file mode 100644 index 0000000..4592d62 --- /dev/null +++ b/skia/viewer/build/windows/build.bat
@@ -0,0 +1,72 @@ +@echo off + set "DEPENDENCIES_DIR=%cd%\dependencies" +set "BAT_DIR=%cd%" + +if not exist "%DEPENDENCIES_DIR%\bin\premake5.exe" ( + pushd "%DEPENDENCIES_DIR%" + call .\get_premake5.bat || goto :error + popd +) +if not exist "%DEPENDENCIES_DIR%\skia" goto :get_skia +if "%FORCE_BUILD%"=="true" goto :get_skia +goto :got_skia + +:get_skia +pushd "%DEPENDENCIES_DIR%" +call .\get_skia.bat || goto :error +popd + +:got_skia + +if not exist "%DEPENDENCIES_DIR%\skia\out\static\skia.lib" goto :build_skia +if "%FORCE_BUILD%"=="true" goto :build_skia +goto :built_skia + +:build_skia +pushd "%DEPENDENCIES_DIR%" +call .\make_skia.bat || goto :error +popd + +:built_skia + +if not exist "%DEPENDENCIES_DIR%\skia" ( + pushd "%DEPENDENCIES_DIR%" + call .\get_skia.bat || goto :error + popd +) + +if not exist "%DEPENDENCIES_DIR%\gl3w" ( + pushd "%DEPENDENCIES_DIR%" + call .\make_gl3w.bat || goto :error + popd +) + +if not exist "%DEPENDENCIES_DIR%\imgui" ( + pushd "%DEPENDENCIES_DIR%" + call .\get_imgui.bat || goto :error + popd +) + +export "MSBuild=%ProgramFiles%\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe" + +if not exist "%DEPENDENCIES_DIR%\glfw" ( + pushd "%DEPENDENCIES_DIR%" + call .\make_glfw.bat || goto :error + popd +) + +set "PREMAKE=%DEPENDENCIES_DIR%\bin\premake5.exe" +%PREMAKE% --file=premake5_win.lua vs2022 + +call "%MSBuild%" rive.sln + +if not exist "%BAT_DIR%\..\..\..\package\Runtime\Libraries\Windows" mkdir %BAT_DIR%\..\..\..\package\Runtime\Libraries\Windows +copy .\bin\debug\rive.dll %BAT_DIR%\..\..\..\package\Runtime\Libraries\Windows\rive.dll + +goto :end + +:error +echo Failed with error #%errorlevel%. +exit /b %errorlevel% + +:end \ No newline at end of file
diff --git a/skia/viewer/build/windows/dependencies/get_imgui.bat b/skia/viewer/build/windows/dependencies/get_imgui.bat new file mode 100644 index 0000000..d93b0dc --- /dev/null +++ b/skia/viewer/build/windows/dependencies/get_imgui.bat
@@ -0,0 +1,12 @@ +@echo off +if not exist ".\imgui" ( + git clone https://github.com/ocornut/imgui imgui +) else ( + pushd imgui + git fetch + git pull + popd +) +pushd .\imgui +git checkout master +popd
diff --git a/skia/viewer/build/windows/dependencies/get_premake5.bat b/skia/viewer/build/windows/dependencies/get_premake5.bat new file mode 100644 index 0000000..586fcad --- /dev/null +++ b/skia/viewer/build/windows/dependencies/get_premake5.bat
@@ -0,0 +1,10 @@ +@echo off +if not exist ".\bin" mkdir bin +echo Downloading Premake5 +curl https://github.com/premake/premake-core/releases/download/v5.0.0-beta1/premake-5.0.0-beta1-windows.zip -L -o .\bin\premake_windows.zip +pushd bin +:: Export premake5 into bin +tar -xf premake_windows.zip +:: Delete downloaded archive +del premake_windows.zip +popd \ No newline at end of file
diff --git a/skia/viewer/build/windows/dependencies/get_skia.bat b/skia/viewer/build/windows/dependencies/get_skia.bat new file mode 100644 index 0000000..d85d4e9 --- /dev/null +++ b/skia/viewer/build/windows/dependencies/get_skia.bat
@@ -0,0 +1,13 @@ +@echo off +if not exist ".\skia" ( + git clone https://github.com/google/skia skia +) else ( + pushd skia + git fetch + git pull + popd +) +pushd .\skia +git checkout chrome/m99 +python3 tools/git-sync-deps +popd \ No newline at end of file
diff --git a/skia/viewer/build/windows/dependencies/make_gl3w.bat b/skia/viewer/build/windows/dependencies/make_gl3w.bat new file mode 100644 index 0000000..5b2ae02 --- /dev/null +++ b/skia/viewer/build/windows/dependencies/make_gl3w.bat
@@ -0,0 +1,16 @@ +@echo off +if not exist ".\gl3w" ( + git clone https://github.com/skaslev/gl3w gl3w +) else ( + cd gl3w + git fetch + git pull +) +pushd .\gl3w +if not exist ".\build" mkdir build +pushd build +cmake ../ +set "MSBuild=%ProgramFiles%\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe" +call "%MSBuild%" gl3w.sln +popd +popd \ No newline at end of file
diff --git a/skia/viewer/build/windows/dependencies/make_glfw.bat b/skia/viewer/build/windows/dependencies/make_glfw.bat new file mode 100644 index 0000000..8841102 --- /dev/null +++ b/skia/viewer/build/windows/dependencies/make_glfw.bat
@@ -0,0 +1,20 @@ +@echo off +if not exist ".\glfw" ( + git clone https://github.com/glfw/glfw glfw +) else ( + pushd glfw + git fetch + git pull + popd +) +pushd .\glfw +git checkout master +popd + +mkdir -p glfw_build +cd glfw_build +cmake ../glfw -DBUILD_SHARED_LIBS=OFF +rem Force compile with /MT, GLFW defaults to /MDd but the rest of our libs expect /MT +set _CL_=/MT +call "%MSBuild%" GLFW.sln +
diff --git a/skia/viewer/build/windows/dependencies/make_skia.bat b/skia/viewer/build/windows/dependencies/make_skia.bat new file mode 100644 index 0000000..2c5aada --- /dev/null +++ b/skia/viewer/build/windows/dependencies/make_skia.bat
@@ -0,0 +1,99 @@ +@echo off +cd skia +set clang_win = "C:\Program Files\LLVM" +set COMPILER_FLAGS = ^ + \"-Wno-c++98-compat\",^ + \"-Wno-c++98-compat-pedantic\",^ + \"-Wno-reserved-macro-identifier\",^ + \"-Wno-newline-eof\",^ + \"-Wno-old-style-cast\",^ + \"-Wno-unused-parameter\",^ + \"-Wno-float-equal\",^ + \"-Wno-implicit-float-conversion\",^ + \"-Wno-shadow\",^ + \"-Wno-sign-conversion\",^ + \"-Wno-inconsistent-missing-destructor-override\",^ + \"-Wno-nested-anon-types\",^ + \"-Wno-suggest-destructor-override\",^ + \"-Wno-non-virtual-dtor\",^ + \"-Wno-unknown-argument\",^ + \"-Wno-gnu-anonymous-struct\",^ + \"-Wno-extra-semi\",^ + \"-Wno-cast-qual\",^ + \"-Wno-ignored-qualifiers\",^ + \"-Wno-double-promotion\",^ + \"-Wno-tautological-unsigned-zero-compare\",^ + \"-Wno-unreachable-code-break\",^ + \"-Wno-global-constructors\",^ + \"-Wno-switch-enum\",^ + \"-Wno-shorten-64-to-32\",^ + \"-Wno-missing-prototypes\",^ + \"-Wno-implicit-int-conversion\",^ + \"-Wno-unused-macros\",^ + \"-Wno-deprecated-copy-with-user-provided-dtor\",^ + \"-Wno-missing-variable-declarations\",^ + \"-Wno-ctad-maybe-unsupported\",^ + \"-Wno-vla-extension\",^ + \"-Wno-float-conversion\",^ + \"-Wno-gnu-zero-variadic-macro-arguments\",^ + \"-Wno-undef\",^ + \"-Wno-documentation\",^ + \"-Wno-documentation-pedantic\",^ + \"-Wno-documentation-unknown-command\",^ + \"-Wno-suggest-override\",^ + \"-Wno-unused-exception-parameter\",^ + \"-Wno-cast-align\",^ + \"-Wno-deprecated-declarations\",^ + \"-Wno-shadow-field\",^ + \"-Wno-nonportable-system-include-path\",^ + \"-Wno-reserved-identifier\",^ + \"-Wno-thread-safety-negative\",^ + \"-Wno-exit-time-destructors\",^ + \"-Wno-unreachable-code\",^ + \"-Wno-zero-as-null-pointer-constant\",^ + \"-Wno-pedantic\",^ + \"-Wno-sign-compare\",^ + \"-fno-rtti\",^ + \"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", ^ + \"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", ^ + \"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", ^ + \"-DSK_DISABLE_AAA\", ^ + \"-DSK_DISABLE_EFFECT_DESERIALIZATION\", ^ + \"/MT" + +set ARGS=extra_cflags=[%COMPILER_FLAGS%] ^ + is_official_build=false^ + skia_use_gl=true^ + skia_use_zlib=true^ + skia_enable_gpu=true^ + skia_enable_fontmgr_empty=false^ + skia_use_libpng_encode=false^ + skia_use_libpng_decode=true^ + skia_enable_skgpu_v1=true^ + skia_use_dng_sdk=false^ + skia_use_egl=false^ + skia_use_expat=false^ + skia_use_fontconfig=false^ + skia_use_freetype=false^ + skia_use_icu=false^ + skia_use_libheif=false^ + skia_use_system_libpng=false^ + skia_use_libjpeg_turbo_encode=false^ + skia_use_libjpeg_turbo_decode=false^ + skia_use_libwebp_encode=false^ + skia_use_libwebp_decode=false^ + skia_use_lua=false^ + skia_use_piex=false^ + skia_use_vulkan=false^ + skia_use_metal=false^ + skia_use_angle=false^ + skia_use_direct3d=false^ + skia_use_system_zlib=false^ + skia_enable_spirv_validation=false^ + skia_enable_pdf=false^ + skia_enable_skottie=false^ + skia_enable_tools=false + +bin\gn gen out\static --type=static_library --args="%ARGS%" +ninja -C out\static +cd .. \ No newline at end of file
diff --git a/skia/viewer/build/windows/premake5_win.lua b/skia/viewer/build/windows/premake5_win.lua new file mode 100644 index 0000000..d0a8975 --- /dev/null +++ b/skia/viewer/build/windows/premake5_win.lua
@@ -0,0 +1,59 @@ +workspace "rive" +configurations { "debug", "release" } + +project "rive_viewer" +kind "ConsoleApp" +language "C++" +cppdialect "C++17" +toolset "clang" +targetdir "bin/%{cfg.buildcfg}" +objdir "obj/%{cfg.buildcfg}" + +skia = "dependencies/skia" +gl3w = "dependencies/gl3w/build" +rive = "../../../../" +imgui = "dependencies/imgui" +glfw_build = "dependencies/glfw_build/src" +glfw = "dependencies/glfw" + +includedirs { "../include", skia, skia .. "/include/core", skia .. "/include/effects", skia .. "/include/gpu", + skia .. "/include/config", gl3w .. "/include", rive .. "/include", rive .. "/skia/renderer/include", imgui, glfw .. "/include", "dependencies" } +libdirs { skia .. "/out/static" } + +links { "skia", "glfw3", "opengl32" } +libdirs { "../../../build/bin/%{cfg.buildcfg}", glfw_build .. "/Debug", + "../../dependencies/skia/out/static", "../../renderer/build/bin/%{cfg.buildcfg}" } + +files { "../../src/**.cpp", rive .. "/src/**.cpp", rive .. "/skia/renderer/src/**.cpp", gl3w .. "/src/gl3w.c", + imgui .. "/backends/imgui_impl_glfw.cpp", + imgui .. "/backends/imgui_impl_opengl3.cpp", imgui .. "/imgui_widgets.cpp", + imgui .. "/imgui.cpp", imgui .. "/imgui_tables.cpp", + imgui .. "/imgui_draw.cpp" } + +defines { "_USE_MATH_DEFINES", "NOMINMAX" } +architecture("x86_64") +buildoptions { "/MT", "-Wno-c++98-compat", "-Wno-unused-template", "-Wno-c++98-compat-pedantic", + "-Wno-reserved-macro-identifier", "-Wno-newline-eof", "-Wno-old-style-cast", "-Wno-unused-parameter", + "-Wno-float-equal", "-Wno-implicit-float-conversion", "-Wno-shadow", "-Wno-sign-conversion", + "-Wno-inconsistent-missing-destructor-override", "-Wno-nested-anon-types", + "-Wno-suggest-destructor-override", "-Wno-non-virtual-dtor", "-Wno-unknown-argument", + "-Wno-gnu-anonymous-struct", "-Wno-extra-semi", "-Wno-cast-qual", "-Wno-ignored-qualifiers", + "-Wno-double-promotion", "-Wno-tautological-unsigned-zero-compare", "-Wno-unreachable-code-break", + "-Wno-global-constructors", "-Wno-switch-enum", "-Wno-shorten-64-to-32", "-Wno-missing-prototypes", + "-Wno-implicit-int-conversion", "-Wno-unused-macros", "-Wno-deprecated-copy-with-user-provided-dtor", + "-Wno-missing-variable-declarations", "-Wno-ctad-maybe-unsupported", "-Wno-vla-extension", + "-Wno-float-conversion", "-Wno-gnu-zero-variadic-macro-arguments", "-Wno-undef", "-Wno-documentation", + "-Wno-documentation-pedantic", "-Wno-documentation-unknown-command", "-Wno-suggest-override", + "-Wno-unused-exception-parameter", "-Wno-cast-align", "-Wno-deprecated-declarations", "-Wno-shadow-field", + "-Wno-nonportable-system-include-path", "-Wno-reserved-identifier", "-Wno-thread-safety-negative", + "-Wno-exit-time-destructors", "-Wno-unreachable-code", "-Wno-zero-as-null-pointer-constant", + "-Wno-pedantic", "-Wno-sign-compare", "-Wall", "-fno-exceptions", "-fno-rtti", "-g" } +filter "configurations:debug" +defines { "DEBUG" } +symbols "On" + +filter "configurations:release" + +defines { "RELEASE" } +defines { "NDEBUG" } +optimize "On"