Skip to content

Commit 05ba461

Browse files
committed
wip: compile on windows
1 parent 17665e4 commit 05ba461

File tree

10 files changed

+95
-5
lines changed

10 files changed

+95
-5
lines changed

common/src/render.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include <sys/types.h>
66
#include <sys/stat.h>
77
#include <cstdio>
8+
#if defined(linux) || defined(__linux) || defined(__linux__)
89
#include <unistd.h>
10+
#endif
911
#include <fcntl.h>
1012

1113
#include <cstdint>

skia/build_cpp_windows.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -ev
3+
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
4+
cd "$here"
5+
6+
./cmakelists.dhall
7+
8+
generate_buildinfo() {
9+
echo -en "#pragma once\nnamespace buildinfo {\n static const char *gitCommit=\""
10+
git log -1 --pretty=format:"%H" | tr -d "\n"
11+
echo -en "\";\n static const bool gitDirty="
12+
if [[ $(git diff --stat) != '' ]]; then
13+
echo -n "true"
14+
else
15+
echo -n "false"
16+
fi
17+
echo -en ";\n}\n"
18+
}
19+
generate_buildinfo > "$here/imzero_client_skia_sdl3_impl/buildinfo.gen.h"
20+
21+
mkdir -p build
22+
cd build
23+
cmake -DCMAKE_C_COMPILER="clang" \
24+
-DCMAKE_CXX_COMPILER="clang++" \
25+
-G "Unix Makefiles" \
26+
../CMakeLists.txt
27+
make -j

skia/build_windows.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -ev
3+
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
4+
cd "$here"
5+
source "env.sh"
6+
export IMZERO_CLIENT_CPP_ROOT="$(realpath "$here")"
7+
export IMGUI_SKIA_CPP_ROOT="$(realpath "$here/..")"
8+
#./copy_libs_windows.sh
9+
./build_cpp_windows.sh
10+
#./build_go.sh
11+
rm -rf bin
12+
mkdir -p bin
13+
#mv build/imzeroClientSkiaSdl3Impl* bin/imgui_skia_exe
14+
15+
#mkdir -p .vscode
16+
#./vscode.dhall

skia/dhall/sourceTreeParts.dhall

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ let imzeroClientSkiaSdl3Impl =
258258
, includeDirs = {
259259
, local = [
260260
, "${dir}"
261+
, "${dir}/../../../contrib/qoi"
261262
]
262263
, global = [] : List Text
263264
}

skia/imzero_client_skia_sdl3_impl/imzero_client_skia_sdl3_app.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void *qoiMalloc(const size_t sz) {
6868
assert(lastSz == sz && "assuming constant width, height and depth of qoi images");
6969
return qoiBuffer;
7070
}
71-
#include "../contrib/qoi/qoi.h"
71+
#include "qoi.h"
7272

