Skip to content

Instantly share code, notes, and snippets.

@ericmj
Last active January 9, 2018 00:58
Show Gist options
  • Save ericmj/094371725660393b3f320b7001159a2c to your computer and use it in GitHub Desktop.
Save ericmj/094371725660393b3f320b7001159a2c to your computer and use it in GitHub Desktop.
Install and patch old OTPs for asdf and macOS 10.13
#!/bin/bash
otp_version=$1
asdf_dir=$(dirname $(dirname $(which asdf)))
pushd $asdf_dir/installs/erlang
rm -rf $otp_version
rm -rf src_$otp_version
git clone git@github.com:erlang/otp.git src_$otp_version -b OTP-$otp_version --single-branch --depth 1
pushd src_$otp_version
sed -i '' 's/DED_LDFLAGS="-bundle -flat_namespace -undefined suppress"/DED_LDFLAGS="-bundle -bundle_loader \${ERL_TOP}\/bin\/\$host\/beam.smp"/' erts/configure.in
# sed -i '' 's/if((index < memenv->next) && ((index == 0) || (temp > NULL)))/if((index < memenv->next) && ((index == 0) || (temp != (void *)NULL)))/' lib/wx/c_src/wxe_impl.cpp
patch -N -p1 <<'_END_PATCH'
diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index 0d2da5d4a79..8118136d30e 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -666,7 +666,7 @@ void * WxeApp::getPtr(char * bp, wxeMemEnv *memenv) {
throw wxe_badarg(index);
}
void * temp = memenv->ref2ptr[index];
- if((index < memenv->next) && ((index == 0) || (temp > NULL)))
+ if((index < memenv->next) && ((index == 0) || (temp != (void *)NULL)))
return temp;
else {
throw wxe_badarg(index);
@@ -678,7 +678,7 @@ void WxeApp::registerPid(char * bp, ErlDrvTermData pid, wxeMemEnv * memenv) {
if(!memenv)
throw wxe_badarg(index);
void * temp = memenv->ref2ptr[index];
- if((index < memenv->next) && ((index == 0) || (temp > NULL))) {
+ if((index < memenv->next) && ((index == 0) || (temp != (void *) NULL))) {
ptrMap::iterator it;
it = ptr2ref.find(temp);
if(it != ptr2ref.end()) {
_END_PATCH
./otp_build autoconf
./configure --with-ssl=/usr/local/opt/openssl --prefix=$asdf_dir/installs/erlang/$otp_version
make -j8
make install
popd
rm -rf src_$otp_version
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment