Skip to content

Commit 26ed39e

Browse files
committed
Cache iconv too
1 parent 7788966 commit 26ed39e

2 files changed

Lines changed: 28 additions & 11 deletions

File tree

.github/actions/universal-package/action.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ description: Create universal Homebrew package which contains x86_64 and arm64
77
# that has both x86_64 and arm64 arch, as Homebrew's distributed bottles are thin binaries with only one arch.
88
#
99
# We still use Homebrew to manage the library because their formulas are up to date and have correct build instructions
10-
# that will work. This way we don't have to manually configuring and building and updating the package info.
10+
# that will work. This way we don't have to manually configure, build, and update the package info.
1111

1212
inputs:
1313
formula:
14-
description: Formura name
14+
description: Formula name
1515
required: true
1616
contents:
1717
description: Path for contents in package's keg
1818
required: true
19+
gnuiconv:
20+
description: Use the Homebrew GNU libiconv instead of system one
21+
type: boolean
22+
required: false
1923
runs:
2024
using: 'composite'
2125
steps:
@@ -31,20 +35,21 @@ runs:
3135
# version and stomp what we have here.
3236
brew update
3337
34-
# Patch the official Homebrew formula to explicitly build for min deployment target and a universal binary.
35-
#
36-
# We also need to explicitly use system Clang because Homebrew's bundled clang script tries to inject -march
38+
# Patch the official Homebrew formula to explicitly build for min deployment target and a universal binary. We
39+
# also need to explicitly use system Clang because Homebrew's bundled clang script tries to inject -march
3740
# compiler flags that will cause universal builds to fail as Clang does not like that.
38-
#
39-
# We also manually depend on GNU libiconv as Apple iconv is broken since macOS 14. This is necessary as MacVim
40-
# itself it built against it and we need both to match.
4141
brew cat ${formula} | \
42-
sed '/^[[:blank:]]*def install$/i\'$'\n depends_on "libiconv"\n' | \
4342
sed '/^[[:blank:]]*def install$/a\'$'\n ENV["MACOSX_DEPLOYMENT_TARGET"] = "'${MACOSX_DEPLOYMENT_TARGET}$'"\n' | \
4443
sed '/^[[:blank:]]*def install$/a\'$'\n ENV["CC"] = "/usr/bin/clang"\n' | \
4544
sed '/^[[:blank:]]*def install$/a\'$'\n ENV["CFLAGS"] = "-arch x86_64 -arch arm64"\n' | \
4645
sed '/^[[:blank:]]*def install$/a\'$'\n ENV["LDFLAGS"] = "-arch x86_64 -arch arm64"\n' >${formula}.rb
4746
47+
if [[ "${{ inputs.gnuiconv }}" == "true" ]]; then
48+
# We also manually depend on GNU libiconv as Apple iconv is broken since macOS 14. This is necessary as MacVim
49+
# itself it built against it and we need both to match.
50+
sed -i.bak '/^[[:blank:]]*def install$/i\'$'\n depends_on "libiconv"\n' ${formula}.rb
51+
fi
52+
4853
# Homebrew requires formula files to be placed in taps and disallows
4954
# installing from raw paths, so we manually create a taps folder for a
5055
# 'macvim-dev/deps' tap.
@@ -90,7 +95,9 @@ runs:
9095
brew list ${formula} &>/dev/null || brew install --quiet --formula -s macvim-dev/deps/${formula}
9196
9297
# If formula was cached, this step is necessary to relink it to brew prefix (e.g. /usr/local)
93-
brew unlink ${formula} && brew link ${formula}
98+
# The "-f" is there to force link keg-only formulas. Homebrew doesn't provide a command to just link in the
99+
# optional /opt/homebrew/opt/... folders, so we have to resort to doing this.
100+
brew unlink ${formula} && brew link -f ${formula}
94101
echo '::endgroup::'
95102
96103
echo '::group::Verify built version'

.github/workflows/macvim-buildtest.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ jobs:
8989
xcode-select -p
9090
xcodebuild -version
9191
92+
# Set up, install, and cache libiconv library to work around broken Apple iconv since macOS 14.
93+
94+
- name: Set up libiconv
95+
if: inputs.publish
96+
uses: ./.github/actions/universal-package
97+
with:
98+
formula: libiconv
99+
contents: opt/libiconv/lib/libiconv.a,opt/libiconv/lib/libiconv.dylib
100+
92101
# Set up, install, and cache gettext library for localization.
93102

94103
- name: Set up gettext
@@ -97,6 +106,7 @@ jobs:
97106
with:
98107
formula: gettext
99108
contents: lib/libintl.a,lib/libintl.dylib
109+
gnuiconv: true
100110

101111
# Set up, install, and cache libsodium library for encryption.
102112

@@ -112,7 +122,7 @@ jobs:
112122
- name: Install packages
113123
run: |
114124
# GNU iconv is installed to work around broken Apple iconv
115-
brew install --quiet libtool libiconv
125+
brew install --quiet libtool
116126
117127
- name: Install packages for testing
118128
run: |

0 commit comments

Comments
 (0)