Skip to content

Commit 11993dc

Browse files
committed
Move more Makefile and PathOfBuilding editing into shell scripts; try to fix build for Mac 10.13
1 parent 30b5bdb commit 11993dc

File tree

3 files changed

+39
-19
lines changed

3 files changed

+39
-19
lines changed

Makefile

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ pob: load_pob luacurl frontend
4343
cp -rf PathOfBuilding PathOfBuildingBuild; \
4444
pushd PathOfBuildingBuild; \
4545
bash ../editPathOfBuildingBuild.sh; \
46-
unzip runtime-win32.zip lua/xml.lua lua/base64.lua lua/sha1.lua; \
47-
mv lua/*.lua .; \
48-
rmdir lua; \
49-
cp ../lcurl.so .; \
50-
mv src/* .; \
51-
rmdir src; \
5246
popd
5347

5448
frontend:
@@ -60,20 +54,10 @@ load_pob:
6054
git add . && git fetch && git reset --hard origin/dev; \
6155
popd
6256

63-
# The seds below ensure that:
64-
#
65-
# - we only replace `lua` with `luajit` once
66-
# - we use pkg-config to find the right path for curl libraries
67-
# - we use gcc-12 from Homebrew instead of clang, to ensure that we build
68-
# the x86_64 library on ARM systems
69-
# - we target only MacOS 10.5 or later; otherwise, we get an error
7057
luacurl:
7158
git clone --depth 1 https://github.com/Lua-cURL/Lua-cURLv3.git; \
72-
pushd Lua-cURLv3; \
73-
sed -i '' 's/\?= lua$$/\?= luajit/' Makefile; \
74-
sed -i '' 's@shell .* --libs libcurl@shell PKG_CONFIG_PATH=\$$\$$(arch --x86_64 brew --prefix --installed curl)/lib/pkgconfig \$$(PKG_CONFIG) --libs libcurl@' Makefile; \
75-
sed -i '' 's@?= \$$(MAC_ENV) gcc$$@ = \$$(MAC_ENV) arch=x86_64 gcc-12@' Makefile; \
76-
sed -i '' "s@MACOSX_DEPLOYMENT_TARGET='10.3'@MACOSX_DEPLOYMENT_TARGET='10.5'@" Makefile; \
59+
bash editLuaCurlMakefile.sh; \
60+
pushd Lua-cURLv3; \
7761
make; \
7862
mv lcurl.so ../lcurl.so; \
7963
popd

editLuaCurlMakefile.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
pushd Lua-cURLv3
3+
4+
# We only replace `lua` with `luajit` once
5+
sed -i '' 's/?= lua$/?= luajit/' Makefile
6+
# We use pkg-config to find the right path for curl libraries
7+
sed -i '' 's@shell .* --libs libcurl@shell PKG_CONFIG_PATH=$$(arch --x86_64 brew --prefix --installed curl)/lib/pkgconfig $(PKG_CONFIG) --libs libcurl@' Makefile
8+
# We use the Homebrew installed GCC and build for x86_64 to ensure we build the
9+
# x86_64 library, even on ARM systems
10+
sed -i '' 's@?= \$(MAC_ENV) gcc$@ = \$(MAC_ENV) arch=x86_64 gcc-12@' Makefile
11+
# We target only MacOS 10.8 or later; otherwise, we get an error. We get an
12+
# error for targeting <10.5 and a warning for <10.8
13+
sed -i '' "s@MACOSX_DEPLOYMENT_TARGET='10.3'@MACOSX_DEPLOYMENT_TARGET='10.8'@" Makefile
14+
15+
# Some users on old versions of MacOS 10.13 run into the error:
16+
# dyld: cannot load 'PathOfBuilding' (load command 0x80000034 is unknown)
17+
#
18+
# It looks like 0x80000034 is associated with the fixup_chains optimization
19+
# that improves startup time:
20+
# https://www.emergetools.com/blog/posts/iOS15LaunchTime
21+
#
22+
# For compatibility, we disable that using the flag from this thread:
23+
# https://github.com/python/cpython/issues/97524
24+
if ! grep -q "LDFLAGS =" Makefile; then
25+
sed -i '' '/LIBS =/a\
26+
LDFLAGS = -Wl,-no_fixup_chains
27+
' Makefile
28+
fi
29+
popd

editPathOfBuildingBuild.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3-
cd "$DIR/PathOfBuildingBuild"
43

54
# We remove the `launch.devMode or` to ensure the user's builds are stored not in
65
# the binary, but within their user directory
@@ -19,3 +18,11 @@ sed -E -i '' "$SED_COMMAND" src/Classes/TreeTab.lua
1918
sed -E -i '' "$SED_COMMAND" src/Modules/BuildSiteTools.lua
2019
# Do not remove SSL for LaunchInstall and Update as that's more sensitive, but
2120
# also unused.
21+
22+
# Run remaining setup
23+
unzip runtime-win32.zip lua/xml.lua lua/base64.lua lua/sha1.lua
24+
mv lua/*.lua .
25+
rmdir lua
26+
cp ../lcurl.so .
27+
mv src/* .
28+
rmdir src

0 commit comments

Comments
 (0)