forked from Chatterino/chatterino2
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -2,73 +2,49 @@ | |
|
||
set -e | ||
|
||
# c-v-pasted from .zsh_commands | ||
# Prefix for where to find the ARM64 library | ||
arm64_homebrew_dir="/opt/homebrew" | ||
# Prefix for where to find the x86 library | ||
x86_64_homebrew_dir="/opt/homebrew-x86_64" | ||
# Directory where we place the finished universal library | ||
universal_lib_dir="/opt/universal-lib" | ||
|
||
# args: path-to-library (in homebrew dir) | ||
c2-make-universal-dylib() { | ||
# Prefix for where to find the ARM64 library | ||
local _arm64_homebrew="/opt/homebrew" | ||
|
||
# Prefix for where to find the x86 library | ||
local _x86_64_homebrew="/opt/homebrew-x86_64" | ||
|
||
# Prefix we use to override the library (should be the base systems directory) | ||
local _override_homebrew="${_arm64_homebrew}" | ||
|
||
# Directory where we place the finished universal library | ||
local _universal_lib="/opt/universal-lib" | ||
|
||
local _input_lib="$1" | ||
if [ -z "${_input_lib}" ]; then | ||
echo "usage: $0 [lib-path-relative-to-homebrew] (e.g. $0 lib/libboost_random-mt.dylib)" | ||
return | ||
fi | ||
|
||
if [ ! -d "${_arm64_homebrew}" ]; then | ||
echo "error: The ARM64 homebrew directory (${_arm64_homebrew}) does not exist" | ||
return | ||
fi | ||
if [ ! -d "${_x86_64_homebrew}" ]; then | ||
echo "error: The x86_64 homebrew directory (${_x86_64_homebrew}) does not exist" | ||
return | ||
fi | ||
if [ ! -d "${_universal_lib}" ]; then | ||
echo "error: The universal lib directory (${_universal_lib}) does not exist" | ||
return | ||
exit 1 | ||
fi | ||
|
||
if [ ! -w "${_universal_lib}" ]; then | ||
echo "error: The current user does not have write permission in the universal lib directory (${_universal_lib})" | ||
return | ||
if [ ! -w "${universal_lib_dir}" ]; then | ||
echo "error: The current user does not have write permission in the universal lib directory (${universal_lib_dir})" | ||
exit 1 | ||
fi | ||
|
||
local _input_lib_filename="$(basename "${_input_lib}")" | ||
|
||
local _arm64_lib="${_arm64_homebrew}/${_input_lib}" | ||
local _x86_64_lib="${_x86_64_homebrew}/${_input_lib}" | ||
local _override_lib=$(realpath "${_override_homebrew}/${_input_lib}") | ||
|
||
local _universal_lib="${_universal_lib}/${_input_lib_filename}" | ||
local _arm64_lib="${arm64_homebrew_dir}/${_input_lib}" | ||
local _x86_64_lib="${x86_64_homebrew_dir}/${_input_lib}" | ||
local _override_lib=$(realpath "${arm64_homebrew_dir}/${_input_lib}") | ||
|
||
if [ -f "${_universal_lib}" ]; then | ||
echo "warning: The final output path (${_universal_lib}) already exists, you might run into errors" | ||
echo "Some of these errors can be solved by re-linking the original libraries (e.g. brew link --overwrite boost), or re-installing them (e.g. brew reinstall [email protected])" | ||
echo "" | ||
fi | ||
local _universal_lib="${universal_lib_dir}/${_input_lib_filename}" | ||
|
||
if [ ! -f "${_arm64_lib}" ]; then | ||
echo "error: The ARM64 library cannot be found at '${_arm64_lib}' (combined prefix '${_arm64_homebrew}' with '${_input_lib})" | ||
return | ||
echo "error: The ARM64 library '${_input_lib}' cannot be found at '${_arm64_lib}'" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -f "${_x86_64_lib}" ]; then | ||
echo "error: The x86_64 library cannot be found at '${_x86_64_lib}' (combined prefix '${_arm64_homebrew}' with '${_input_lib})" | ||
return | ||
echo "error: The x86_64 library '${_input_lib}' cannot be found at '${_x86_64_lib}'" | ||
exit 1 | ||
fi | ||
|
||
# Create the combined library | ||
if ! lipo "${_arm64_lib}" "${_x86_64_lib}" -create -output "${_universal_lib}"; then | ||
echo "error: Something went wrong creating the combined library" | ||
echo "Some errors can be solved by re-linking the original libraries (e.g. brew link --overwrite boost)" | ||
return | ||
exit 1 | ||
fi | ||
|
||
echo "Created the combined library at '${_universal_lib}" | ||
|
@@ -78,33 +54,25 @@ c2-make-universal-dylib() { | |
ln -v -s "${_universal_lib}" "${_override_lib}" | ||
} | ||
|
||
sudo mkdir /opt/homebrew-x86_64 | ||
sudo mkdir /opt/universal-lib | ||
sudo mkdir "$x86_64_homebrew_dir" | ||
sudo mkdir "$universal_lib_dir" | ||
|
||
sudo chown -R $USER /opt/universal-lib | ||
sudo chown -R $USER "$universal_lib_dir" | ||
|
||
echo "Installing x86_64 brew" | ||
sudo curl -L https://github.com/Homebrew/brew/tarball/master | sudo tar xz --strip 1 -C /opt/homebrew-x86_64 | ||
sudo chown -R $USER /opt/homebrew-x86_64 | ||
sudo curl -L https://github.com/Homebrew/brew/tarball/master | sudo tar xz --strip 1 -C "$x86_64_homebrew_dir" | ||
sudo chown -R $USER "$x86_64_homebrew_dir" | ||
|
||
echo "Installing ARM dependencies" | ||
brew install "$@" | ||
|
||
echo "Installing x86_64 dependencies" | ||
for dep in "$@" | ||
do | ||
arch -x86_64 /opt/homebrew-x86_64/bin/brew fetch --force --bottle-tag=x86_64_monterey "$dep" | ||
arch -x86_64 /opt/homebrew-x86_64/bin/brew install $(arch -x86_64 /opt/homebrew-x86_64/bin/brew --cache --bottle-tag=x86_64_monterey "$dep") | ||
arch -x86_64 "$x86_64_homebrew_dir/bin/brew" fetch --force --bottle-tag=x86_64_monterey "$dep" | ||
arch -x86_64 "$x86_64_homebrew_dir/bin/brew" install $(arch -x86_64 "$x86_64_homebrew_dir/bin/brew" --cache --bottle-tag=x86_64_monterey "$dep") | ||
done | ||
|
||
echo "Unlink & link libraries" | ||
brew unlink "$@" || true | ||
brew link --overwrite "$@" | ||
|
||
echo "Unlink & link x86_64" | ||
arch -x86_64 /opt/homebrew-x86_64/bin/brew unlink "$@" || true | ||
arch -x86_64 /opt/homebrew-x86_64/bin/brew link --overwrite "$@" | ||
|
||
echo "Relinking boost libraries" | ||
c2-make-universal-dylib lib/libboost_random-mt.dylib | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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