mirror of
https://git.proxmox.com/git/libgit2
synced 2025-07-10 13:25:14 +00:00
Merge pull request #1823 from kadamski/building4android
Small changes enabling compiling libgit2 for Android.
This commit is contained in:
commit
c46fe0c651
@ -29,6 +29,8 @@ OPTION( PROFILE "Generate profiling information" OFF )
|
|||||||
OPTION( ENABLE_TRACE "Enables tracing support" OFF )
|
OPTION( ENABLE_TRACE "Enables tracing support" OFF )
|
||||||
OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )
|
OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF )
|
||||||
|
|
||||||
|
OPTION( ANDROID "Build for android NDK" OFF )
|
||||||
|
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
# This option is only available when building with MSVC. By default, libgit2
|
# This option is only available when building with MSVC. By default, libgit2
|
||||||
# is build using the cdecl calling convention, which is useful if you're
|
# is build using the cdecl calling convention, which is useful if you're
|
||||||
@ -127,7 +129,7 @@ IF (ENABLE_TRACE STREQUAL "ON")
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Include POSIX regex when it is required
|
# Include POSIX regex when it is required
|
||||||
IF(WIN32 OR AMIGA)
|
IF(WIN32 OR AMIGA OR ANDROID)
|
||||||
INCLUDE_DIRECTORIES(deps/regex)
|
INCLUDE_DIRECTORIES(deps/regex)
|
||||||
SET(SRC_REGEX deps/regex/regex.c)
|
SET(SRC_REGEX deps/regex/regex.c)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
@ -409,7 +411,7 @@ ENDIF ()
|
|||||||
IF (BUILD_EXAMPLES)
|
IF (BUILD_EXAMPLES)
|
||||||
FILE(GLOB_RECURSE EXAMPLE_SRC examples/network/*.c examples/network/*.h)
|
FILE(GLOB_RECURSE EXAMPLE_SRC examples/network/*.c examples/network/*.h)
|
||||||
ADD_EXECUTABLE(cgit2 ${EXAMPLE_SRC})
|
ADD_EXECUTABLE(cgit2 ${EXAMPLE_SRC})
|
||||||
IF(WIN32)
|
IF(WIN32 OR ANDROID)
|
||||||
TARGET_LINK_LIBRARIES(cgit2 git2)
|
TARGET_LINK_LIBRARIES(cgit2 git2)
|
||||||
ELSE()
|
ELSE()
|
||||||
TARGET_LINK_LIBRARIES(cgit2 git2 pthread)
|
TARGET_LINK_LIBRARIES(cgit2 git2 pthread)
|
||||||
|
22
README.md
22
README.md
@ -108,6 +108,28 @@ See [the wiki]
|
|||||||
(https://github.com/libgit2/libgit2/wiki/Building-libgit2-on-Windows)
|
(https://github.com/libgit2/libgit2/wiki/Building-libgit2-on-Windows)
|
||||||
for more detailed instructions.
|
for more detailed instructions.
|
||||||
|
|
||||||
|
Android
|
||||||
|
-------
|
||||||
|
|
||||||
|
Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
|
||||||
|
Optionaly, crosscompile and install OpenSSL inside of it. Then create CMake
|
||||||
|
toolchain file that configures paths to your crosscompiler (substitude `{PATH}`
|
||||||
|
with full path to the toolchain):
|
||||||
|
|
||||||
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
SET(CMAKE_SYSTEM_VERSION Android)
|
||||||
|
|
||||||
|
SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
|
||||||
|
SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
|
||||||
|
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
|
||||||
|
Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile} -DANDROID=1` to cmake command
|
||||||
|
when configuring.
|
||||||
|
|
||||||
Language Bindings
|
Language Bindings
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ void git__qsort_r(
|
|||||||
void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload)
|
void *els, size_t nel, size_t elsize, git__sort_r_cmp cmp, void *payload)
|
||||||
{
|
{
|
||||||
#if defined(__MINGW32__) || defined(__OpenBSD__) || defined(AMIGA) || \
|
#if defined(__MINGW32__) || defined(__OpenBSD__) || defined(AMIGA) || \
|
||||||
defined(__gnu_hurd__) || \
|
defined(__gnu_hurd__) || defined(__ANDROID_API__) || \
|
||||||
(__GLIBC__ == 2 && __GLIBC_MINOR__ < 8)
|
(__GLIBC__ == 2 && __GLIBC_MINOR__ < 8)
|
||||||
git__insertsort_r(els, nel, elsize, NULL, cmp, payload);
|
git__insertsort_r(els, nel, elsize, NULL, cmp, payload);
|
||||||
#elif defined(GIT_WIN32)
|
#elif defined(GIT_WIN32)
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
#include "posix.h"
|
#include "posix.h"
|
||||||
#include "loose_data.h"
|
#include "loose_data.h"
|
||||||
|
|
||||||
|
#ifdef __ANDROID_API__
|
||||||
|
# define S_IREAD S_IRUSR
|
||||||
|
# define S_IWRITE S_IWUSR
|
||||||
|
#endif
|
||||||
|
|
||||||
static void write_object_files(object_data *d)
|
static void write_object_files(object_data *d)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
Loading…
Reference in New Issue
Block a user