Skip to content

Commit 290d785

Browse files
compile fribidi on Windows as part of platform layer build
1 parent 0ac55cd commit 290d785

File tree

7 files changed

+96
-72
lines changed

7 files changed

+96
-72
lines changed

scripts/dev.py

Lines changed: 75 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import glob
22
import os
33
import sys
4+
import sysconfig
45
import platform
56
import re
67
import urllib.request
@@ -570,26 +571,69 @@ def build_fribidi(release=False):
570571
############################################################
571572
#TODO: sort out what we should do on Windows
572573
############################################################
573-
subprocess.run([
574-
"./autogen.sh"
575-
], check=True)
574+
if platform.system() == "Windows":
575+
pythonScriptsPath = sysconfig.get_path('scripts', f'{os.name}_user')
576576

577-
subprocess.run([
578-
"./configure"
579-
], check=True)
577+
meson = "meson"
580578

581-
subprocess.run([
582-
"make"
583-
], check=True)
579+
try:
580+
subprocess.run(["meson"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
581+
except FileNotFoundError:
582+
print("meson not found, installing...")
583+
subprocess.run([
584+
"python", "-m", "pip", "install", "meson"
585+
], check=True)
586+
587+
try:
588+
subprocess.run(["meson"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
589+
except FileNotFoundError:
590+
meson = os.path.join(pythonScriptsPath, "meson.exe")
591+
592+
593+
yeetdir("build")
594+
595+
subprocess.run([
596+
meson, "setup", "build", "-Ddocs=false"
597+
], check=True)
584598

585-
# fix install name for macOS
586-
if platform.system() == "Darwin":
587599
subprocess.run([
588-
"install_name_tool",
589-
"-id", "libfribidi.dylib",
590-
"lib/.libs/libfribidi.dylib",
600+
meson, "compile", "-C", "build"
591601
], check=True)
592602

603+
# meson puts stuff in build/lib, copy it over to the same place as its put on mac
604+
os.makedirs("lib/.libs", exist_ok=True)
605+
606+
shutil.copy("build/lib/fribidi-0.dll", "lib/.libs/")
607+
shutil.copy("build/lib/fribidi.lib", "lib/.libs/")
608+
shutil.copy("build/config.h", ".")
609+
shutil.copy("build/lib/fribidi-config.h", "lib")
610+
611+
for f in glob.glob("build/gen.tab/*.i"):
612+
shutil.copy(f, ".")
613+
614+
shutil.copy("build/gen.tab/fribidi-unicode-version.h", "lib")
615+
616+
else:
617+
subprocess.run([
618+
"./autogen.sh"
619+
], check=True)
620+
621+
subprocess.run([
622+
"./configure"
623+
], check=True)
624+
625+
subprocess.run([
626+
"make"
627+
], check=True)
628+
629+
# fix install name for macOS
630+
if platform.system() == "Darwin":
631+
subprocess.run([
632+
"install_name_tool",
633+
"-id", "libfribidi.dylib",
634+
"lib/.libs/libfribidi.dylib",
635+
], check=True)
636+
593637

594638
# build wasm
595639
clang = 'clang'
@@ -611,15 +655,20 @@ def build_fribidi(release=False):
611655
subprocess.run([
612656
clang,
613657
"--target=wasm32",
614-
"--no-standard-libraries",
658+
"--no-standard-libraries", "-I../../src/orca-libc/include",
615659
"-mbulk-memory",
616660
"-Wl,--no-entry",
617661
"-Wl,--export-dynamic",
618662
"-Wl,--relocatable",
619-
"-DHAVE_CONFIG_H",
663+
"-DHAVE_STRINGIZE=1",
664+
"-DHAVE_STRING_H=1",
665+
"-DHAVE_STRINGS_H=1",
666+
"-DHAVE_MEMMOVE",
667+
"-DHAVE_MEMSET",
668+
"-DHAVE_STDLIB_H=1",
669+
"-DHAVE_STRDUP",
620670
"-I.",
621671
"-Ilib",
622-
"-I../../src/orca-libc/include",
623672
*source_files,
624673
"-o", "libfribidi_wasm.a",
625674
], check=True)
@@ -631,15 +680,15 @@ def build_fribidi(release=False):
631680
sums = []
632681

633682
if platform.system() == "Windows":
634-
shutil.copy("build/fribidi/lib/.libs/libfribidi.dll", "build/fribidi.out/bin")
683+
shutil.copy("build/fribidi/lib/.libs/fribidi-0.dll", "build/fribidi.out/bin")
635684
sums.append({
636-
"file": "bin/libfribidi.dll",
637-
"sum": checksum.filesum("build/fribidi.out/bin/libfribidi.dll")
685+
"file": "bin/fribidi-0.dll",
686+
"sum": checksum.filesum("build/fribidi.out/bin/fribidi-0.dll")
638687
})
639-
shutil.copy("build/fribidi/lib/.libs/libfribidi.dll.lib", "build/fribidi.out/bin")
688+
shutil.copy("build/fribidi/lib/.libs/fribidi.lib", "build/fribidi.out/bin")
640689
sums.append({
641-
"file": "bin/libfribidi.dll.lib",
642-
"sum": checksum.filesum("build/fribidi.out/bin/libfribidi.dll.lib")
690+
"file": "bin/fribidi.lib",
691+
"sum": checksum.filesum("build/fribidi.out/bin/fribidi.lib")
643692
})
644693
else:
645694
shutil.copy("build/fribidi/lib/.libs/libfribidi.dylib", "build/fribidi.out/bin")
@@ -1131,8 +1180,8 @@ def build_platform_layer_lib_win(release):
11311180
"/DELAYLOAD:webgpu.dll",
11321181
"libharfbuzz.dll.lib",
11331182
"/DELAYLOAD:libharfbuzz.dll",
1134-
"libfribidi.dll.lib",
1135-
"/DELAYLOAD:libfribidi.dll",
1183+
"fribidi.lib",
1184+
"/DELAYLOAD:fribidi-0.dll",
11361185
]
11371186

11381187
debug_flags = ["/O2", "/Zi"] if release else ["/Zi", "/DOC_DEBUG", "/DOC_LOG_COMPILE_DEBUG"]
@@ -1645,7 +1694,7 @@ def package_sdk_internal(dest, target):
16451694
shutil.copy(os.path.join("build", "bin", "libGLESv2.dll"), bin_dir)
16461695
shutil.copy(os.path.join("build", "bin", "webgpu.dll"), bin_dir)
16471696
shutil.copy(os.path.join("build", "bin", "libharfbuzz.dll"), bin_dir)
1648-
shutil.copy(os.path.join("build", "bin", "libfribidi.dll"), bin_dir)
1697+
shutil.copy(os.path.join("build", "bin", "fribidi-0.dll"), bin_dir)
16491698
else:
16501699
shutil.copy(os.path.join("build", "bin", "orca"), bin_dir)
16511700
shutil.copy(os.path.join("build", "bin", "orca_runtime"), bin_dir)

sketches/text-layout/build.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ cl /we4013 /Zi /Zc:preprocessor /std:c11 /experimental:c11atomics %INCLUDES% mai
66
copy ..\..\build\bin\orca.dll bin
77
copy ..\..\build\bin\webgpu.dll bin
88
copy ..\..\build\bin\libharfbuzz.dll bin
9+
copy ..\..\build\bin\fribidi-0.dll bin

sketches/text-layout/main.c

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -210,38 +210,7 @@ int main()
210210

211211
{
212212
oc_move_to(origin.x, origin.y);
213-
oc_set_color_rgba(0, 0, 0, 1);
214-
215-
/*
216-
oc_str32 codepoints = oc_utf8_push_to_codepoints(scratch.arena, text);
217-
oc_glyph_run* run = oc_text_shape(scratch.arena, zapFont, 0, codepoints, 0, codepoints.len);
218-
oc_text_draw_run(run, fontSize);
219213

220-
if(mouseClicked)
221-
{
222-
cursor = oc_glyph_run_point_to_cursor(run, fontSize, oc_vec2_sub(mousePoint, origin));
223-
}
224-
225-
//TODO: move to next/prev utf8 char.
226-
//TODO: when we do grapheme segmentation, move to next grapheme
227-
if(moveCursor == 1 && cursor <= text.len)
228-
{
229-
cursor = oc_min(cursor + 1, text.len);
230-
}
231-
else if(moveCursor == -1 && cursor > 0)
232-
{
233-
cursor--;
234-
}
235-
236-
oc_vec2 pos = oc_glyph_run_cursor_to_point(run, fontSize, cursor);
237-
oc_move_to(origin.x + pos.x, origin.y + pos.y + metrics.descent);
238-
oc_line_to(origin.x + pos.x, origin.y + pos.y - metrics.ascent);
239-
oc_set_color_rgba(0, 0, 0, 1);
240-
oc_set_width(1);
241-
oc_stroke();
242-
243-
//oc_text_draw_utf8(text, font, fontSize);
244-
*/
245214
oc_text_line* line = oc_text_line_from_utf8(scratch.arena,
246215
text,
247216
&(oc_text_attributes){
@@ -276,6 +245,7 @@ int main()
276245
oc_stroke();
277246
}
278247

248+
/*
279249
{
280250
oc_move_to(200, 300);
281251
oc_line_to(300, 300);
@@ -290,7 +260,7 @@ int main()
290260
291261
oc_str32 codepoints = oc_utf8_push_to_codepoints(scratch.arena, OC_STR8("以呂波耳本部止"));
292262
293-
oc_glyph_run* run = oc_text_shape(scratch.arena,
263+
oc_text_run* run = oc_text_shape(scratch.arena,
294264
japaneseFont,
295265
&(oc_text_shape_settings){
296266
.direction = OC_TEXT_DIRECTION_TTB,
@@ -333,6 +303,7 @@ int main()
333303
oc_set_text_flip(false);
334304
oc_matrix_pop();
335305
}
306+
*/
336307

337308
{
338309
oc_move_to(500, 400);
@@ -347,15 +318,14 @@ int main()
347318

348319
oc_str32 codepoints = oc_utf8_push_to_codepoints(scratch.arena, OC_STR8("مرحبا"));
349320

350-
oc_glyph_run* run = oc_text_shape(scratch.arena,
351-
arabicFont,
352-
&(oc_text_shape_settings){
353-
.direction = OC_TEXT_DIRECTION_RTL,
354-
},
355-
codepoints,
356-
0,
357-
codepoints.len);
358-
oc_text_draw_run(run, fontSize);
321+
oc_text_line* line = oc_text_line_from_utf32(scratch.arena,
322+
codepoints,
323+
&(oc_text_attributes){
324+
.font = arabicFont,
325+
.fontSize = fontSize,
326+
.color = { 0, 0, 0, 1 },
327+
});
328+
oc_text_line_draw(line);
359329
}
360330

361331
{

sketches/ui/build.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@ set INCLUDES=/I ..\..\src /I ..\..\src\util /I ..\..\src\platform /I ../../ext /
33

44
if not exist "bin" mkdir bin
55
cl /we4013 /Zi /Zc:preprocessor /std:c11 /experimental:c11atomics %INCLUDES% main.c /link /LIBPATH:../../build/bin orca.dll.lib /out:bin/example_ui.exe
6+
67
copy ..\..\build\bin\orca.dll bin
8+
copy ..\..\build\bin\webgpu.dll bin
9+
copy ..\..\build\bin\libharfbuzz.dll bin
10+
copy ..\..\build\bin\fribidi-0.dll bin

sketches/ui/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cmd command = CMD_NONE;
3838

3939
void log_push(const char* line)
4040
{
41-
oc_str8_list_push(&logArena, &logLines, (oc_str8)OC_STR8(line));
41+
oc_str8_list_push(&logArena, &logLines, OC_STR8(line));
4242
}
4343

4444
void log_pushf(const char* format, ...)

src/ui/ui.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4386,7 +4386,7 @@ oc_ui_palette OC_UI_DARK_PALETTE = {
43864386
.white = { 1, 1, 1, 1, OC_COLOR_SPACE_SRGB }
43874387
};
43884388

4389-
oc_ui_theme OC_UI_DARK_THEME = {
4389+
ORCA_API oc_ui_theme OC_UI_DARK_THEME = {
43904390
.white = { 0.894, 0.906, 0.961, 1, OC_COLOR_SPACE_SRGB },
43914391
.primary = { 0.33, 0.66, 1, 1, OC_COLOR_SPACE_SRGB }, // blue5
43924392
.primaryHover = { 0.5, 0.757, 1, 1, OC_COLOR_SPACE_SRGB }, // blue6
@@ -4577,7 +4577,7 @@ oc_ui_palette OC_UI_LIGHT_PALETTE = {
45774577
.white = { 1, 1, 1, 1, OC_COLOR_SPACE_SRGB }
45784578
};
45794579

4580-
oc_ui_theme OC_UI_LIGHT_THEME = {
4580+
ORCA_API oc_ui_theme OC_UI_LIGHT_THEME = {
45814581
.white = { 1, 1, 1, 1, OC_COLOR_SPACE_SRGB },
45824582
.primary = { 0.000, 0.392, 0.980, 1, OC_COLOR_SPACE_SRGB }, // blue5
45834583
.primaryHover = { 0.000, 0.384, 0.839, 1, OC_COLOR_SPACE_SRGB }, // blue6

src/ui/ui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ typedef struct oc_ui_theme
373373
oc_ui_palette* palette;
374374
} oc_ui_theme;
375375

376-
extern oc_ui_theme OC_UI_DARK_THEME;
377-
extern oc_ui_theme OC_UI_LIGHT_THEME;
376+
ORCA_API extern oc_ui_theme OC_UI_DARK_THEME;
377+
ORCA_API extern oc_ui_theme OC_UI_LIGHT_THEME;
378378

379379
typedef struct oc_ui_tag
380380
{

0 commit comments

Comments
 (0)