Skip to content

Commit 2159d15

Browse files
authored
Merge pull request #2248 from uvguy/master
Add support c++ target on android
2 parents e230ae7 + 7ef7770 commit 2159d15

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

contributors.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ YYYY/MM/DD, github id, Full name, email
182182
2017/12/13, enessoylu, Enes Soylu, [email protected]
183183
2017/12/20, kbsletten, Kyle Sletten, [email protected]
184184
2017/12/27, jkmar, Jakub Marciniszyn, [email protected]
185+
2018/03/10, uvguy, [email protected]
185186
2018/01/06, kasbah, Kaspar Emanuel, [email protected]
186187
2018/01/15, xgcssch, Sönke Schau, [email protected]
187188
2018/02/08, razfriman, Raz Friman, [email protected]
@@ -201,4 +202,4 @@ YYYY/MM/DD, github id, Full name, email
201202
2018/07/27, Maksim Novikov, [email protected]
202203
2018/07/31 Lucas Henrqiue, [email protected]
203204
2018/08/03, ENDOH takanao, [email protected]
204-
2018/10/29, chrisaycock, Christopher Aycock, chris[at]chrisaycock[dot]com
205+
2018/10/29, chrisaycock, Christopher Aycock, chris[at]chrisaycock[dot]com

runtime/Cpp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHE
104104
if(NOT (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0))
105105
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 5.0 or greater.")
106106
endif ()
107+
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ANDROID)
108+
# Need -Os cflag and cxxflags here to work with exception handling on armeabi.
109+
# see https://github.com/android-ndk/ndk/issues/573
110+
# and without -stdlib=libc++ cxxflags
107111
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND APPLE)
108112
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
109113
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ( CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") )

runtime/Cpp/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The C++ target has been the work of the following people:
2525

2626
## Project Status
2727

28-
* Building on OS X, Windows, and Linux
28+
* Building on OS X, Windows, Android and Linux
2929
* No errors and warnings
3030
* Library linking
3131
* Some unit tests in the OSX project, for important base classes with almost 100% code coverage.
@@ -51,6 +51,9 @@ It will automatically use the CMake description to open up a Visual Studio Solut
5151
#### Compiling on OSX
5252
Either open the included XCode project and build that or use the cmake compilation as described for linux.
5353

54+
#### Compiling on Android
55+
Try run cmake -DCMAKE_ANDROID_NDK=/folder/of/android_ndkr17_and_above -DCMAKE_SYSTEM_NAME=Android -DCMAKE_ANDROID_API=14 -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_STL_TYPE=c++_shared -DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang -DCMAKE_BUILD_TYPE=Release /folder/antlr4_src_dir -G Ninja.
56+
5457
#### Compiling on Linux
5558
- cd <antlr4-dir>/runtime/Cpp (this is where this readme is located)
5659
- mkdir build && mkdir run && cd build

0 commit comments

Comments
 (0)