@@ -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
1212inputs :
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
1923runs :
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.
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'
0 commit comments