diff --git a/.gitattributes b/.gitattributes
new file mode 100755
index 000000000..176a458f9
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100755
index 000000000..c6bcf20d4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,36 @@
+*_wire.txt
+*_wire.bin
+.DS_Store
+*.o
+*.o.d
+*.class
+*.a
+*~
+*.vcxproj
+*.vcxproj.filters
+*.vcxproj.user
+*.sln
+*.suo
+*.keystore
+**/bin/**
+**/gen/**
+**/libs/**
+**/obj/**
+**/*.dir/**
+**/CMakeFiles/**
+**/cmake_install.cmake
+**/CMakeCache.txt
+**/Debug/**
+**/Release/**
+build.xml
+local.properties
+project.properties
+proguard-project.txt
+linklint_results
+Makefile
+flatc
+flattests
+flatsamplebinary
+flatsampletext
+snapshot.sh
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..2fa4160b6
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,76 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(FlatBuffers)
+
+# NOTE: Code coverage only works on Linux & OSX.
+option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
+
+set(FlatBuffers_Compiler_SRCS
+ include/flatbuffers/flatbuffers.h
+ include/flatbuffers/idl.h
+ include/flatbuffers/util.h
+ src/idl_parser.cpp
+ src/idl_gen_cpp.cpp
+ src/idl_gen_java.cpp
+ src/idl_gen_text.cpp
+ src/flatc.cpp
+)
+
+set(FlatBuffers_Tests_SRCS
+ include/flatbuffers/flatbuffers.h
+ include/flatbuffers/idl.h
+ include/flatbuffers/util.h
+ src/idl_parser.cpp
+ src/idl_gen_text.cpp
+ tests/test.cpp
+ # file generate by running compiler on tests/monster_test.fbs
+ tests/monster_test_generated.h
+)
+
+set(FlatBuffers_Sample_Binary_SRCS
+ include/flatbuffers/flatbuffers.h
+ samples/sample_binary.cpp
+ # file generate by running compiler on samples/monster.fbs
+ samples/monster_generated.h
+)
+
+set(FlatBuffers_Sample_Text_SRCS
+ include/flatbuffers/flatbuffers.h
+ include/flatbuffers/idl.h
+ include/flatbuffers/util.h
+ src/idl_parser.cpp
+ src/idl_gen_text.cpp
+ samples/sample_text.cpp
+ # file generate by running compiler on samples/monster.fbs
+ samples/monster_generated.h
+)
+
+set(CMAKE_BUILD_TYPE Debug)
+
+# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
+# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ add_definitions("-std=c++0x")
+ add_definitions("-Wall")
+endif()
+if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
+ add_definitions("-std=c++0x")
+endif()
+
+if(FLATBUFFERS_CODE_COVERAGE)
+ add_definitions("-g -fprofile-arcs -ftest-coverage")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
+endif()
+
+include_directories(include)
+
+add_executable(flatc ${FlatBuffers_Compiler_SRCS})
+add_executable(flattests ${FlatBuffers_Tests_SRCS})
+add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
+add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
+
+add_test(NAME flattest
+ CONFIGURATIONS Debug
+ WORKING_DIRECTORY tests
+ COMMAND flattests)
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100755
index 000000000..d64569567
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
diff --git a/android/.project b/android/.project
new file mode 100755
index 000000000..e7d5931bc
--- /dev/null
+++ b/android/.project
@@ -0,0 +1,20 @@
+
+
+
+ FlatBufferTest
+
diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml
new file mode 100755
index 000000000..a15f547b7
--- /dev/null
+++ b/android/AndroidManifest.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/android/build_apk.sh b/android/build_apk.sh
new file mode 100755
index 000000000..3520626dd
--- /dev/null
+++ b/android/build_apk.sh
@@ -0,0 +1,500 @@
+#!/bin/bash -eu
+# 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.
+#
+# Build, deploy, debug / execute a native Android package based upon
+# NativeActivity.
+
+declare -r script_directory=$(dirname $0)
+declare -r android_root=${script_directory}/../../../../../../
+declare -r script_name=$(basename $0)
+declare -r android_manifest=AndroidManifest.xml
+declare -r os_name=$(uname -s)
+
+# Minimum Android target version supported by this project.
+: ${BUILDAPK_ANDROID_TARGET_MINVERSION:=10}
+# Directory containing the Android SDK
+# (http://developer.android.com/sdk/index.html).
+: ${ANDROID_SDK_HOME:=}
+# Directory containing the Android NDK
+# (http://developer.android.com/tools/sdk/ndk/index.html).
+: ${NDK_HOME:=}
+
+# Display script help and exit.
+usage() {
+ echo "
+Build the Android package in the current directory and deploy it to a
+connected device.
+
+Usage: ${script_name} \\
+ [ADB_DEVICE=serial_number] [BUILD=0] [DEPLOY=0] [RUN_DEBUGGER=1] \
+ [LAUNCH=0] [SWIG_BIN=swig_binary_directory] [SWIG_LIB=swig_include_directory] [ndk-build arguments ...]
+
+ADB_DEVICE=serial_number:
+ serial_number specifies the device to deploy the built apk to if multiple
+ Android devices are connected to the host.
+BUILD=0:
+ Disables the build of the package.
+DEPLOY=0:
+ Disables the deployment of the built apk to the Android device.
+RUN_DEBUGGER=1:
+ Launches the application in gdb after it has been deployed. To debug in
+ gdb, NDK_DEBUG=1 must also be specified on the command line to build a
+ debug apk.
+LAUNCH=0:
+ Disable the launch of the apk on the Android device.
+SWIG_BIN=swig_binary_directory:
+ The directory where the SWIG binary lives. No need to set this if SWIG is
+ installed and point to from your PATH variable.
+SWIG_LIB=swig_include_directory:
+ The directory where SWIG shared include files are, usually obtainable from
+ commandline with \"swig -swiglib\". No need to set this if SWIG is installed
+ and point to from your PATH variable.
+ndk-build arguments...:
+ Additional arguments for ndk-build. See ndk-build -h for more information.
+" >&2
+ exit 1
+}
+
+# Get the number of CPU cores present on the host.
+get_number_of_cores() {
+ case ${os_name} in
+ Darwin)
+ sysctl hw.ncpu | awk '{ print $2 }'
+ ;;
+ CYGWIN*|Linux)
+ awk '/^processor/ { n=$3 } END { print n + 1 }' /proc/cpuinfo
+ ;;
+ *)
+ echo 1
+ ;;
+ esac
+}
+
+# Get the package name from an AndroidManifest.xml file.
+get_package_name_from_manifest() {
+ xmllint --xpath 'string(/manifest/@package)' "${1}"
+}
+
+# Get the library name from an AndroidManifest.xml file.
+get_library_name_from_manifest() {
+ echo "\
+setns android=http://schemas.android.com/apk/res/android
+xpath string(/manifest/application/activity\
+[@android:name=\"android.app.NativeActivity\"]/meta-data\
+[@android:name=\"android.app.lib_name\"]/@android:value)" |
+ xmllint --shell "${1}" | awk '/Object is a string/ { print $NF }'
+}
+
+# Get the number of Android devices connected to the system.
+get_number_of_devices_connected() {
+ adb devices -l | \
+ awk '/^..*$/ { if (p) { print $0 } }
+ /List of devices attached/ { p = 1 }' | \
+ wc -l
+ return ${PIPESTATUS[0]}
+}
+
+# Kill a process and its' children. This is provided for cygwin which
+# doesn't ship with pkill.
+kill_process_group() {
+ local parent_pid="${1}"
+ local child_pid=
+ for child_pid in $(ps -f | \
+ awk '{ if ($3 == '"${parent_pid}"') { print $2 } }'); do
+ kill_process_group "${child_pid}"
+ done
+ kill "${parent_pid}" 2>/dev/null
+}
+
+# Find and run "adb".
+adb() {
+ local adb_path=
+ for path in "$(which adb 2>/dev/null)" \
+ "${ANDROID_SDK_HOME}/sdk/platform-tools/adb" \
+ "${android_root}/prebuilts/sdk/platform-tools/adb"; do
+ if [[ -e "${path}" ]]; then
+ adb_path="${path}"
+ break
+ fi
+ done
+ if [[ "${adb_path}" == "" ]]; then
+ echo -e "Unable to find adb." \
+ "\nAdd the Android ADT sdk/platform-tools directory to the" \
+ "PATH." >&2
+ exit 1
+ fi
+ "${adb_path}" "$@"
+}
+
+# Find and run "android".
+android() {
+ local android_executable=android
+ if echo "${os_name}" | grep -q CYGWIN; then
+ android_executable=android.bat
+ fi
+ local android_path=
+ for path in "$(which ${android_executable})" \
+ "${ANDROID_SDK_HOME}/sdk/tools/${android_executable}" \
+ "${android_root}/prebuilts/sdk/tools/${android_executable}"; do
+ if [[ -e "${path}" ]]; then
+ android_path="${path}"
+ break
+ fi
+ done
+ if [[ "${android_path}" == "" ]]; then
+ echo -e "Unable to find android tool." \
+ "\nAdd the Android ADT sdk/tools directory to the PATH." >&2
+ exit 1
+ fi
+ # Make sure ant is installed.
+ if [[ "$(which ant)" == "" ]]; then
+ echo -e "Unable to find ant." \
+ "\nPlease install ant and add to the PATH." >&2
+ exit 1
+ fi
+
+ "${android_path}" "$@"
+}
+
+# Find and run "ndk-build"
+ndkbuild() {
+ local ndkbuild_path=
+ for path in "$(which ndk-build 2>/dev/null)" \
+ "${NDK_HOME}/ndk-build" \
+ "${android_root}/prebuilts/ndk/current/ndk-build"; do
+ if [[ -e "${path}" ]]; then
+ ndkbuild_path="${path}"
+ break
+ fi
+ done
+ if [[ "${ndkbuild_path}" == "" ]]; then
+ echo -e "Unable to find ndk-build." \
+ "\nAdd the Android NDK directory to the PATH." >&2
+ exit 1
+ fi
+ "${ndkbuild_path}" "$@"
+}
+
+# Get file modification time of $1 in seconds since the epoch.
+stat_mtime() {
+ local filename="${1}"
+ case ${os_name} in
+ Darwin) stat -f%m "${filename}" 2>/dev/null || echo 0 ;;
+ *) stat -c%Y "${filename}" 2>/dev/null || echo 0 ;;
+ esac
+}
+
+# Build the native (C/C++) build targets in the current directory.
+build_native_targets() {
+ # Save the list of output modules in the install directory so that it's
+ # possible to restore their timestamps after the build is complete. This
+ # works around a bug in ndk/build/core/setup-app.mk which results in the
+ # unconditional execution of the clean-installed-binaries rule.
+ restore_libraries="$(find libs -type f 2>/dev/null | \
+ sed -E 's@^libs/(.*)@\1@')"
+
+ # Build native code.
+ ndkbuild -j$(get_number_of_cores) "$@"
+
+ # Restore installed libraries.
+ # Obviously this is a nasty hack (along with ${restore_libraries} above) as
+ # it assumes it knows where the NDK will be placing output files.
+ (
+ IFS=$'\n'
+ for libpath in ${restore_libraries}; do
+ source_library="obj/local/${libpath}"
+ target_library="libs/${libpath}"
+ if [[ -e "${source_library}" ]]; then
+ cp -a "${source_library}" "${target_library}"
+ fi
+ done
+ )
+}
+
+# Select the oldest installed android build target that is at least as new as
+# BUILDAPK_ANDROID_TARGET_MINVERSION. If a suitable build target isn't found,
+# this function prints an error message and exits with an error.
+select_android_build_target() {
+ local -r android_targets_installed=$( \
+ android list targets | \
+ awk -F'"' '/^id:.*android/ { print $2 }')
+ local android_build_target=
+ for android_target in $(echo "${android_targets_installed}" | \
+ awk -F- '{ print $2 }' | sort -n); do
+ if [[ $((android_target)) -ge \
+ $((BUILDAPK_ANDROID_TARGET_MINVERSION)) ]]; then
+ android_build_target="android-${android_target}"
+ break
+ fi
+ done
+ if [[ "${android_build_target}" == "" ]]; then
+ echo -e \
+ "Found installed Android targets:" \
+ "$(echo ${android_targets_installed} | sed 's/ /\n /g;s/^/\n /;')" \
+ "\nAndroid SDK platform" \
+ "android-$((BUILDAPK_ANDROID_TARGET_MINVERSION))" \
+ "must be installed to build this project." \
+ "\nUse the \"android\" application to install API" \
+ "$((BUILDAPK_ANDROID_TARGET_MINVERSION)) or newer." >&2
+ exit 1
+ fi
+ echo "${android_build_target}"
+}
+
+# Sign unsigned apk $1 and write the result to $2 with key store file $3 and
+# password $4.
+# If a key store file $3 and password $4 aren't specified, a temporary
+# (60 day) key is generated and used to sign the package.
+sign_apk() {
+ local unsigned_apk="${1}"
+ local signed_apk="${2}"
+ if [[ $(stat_mtime "${unsigned_apk}") -gt \
+ $(stat_mtime "${signed_apk}") ]]; then
+ local -r key_alias=$(basename ${signed_apk} .apk)
+ local keystore="${3}"
+ local key_password="${4}"
+ [[ "${keystore}" == "" ]] && keystore="${unsigned_apk}.keystore"
+ [[ "${key_password}" == "" ]] && \
+ key_password="${key_alias}123456"
+ if [[ ! -e ${keystore} ]]; then
+ keytool -genkey -v -dname "cn=, ou=${key_alias}, o=fpl" \
+ -storepass ${key_password} \
+ -keypass ${key_password} -keystore ${keystore} \
+ -alias ${key_alias} -keyalg RSA -keysize 2048 -validity 60
+ fi
+ cp "${unsigned_apk}" "${signed_apk}"
+ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \
+ -keystore ${keystore} -storepass ${key_password} \
+ -keypass ${key_password} "${signed_apk}" ${key_alias}
+ fi
+}
+
+# Build the apk $1 for package filename $2 in the current directory using the
+# ant build target $3.
+build_apk() {
+ local -r output_apk="${1}"
+ local -r package_filename="${2}"
+ local -r ant_target="${3}"
+ # Get the list of installed android targets and select the oldest target
+ # that is at least as new as BUILDAPK_ANDROID_TARGET_MINVERSION.
+ local -r android_build_target=$(select_android_build_target)
+ [[ "${android_build_target}" == "" ]] && exit 1
+ echo "Building ${output_apk} for target ${android_build_target}" >&2
+
+ # Create / update build.xml and local.properties files.
+ if [[ $(stat_mtime "${android_manifest}") -gt \
+ $(stat_mtime build.xml) ]]; then
+ android update project --target "${android_build_target}" \
+ -n ${package_filename} --path .
+ fi
+
+ # Use ant to build the apk.
+ ant -quiet ${ant_target}
+
+ # Sign release apks with a temporary key as these packages will not be
+ # redistributed.
+ local unsigned_apk="bin/${package_filename}-${ant_target}-unsigned.apk"
+ if [[ "${ant_target}" == "release" ]]; then
+ sign_apk "${unsigned_apk}" "${output_apk}" "" ""
+ fi
+}
+
+# Uninstall package $1 and install apk $2 on device $3 where $3 is "-s device"
+# or an empty string. If $3 is an empty string adb will fail when multiple
+# devices are connected to the host system.
+install_apk() {
+ local -r uninstall_package_name="${1}"
+ local -r install_apk="${2}"
+ local -r adb_device="${3}"
+ # Uninstall the package if it's already installed.
+ adb ${adb_device} uninstall "${uninstall_package_name}" 1>&2 > /dev/null || \
+ true # no error check
+
+ # Install the apk.
+ # NOTE: The following works around adb not returning an error code when
+ # it fails to install an apk.
+ echo "Install ${install_apk}" >&2
+ local -r adb_install_result=$(adb ${adb_device} install "${install_apk}")
+ echo "${adb_install_result}"
+ if echo "${adb_install_result}" | grep -qF 'Failure ['; then
+ exit 1
+ fi
+}
+
+# Launch previously installed package $1 on device $2.
+# If $2 is an empty string adb will fail when multiple devices are connected
+# to the host system.
+launch_package() {
+ (
+ # Determine the SDK version of Android on the device.
+ local -r android_sdk_version=$(
+ adb ${adb_device} shell cat system/build.prop | \
+ awk -F= '/ro.build.version.sdk/ {
+ v=$2; sub(/[ \r\n]/, "", v); print v
+ }')
+
+ # Clear logs from previous runs.
+ # Note that logcat does not just 'tail' the logs, it dumps the entire log
+ # history.
+ adb ${adb_device} logcat -c
+
+ local finished_msg='Displayed '"${package_name}"
+ local timeout_msg='Activity destroy timeout.*'"${package_name}"
+ # Maximum time to wait before stopping log monitoring. 0 = infinity.
+ local launch_timeout=0
+ # If this is a Gingerbread device, kill log monitoring after 10 seconds.
+ if [[ $((android_sdk_version)) -le 10 ]]; then
+ launch_timeout=10
+ fi
+ # Display logcat in the background.
+ # Stop displaying the log when the app launch / execution completes or the
+ # logcat
+ (
+ adb ${adb_device} logcat | \
+ awk "
+ {
+ print \$0
+ }
+
+ /ActivityManager.*: ${finished_msg}/ {
+ exit 0
+ }
+
+ /ActivityManager.*: ${timeout_msg}/ {
+ exit 0
+ }" &
+ adb_logcat_pid=$!;
+ if [[ $((launch_timeout)) -gt 0 ]]; then
+ sleep $((launch_timeout));
+ kill ${adb_logcat_pid};
+ else
+ wait ${adb_logcat_pid};
+ fi
+ ) &
+ logcat_pid=$!
+ # Kill adb logcat if this shell exits.
+ trap "kill_process_group ${logcat_pid}" SIGINT SIGTERM EXIT
+
+ # If the SDK is newer than 10, "am" supports stopping an activity.
+ adb_stop_activity=
+ if [[ $((android_sdk_version)) -gt 10 ]]; then
+ adb_stop_activity=-S
+ fi
+
+ # Launch the activity and wait for it to complete.
+ adb ${adb_device} shell am start ${adb_stop_activity} -n \
+ ${package_name}/android.app.NativeActivity
+
+ wait "${logcat_pid}"
+ )
+}
+
+# See usage().
+main() {
+ # Parse arguments for this script.
+ local adb_device=
+ local ant_target=release
+ local disable_deploy=0
+ local disable_build=0
+ local run_debugger=0
+ local launch=1
+ local build_package=1
+ for opt; do
+ case ${opt} in
+ NDK_DEBUG=1) ant_target=debug ;;
+ ADB_DEVICE*) adb_device="$(\
+ echo "${opt}" | sed -E 's/^ADB_DEVICE=([^ ]+)$/-s \1/;t;s/.*//')" ;;
+ BUILD=0) disable_build=1 ;;
+ DEPLOY=0) disable_deploy=1 ;;
+ RUN_DEBUGGER=1) run_debugger=1 ;;
+ LAUNCH=0) launch=0 ;;
+ clean) build_package=0 ;;
+ -h|--help|help) usage ;;
+ esac
+ done
+
+ # If a target device hasn't been specified and multiple devices are connected
+ # to the host machine, display an error.
+ local -r devices_connected=$(get_number_of_devices_connected)
+ if [[ "${adb_device}" == "" && $((devices_connected)) -gt 1 && \
+ ($((disable_deploy)) -eq 0 || $((launch)) -ne 0 || \
+ $((run_debugger)) -ne 0) ]]; then
+ if [[ $((disable_deploy)) -ne 0 ]]; then
+ echo "Deployment enabled, disable using DEPLOY=0" >&2
+ fi
+ if [[ $((launch)) -ne 0 ]]; then
+ echo "Launch enabled." >&2
+ fi
+ if [[ $((disable_deploy)) -eq 0 ]]; then
+ echo "Deployment enabled." >&2
+ fi
+ if [[ $((run_debugger)) -ne 0 ]]; then
+ echo "Debugger launch enabled." >&2
+ fi
+ echo "
+Multiple Android devices are connected to this host. Either disable deployment
+and execution of the built .apk using:
+ \"${script_name} DEPLOY=0 LAUNCH=0\"
+
+or specify a device to deploy to using:
+ \"${script_name} ADB_DEVICE=\${device_serial}\".
+
+The Android devices connected to this machine are:
+$(adb devices -l)
+" >&2
+ exit 1
+ fi
+
+ if [[ $((disable_build)) -eq 0 ]]; then
+ # Build the native target.
+ build_native_targets "$@"
+ fi
+
+ # Get the package name from the manifest.
+ local -r package_name=$(get_package_name_from_manifest "${android_manifest}")
+ if [[ "${package_name}" == "" ]]; then
+ echo -e "No package name specified in ${android_manifest},"\
+ "skipping apk build, deploy"
+ "\nand launch steps." >&2
+ exit 0
+ fi
+ local -r package_basename=${package_name/*./}
+ local package_filename=$(get_library_name_from_manifest ${android_manifest})
+ [[ "${package_filename}" == "" ]] && package_filename="${package_basename}"
+
+ # Output apk name.
+ local -r output_apk="bin/${package_filename}-${ant_target}.apk"
+
+ if [[ $((disable_build)) -eq 0 && $((build_package)) -eq 1 ]]; then
+ # Build the apk.
+ build_apk "${output_apk}" "${package_filename}" "${ant_target}"
+ fi
+
+ # Deploy to the device.
+ if [[ $((disable_deploy)) -eq 0 ]]; then
+ install_apk "${package_name}" "${output_apk}" "${adb_device}"
+ fi
+
+ if [[ "${ant_target}" == "debug" && $((run_debugger)) -eq 1 ]]; then
+ # Start debugging.
+ ndk-gdb ${adb_device} --start
+ elif [[ $((launch)) -eq 1 ]]; then
+ launch_package "${package_name}" "${adb_device}"
+ fi
+}
+
+main "$@"
diff --git a/android/jni/Android.mk b/android/jni/Android.mk
new file mode 100755
index 000000000..2418566d3
--- /dev/null
+++ b/android/jni/Android.mk
@@ -0,0 +1,33 @@
+# 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 $(CLEAR_VARS)
+
+LOCAL_MODULE := FlatBufferTest
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include
+LOCAL_SRC_FILES := main.cpp ../../tests/test.cpp ../../src/idl_parser.cpp ../../src/idl_gen_text.cpp
+LOCAL_LDLIBS := -llog -landroid
+LOCAL_STATIC_LIBRARIES := android_native_app_glue
+LOCAL_ARM_MODE:=arm
+LOCAL_CPPFLAGS += -std=c++11 -fexceptions -Wall -Wno-literal-suffix
+
+include $(BUILD_SHARED_LIBRARY)
+
+$(call import-module,android/native_app_glue)
+
+$(call import-add-path,../..)
diff --git a/android/jni/Application.mk b/android/jni/Application.mk
new file mode 100755
index 000000000..56952fc96
--- /dev/null
+++ b/android/jni/Application.mk
@@ -0,0 +1,22 @@
+# 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-10
+APP_PROJECT_PATH := $(call my-dir)/..
+APP_STL := gnustl_static
+
+APP_ABI := armeabi-v7a
+NDK_TOOLCHAIN_VERSION := 4.8
+APP_CPPFLAGS += -std=c++11
diff --git a/android/jni/main.cpp b/android/jni/main.cpp
new file mode 100755
index 000000000..0d643495e
--- /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
+
+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/res/values/strings.xml b/android/res/values/strings.xml
new file mode 100755
index 000000000..ec752393e
--- /dev/null
+++ b/android/res/values/strings.xml
@@ -0,0 +1,20 @@
+
+
+
+ FlatBufferTest
+
diff --git a/docs/documentation.html b/docs/documentation.html
new file mode 100755
index 000000000..1f279d9ea
--- /dev/null
+++ b/docs/documentation.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+Click here if you are not redirected.
+
+
diff --git a/docs/footer.html b/docs/footer.html
new file mode 100755
index 000000000..42bc5f2b9
--- /dev/null
+++ b/docs/footer.html
@@ -0,0 +1,14 @@
+
+
+
+