Squashed 'third_party/flatbuffers/' content from commit acc9990ab

Change-Id: I48550d40d78fea996ebe74e9723a5d1f910de491
git-subtree-dir: third_party/flatbuffers
git-subtree-split: acc9990abd2206491480291b0f85f925110102ea
diff --git a/android/.project b/android/.project
new file mode 100644
index 0000000..e7d5931
--- /dev/null
+++ b/android/.project
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (c) 2014 Google, Inc.
+
+     This software is provided 'as-is', without any express or implied
+     warranty.  In no event will the authors be held liable for any damages
+     arising from the use of this software.
+     Permission is granted to anyone to use this software for any purpose,
+     including commercial applications, and to alter it and redistribute it
+     freely, subject to the following restrictions:
+     1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+     2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+     3. This notice may not be removed or altered from any source distribution.
+ -->
+<projectDescription>
+    <name>FlatBufferTest</name>
+</projectDescription>
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
new file mode 100644
index 0000000..846fd13
--- /dev/null
+++ b/android/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2013 Google, Inc.
+
+     This software is provided 'as-is', without any express or implied
+     warranty.  In no event will the authors be held liable for any damages
+     arising from the use of this software.
+     Permission is granted to anyone to use this software for any purpose,
+     including commercial applications, and to alter it and redistribute it
+     freely, subject to the following restrictions:
+     1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+     2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+     3. This notice may not be removed or altered from any source distribution.
+ -->
+<!-- BEGIN_INCLUDE(manifest) -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="com.example.FlatBufferTest">
+
+    <uses-feature android:glEsVersion="0x00020000"></uses-feature>
+
+    <!-- This .apk has no Java code itself, so set hasCode to false. -->
+    <application android:label="@string/app_name"
+                 android:hasCode="false"
+                 android:allowBackup="false">
+        <!-- Our activity is the built-in NativeActivity framework class.
+             This will take care of integrating with our NDK code. -->
+        <activity android:name="android.app.NativeActivity"
+                android:label="@string/app_name"
+                android:configChanges="orientation|keyboardHidden"
+                android:screenOrientation="landscape">
+            <!-- Tell NativeActivity the name of or .so -->
+            <meta-data android:name="android.app.lib_name"
+                    android:value="FlatBufferTest" />
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>
+<!-- END_INCLUDE(manifest) -->
diff --git a/android/build.gradle b/android/build.gradle
new file mode 100644
index 0000000..5e9809b
--- /dev/null
+++ b/android/build.gradle
@@ -0,0 +1,108 @@
+// Copyright (c) 2017 Google, Inc.
+//
+// This software is provided 'as-is', without any express or implied
+// warranty.  In no event will the authors be held liable for any damages
+// arising from the use of this software.
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+// 1. The origin of this software must not be misrepresented; you must not
+// claim that you wrote the original software. If you use this software
+// in a product, an acknowledgment in the product documentation would be
+// appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must not be
+// misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source distribution.
+
+buildscript {
+  repositories {
+    jcenter()
+  }
+  dependencies {
+    classpath 'com.android.tools.build:gradle:2.3.0'
+  }
+}
+
+allprojects {
+  repositories {
+    jcenter()
+  }
+}
+
+apply plugin: 'com.android.application'
+
+android {
+  compileSdkVersion 25
+  buildToolsVersion '25.0.2'
+
+  sourceSets {
+    main {
+      manifest.srcFile 'AndroidManifest.xml'
+      res.srcDirs = ['res']
+    }
+  }
+
+  externalNativeBuild {
+    ndkBuild {
+      path "jni/Android.mk"
+    }
+  }
+
+  defaultConfig {
+    applicationId 'com.example.FlatBufferTest'
+    // This is the platform API where NativeActivity was introduced.
+    minSdkVersion 9
+    targetSdkVersion 25
+    versionCode 1
+    versionName "1.0"
+
+    buildTypes {
+      release {
+        minifyEnabled false
+      }
+    }
+
+    externalNativeBuild {
+      ndkBuild {
+        targets "FlatBufferTest"
+        arguments "-j" + Runtime.getRuntime().availableProcessors()
+        abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
+      }
+    }
+  }
+
+  lintOptions {
+    abortOnError false
+  }
+
+  // Build with each STL variant.
+  productFlavors {
+    stlport {
+      applicationIdSuffix ".stlport"
+      versionNameSuffix "-stlport"
+      externalNativeBuild {
+        ndkBuild {
+          arguments "APP_STL=stlport_static"
+        }
+      }
+    }
+    gnustl {
+      applicationIdSuffix ".gnustl"
+      versionNameSuffix "-gnustl"
+      externalNativeBuild {
+        ndkBuild {
+          arguments "APP_STL=gnustl_static"
+        }
+      }
+    }
+    libcpp {
+      applicationIdSuffix ".libcpp"
+      versionNameSuffix "-libcpp"
+      externalNativeBuild {
+        ndkBuild {
+          arguments "APP_STL=c++_static"
+        }
+      }
+    }
+  }
+}
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..b4163b8
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..1e1168c
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Jun 19 11:54:59 PDT 2017
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
diff --git a/android/gradlew b/android/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/android/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+    echo "$*"
+}
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+  cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/android/gradlew.bat b/android/gradlew.bat
new file mode 100644
index 0000000..f955316
--- /dev/null
+++ b/android/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
new file mode 100644
index 0000000..e29c872
--- /dev/null
+++ b/android/jni/Android.mk
@@ -0,0 +1,65 @@
+# Copyright (c) 2013 Google, Inc.
+#
+# This software is provided 'as-is', without any express or implied
+# warranty.  In no event will the authors be held liable for any damages
+# arising from the use of this software.
+# Permission is granted to anyone to use this software for any purpose,
+# including commercial applications, and to alter it and redistribute it
+# freely, subject to the following restrictions:
+# 1. The origin of this software must not be misrepresented; you must not
+# claim that you wrote the original software. If you use this software
+# in a product, an acknowledgment in the product documentation would be
+# appreciated but is not required.
+# 2. Altered source versions must be plainly marked as such, and must not be
+# misrepresented as being the original software.
+# 3. This notice may not be removed or altered from any source distribution.
+
+LOCAL_PATH := $(call my-dir)/../..
+
+include $(LOCAL_PATH)/android/jni/include.mk
+LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH))
+
+# Empty static library so that other projects can include just the basic
+# FlatBuffers headers as a module.
+include $(CLEAR_VARS)
+LOCAL_MODULE := flatbuffers
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_CPPFLAGS := -std=c++11 -fexceptions -Wall \
+    -DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE
+
+include $(BUILD_STATIC_LIBRARY)
+
+# static library that additionally includes text parsing/generation/reflection
+# for projects that want richer functionality.
+include $(CLEAR_VARS)
+LOCAL_MODULE := flatbuffers_extra
+LOCAL_SRC_FILES := src/idl_parser.cpp \
+                   src/idl_gen_text.cpp \
+                   src/reflection.cpp \
+                   src/util.cpp \
+                   src/code_generators.cpp
+LOCAL_STATIC_LIBRARIES := flatbuffers
+LOCAL_ARM_MODE := arm
+include $(BUILD_STATIC_LIBRARY)
+
+# FlatBuffers test
+include $(CLEAR_VARS)
+LOCAL_MODULE := FlatBufferTest
+LOCAL_SRC_FILES := android/jni/main.cpp \
+                   tests/test.cpp \
+                   tests/test_assert.h \
+                   tests/test_builder.h \
+                   tests/test_assert.cpp \
+                   tests/test_builder.cpp \
+                   tests/native_type_test_impl.h \
+                   tests/native_type_test_impl.cpp \
+                   src/idl_gen_fbs.cpp \
+                   src/idl_gen_general.cpp
+LOCAL_LDLIBS := -llog -landroid -latomic
+LOCAL_STATIC_LIBRARIES := android_native_app_glue flatbuffers_extra
+LOCAL_ARM_MODE := arm
+include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,android/native_app_glue)
+
+$(call import-add-path,$(LOCAL_PATH)/../..)
diff --git a/android/jni/Application.mk b/android/jni/Application.mk
new file mode 100644
index 0000000..ca9e800
--- /dev/null
+++ b/android/jni/Application.mk
@@ -0,0 +1,20 @@
+# Copyright (c) 2014 Google, Inc.
+#
+# This software is provided 'as-is', without any express or implied
+# warranty.  In no event will the authors be held liable for any damages
+# arising from the use of this software.
+# Permission is granted to anyone to use this software for any purpose,
+# including commercial applications, and to alter it and redistribute it
+# freely, subject to the following restrictions:
+# 1. The origin of this software must not be misrepresented; you must not
+# claim that you wrote the original software. If you use this software
+# in a product, an acknowledgment in the product documentation would be
+# appreciated but is not required.
+# 2. Altered source versions must be plainly marked as such, and must not be
+# misrepresented as being the original software.
+# 3. This notice may not be removed or altered from any source distribution.
+APP_PLATFORM := android-9
+APP_PROJECT_PATH := $(call my-dir)/..
+APP_STL ?= stlport_static
+APP_ABI := armeabi-v7a
+APP_CPPFLAGS += -std=c++11
diff --git a/android/jni/build_flatc.bat b/android/jni/build_flatc.bat
new file mode 100644
index 0000000..0b3f2ad
--- /dev/null
+++ b/android/jni/build_flatc.bat
@@ -0,0 +1,68 @@
+@rem Copyright (c) 2013 Google, Inc.
+@rem
+@rem This software is provided 'as-is', without any express or implied
+@rem warranty.  In no event will the authors be held liable for any damages
+@rem arising from the use of this software.
+@rem Permission is granted to anyone to use this software for any purpose,
+@rem including commercial applications, and to alter it and redistribute it
+@rem freely, subject to the following restrictions:
+@rem 1. The origin of this software must not be misrepresented; you must not
+@rem claim that you wrote the original software. If you use this software
+@rem in a product, an acknowledgment in the product documentation would be
+@rem appreciated but is not required.
+@rem 2. Altered source versions must be plainly marked as such, and must not be
+@rem misrepresented as being the original software.
+@rem 3. This notice may not be removed or altered from any source distribution.
+@echo off
+
+setlocal enabledelayedexpansion
+
+set thispath=%~dp0
+
+rem Path to cmake passed in by caller.
+set cmake=%1
+rem Path to cmake project to build.
+set cmake_project_path=%2
+
+rem Newest and oldest version of Visual Studio that it's possible to select.
+set visual_studio_version_max=20
+set visual_studio_version_min=8
+
+rem Determine the newest version of Visual Studio installed on this machine.
+set visual_studio_version=
+for /L %%a in (%visual_studio_version_max%,-1,%visual_studio_version_min%) do (
+  echo Searching for Visual Studio %%a >&2
+  reg query HKLM\SOFTWARE\Microsoft\VisualStudio\%%a.0 /ve 1>NUL 2>NUL
+  if !ERRORLEVEL! EQU 0 (
+    set visual_studio_version=%%a
+    goto found_vs
+  )
+)
+echo Unable to determine whether Visual Studio is installed. >&2
+exit /B 1
+:found_vs
+
+rem Map Visual Studio version to cmake generator name.
+if "%visual_studio_version%"=="8" (
+  set cmake_generator=Visual Studio 8 2005
+)
+if "%visual_studio_version%"=="9" (
+  set cmake_generator=Visual Studio 9 2008
+)
+if %visual_studio_version% GEQ 10 (
+  set cmake_generator=Visual Studio %visual_studio_version%
+)
+rem Set visual studio version variable for msbuild.
+set VisualStudioVersion=%visual_studio_version%.0
+
+rem Generate Visual Studio solution.
+echo Generating solution for %cmake_generator%. >&2
+cd "%cmake_project_path%"
+%cmake% -G"%cmake_generator%"
+if %ERRORLEVEL% NEQ 0 (
+  exit /B %ERRORLEVEL%
+)
+
+rem Build flatc
+python %thispath%\msbuild.py flatc.vcxproj
+if ERRORLEVEL 1 exit /B 1
diff --git a/android/jni/include.mk b/android/jni/include.mk
new file mode 100644
index 0000000..b53e257
--- /dev/null
+++ b/android/jni/include.mk
@@ -0,0 +1,237 @@
+# Copyright 2014 Google Inc. All rights reserved.
+#
+# 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.
+
+# This file contains utility functions for Android projects using Flatbuffers.
+# To use this file, include it in your project's Android.mk by calling near the
+# top of your android makefile like so:
+#
+#     include $(FLATBUFFERS_DIR)/android/jni/include.mk
+#
+# You will also need to import the flatbuffers module using the standard
+# import-module function.
+#
+# The main functionality this file provides are the following functions:
+# flatbuffers_fbs_to_h: Converts flatbuffer schema paths to header paths.
+# flatbuffers_header_build_rule:
+#     Creates a build rule for a schema's generated header. This build rule
+#     has a dependency on the flatc compiler which will be built if necessary.
+# flatbuffers_header_build_rules:
+#     Creates build rules for generated headers for each schema listed and sets
+#     up depenedendies.
+#
+# More information and example usage can be found in the comments preceeding
+# each function.
+
+# Targets to build the Flatbuffers compiler as well as some utility definitions
+ifeq (,$(FLATBUFFERS_INCLUDE_MK_))
+FLATBUFFERS_INCLUDE_MK_ := 1
+
+# Portable version of $(realpath) that omits drive letters on Windows.
+realpath-portable = $(join $(filter %:,$(subst :,: ,$1)),\
+                      $(realpath $(filter-out %:,$(subst :,: ,$1))))
+
+PROJECT_OS := $(OS)
+ifeq (,$(OS))
+PROJECT_OS := $(shell uname -s)
+else
+ifneq ($(findstring Windows,$(PROJECT_OS)),)
+PROJECT_OS := Windows
+endif
+endif
+
+# The following block generates build rules which result in headers being
+# rebuilt from flatbuffers schemas.
+
+FLATBUFFERS_CMAKELISTS_DIR := \
+  $(call realpath-portable,$(dir $(lastword $(MAKEFILE_LIST)))/../..)
+
+# Directory that contains the FlatBuffers compiler.
+ifeq (Windows,$(PROJECT_OS))
+FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
+FLATBUFFERS_FLATC := $(lastword \
+                       $(wildcard $(FLATBUFFERS_FLATC_PATH)/*/flatc.exe) \
+                       $(wildcard $(FLATBUFFERS_FLATC_PATH)/flatc.exe))
+endif
+ifeq (Linux,$(PROJECT_OS))
+FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
+FLATBUFFERS_FLATC := $(FLATBUFFERS_FLATC_PATH)/flatc
+endif
+ifeq (Darwin,$(PROJECT_OS))
+FLATBUFFERS_FLATC_PATH?=$(FLATBUFFERS_CMAKELISTS_DIR)
+FLATBUFFERS_FLATC := $(lastword \
+                       $(wildcard $(FLATBUFFERS_FLATC_PATH)/*/flatc) \
+                       $(wildcard $(FLATBUFFERS_FLATC_PATH)/flatc))
+endif
+
+FLATBUFFERS_FLATC_ARGS?=
+
+# Search for cmake.
+CMAKE_ROOT := \
+  $(call realpath-portable,$(LOCAL_PATH)/../../../../../../prebuilts/cmake)
+ifeq (,$(CMAKE))
+ifeq (Linux,$(PROJECT_OS))
+CMAKE := $(wildcard $(CMAKE_ROOT)/linux-x86/current/bin/cmake*)
+endif
+ifeq (Darwin,$(PROJECT_OS))
+CMAKE := \
+  $(wildcard $(CMAKE_ROOT)/darwin-x86_64/current/*.app/Contents/bin/cmake)
+endif
+ifeq (Windows,$(PROJECT_OS))
+CMAKE := $(wildcard $(CMAKE_ROOT)/windows/current/bin/cmake*)
+endif
+endif
+ifeq (,$(CMAKE))
+CMAKE := cmake
+endif
+
+# Windows friendly portable local path.
+# GNU-make doesn't like : in paths, must use relative paths on Windows.
+ifeq (Windows,$(PROJECT_OS))
+PORTABLE_LOCAL_PATH =
+else
+PORTABLE_LOCAL_PATH = $(LOCAL_PATH)/
+endif
+
+# Generate a host build rule for the flatbuffers compiler.
+ifeq (Windows,$(PROJECT_OS))
+define build_flatc_recipe
+	$(FLATBUFFERS_CMAKELISTS_DIR)\android\jni\build_flatc.bat \
+        $(CMAKE) $(FLATBUFFERS_CMAKELISTS_DIR)
+endef
+endif
+ifeq (Linux,$(PROJECT_OS))
+define build_flatc_recipe
+	+cd $(FLATBUFFERS_CMAKELISTS_DIR) && \
+      $(CMAKE) . && \
+      $(MAKE) flatc
+endef
+endif
+ifeq (Darwin,$(PROJECT_OS))
+define build_flatc_recipe
+	cd $(FLATBUFFERS_CMAKELISTS_DIR) && "$(CMAKE)" -GXcode . && \
+        xcodebuild -target flatc
+endef
+endif
+ifeq (,$(build_flatc_recipe))
+ifeq (,$(FLATBUFFERS_FLATC))
+$(error flatc binary not found!)
+endif
+endif
+
+# Generate a build rule for flatc.
+ifeq ($(strip $(FLATBUFFERS_FLATC)),)
+flatc_target := build_flatc
+.PHONY: $(flatc_target)
+FLATBUFFERS_FLATC := \
+  python $(FLATBUFFERS_CMAKELISTS_DIR)/android/jni/run_flatc.py \
+    $(FLATBUFFERS_CMAKELISTS_DIR)
+else
+flatc_target := $(FLATBUFFERS_FLATC)
+endif
+$(flatc_target):
+	$(call build_flatc_recipe)
+
+# $(flatbuffers_fbs_to_h schema_dir,output_dir,path)
+#
+# Convert the specified schema path to a Flatbuffers generated header path.
+# For example:
+#
+# $(call flatbuffers_fbs_to_h,$(MY_PROJ_DIR)/schemas,\
+#   $(MY_PROJ_DIR)/gen/include,$(MY_PROJ_DIR)/schemas/example.fbs)
+#
+# This will convert the file path `$(MY_PROJ_DIR)/schemas/example.fbs)` to
+# `$(MY_PROJ_DIR)/gen/include/example_generated.h`
+define flatbuffers_fbs_to_h
+$(subst $(1),$(2),$(patsubst %.fbs,%_generated.h,$(3)))
+endef
+
+# $(flatbuffers_header_build_rule schema_file,schema_dir,output_dir,\
+#   schema_include_dirs)
+#
+# Generate a build rule that will convert a Flatbuffers schema to a generated
+# header derived from the schema filename using flatbuffers_fbs_to_h. For
+# example:
+#
+# $(call flatbuffers_header_build_rule,$(MY_PROJ_DIR)/schemas/example.fbs,\
+#   $(MY_PROJ_DIR)/schemas,$(MY_PROJ_DIR)/gen/include)
+#
+# The final argument, schema_include_dirs, is optional and is only needed when
+# the schema files depend on other schema files outside their own directory.
+define flatbuffers_header_build_rule
+$(eval \
+  $(call flatbuffers_fbs_to_h,$(2),$(3),$(1)): $(1) $(flatc_target)
+	$(call host-echo-build-step,generic,Generate) \
+      $(subst $(LOCAL_PATH)/,,$(call flatbuffers_fbs_to_h,$(2),$(3),$(1)))
+	$(hide) $$(FLATBUFFERS_FLATC) $(FLATBUFFERS_FLATC_ARGS) \
+      $(foreach include,$(4),-I $(include)) -o $$(dir $$@) -c $$<)
+endef
+
+# TODO: Remove when the LOCAL_PATH expansion bug in the NDK is fixed.
+# Override the default behavior of local-source-file-path to workaround
+# a bug which prevents the build of deeply nested projects when NDK_OUT is
+# set.
+local-source-file-path=\
+$(if $(call host-path-is-absolute,$1),$1,$(call \
+    realpath-portable,$(LOCAL_PATH)/$1))
+
+
+# $(flatbuffers_header_build_rules schema_files,schema_dir,output_dir,\
+#   schema_include_dirs,src_files,[build_target],[dependencies]))
+#
+# $(1) schema_files: Space separated list of flatbuffer schema files.
+# $(2) schema_dir: Directory containing the flatbuffer schemas.
+# $(3) output_dir: Where to place the generated files.
+# $(4) schema_include_dirs: Directories to include when generating schemas.
+# $(5) src_files: Files that should depend upon the headers generated from the
+#   flatbuffer schemas.
+# $(6) build_target: Name of a build target that depends upon all generated
+#   headers.
+# $(7) dependencies: Space seperated list of additional build targets src_files
+#   should depend upon.
+#
+# Use this in your own Android.mk file to generate build rules that will
+# generate header files for your flatbuffer schemas as well as automatically
+# set your source files to be dependent on the generated headers. For example:
+#
+# $(call flatbuffers_header_build_rules,$(MY_PROJ_SCHEMA_FILES),\
+#   $(MY_PROJ_SCHEMA_DIR),$(MY_PROJ_GENERATED_OUTPUT_DIR),
+#   $(MY_PROJ_SCHEMA_INCLUDE_DIRS),$(LOCAL_SRC_FILES))
+#
+# NOTE: Due problesm with path processing in ndk-build when presented with
+# deeply nested projects must redefine LOCAL_PATH after include this makefile
+# using:
+#
+# LOCAL_PATH := $(call realpath-portable,$(LOCAL_PATH))
+#
+define flatbuffers_header_build_rules
+$(foreach schema,$(1),\
+  $(call flatbuffers_header_build_rule,\
+    $(schema),$(strip $(2)),$(strip $(3)),$(strip $(4))))\
+$(foreach src,$(strip $(5)),\
+  $(eval $(call local-source-file-path,$(src)): \
+    $(foreach schema,$(strip $(1)),\
+      $(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))))\
+$(if $(6),\
+  $(foreach schema,$(strip $(1)),\
+    $(eval $(6): \
+      $(call flatbuffers_fbs_to_h,$(strip $(2)),$(strip $(3)),$(schema)))),)\
+$(if $(7),\
+  $(foreach src,$(strip $(5)),\
+      $(eval $(call local-source-file-path,$(src)): $(strip $(7)))),)\
+$(if $(7),\
+  $(foreach dependency,$(strip $(7)),\
+      $(eval $(6): $(dependency))),)
+endef
+
+endif  # FLATBUFFERS_INCLUDE_MK_
diff --git a/android/jni/main.cpp b/android/jni/main.cpp
new file mode 100644
index 0000000..0d64349
--- /dev/null
+++ b/android/jni/main.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#include <android_native_app_glue.h>
+
+extern int main(int argc, char **argv);
+
+void android_main(android_app *app) {
+  // Make sure glue isn't stripped.
+  app_dummy();
+
+  main(0, NULL);
+}
diff --git a/android/jni/msbuild.py b/android/jni/msbuild.py
new file mode 100644
index 0000000..5f92d70
--- /dev/null
+++ b/android/jni/msbuild.py
@@ -0,0 +1,77 @@
+#!/usr/bin/python
+# Copyright 2014 Google Inc. All rights reserved.
+#
+# 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.
+
+"""Simple script that locates the newest MSBuild in one of several locations.
+
+This script will find the highest version number of MSBuild and run it,
+passing its arguments through to MSBuild.
+"""
+
+import glob
+import os
+import re
+import string
+import subprocess
+import sys
+
+SYSTEMROOT = os.getenv("SYSTEMROOT", "c:\\windows")
+PROGRAM_FILES = os.getenv("ProgramFiles", "c:\\Program Files")
+PROGRAM_FILES_X86 = os.getenv("ProgramFiles(x86)", "c:\\Program Files (x86)")
+
+SEARCH_FOLDERS = [ PROGRAM_FILES + "\\MSBuild\\*\\Bin\\MSBuild.exe",
+                   PROGRAM_FILES_X86 + "\\MSBuild\\*\\Bin\\MSBuild.exe",
+                   SYSTEMROOT + "\\Microsoft.NET\Framework\\*\\MSBuild.exe" ]
+
+def compare_version(a, b):
+  """Compare two version number strings of the form W.X.Y.Z.
+
+  The numbers are compared most-significant to least-significant.
+  For example, 12.345.67.89 > 2.987.88.99.
+
+  Args:
+    a: First version number string to compare
+    b: Second version number string to compare
+
+  Returns:
+    0 if the numbers are identical, a positive number if 'a' is larger, and
+    a negative number if 'b' is larger.
+  """
+  aa = string.split(a, ".")
+  bb = string.split(b, ".")
+  for i in range(0, 4):
+    if aa[i] != bb[i]:
+      return cmp(int(aa[i]), int(bb[i]))
+  return 0
+
+def main():
+  msbuilds = []
+
+  for folder in SEARCH_FOLDERS:
+    for file in glob.glob(folder):
+      p = subprocess.Popen([file, "/version"], stdout=subprocess.PIPE)
+      out, err = p.communicate()
+      match = re.search("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$", out, re.M)
+      if match:
+        msbuilds.append({ 'ver':match.group(), 'exe':file })
+  msbuilds.sort(lambda x, y: compare_version(x['ver'], y['ver']), reverse=True)
+  if len(msbuilds) == 0:
+    print "Unable to find MSBuild.\n"
+    return -1;
+  cmd = [msbuilds[0]['exe']]
+  cmd.extend(sys.argv[1:])
+  return subprocess.call(cmd)
+
+if __name__ == '__main__':
+  sys.exit(main())
diff --git a/android/jni/run_flatc.py b/android/jni/run_flatc.py
new file mode 100755
index 0000000..cda13bb
--- /dev/null
+++ b/android/jni/run_flatc.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# Copyright 2015 Google Inc. All rights reserved.
+#
+# 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.
+
+import os
+import platform
+import subprocess
+import sys
+
+EXECUTABLE_EXTENSION = '.exe' if platform.system() == 'Windows' else ''
+# Paths to search for flatc relative to the current working directory.
+FLATC_SEARCH_PATHS = [os.path.curdir, 'Release', 'Debug']
+
+def main():
+  """Script that finds and runs flatc built from source."""
+  if len(sys.argv) < 2:
+    sys.stderr.write('Usage: run_flatc.py flatbuffers_dir [flatc_args]\n')
+    return 1
+  cwd = os.getcwd()
+  flatc = ''
+  flatbuffers_dir = sys.argv[1]
+  for path in FLATC_SEARCH_PATHS:
+    current = os.path.join(flatbuffers_dir, path,
+                           'flatc' + EXECUTABLE_EXTENSION)
+    if os.path.exists(current):
+      flatc = current
+      break
+  if not flatc:
+    sys.stderr.write('flatc not found\n')
+    return 1
+  command = [flatc] + sys.argv[2:]
+  return subprocess.call(command)
+
+if __name__ == '__main__':
+  sys.exit(main())
diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml
new file mode 100644
index 0000000..ec75239
--- /dev/null
+++ b/android/res/values/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2014 Google, Inc.
+
+     This software is provided 'as-is', without any express or implied
+     warranty.  In no event will the authors be held liable for any damages
+     arising from the use of this software.
+     Permission is granted to anyone to use this software for any purpose,
+     including commercial applications, and to alter it and redistribute it
+     freely, subject to the following restrictions:
+     1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+     2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+     3. This notice may not be removed or altered from any source distribution.
+ -->
+<resources>
+    <string name="app_name">FlatBufferTest</string>
+</resources>