Skip to content

Commit

Permalink
support Apple M1
Browse files Browse the repository at this point in the history
  • Loading branch information
coleflowers committed May 20, 2021
1 parent f74a29a commit b4dbda7
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ root=`pwd`
antlr=`pwd`/library/antlrruntime
deps=`pwd`/deps
jsoncpp=`pwd`/library/jsoncpp

SYSTEM=`uname -s`
ARCH=`uname -p`

cd deps
curl -O https://www.antlr.org/download/antlr-4.7.1-complete.jar
cd ..
Expand All @@ -13,13 +17,43 @@ svn co https://github.com/antlr/antlr4/tags/4.7.1/runtime/Cpp library/antlrrunti
cd library/antlrruntime
mkdir build
cd build
cmake .. -DANTLR_JAR_LOCATION=$deps/antlr-4.7.1-complete.jar -DWITH_DEMO=True
make
DESTDIR=$deps make install
if [ $SYSTEM = "Darwin" ] && [ $ARCH = "arm" ];then
cmake .. -DANTLR_JAR_LOCATION=$deps/antlr-4.7.1-complete.jar -DWITH_DEMO=True -DCMAKE_OSX_ARCHITECTURES=x86_64
make
cp -r ../dist x86
make clean
cmake .. -DANTLR_JAR_LOCATION=$deps/antlr-4.7.1-complete.jar -DWITH_DEMO=True -DCMAKE_OSX_ARCHITECTURES=arm64
make
cp -r ../dist arm
lipo -create -output libantlr4-runtime.a ./arm/libantlr4-runtime.a ./x86/libantlr4-runtime.a
lipo -create -output libantlr4-runtime.4.7.1.dylib ./arm/libantlr4-runtime.4.7.1.dylib ./x86/libantlr4-runtime.4.7.1.dylib
cp libantlr4-runtime.a ../dist
cp libantlr4-runtime.4.7.1.dylib ../dist
DESTDIR=$deps make install
else
cmake .. -DANTLR_JAR_LOCATION=$deps/antlr-4.7.1-complete.jar -DWITH_DEMO=True
make
DESTDIR=$deps make install
fi

# make jsoncpp
cd $jsoncpp
mkdir build
cd build
cmake ..
DESTDIR=$deps make install
if [ $SYSTEM = "Darwin" ] && [ $ARCH = "arm" ];then
cmake -DCMAKE_OSX_ARCHITECTURES=x86_64 ..
DESTDIR=./x86 make install
make clean
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ..
DESTDIR=./arm make install
make clean
lipo -create -output libjsoncpp.a ./arm/usr/local/lib/libjsoncpp.a ./x86/usr/local/lib/libjsoncpp.a
cp libjsoncpp.a ./src/lib_json/libjsoncpp.a
DESTDIR=$deps make install
else
cmake ..
DESTDIR=$deps make install
fi

cd $root
echo "Succ!"

0 comments on commit b4dbda7

Please sign in to comment.