Skip to content

Commit 9d743d1

Browse files
committed
Adding support for windows viewer build.
1 parent 8048c63 commit 9d743d1

File tree

10 files changed

+325
-3
lines changed

10 files changed

+325
-3
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,19 @@ skia/**/build/android
8181
/build/macosx
8282
/build/android
8383
/skia/dependencies/skia_rive_optimized
84+
build/windows/obj
85+
dev/test
86+
skia/renderer/build
87+
skia/viewer/build/windows/dependencies/imgui
88+
skia/viewer/build/windows/dependencies/gl3w
89+
skia/viewer/build/windows/dependencies/skia
90+
skia/viewer/build/windows/dependencies/glfw
91+
skia/viewer/build/windows/dependencies/glfw_build
92+
skia/viewer/build/windows/obj
93+
skia/viewer/build/windows/*.sln
94+
skia/viewer/build/windows/*.vcxproj
95+
skia/viewer/build/windows/*.vcxproj.filters
96+
skia/viewer/build/*.sln
97+
skia/viewer/build/*.vcxproj
98+
skia/viewer/build/*.vcxproj.filters
99+
*.pdb
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
@echo off
2+
set "DEPENDENCIES_DIR=%cd%\dependencies"
3+
set "BAT_DIR=%cd%"
4+
5+
if not exist "%DEPENDENCIES_DIR%\bin\premake5.exe" (
6+
pushd "%DEPENDENCIES_DIR%"
7+
call .\get_premake5.bat || goto :error
8+
popd
9+
)
10+
if not exist "%DEPENDENCIES_DIR%\skia" goto :get_skia
11+
if "%FORCE_BUILD%"=="true" goto :get_skia
12+
goto :got_skia
13+
14+
:get_skia
15+
pushd "%DEPENDENCIES_DIR%"
16+
call .\get_skia.bat || goto :error
17+
popd
18+
19+
:got_skia
20+
21+
if not exist "%DEPENDENCIES_DIR%\skia\out\static\skia.lib" goto :build_skia
22+
if "%FORCE_BUILD%"=="true" goto :build_skia
23+
goto :built_skia
24+
25+
:build_skia
26+
pushd "%DEPENDENCIES_DIR%"
27+
call .\make_skia.bat || goto :error
28+
popd
29+
30+
:built_skia
31+
32+
if not exist "%DEPENDENCIES_DIR%\skia" (
33+
pushd "%DEPENDENCIES_DIR%"
34+
call .\get_skia.bat || goto :error
35+
popd
36+
)
37+
38+
if not exist "%DEPENDENCIES_DIR%\gl3w" (
39+
pushd "%DEPENDENCIES_DIR%"
40+
call .\make_gl3w.bat || goto :error
41+
popd
42+
)
43+
44+
if not exist "%DEPENDENCIES_DIR%\imgui" (
45+
pushd "%DEPENDENCIES_DIR%"
46+
call .\get_imgui.bat || goto :error
47+
popd
48+
)
49+
50+
export "MSBuild=%ProgramFiles%\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe"
51+
52+
if not exist "%DEPENDENCIES_DIR%\glfw" (
53+
pushd "%DEPENDENCIES_DIR%"
54+
call .\make_glfw.bat || goto :error
55+
popd
56+
)
57+
58+
set "PREMAKE=%DEPENDENCIES_DIR%\bin\premake5.exe"
59+
%PREMAKE% --file=premake5_win.lua vs2022
60+
61+
call "%MSBuild%" rive.sln
62+
63+
if not exist "%BAT_DIR%\..\..\..\package\Runtime\Libraries\Windows" mkdir %BAT_DIR%\..\..\..\package\Runtime\Libraries\Windows
64+
copy .\bin\debug\rive.dll %BAT_DIR%\..\..\..\package\Runtime\Libraries\Windows\rive.dll
65+
66+
goto :end
67+
68+
:error
69+
echo Failed with error #%errorlevel%.
70+
exit /b %errorlevel%
71+
72+
:end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@echo off
2+
if not exist ".\imgui" (
3+
git clone https://github.com/ocornut/imgui imgui
4+
) else (
5+
pushd imgui
6+
git fetch
7+
git pull
8+
popd
9+
)
10+
pushd .\imgui
11+
git checkout master
12+
popd
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@echo off
2+
if not exist ".\bin" mkdir bin
3+
echo Downloading Premake5
4+
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
5+
pushd bin
6+
:: Export premake5 into bin
7+
tar -xf premake_windows.zip
8+
:: Delete downloaded archive
9+
del premake_windows.zip
10+
popd
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@echo off
2+
if not exist ".\skia" (
3+
git clone https://github.com/google/skia skia
4+
) else (
5+
pushd skia
6+
git fetch
7+
git pull
8+
popd
9+
)
10+
pushd .\skia
11+
git checkout chrome/m99
12+
python3 tools/git-sync-deps
13+
popd
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
if not exist ".\gl3w" (
3+
git clone https://github.com/skaslev/gl3w gl3w
4+
) else (
5+
cd gl3w
6+
git fetch
7+
git pull
8+
)
9+
pushd .\gl3w
10+
if not exist ".\build" mkdir build
11+
pushd build
12+
cmake ../
13+
set "MSBuild=%ProgramFiles%\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe"
14+
call "%MSBuild%" gl3w.sln
15+
popd
16+
popd
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@echo off
2+
if not exist ".\glfw" (
3+
git clone https://github.com/glfw/glfw glfw
4+
) else (
5+
pushd glfw
6+
git fetch
7+
git pull
8+
popd
9+
)
10+
pushd .\glfw
11+
git checkout master
12+
popd
13+
14+
mkdir -p glfw_build
15+
cd glfw_build
16+
cmake ../glfw -DBUILD_SHARED_LIBS=OFF
17+
rem Force compile with /MT, GLFW defaults to /MDd but the rest of our libs expect /MT
18+
set _CL_=/MT
19+
call "%MSBuild%" GLFW.sln
20+
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
@echo off
2+
cd skia
3+
set clang_win = "C:\Program Files\LLVM"
4+
set COMPILER_FLAGS = ^
5+
\"-Wno-c++98-compat\",^
6+
\"-Wno-c++98-compat-pedantic\",^
7+
\"-Wno-reserved-macro-identifier\",^
8+
\"-Wno-newline-eof\",^
9+
\"-Wno-old-style-cast\",^
10+
\"-Wno-unused-parameter\",^
11+
\"-Wno-float-equal\",^
12+
\"-Wno-implicit-float-conversion\",^
13+
\"-Wno-shadow\",^
14+
\"-Wno-sign-conversion\",^
15+
\"-Wno-inconsistent-missing-destructor-override\",^
16+
\"-Wno-nested-anon-types\",^
17+
\"-Wno-suggest-destructor-override\",^
18+
\"-Wno-non-virtual-dtor\",^
19+
\"-Wno-unknown-argument\",^
20+
\"-Wno-gnu-anonymous-struct\",^
21+
\"-Wno-extra-semi\",^
22+
\"-Wno-cast-qual\",^
23+
\"-Wno-ignored-qualifiers\",^
24+
\"-Wno-double-promotion\",^
25+
\"-Wno-tautological-unsigned-zero-compare\",^
26+
\"-Wno-unreachable-code-break\",^
27+
\"-Wno-global-constructors\",^
28+
\"-Wno-switch-enum\",^
29+
\"-Wno-shorten-64-to-32\",^
30+
\"-Wno-missing-prototypes\",^
31+
\"-Wno-implicit-int-conversion\",^
32+
\"-Wno-unused-macros\",^
33+
\"-Wno-deprecated-copy-with-user-provided-dtor\",^
34+
\"-Wno-missing-variable-declarations\",^
35+
\"-Wno-ctad-maybe-unsupported\",^
36+
\"-Wno-vla-extension\",^
37+
\"-Wno-float-conversion\",^
38+
\"-Wno-gnu-zero-variadic-macro-arguments\",^
39+
\"-Wno-undef\",^
40+
\"-Wno-documentation\",^
41+
\"-Wno-documentation-pedantic\",^
42+
\"-Wno-documentation-unknown-command\",^
43+
\"-Wno-suggest-override\",^
44+
\"-Wno-unused-exception-parameter\",^
45+
\"-Wno-cast-align\",^
46+
\"-Wno-deprecated-declarations\",^
47+
\"-Wno-shadow-field\",^
48+
\"-Wno-nonportable-system-include-path\",^
49+
\"-Wno-reserved-identifier\",^
50+
\"-Wno-thread-safety-negative\",^
51+
\"-Wno-exit-time-destructors\",^
52+
\"-Wno-unreachable-code\",^
53+
\"-Wno-zero-as-null-pointer-constant\",^
54+
\"-Wno-pedantic\",^
55+
\"-Wno-sign-compare\",^
56+
\"-fno-rtti\",^
57+
\"-DSK_DISABLE_LEGACY_SHADERCONTEXT\", ^
58+
\"-DSK_DISABLE_LOWP_RASTER_PIPELINE\", ^
59+
\"-DSK_FORCE_RASTER_PIPELINE_BLITTER\", ^
60+
\"-DSK_DISABLE_AAA\", ^
61+
\"-DSK_DISABLE_EFFECT_DESERIALIZATION\", ^
62+
\"/MT"
63+
64+
set ARGS=extra_cflags=[%COMPILER_FLAGS%] ^
65+
is_official_build=false^
66+
skia_use_gl=true^
67+
skia_use_zlib=true^
68+
skia_enable_gpu=true^
69+
skia_enable_fontmgr_empty=false^
70+
skia_use_libpng_encode=false^
71+
skia_use_libpng_decode=true^
72+
skia_enable_skgpu_v1=true^
73+
skia_use_dng_sdk=false^
74+
skia_use_egl=false^
75+
skia_use_expat=false^
76+
skia_use_fontconfig=false^
77+
skia_use_freetype=false^
78+
skia_use_icu=false^
79+
skia_use_libheif=false^
80+
skia_use_system_libpng=false^
81+
skia_use_libjpeg_turbo_encode=false^
82+
skia_use_libjpeg_turbo_decode=false^
83+
skia_use_libwebp_encode=false^
84+
skia_use_libwebp_decode=false^
85+
skia_use_lua=false^
86+
skia_use_piex=false^
87+
skia_use_vulkan=false^
88+
skia_use_metal=false^
89+
skia_use_angle=false^
90+
skia_use_direct3d=false^
91+
skia_use_system_zlib=false^
92+
skia_enable_spirv_validation=false^
93+
skia_enable_pdf=false^
94+
skia_enable_skottie=false^
95+
skia_enable_tools=false
96+
97+
bin\gn gen out\static --type=static_library --args="%ARGS%"
98+
ninja -C out\static
99+
cd ..
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
workspace "rive"
2+
configurations { "debug", "release" }
3+
4+
project "rive_viewer"
5+
kind "ConsoleApp"
6+
language "C++"
7+
cppdialect "C++17"
8+
toolset "clang"
9+
targetdir "bin/%{cfg.buildcfg}"
10+
objdir "obj/%{cfg.buildcfg}"
11+
12+
skia = "dependencies/skia"
13+
gl3w = "dependencies/gl3w/build"
14+
rive = "../../../../"
15+
imgui = "dependencies/imgui"
16+
glfw_build = "dependencies/glfw_build/src"
17+
glfw = "dependencies/glfw"
18+
19+
includedirs { "../include", skia, skia .. "/include/core", skia .. "/include/effects", skia .. "/include/gpu",
20+
skia .. "/include/config", gl3w .. "/include", rive .. "/include", rive .. "/skia/renderer/include", imgui, glfw .. "/include", "dependencies" }
21+
libdirs { skia .. "/out/static" }
22+
23+
links { "skia", "glfw3", "opengl32" }
24+
libdirs { "../../../build/bin/%{cfg.buildcfg}", glfw_build .. "/Debug",
25+
"../../dependencies/skia/out/static", "../../renderer/build/bin/%{cfg.buildcfg}" }
26+
27+
files { "../../src/**.cpp", rive .. "/src/**.cpp", rive .. "/skia/renderer/src/**.cpp", gl3w .. "/src/gl3w.c",
28+
imgui .. "/backends/imgui_impl_glfw.cpp",
29+
imgui .. "/backends/imgui_impl_opengl3.cpp", imgui .. "/imgui_widgets.cpp",
30+
imgui .. "/imgui.cpp", imgui .. "/imgui_tables.cpp",
31+
imgui .. "/imgui_draw.cpp" }
32+
33+
defines { "_USE_MATH_DEFINES", "NOMINMAX" }
34+
architecture("x86_64")
35+
buildoptions { "/MT", "-Wno-c++98-compat", "-Wno-unused-template", "-Wno-c++98-compat-pedantic",
36+
"-Wno-reserved-macro-identifier", "-Wno-newline-eof", "-Wno-old-style-cast", "-Wno-unused-parameter",
37+
"-Wno-float-equal", "-Wno-implicit-float-conversion", "-Wno-shadow", "-Wno-sign-conversion",
38+
"-Wno-inconsistent-missing-destructor-override", "-Wno-nested-anon-types",
39+
"-Wno-suggest-destructor-override", "-Wno-non-virtual-dtor", "-Wno-unknown-argument",
40+
"-Wno-gnu-anonymous-struct", "-Wno-extra-semi", "-Wno-cast-qual", "-Wno-ignored-qualifiers",
41+
"-Wno-double-promotion", "-Wno-tautological-unsigned-zero-compare", "-Wno-unreachable-code-break",
42+
"-Wno-global-constructors", "-Wno-switch-enum", "-Wno-shorten-64-to-32", "-Wno-missing-prototypes",
43+
"-Wno-implicit-int-conversion", "-Wno-unused-macros", "-Wno-deprecated-copy-with-user-provided-dtor",
44+
"-Wno-missing-variable-declarations", "-Wno-ctad-maybe-unsupported", "-Wno-vla-extension",
45+
"-Wno-float-conversion", "-Wno-gnu-zero-variadic-macro-arguments", "-Wno-undef", "-Wno-documentation",
46+
"-Wno-documentation-pedantic", "-Wno-documentation-unknown-command", "-Wno-suggest-override",
47+
"-Wno-unused-exception-parameter", "-Wno-cast-align", "-Wno-deprecated-declarations", "-Wno-shadow-field",
48+
"-Wno-nonportable-system-include-path", "-Wno-reserved-identifier", "-Wno-thread-safety-negative",
49+
"-Wno-exit-time-destructors", "-Wno-unreachable-code", "-Wno-zero-as-null-pointer-constant",
50+
"-Wno-pedantic", "-Wno-sign-compare", "-Wall", "-fno-exceptions", "-fno-rtti", "-g" }
51+
filter "configurations:debug"
52+
defines { "DEBUG" }
53+
symbols "On"
54+
55+
filter "configurations:release"
56+
57+
defines { "RELEASE" }
58+
defines { "NDEBUG" }
59+
optimize "On"

skia/viewer/src/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,20 @@ void glfwDropCallback(GLFWwindow* window, int count, const char** paths) {
105105
// Just get the last dropped file for now...
106106
filename = paths[count - 1];
107107

108-
FILE* fp = fopen(filename.c_str(), "r");
108+
FILE* fp = fopen(filename.c_str(), "rb");
109109
fseek(fp, 0, SEEK_END);
110110
fileBytesLength = ftell(fp);
111111
fseek(fp, 0, SEEK_SET);
112112
delete[] fileBytes;
113113
fileBytes = new uint8_t[fileBytesLength];
114-
if (fread(fileBytes, 1, fileBytesLength, fp) != fileBytesLength) {
114+
auto read = fread(fileBytes, 1, fileBytesLength, fp);
115+
if (read != fileBytesLength) {
115116
delete[] fileBytes;
116-
fprintf(stderr, "failed to read all of %s\n", filename.c_str());
117+
fprintf(stderr,
118+
"failed to read all of %s (%d of %d)\n",
119+
filename.c_str(),
120+
read,
121+
fileBytesLength);
117122
return;
118123
}
119124
initAnimation(0);

0 commit comments

Comments
 (0)