Skip to content

Commit

Permalink
Merge branch 'vlovich-fix-android-build'
Browse files Browse the repository at this point in the history
  • Loading branch information
hodduc committed Aug 2, 2016
2 parents ba2dc49 + 5c57c22 commit d865c71
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 4 deletions.
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ elseif (CMAKE_BUILD_TYPE STREQUAL Release)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_RELEASE_FLAGS}")
endif()

add_definitions(-DUSE_OPENSSL)
add_definitions(-DUSE_OPENSSL -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS)

if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(ARCH "amd64")
Expand All @@ -45,10 +45,10 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
set(ARCH "386")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
set(ARCH "386")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm.*")
set(ARCH "arm")
#elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
# set(ARCH "aarch64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(ARCH "aarch64")
else()
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
endif()
Expand Down Expand Up @@ -196,6 +196,16 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")

src/base/threading/platform_thread_linux.cc
)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(
BASE_ARCH_LIBRARIES
)
set(
BASE_ARCH_SOURCES

src/base/threading/platform_thread_linux.cc
src/base/threading/thread_local_android.cc
)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
set(
BASE_ARCH_LIBRARIES
Expand Down
2 changes: 2 additions & 0 deletions boringssl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv6")
set(ARCH "arm")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7-a")
set(ARCH "arm")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^armv*")
set(ARCH "arm")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(ARCH "aarch64")
else()
Expand Down
4 changes: 4 additions & 0 deletions protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ project (libprotobuf)

include_directories(../src/third_party/protobuf/src ../src/third_party/protobuf/)

if (NOT ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -DHAVE_PTHREAD")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_PTHREAD")
endif()

add_library(
protobuf
Expand Down
29 changes: 29 additions & 0 deletions src/base/os_compat_android.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_OS_COMPAT_ANDROID_H_
#define BASE_OS_COMPAT_ANDROID_H_
#pragma once

#include <fcntl.h>
#include <sys/types.h>
#include <utime.h>

// Not implemented in Bionic.
extern "C" int futimes(int fd, const struct timeval tv[2]);

// The prototype of mkdtemp is missing.
extern "C" char* mkdtemp(char* path);

// Android has no timegm().
extern "C" time_t timegm(struct tm* const t);

// The lockf() function is not available on Android; we translate to flock().
#define F_LOCK LOCK_EX
#define F_ULOCK LOCK_UN
inline int lockf(int fd, int cmd, off_t ignored_len) {
return flock(fd, cmd);
}

#endif // BASE_OS_COMPAT_ANDROID_H_
31 changes: 31 additions & 0 deletions src/base/threading/thread_local_android.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/threading/thread_local.h"

namespace base {
namespace internal {

// static
void ThreadLocalPlatform::AllocateSlot(SlotType* slot) {
slot->Initialize(nullptr);
}

// static
void ThreadLocalPlatform::FreeSlot(SlotType slot) {
slot.Free();
}

// static
void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) {
return slot.Get();
}

// static
void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) {
slot.Set(value);
}

} // namespace internal
} // namespace base

0 comments on commit d865c71

Please sign in to comment.