forked from wine-mirror/wine
-
Notifications
You must be signed in to change notification settings - Fork 0
bundle dylibs and improve build workflow #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zenfinityy
merged 15 commits into
mythic-crossover-24.0.7-preview
from
mythic-crossover-24.0.7-develop
Dec 24, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2eceae4
feat!(build): bundle necessary dylibs
zenfinityy 4ff66ee
fix: move dylib bundler back one directory
zenfinityy 80c83d0
Update build.yml
zenfinityy 25d2819
fix(build): replace wine64 symlink with executable wrapper
zenfinityy 3926fee
refactor(build): streamline dylib bundling process
zenfinityy 9bb34c9
feat(build): include wine mono
zenfinityy 2565c82
fix(build): update bad chmod command for wine64 executable wrapper
zenfinityy 88d7fb7
chore(build): add comment to wine64 executable wrapper
zenfinityy 195fa3a
chore(build): remove unneeded `-p` argument for relevant `mkdir`s
zenfinityy 6897e61
chore(build): tidy up comments
zenfinityy 79e5dd4
genius was calling. i declined
zenfinityy d50ee77
fix(dylib_bundler): rename path variable due to conflicts
zenfinityy f70f4fa
refactor(build): use all codes during engine artifact compression
zenfinityy ee6fcae
feat(build): include wine gecko
zenfinityy 80dfcda
fix(build): increase compression level for engine artifact
zenfinityy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| #!/bin/zsh | ||
|
|
||
| # this is a script created for Mythic to bundle its dependencies' dylibs and copy them to the appropriate location. | ||
|
|
||
| set -e | ||
|
|
||
| # Output directory (can be overridden via environment variable) | ||
| ENGINE_DIR="${ENGINE_DIR:-Engine/wine}" | ||
| BREW_PREFIX=$(brew --prefix) | ||
|
|
||
| # List of GStreamer plugins to bundle, minus the 'libgst' prefix | ||
| GSTREAMER_PLUGINS=( | ||
| applemedia | ||
| asf | ||
| audioconvert | ||
| audioparsers | ||
| audioresample | ||
| avi | ||
| coreelements | ||
| debug | ||
| deinterlace | ||
| id3demux | ||
| isomp4 | ||
| libav | ||
| opengl | ||
| playback | ||
| typefindfunctions | ||
| videoconvertscale | ||
| videofilter | ||
| videoparsersbad | ||
| wavparse | ||
| ) | ||
|
|
||
| # list of keg-only formulae and their main dylib names | ||
| BUNDLE_LIBS=( | ||
| molten-vk:libMoltenVK | ||
| sdl2:libSDL2-2.0.0 | ||
| freetype:libfreetype | ||
| gnutls:libgnutls | ||
| libpng:libpng16 | ||
| libtiff:libtiff | ||
| libpcap:libpcap | ||
| jpeg:libjpeg | ||
| libffi:libffi | ||
| ) | ||
|
|
||
| typeset -A seen_dylibs | ||
| typeset -a all_dylibs | ||
|
|
||
| get_lib_path() { | ||
| local formula="$1" libname="$2" | ||
| local prefix=$(brew --prefix "$formula" 2>/dev/null) || return 1 | ||
| find "$prefix/lib" -maxdepth 1 -name "${libname}*.dylib" -type f 2>/dev/null | head -1 | ||
| } | ||
|
|
||
| resolve_rpath() { | ||
| local name="${1#@rpath/}" | ||
|
|
||
| # Check main lib dir first | ||
| [[ -f "${BREW_PREFIX}/lib/${name}" ]] && { echo "${BREW_PREFIX}/lib/${name}"; return; } | ||
|
|
||
| # Search keg-only formula lib dirs | ||
| for entry in "${BUNDLE_LIBS[@]}"; do | ||
| local formula="${entry%%:*}" | ||
| local lib_path="$(brew --prefix "$formula" 2>/dev/null)/lib/${name}" | ||
| [[ -f "$lib_path" ]] && { echo "$lib_path"; return; } | ||
| done | ||
| } | ||
|
|
||
| normalize_path() { | ||
| python3 -c "import os; print(os.path.realpath('$1'))" 2>/dev/null || echo "$1" | ||
| } | ||
|
|
||
| find_dependencies() { | ||
| local dylib="$1" | ||
| local norm=$(normalize_path "$dylib") | ||
|
|
||
| [[ -n "${seen_dylibs[$norm]}" ]] && return | ||
| seen_dylibs[$norm]=1 | ||
| all_dylibs+=("$dylib") | ||
|
|
||
| local -a queue=("$dylib") | ||
|
|
||
| while [[ ${#queue[@]} -gt 0 ]]; do | ||
| local current="${queue[1]}" | ||
| queue=("${queue[@]:1}") | ||
|
|
||
| for ref in $(otool -L "$current" 2>/dev/null | tail -n +2 | awk '/^\t/ {print $1}' | grep '\.dylib'); do | ||
| [[ "$ref" == /usr/lib/* || "$ref" == /System/* ]] && continue | ||
| [[ "$ref" == @loader_path/* || "$ref" == @executable_path/* ]] && continue | ||
|
|
||
| [[ "$ref" == @rpath/* ]] && { ref=$(resolve_rpath "$ref"); [[ -z "$ref" ]] && continue; } | ||
|
|
||
| norm=$(normalize_path "$ref") | ||
| [[ -z "${seen_dylibs[$norm]}" ]] && { | ||
| seen_dylibs[$norm]=1 | ||
| all_dylibs+=("$ref") | ||
| queue+=("$ref") | ||
| } | ||
| done | ||
| done | ||
| } | ||
|
|
||
| fix_install_names() { | ||
| local file="$1" prefix="$2" | ||
| chmod u+w "$file" | ||
| install_name_tool -id "${prefix}$(basename "$file")" "$file" 2>/dev/null || true | ||
|
|
||
| otool -L "$file" | grep -v "$file" | awk '{print $1}' | while read -r lib_path; do | ||
| [[ "$lib_path" != /usr/lib* && "$lib_path" != /System/* ]] && \ | ||
| install_name_tool -change "$lib_path" "${prefix}${lib_path##*/}" "$file" 2>/dev/null || true | ||
| done | ||
| codesign -fs- "$file" 2>/dev/null || true | ||
| } | ||
|
|
||
| copy_dylib() { | ||
| local lib="$1" dest_dir="${ENGINE_DIR}/lib" prefix="@loader_path/" | ||
|
|
||
| [[ "$lib" == *"/gstreamer-1.0/"* ]] && { dest_dir="${ENGINE_DIR}/lib/gstreamer-1.0"; prefix="@loader_path/../"; } | ||
|
|
||
| local dest="${dest_dir}/$(basename "$lib")" | ||
| mkdir -p "$dest_dir" | ||
| [[ -f "$dest" ]] && return 0 | ||
|
|
||
| cp -L "$lib" "$dest" | ||
| fix_install_names "$dest" "$prefix" | ||
| } | ||
|
|
||
| main() { | ||
| local gst_prefix=$(brew --prefix gstreamer) | ||
|
|
||
| echo "=== Processing GStreamer plugins ===" | ||
| for plugin in "${GSTREAMER_PLUGINS[@]}"; do | ||
| local lib_path="${gst_prefix}/lib/gstreamer-1.0/libgst${plugin}.dylib" | ||
| [[ -f "$lib_path" ]] && find_dependencies "$lib_path" || echo "Warning: $plugin not found" | ||
| done | ||
|
|
||
| echo "=== Processing libraries ===" | ||
| for entry in "${BUNDLE_LIBS[@]}"; do | ||
| local formula="${entry%%:*}" libname="${entry#*:}" | ||
| local lib_path=$(get_lib_path "$formula" "$libname") | ||
| [[ -n "$lib_path" ]] && find_dependencies "$lib_path" || echo "Warning: $formula not found" | ||
| done | ||
|
|
||
| echo "=== Copying ${#all_dylibs[@]} dylibs ===" | ||
| for dylib in "${all_dylibs[@]}"; do copy_dylib "$dylib"; done | ||
|
|
||
| [[ -d "${gst_prefix}/lib/gstreamer-1.0/include" ]] && { | ||
| mkdir -p "${ENGINE_DIR}/lib/gstreamer-1.0" | ||
| cp -a "${gst_prefix}/lib/gstreamer-1.0/include" "${ENGINE_DIR}/lib/gstreamer-1.0/" | ||
| } | ||
|
|
||
| echo "=== Fixing Wine .so files ===" | ||
| for so in "${ENGINE_DIR}"/lib/wine/x86_64-unix/*.so(N); do | ||
| otool -L "$so" 2>/dev/null | grep -q "/usr/local\|/opt/homebrew" && fix_install_names "$so" "@rpath/" | ||
| done | ||
|
|
||
| echo "=== Done: ${#all_dylibs[@]} dylibs bundled ===" | ||
| } | ||
|
|
||
| main "$@" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The normalize_path function has a command injection vulnerability. The path argument is directly interpolated into a Python command string without proper escaping. If a file path contains special characters like single quotes, backticks, or dollar signs, it could lead to arbitrary command execution. Consider using a safer approach such as passing the path as a JSON-escaped string or using Python's sys.argv.