Skip to content

Commit

Permalink
fix libfribidi install name on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfouilleul committed Nov 5, 2024
1 parent cd4c210 commit 62172b7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ scripts/files
/ext
src/ext/angle
src/ext/harfbuzz
src/ext/fribidi

sketches/*/bin

Expand Down
21 changes: 20 additions & 1 deletion scripts/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,15 @@ def build_fribidi(release=False):
"make"
], check=True)

# fix install name for macOS
if platform.system() == "Darwin":
subprocess.run([
"install_name_tool",
"-id", "libfribidi.dylib",
"lib/.libs/libfribidi.dylib",
], check=True)


# build wasm
source_files = glob.glob("lib/*.c");

Expand Down Expand Up @@ -1105,6 +1114,8 @@ def build_platform_layer_lib_win(release):
"/DELAYLOAD:webgpu.dll",
"libharfbuzz.dll.lib",
"/DELAYLOAD:libharfbuzz.dll",
"libfribidi.dll.lib",
"/DELAYLOAD:libfribidi.dll",
]

debug_flags = ["/O2", "/Zi"] if release else ["/Zi", "/DOC_DEBUG", "/DOC_LOG_COMPILE_DEBUG"]
Expand Down Expand Up @@ -1175,7 +1186,7 @@ def build_platform_layer_lib_mac(release):
"build/orca_c.o", "build/orca_objc.o",
"-Lbuild/bin", "-lc", "-lc++",
"-framework", "Carbon", "-framework", "Cocoa", "-framework", "Metal", "-framework", "QuartzCore",
"-weak-lEGL", "-weak-lGLESv2", "-weak-lwebgpu", "-weak-lharfbuzz"
"-weak-lEGL", "-weak-lGLESv2", "-weak-lwebgpu", "-weak-lharfbuzz", "-weak-lfribidi",
], check=True)

# change dependent libs path to @rpath
Expand All @@ -1196,6 +1207,12 @@ def build_platform_layer_lib_mac(release):
"build/bin/liborca.dylib",
], check=True)

subprocess.run([
"install_name_tool",
"-change", "libfribidi.dylib", "@rpath/libfribidi.dylib",
"build/bin/liborca.dylib",
], check=True)

# add executable path to rpath. Client executable can still add its own
# rpaths if needed, e.g. @executable_path/libs/ etc.
subprocess.run([
Expand Down Expand Up @@ -1611,6 +1628,7 @@ def package_sdk_internal(dest, target):
shutil.copy(os.path.join("build", "bin", "libGLESv2.dll"), bin_dir)
shutil.copy(os.path.join("build", "bin", "webgpu.dll"), bin_dir)
shutil.copy(os.path.join("build", "bin", "libharfbuzz.dll"), bin_dir)
shutil.copy(os.path.join("build", "bin", "libfribidi.dll"), bin_dir)
else:
shutil.copy(os.path.join("build", "bin", "orca"), bin_dir)
shutil.copy(os.path.join("build", "bin", "orca_runtime"), bin_dir)
Expand All @@ -1620,6 +1638,7 @@ def package_sdk_internal(dest, target):
shutil.copy(os.path.join("build", "bin", "libGLESv2.dylib"), bin_dir)
shutil.copy(os.path.join("build", "bin", "libwebgpu.dylib"), bin_dir)
shutil.copy(os.path.join("build", "bin", "libharfbuzz.dylib"), bin_dir)
shutil.copy(os.path.join("build", "bin", "libfribidi.dylib"), bin_dir)

shutil.copytree(os.path.join("build", "orca-libc"), libc_dir, dirs_exist_ok=True)
shutil.copytree("resources", res_dir, dirs_exist_ok=True)
Expand Down
4 changes: 4 additions & 0 deletions src/tool/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,14 @@ int winBundle(
oc_str8 eglLib = oc_path_append(a, sdkDir, OC_STR8("bin/libEGL.dll"));
oc_str8 wgpuLib = oc_path_append(a, sdkDir, OC_STR8("bin/webgpu.dll"));
oc_str8 harfbuzzLib = oc_path_append(a, sdkDir, OC_STR8("bin/libharfbuzz.dll"));
oc_str8 fribidiLib = oc_path_append(a, sdkDir, OC_STR8("bin/libhfribidi.dll"));

TRY(oc_sys_copy(orcaLib, exeDir));
TRY(oc_sys_copy(glesLib, exeDir));
TRY(oc_sys_copy(eglLib, exeDir));
TRY(oc_sys_copy(wgpuLib, exeDir));
TRY(oc_sys_copy(harfbuzzLib, exeDir));
TRY(oc_sys_copy(fribidiLib, exeDir));

//-----------------------------------------------------------
//NOTE: copy wasm module and data
Expand Down Expand Up @@ -297,13 +299,15 @@ int macBundle(
oc_str8 eglLib = oc_path_append(a, sdkDir, OC_STR8("bin/libEGL.dylib"));
oc_str8 wgpu_lib = oc_path_append(a, sdkDir, OC_STR8("bin/libwebgpu.dylib"));
oc_str8 harfbuzz_lib = oc_path_append(a, sdkDir, OC_STR8("bin/libharfbuzz.dylib"));
oc_str8 fribidi_lib = oc_path_append(a, sdkDir, OC_STR8("bin/libfribidi.dylib"));

TRY(oc_sys_copy(orcaExe, exeDir));
TRY(oc_sys_copy(orcaLib, exeDir));
TRY(oc_sys_copy(glesLib, exeDir));
TRY(oc_sys_copy(eglLib, exeDir));
TRY(oc_sys_copy(wgpu_lib, exeDir));
TRY(oc_sys_copy(harfbuzz_lib, exeDir));
TRY(oc_sys_copy(fribidi_lib, exeDir));

//-----------------------------------------------------------
//NOTE: copy wasm module and data
Expand Down

0 comments on commit 62172b7

Please sign in to comment.