18
18
vi_cv_dll_name_perl : /System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/libperl.dylib
19
19
vi_cv_dll_name_python : /System/Library/Frameworks/Python.framework/Versions/2.7/Python
20
20
vi_cv_dll_name_python3 : /usr/local/Frameworks/Python.framework/Versions/3.9/Python
21
+ vi_cv_dll_name_python3_arm64 : /opt/homebrew/Frameworks/Python.framework/Versions/3.9/Python
21
22
vi_cv_dll_name_ruby : /usr/local/opt/ruby/lib/libruby.dylib
23
+ vi_cv_dll_name_ruby_arm64 : /opt/homebrew/opt/ruby/lib/libruby.dylib
24
+ vi_cv_dll_name_lua_arm64 : /opt/homebrew/lib/liblua.dylib
22
25
23
26
VIM_BIN : src/MacVim/build/Release/MacVim.app/Contents/MacOS/Vim
24
27
MACVIM_BIN : src/MacVim/build/Release/MacVim.app/Contents/MacOS/MacVim
@@ -38,18 +41,27 @@ jobs:
38
41
- os : macos-10.15
39
42
xcode : 11.7
40
43
- os : macos-10.15
41
- publish : true
42
44
- os : macos-11.0
45
+ publish : true
43
46
44
47
runs-on : ${{ matrix.os }}
45
48
46
49
steps :
47
50
- uses : actions/checkout@v2
48
51
49
- # Set up and install gettext for localization.
52
+ # Set up, install, and cache gettext library for localization.
53
+ #
50
54
# Instead of using the default binary installed by Homebrew, need to build our own because gettext is statically
51
55
# linked in MacVim, and need to be built against MACOSX_DEPLOYMENT_TARGET to ensure the built binary will work on
52
56
# supported macOS versions.
57
+ #
58
+ # In addition, to support building a universal MacVim, we need an arm64 version of gettext as well in order to
59
+ # create a universal gettext binary to link against (Homebrew only distributes thin binaries and therefore this
60
+ # has to be done manually). To do that, we will just pull the bottle directly from Homebrew and patch it in using
61
+ # lipo. We can't use normal brew commands to get the bottle because brew doesn't natively support cross-compiling
62
+ # and we are running CI on x86_64 Macs. We also don't need to worry about the min deployment target fix on arm64
63
+ # because all Apple Silicon Macs have to run on macOS 11+.
64
+
53
65
- name : Set up gettext
54
66
if : matrix.publish
55
67
run : |
@@ -71,11 +83,12 @@ jobs:
71
83
brew uninstall --ignore-dependencies gettext
72
84
73
85
- name : Cache gettext
86
+ id : cache-gettext
74
87
if : matrix.publish
75
88
uses : actions/cache@v2
76
89
with :
77
90
path : /usr/local/Cellar/gettext
78
- key : gettext-homebrew-cache-${{ runner.os }} -${{ hashFiles('gettext.rb') }}
91
+ key : gettext-homebrew-cache-patched-unified -${{ hashFiles('gettext.rb') }}
79
92
80
93
- name : Install gettext
81
94
if : matrix.publish
85
98
brew install -s gettext.rb # This will be a no-op if gettext was cached
86
99
brew link gettext # If gettext was cached, this step is necessary to relink it to /usr/local/
87
100
101
+ - name : Create universal gettext with arm64 bottle
102
+ if : matrix.publish && steps.cache-gettext.outputs.cache-hit != 'true'
103
+ env :
104
+ HOMEBREW_NO_AUTO_UPDATE : 1
105
+ run : |
106
+ set -o verbose
107
+
108
+ # Manually download and extract gettext bottle for arm64
109
+ gettext_url=$(brew info --json gettext | ruby -rjson -e 'j = JSON.parse(STDIN.read); puts j[0]["bottle"]["stable"]["files"]["arm64_big_sur"]["url"]')
110
+ gettext_ver=$(brew info --json gettext | ruby -rjson -e 'j = JSON.parse(STDIN.read); puts j[0]["versions"]["stable"]')
111
+
112
+ mkdir gettext_download
113
+ cd gettext_download
114
+ wget --no-verbose ${gettext_url}
115
+ tar xf gettext*.tar.gz
116
+
117
+ # Just for diagnostics, print out the old archs. This should be a thin binary (x86_64)
118
+ lipo -info /usr/local/lib/libintl.a
119
+ lipo -info /usr/local/lib/libintl.dylib
120
+
121
+ # Create a universal binary by patching the custom built x86_64 one with the downloaded arm64 one.
122
+ # Modify the actual binaries in /usr/local/Cellar instead of the symlinks to allow caching to work.
123
+ lipo -create -output /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.a /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.a ./gettext/${gettext_ver}/lib/libintl.a
124
+ lipo -create -output /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.dylib /usr/local/Cellar/gettext/${gettext_ver}/lib/libintl.dylib ./gettext/${gettext_ver}/lib/libintl.dylib
125
+
126
+ # Print out the new archs and verify they are universal with 2 archs.
127
+ lipo -info /usr/local/lib/libintl.a | grep 'x86_64 arm64'
128
+ lipo -info /usr/local/lib/libintl.dylib | grep 'x86_64 arm64'
129
+
130
+ # Set up remaining packages and tools
131
+
88
132
- name : Install packages
89
133
if : matrix.publish
90
134
env :
@@ -101,6 +145,8 @@ jobs:
101
145
sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
102
146
xcode-select -p
103
147
148
+ # All set up steps are done. Build and test MacVim below.
149
+
104
150
- name : Configure
105
151
run : |
106
152
set -o verbose
@@ -111,7 +157,6 @@ jobs:
111
157
--with-tlib=ncurses
112
158
--enable-cscope
113
159
--enable-gui=macvim
114
- --with-macarchs=x86_64
115
160
--with-compiledby="GitHub Actions"
116
161
)
117
162
if ${{ matrix.publish == true }}; then
@@ -122,6 +167,11 @@ jobs:
122
167
--enable-rubyinterp=dynamic
123
168
--enable-luainterp=dynamic
124
169
--with-lua-prefix=/usr/local
170
+ --with-macarchs="x86_64 arm64"
171
+ )
172
+ else
173
+ CONFOPT+=(
174
+ --with-macarchs=x86_64
125
175
)
126
176
fi
127
177
echo "CONFOPT: ${CONFOPT[@]}"
@@ -140,6 +190,12 @@ jobs:
140
190
grep -q -- "-DDYNAMIC_PYTHON3_DLL=\\\\\"${vi_cv_dll_name_python3}\\\\\"" src/auto/config.mk
141
191
grep -q -- "-DDYNAMIC_RUBY_DLL=\\\\\"${vi_cv_dll_name_ruby}\\\\\"" src/auto/config.mk
142
192
193
+ # Also search for the arm64 overrides for the default library locations, which are different from x86_64
194
+ # because Homebrew puts them at a different place.
195
+ grep -q -- "-DDYNAMIC_PYTHON3_DLL_ARM64=\\\\\"${vi_cv_dll_name_python3_arm64}\\\\\"" src/auto/config.mk
196
+ grep -q -- "-DDYNAMIC_RUBY_DLL_ARM64=\\\\\"${vi_cv_dll_name_ruby_arm64}\\\\\"" src/auto/config.mk
197
+ grep -q -- "-DDYNAMIC_LUA_DLL_ARM64=\\\\\"${vi_cv_dll_name_lua_arm64}\\\\\"" src/auto/config.mk
198
+
143
199
- name : Show configure output
144
200
run : |
145
201
cat src/auto/config.mk
@@ -185,12 +241,11 @@ jobs:
185
241
echo 'Found external dynamic linkage!'; false
186
242
fi
187
243
188
- # Make sure we are building x86_64 only. arm64 builds don't work properly now, so we don't want to accidentally build
189
- # it as it will get prioritized by Apple Silicon Macs.
244
+ # Make sure we are building universal x86_64 / arm64 builds and didn't accidentally create a thin app.
190
245
check_arch() {
191
246
local archs=($(lipo -archs "$1"))
192
- if [[ ${archs[@]} != x86_64 ]]; then
193
- echo "Found unexpected arch(s) in $1: ${archs[@]}"; false
247
+ if [[ ${archs[@]} != " x86_64 arm64" ]]; then
248
+ echo "Wrong arch(s) in $1: ${archs[@]}"; false
194
249
fi
195
250
}
196
251
check_arch "${VIM_BIN}"
0 commit comments