diff options
author | Narayan Kamath <narayan@google.com> | 2012-09-14 16:05:45 +0100 |
---|---|---|
committer | Narayan Kamath <narayan@google.com> | 2012-09-14 16:28:09 +0100 |
commit | 0172f3c6f03973e56208e013178ec68365255c60 (patch) | |
tree | 4f5093f36afb6e322ab104782b57f69a0c533b5a | |
parent | f163f6985a63328d07e3de249ad3daf4a0c67d8a (diff) | |
download | marisa-trie-0172f3c6f03973e56208e013178ec68365255c60.tar.gz |
Get Marisa compiling under android.
Note that the code here still uses std::string and
not the "google3" string. That change can be made later.
We also use gnustl_static for STL dependencies. This is
our only option because the code here uses exceptions.
Change-Id: I24027b6ab075440fdc993166399be9374465cd71
-rw-r--r-- | Android.mk | 44 | ||||
-rw-r--r-- | README.android | 3 | ||||
-rw-r--r-- | lib/marisa/key.h | 2 | ||||
-rw-r--r-- | lib/marisa/mapper.cc | 4 | ||||
-rw-r--r-- | lib/marisa/marisa-string.h (renamed from lib/marisa/string.h) | 0 | ||||
-rw-r--r-- | lib/marisa/tail.h | 2 |
6 files changed, 50 insertions, 5 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..46b4440 --- /dev/null +++ b/Android.mk @@ -0,0 +1,44 @@ +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_C_INCLUDES += $(LOCAL_PATH)/lib/marisa +LOCAL_CFLAGS += -fexceptions +LOCAL_CPP_EXTENSION := .cc + +LOCAL_NDK_STL_VARIANT := gnustl_static + +LOCAL_SRC_FILES := lib/marisa/base.cc \ + lib/marisa/intvector.cc \ + lib/marisa/progress.cc \ + lib/marisa/tail.cc \ + lib/marisa/trie.cc \ + lib/marisa/trie-search.cc \ + lib/marisa/bitvector.cc \ + lib/marisa/mapper.cc \ + lib/marisa/reader.cc \ + lib/marisa/trie-build.cc \ + lib/marisa/trie-c.cc \ + lib/marisa/writer.cc + +$(info $(LOCAL_SRC_FILES)) + +LOCAL_MODULE := libmarisa-trie + +LOCAL_SDK_VERSION := 14 + +include $(BUILD_STATIC_LIBRARY) diff --git a/README.android b/README.android index 6dfc6a2..4a6b6b4 100644 --- a/README.android +++ b/README.android @@ -14,3 +14,6 @@ Homepage: http://code.google.com/p/marisa-trie/ Local Modifications: - Remove files under vs2008/ as we don't need to build under visual studio. +- Changes to string.h to avoid a header collision with the C + standard header with the same name. +- Apply patch 30551945 from alexgru to fix a critical bug. diff --git a/lib/marisa/key.h b/lib/marisa/key.h index 33dec2e..eac27be 100644 --- a/lib/marisa/key.h +++ b/lib/marisa/key.h @@ -1,8 +1,6 @@ #ifndef MARISA_KEY_H_ #define MARISA_KEY_H_ -#include "string.h" - namespace marisa { template <typename T> diff --git a/lib/marisa/mapper.cc b/lib/marisa/mapper.cc index c03373c..4562a6d 100644 --- a/lib/marisa/mapper.cc +++ b/lib/marisa/mapper.cc @@ -22,7 +22,7 @@ Mapper::Mapper() Mapper::Mapper(const void *ptr, std::size_t size) : ptr_(ptr), origin_(NULL), avail_(size), size_(0), file_(NULL), map_(NULL) { - MARISA_THROW_IF((ptr != NULL) && (size != 0), MARISA_PARAM_ERROR); + MARISA_THROW_IF((ptr == NULL) || (size == 0), MARISA_PARAM_ERROR); } #else // defined _WIN32 || defined _WIN64 Mapper::Mapper() @@ -30,7 +30,7 @@ Mapper::Mapper() Mapper::Mapper(const void *ptr, std::size_t size) : ptr_(ptr), origin_(MAP_FAILED), avail_(size), size_(0), fd_(-1) { - MARISA_THROW_IF((ptr != NULL) && (size != 0), MARISA_PARAM_ERROR); + MARISA_THROW_IF((ptr == NULL) || (size == 0), MARISA_PARAM_ERROR); } #endif // defined _WIN32 || defined _WIN64 diff --git a/lib/marisa/string.h b/lib/marisa/marisa-string.h index b0e272e..b0e272e 100644 --- a/lib/marisa/string.h +++ b/lib/marisa/marisa-string.h diff --git a/lib/marisa/tail.h b/lib/marisa/tail.h index b7679ad..a8a2b1e 100644 --- a/lib/marisa/tail.h +++ b/lib/marisa/tail.h @@ -1,7 +1,7 @@ #ifndef MARISA_TAIL_H_ #define MARISA_TAIL_H_ -#include "string.h" +#include "marisa-string.h" #include "vector.h" namespace marisa { |