Skip to content

Commit 823e070

Browse files
committed
[New] Build targeting android
1 parent 0bbbfc2 commit 823e070

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

build-android.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake --build . --target clean
2+
rm CMakeCache.txt
3+
cmake -B build-android -G Ninja \
4+
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
5+
-DANDROID_ABI=arm64-v8a \
6+
-DANDROID_PLATFORM=android-30 \
7+
-DCMAKE_BUILD_TYPE=Release
8+
cmake --build build-android --config Release

include/bux/XPlatform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace bux {
1616

17-
#ifndef __APPLE__
17+
#if !defined(__APPLE__) && !defined(__ANDROID__)
1818
using T_LocalZone = const std::chrono::time_zone *;
1919
inline T_LocalZone local_zone() { return std::chrono::get_tzdb().current_zone(); }
2020
#define LOCALZONE_IS_TIMEZONE (1)

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ add_library(bux STATIC
1616
)
1717
target_include_directories(bux PRIVATE ../include/bux)
1818
target_compile_features(bux PRIVATE cxx_std_23)
19+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
20+
target_compile_options(bux PUBLIC -fPIC)
21+
endif()
1922
#target_compile_options(bux PRIVATE -g -O0)
2023
if(Iconv_FOUND)
2124
target_link_libraries(bux Iconv::Iconv)

src/StrUtil.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
#include <cstring> // strstr(), strlen()
77
#ifdef _WIN32
88
#include <processenv.h> // ExpandEnvironmentStringsA()
9-
#elif defined(__unix__) || defined(__unix) || defined(__gnu_linux__)
9+
#elif !defined(__ANDROID__) && (defined(__unix__) || defined(__unix) || defined(__gnu_linux__))
1010
#include <wordexp.h> // wordexp(), wordfree()
1111
#else
1212
#define DISABLE_EXPAND_ENV_
1313
#endif
1414
#ifdef __unix__
15-
#include <cxxabi.h> // abi::__cxa_demangle()
15+
#include <cstdlib> // free()
16+
#include <cxxabi.h> // abi::__cxa_demangle()
1617
#endif
1718

1819

0 commit comments

Comments
 (0)