Skip to content

Commit

Permalink
last
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Sep 28, 2024
1 parent 885994e commit 96adea0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 64 deletions.
88 changes: 28 additions & 60 deletions .CI/SetupHomebrewDeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,16 @@ jobs:

# macOS
- uses: actions/download-artifact@v4
name: macOS Qt6.7.3 dmg
name: macOS Qt6.7.1 dmg
with:
name: chatterino-macos-Qt-6.7.3-universal.dmg
name: chatterino-macos-Qt-6.7.1-universal.dmg
path: release-artifacts/

- name: Rename artifacts
run: |
ls -l
# Rename the macos build to indicate that it's for macOS 12.0 users
mv chatterino-macos-Qt-6.7.3-x86_64.dmg Chatterino-macOS-12.0-universal.dmg
mv chatterino-macos-Qt-6.7.1-universal.dmg Chatterino-macOS-12.0-universal.dmg
working-directory: release-artifacts
shell: bash

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
mv chatterino-windows-x86-64-Qt-6.7.3-symbols.pdb.7z Chatterino-Windows-debug-symbols.pdb.7z
mv chatterino-macos-Qt-6.7.3-universal.dmg Chatterino.dmg
mv chatterino-macos-Qt-6.7.1-universal.dmg Chatterino.dmg
- name: Hash files
working-directory: build
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.c7.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- Dev(macOS): Changed CFBundleIdentifier from `com.chatterino` to `app.7tv.chatterino7` (fec0dbdf558b1e6e358971a256f5540d34bb6a8d)
- Dev: Updated Conan version used in CI to 2.4 (330d05d50ffd296b34744dbcc97290534e8cf704)
- Dev(Windows): Updated `libavif` to 1.0.4, `boost` to 1.85, and `openssl` to 3.2.2 (330d05d50ffd296b34744dbcc97290534e8cf704)
- Dev(macOS): A single universal app is now released for macOS (#274)

0 comments on commit 96adea0

Please sign in to comment.