7373
template <typename T>
7474
static void applyFlag(int &flag,T val,bool v) {
@@ -635,6 +635,7 @@ void ImZeroClient::App::setup(ImZeroCliOptions &opts) {
635635
fFffiOutFile = stdout;
636636
// setup skia/imgui shared objects
637637
if (opts.fFffiInterpreter) {
638+
#if defined(linux) || defined(__linux) || defined(__linux__)
638639
if (opts.fFffiInFile != nullptr) {
639640
fFffiInFile = fopen(opts.fFffiInFile, "rw");
640641
if (fFffiInFile == nullptr) {
@@ -651,6 +652,9 @@ void ImZeroClient::App::setup(ImZeroCliOptions &opts) {
651652
}
652653
setvbuf(fFffiOutFile, nullptr, _IONBF, 0);
653654
}
655+
#else
656+
// FIXME TODO
657+
#endif
654658
}
655659
}
656660
fFffiInterpreter = opts.fFffiInterpreter;
@@ -711,7 +715,11 @@ int ImZeroClient::App::mainLoopHeadless(const ImZeroCliOptions &opts, ImVec4 con
711715

712716
if(opts.fVideoUserInteractionEventsFile != nullptr && opts.fVideoUserInteractionEventsFile[0] != '\0') {
713717
// RDWR: having at least one writer will prevent SIG_PIPE
718+
#if defined(linux) || defined(__linux) || defined(__linux__)
714719
fUserInteractionFd = open(opts.fVideoUserInteractionEventsFile, O_RDWR | O_NONBLOCK);
720+
#else
721+
// FIXME TODO
722+
#endif
715723
if(fUserInteractionFd == -1) {
716724
fprintf(stderr, "unable to open user interaction events in file %s: %s\n", opts.fVideoUserInteractionEventsFile, strerror(errno));
717725
return 1;
@@ -1062,7 +1070,11 @@ void ImZeroClient::App::videoPaint(SkCanvas* canvas, int width, int height) { Zo
10621070
}
10631071
ImZeroClient::App::~App() {
10641072
if(fDispatchInteractionEvents) {
1073+
#if defined(linux) || defined(__linux) || defined(__linux__)
10651074
close(fUserInteractionFd);
1075+
#else
1076+
// FIXME TODO
1077+
#endif
10661078
fDispatchInteractionEvents = false;
10671079
}
10681080
}
@@ -1113,10 +1125,15 @@ void ImZeroClient::App::dispatchUserInteractionEventsBinary() {
11131125
break;
11141126
case 1: // read message length
11151127
{
1128+
#if defined(linux) || defined(__linux) || defined(__linux__)
11161129
auto r = read(fUserInteractionFd,p,bytesToRead);
11171130
if(r <= 0) {
11181131
return;
11191132
}
1133+
#else
1134+
// FIXME TODO
1135+
int r = 0;
1136+
#endif
11201137
bytesToRead -= r;
11211138
p += r;
11221139
if(bytesToRead == 0) {
@@ -1133,7 +1150,12 @@ void ImZeroClient::App::dispatchUserInteractionEventsBinary() {
11331150
break;
11341151
case 2: // read message
11351152
{
1153+
#if defined(linux) || defined(__linux) || defined(__linux__)
11361154
auto r = read(fUserInteractionFd,p,bytesToRead);
1155+
#else
1156+
// FIXME TODO
1157+
int r = 0;
1158+
#endif
11371159
bytesToRead -= r;
11381160
p += r;
11391161
if(bytesToRead == 0) {
@@ -1325,7 +1347,12 @@ void ImZeroClient::App::dispatchUserInteractionEventsFB() {
13251347
break;
13261348
case 1: // read flatbuffers message length
13271349
{
1350+
#if defined(linux) || defined(__linux) || defined(__linux__)
13281351
auto r = read(fUserInteractionFd,p,bytesToRead);
1352+
#else
1353+
// FIXME TODO
1354+
int r = 0;
1355+
#endif
13291356
if(r <= 0) {
13301357
return;
13311358
}
@@ -1346,7 +1373,12 @@ void ImZeroClient::App::dispatchUserInteractionEventsFB() {
13461373
case 2: // read flatbuffers message
13471374
{
13481375
//fprintf(stderr, "reading message of size %d\n", (int)bytesToRead);
1376+
#if defined(linux) || defined(__linux) || defined(__linux__)
13491377
auto r = read(fUserInteractionFd,p,bytesToRead);
1378+
#else
1379+
// FIXME TODO
1380+
int r = 0;
1381+
#endif
13501382
bytesToRead -= r;
13511383
p += r;
13521384
if(bytesToRead == 0) {
@@ -1490,4 +1522,4 @@ ImZeroClient::App::App() {
14901522
fPreviousTime = 0.0;
14911523
fOutputFormat = kRawFrameOutputFormat_None;
14921524
fUserInteractionFd = 0;
1493-
}
1525+
}

skia/imzero_client_skia_sdl3_impl/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
#include <SDL3/SDL_main.h>
12
#include "imzero_client_skia_sdl3_app.h"
23
#include "imzero_client_skia_sdl3_cli_options.h"
34

5+
#if defined(linux) || defined(__linux) || defined(__linux__)
46
#include <sys/prctl.h>
7+
#endif
58
#ifdef TRACY_ENABLE
69
#include <cstdlib>
710
#include "tracy/Tracy.hpp"
@@ -39,7 +42,7 @@ void operator delete(void* ptr) noexcept {
3942
#endif
4043
#endif
4144

42-
int main(const int argc, const char** argv) {
45+
int SDL_main(const int argc, const char** argv) {
4346
#ifdef TRACY_ENABLE
4447
ImGui::SetAllocatorFunctions(imZeroMemAlloc,imZeroMemFree,nullptr);
4548
#endif
@@ -53,10 +56,12 @@ int main(const int argc, const char** argv) {
5356
opts.parse(argc, argv, stderr, usedFlags);
5457
opts.checkConsistency(argc, argv, stderr, usedFlags);
5558

59+
#if defined(linux) || defined(__linux) || defined(__linux__)
5660
if (0 > prctl(PR_SET_DUMPABLE, opts.fCoreDump ? 1 : 0)) {
5761
perror("unable to set prctl(PR_SET_DUMPABLE)");
5862
return 1;
5963
}
64+
#endif
6065

6166
ImZeroClient::App app{};
6267
app.setup(opts);

skia_minimal/copy_libs_windows.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ copy() {
99
}
1010
copy "$here/contrib/sdl/build/RelWithDebInfo/SDL3.dll"
1111
copy "$here/../../contrib/skia/out/Shared/skparagraph.dll"
12+
copy "$here/../../contrib/skia/out/Shared/skparagraph.dll.lib"
1213
copy "$here/../../contrib/skia/out/Shared/skia.dll"
14+
copy "$here/../../contrib/skia/out/Shared/skia.dll.lib"
1315
copy "$here/../../contrib/skia/out/Shared/skunicode_core.dll"
16+
copy "$here/../../contrib/skia/out/Shared/skunicode_core.dll.lib"
1417
copy "$here/../../contrib/skia/out/Shared/skunicode_icu.dll"
18+
copy "$here/../../contrib/skia/out/Shared/skunicode_icu.dll.lib"
1519
copy "$here/../../contrib/skia/out/Shared/bentleyottmann.dll"
20+
copy "$here/../../contrib/skia/out/Shared/bentleyottmann.dll.lib"
1621
copy "$here/../../contrib/skia/out/Shared/skshaper.dll"
22+
copy "$here/../../contrib/skia/out/Shared/skshaper.dll.lib"

skia_minimal/example_sdl3/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#include <SDL3/SDL_main.h>
12
#include "imgui_skia_app_sdl3.h"
23

3-
int main(int argc, const char** argv) {
4+
int SDL_main(int argc, const char** argv) {
45
ImGuiSkia::Driver::CliOptions opts{};
56
uint64_t usedFlags = 0;
67
if(opts.hasHelpFlag(argc, argv)) {

skia_minimal/imgui_skia_driver_impl/imgui_skia_app_sdl3.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "imgui_impl_sdl3.h"
88
#include "imgui_internal.h"
99

10-
#include <SDL3/SDL_main.h>
1110
#if defined(IMGUI_IMPL_OPENGL_ES2)
1211
#include <SDL3/SDL_opengles2.h>
1312
#else

skia_minimal/patch_skia_m124.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -ev
23
here=$(dirname "$(readlink -f "$BASH_SOURCE")")
34
cd "$here/../../contrib/skia/"
45
echo "applying patches to skia m124"

0 commit comments

Comments
 (0)