├── .gitmodules ├── CONTRIBUTING ├── LICENSE ├── __init__.py ├── autobuild ├── build_android ├── build_android.cmd └── build_android.py ├── bin ├── android_ndk_perf ├── android_ndk_perf.cmd ├── android_ndk_perf.py ├── build_all_android ├── build_all_android.cmd ├── build_all_android.py └── setup_all_prereqs.py ├── buildutil ├── __init__.py ├── android.py ├── android_common.mk ├── android_test.py ├── cmake_common.txt ├── common.py ├── common_test.py ├── linux.py └── linux_test.py ├── disttools ├── __init__.py ├── config.json └── push_package.py ├── docs ├── __init__.py ├── generate_docs ├── generate_docs.cmd ├── generate_docs.py ├── py_filter ├── py_filter.bat ├── src │ ├── buildutil │ │ ├── api_reference.md │ │ ├── examples.md │ │ ├── examples_android.md │ │ ├── examples_linux.md │ │ └── overview.md │ ├── contributing.md │ ├── doxyfile │ ├── doxygen_layout.xml │ ├── footer.html │ ├── header.html │ ├── html_overlay │ │ ├── fpl_logo_small.png │ │ ├── ftv2mnode.png │ │ └── ftv2pnode.png │ ├── index.md │ ├── iossdkversions.js │ ├── libfplutil │ │ ├── examples.md │ │ ├── linking.md │ │ ├── main.md │ │ ├── overview.md │ │ └── print.md │ ├── prereqisites.md │ ├── readme.md │ ├── style.css │ ├── tested_ios_sdk_versions.json │ └── tools │ │ ├── android_ndk_perf.md │ │ ├── android_ndk_perf_visualize.png │ │ ├── android_ndk_perf_visualize_chart.png │ │ ├── android_ndk_perf_visualize_details.png │ │ ├── android_ndk_perf_visualize_legend.png │ │ ├── android_ndk_perf_visualize_summary.png │ │ ├── build_all_android.md │ │ └── report.html └── update_code_snippets.py ├── examples ├── buildutil_example │ ├── android │ │ └── build.py │ └── linux │ │ ├── CMakeLists.txt │ │ ├── build.py │ │ └── main.c └── libfplutil_example │ ├── AndroidManifest.xml │ ├── jni │ ├── Android.mk │ └── Application.mk │ └── main.c ├── fbx_common ├── CMakeLists.txt ├── cmake_fbx.txt ├── include │ └── fbx_common │ │ ├── fbx_common.h │ │ └── fbx_sdk_no_warnings.h └── src │ └── fbx_common.cpp ├── libfplutil ├── CMakeLists.txt ├── include │ └── fplutil │ │ ├── android_utils.h │ │ ├── file_utils.h │ │ ├── index_allocator.h │ │ ├── intrusive_list.h │ │ ├── main.h │ │ ├── mutex.h │ │ ├── print.h │ │ ├── string_utils.h │ │ ├── variable_size.h │ │ └── version.h ├── jni │ ├── Android.mk │ ├── Application.mk │ └── libs │ │ └── googletest │ │ ├── Android.mk │ │ └── Application.mk ├── src │ ├── android_utils.cpp │ ├── file_utils.cpp │ ├── main.c │ ├── print.c │ ├── print_cxx.cc │ └── string_utils.cpp └── unit_tests │ ├── CMakeLists.txt │ ├── test_index_allocator │ ├── AndroidManifest.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── test_index_allocator.cc │ ├── test_intrusive_list │ ├── AndroidManifest.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── test_intrusive_list.cc │ ├── test_main │ ├── AndroidManifest.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── test_main.cc │ ├── test_perrormsg │ ├── AndroidManifest.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── test_perrormsg.cc │ ├── test_stdio │ ├── AndroidManifest.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── test_stdio.cc │ ├── test_string │ ├── AndroidManifest.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ └── test_string.cc │ └── test_variable_size │ ├── AndroidManifest.xml │ ├── jni │ ├── Android.mk │ └── Application.mk │ └── test_variable_size.cc ├── libs ├── cardboard.jar └── libprotobuf-java-2.6-nano.jar ├── perf ├── bin │ ├── COPYING │ ├── LICENSE │ ├── android-16 │ │ ├── arch-arm │ │ │ ├── build_info │ │ │ └── perf │ │ ├── arch-x86 │ │ │ ├── build_info │ │ │ └── perf │ │ ├── darwin-x86 │ │ │ ├── build_info │ │ │ └── perfhost │ │ └── linux-x86 │ │ │ ├── build_info │ │ │ └── perfhost │ ├── android-17 │ │ ├── arch-arm │ │ │ ├── build_info │ │ │ └── perf │ │ ├── arch-mips │ │ │ ├── build_info │ │ │ └── perf │ │ ├── arch-x86 │ │ │ ├── build_info │ │ │ └── perf │ │ ├── darwin-x86 │ │ │ ├── build_info │ │ │ └── perfhost │ │ └── linux-x86 │ │ │ ├── build_info │ │ │ └── perfhost │ ├── android-18 │ │ ├── arch-arm │ │ │ ├── build_info │ │ │ └── perf │ │ ├── arch-mips │ │ │ ├── build_info │ │ │ └── perf │ │ ├── arch-x86 │ │ │ ├── build_info │ │ │ └── perf │ │ ├── darwin-x86 │ │ │ ├── build_info │ │ │ └── perfhost │ │ └── linux-x86 │ │ │ ├── build_info │ │ │ └── perfhost │ └── android-19 │ │ ├── arch-arm │ │ ├── build_info │ │ └── perf │ │ ├── arch-mips │ │ ├── build_info │ │ └── perf │ │ ├── arch-x86 │ │ ├── build_info │ │ └── perf │ │ ├── darwin-x86 │ │ ├── build_info │ │ └── perfhost │ │ └── linux-x86 │ │ ├── build_info │ │ └── perfhost ├── build │ ├── build@ │ │ ├── b225d8b17ee61f0cfe4fb14e7153826183872b00.patch │ │ ├── b34d556982095a8fe84273ffceadd80f41325acf.patch │ │ └── ed7d36d0b422b3cb6f15e62c3c88d4f0ad96a613.patch │ ├── build_perf.py │ ├── external@elfutils │ │ └── 101941576c52a1270c9c2d63ea95d48729d6cf96.patch │ ├── external@linux-tools-perf │ │ ├── 2db19c77b59c71eef27e9876d4c09ceb6966608d.patch │ │ ├── 48630d72aea6bab5223eb2538c34d87c1500d7f6.patch │ │ └── 8a1715044713722b9fa01419a2148a4a2a67aae5.patch │ └── frameworks@native │ │ ├── 9c7db08049e1d36c2f60dd703f27c432bc8cfbc5.patch │ │ └── ac9a96da65f6eae4513654adaad8a457d1c1575c.patch └── tools │ ├── LICENSE │ └── telemetry │ └── telemetry │ └── core │ └── platform │ └── profiler │ └── perf_vis │ ├── LICENSE-d3.v3.min.js.txt │ ├── LICENSE-jquery.txt │ ├── LICENSE-sammy.js.txt │ ├── d3.v3.min.js │ ├── jquery-1.11.0.min.js │ ├── perf-vis │ ├── perf-vis-template.html │ ├── perf-vis.cmd │ ├── perf-vis.py │ ├── perf_to_tracing_json │ ├── perf_to_tracing_json.cmd │ ├── perf_to_tracing_json.py │ ├── sammy-latest.min.js │ └── sequences.js ├── readme.md └── setuputil ├── __init__.py ├── android.py ├── common.py ├── linux.py ├── mac.py ├── util.py └── windows.py /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/googletest"] 2 | path = dependencies/googletest 3 | url = http://github.com/google/googletest.git 4 | -------------------------------------------------------------------------------- /CONTRIBUTING: -------------------------------------------------------------------------------- 1 | Contributing {#contributing} 2 | ============ 3 | 4 | Want to contribute? Great! First, read this page (including the small print at 5 | the end). 6 | 7 | # Before you contribute 8 | Before we can use your code, you must sign the 9 | [Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1) 10 | (CLA), which you can do online. The CLA is necessary mainly because you own the 11 | copyright to your changes, even after your contribution becomes part of our 12 | codebase, so we need your permission to use and distribute your code. We also 13 | need to be sure of various other things—for instance that you'll tell us if you 14 | know that your code infringes on other people's patents. You don't have to sign 15 | the CLA until after you've submitted your code for review and a member has 16 | approved it, but you must do it before we can put your code into our codebase. 17 | Before you start working on a larger contribution, you should get in touch with 18 | us first through the issue tracker with your idea so that we can help out and 19 | possibly guide you. Coordinating up front makes it much easier to avoid 20 | frustration later on. 21 | 22 | # Code reviews 23 | All submissions, including submissions by project members, require review. We 24 | use Github pull requests for this purpose. 25 | 26 | # The small print 27 | Contributions made by corporations are covered by a different agreement than 28 | the one above, the Software Grant and Corporate Contributor License Agreement. 29 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/__init__.py -------------------------------------------------------------------------------- /autobuild/build_android: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2014 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | $0.py "$@" 16 | 17 | -------------------------------------------------------------------------------- /autobuild/build_android.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright 2014 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | python %~dp0\build_android.py %* 15 | -------------------------------------------------------------------------------- /autobuild/build_android.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright 2014 Google Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """Android automated build script. 17 | 18 | This script may be used for turnkey android builds of fplutil. 19 | 20 | Optional environment variables: 21 | 22 | ANDROID_SDK_HOME = Path to the Android SDK. Required if it is not passed on the 23 | command line. 24 | NDK_HOME = Path to the Android NDK. Required if it is not in passed on the 25 | command line. 26 | MAKE_FLAGS = String to override the default make flags with for ndk-build. 27 | ANT_PATH = Path to ant executable. Required if it is not in $PATH or passed on 28 | the command line. 29 | """ 30 | 31 | import argparse 32 | import os 33 | import sys 34 | sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) 35 | import buildutil.android 36 | import buildutil.common 37 | 38 | PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), 39 | os.pardir)) 40 | 41 | GOOGLETEST_MAKEFILE = os.path.join('googletest', 'Android.mk') 42 | 43 | # Set of paths to search for googletest. 44 | GOOGLETEST_DEFAULT_PATHS = [ 45 | os.path.abspath(os.path.join(PROJECT_ROOT, 'dependencies')), 46 | os.path.abspath(os.path.join(PROJECT_ROOT, os.pardir))] 47 | 48 | 49 | def main(): 50 | parser = argparse.ArgumentParser() 51 | buildutil.android.BuildEnvironment.add_arguments(parser) 52 | 53 | googletest_default_path = GOOGLETEST_DEFAULT_PATHS[0] 54 | for path in GOOGLETEST_DEFAULT_PATHS: 55 | if os.path.exists(os.path.join(path, GOOGLETEST_MAKEFILE)): 56 | googletest_default_path = path 57 | break 58 | 59 | parser.add_argument('-G', '--gtest_path', 60 | help='Path to Google Test', dest='gtest_path', 61 | default=googletest_default_path) 62 | 63 | args = parser.parse_args() 64 | 65 | env = buildutil.android.BuildEnvironment(args) 66 | 67 | gtest_arg = 'GOOGLETEST_PATH="%s"' % args.gtest_path 68 | if env.make_flags: 69 | env.make_flags = '%s %s' % (env.make_flags, gtest_arg) 70 | else: 71 | env.make_flags = gtest_arg 72 | 73 | env.git_clean() 74 | (rc, errmsg) = env.build_all(exclude_dirs=['dependencies']) 75 | if (rc == 0): 76 | env.make_archive(['libs', 'apks', os.path.join('libfplutil', 'include'), 77 | os.path.join('libfplutil', 'jni')], 'output.zip', 78 | exclude=['objs', 'objs-debug']) 79 | else: 80 | print >> sys.stderr, errmsg 81 | 82 | return rc 83 | 84 | if __name__ == '__main__': 85 | sys.exit(main()) 86 | -------------------------------------------------------------------------------- /bin/android_ndk_perf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2014 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | $0.py "$@" 16 | -------------------------------------------------------------------------------- /bin/android_ndk_perf.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright 2014 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | python %~dp0\android_ndk_perf.py %* 15 | -------------------------------------------------------------------------------- /bin/build_all_android: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2014 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | $0.py "$@" 16 | -------------------------------------------------------------------------------- /bin/build_all_android.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright 2014 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | python %~dp0\build_all_android.py %* 15 | -------------------------------------------------------------------------------- /buildutil/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | """Build utilities for use in automated build scripts and tools. 17 | 18 | This module is a set of functions that can be used to help implement tools 19 | to perform typical build tasks. The main focus is to enable turnkey building 20 | both for users and also for continuous integration builds and tests. 21 | 22 | Simple usage example: 23 | 24 | import buildutil.linux 25 | 26 | def main(): 27 | env = buildutil.linux.BuildEnvironment(buildutil.linux.build_defaults()) 28 | 29 | env.run_make() 30 | env.make_archive(['bin', 'lib', 'include'], 'output.zip') 31 | 32 | 33 | Please see examples/buildutil/* for more comprehensive uses. 34 | """ 35 | -------------------------------------------------------------------------------- /buildutil/linux.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | 16 | """@file buildutil/linux.py Linux-specific BuildEnvironment sub-module. 17 | 18 | Optional environment variables: 19 | 20 | @li CMAKE_PATH = Path to CMake binary. Required if cmake is not in $PATH, 21 | or not passed on command line. 22 | @li CMAKE_FLAGS = String to override the default CMake flags with. 23 | 24 | @package fplutil.buildutil.linux Linux-specific BuildEnvironment sub-module. 25 | """ 26 | 27 | import distutils.spawn 28 | import os 29 | import shlex 30 | import sys 31 | sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) 32 | import buildutil.common as common 33 | 34 | _CMAKE_PATH_ENV_VAR = 'CMAKE_PATH' 35 | _CMAKE_FLAGS_ENV_VAR = 'CMAKE_FLAGS' 36 | _CMAKE_PATH = 'cmake_path' 37 | _CMAKE_FLAGS = 'cmake_flags' 38 | 39 | 40 | class BuildEnvironment(common.BuildEnvironment): 41 | 42 | """Class representing a Linux build environment. 43 | 44 | This class adds Linux-specific functionality to the common 45 | BuildEnvironment. 46 | 47 | Attributes: 48 | cmake_path: Path to the cmake binary, for cmake-based projects. 49 | cmake_flags: Flags to pass to cmake, for cmake-based projects. 50 | """ 51 | 52 | CMAKE = 'cmake' 53 | 54 | def __init__(self, arguments): 55 | """Constructs the BuildEnvironment with basic information needed to build. 56 | 57 | The build properties as set by argument parsing are also available 58 | to be modified by code using this object after construction. 59 | 60 | It is required to call this function with a valid arguments object, 61 | obtained either by calling argparse.ArgumentParser.parse_args() after 62 | adding this modules arguments via buildutils.add_arguments(), or by passing 63 | in an object returned from buildutils.build_defaults(). 64 | 65 | Args: 66 | arguments: The argument object returned from ArgumentParser.parse_args(). 67 | """ 68 | 69 | super(BuildEnvironment, self).__init__(arguments) 70 | 71 | if type(arguments) is dict: 72 | args = arguments 73 | else: 74 | args = vars(arguments) 75 | 76 | self.cmake_path = args[_CMAKE_PATH] 77 | self.cmake_flags = args[_CMAKE_FLAGS] 78 | 79 | @staticmethod 80 | def build_defaults(): 81 | """Helper function to set build defaults. 82 | 83 | Returns: 84 | A dict containing appropriate defaults for a build. 85 | """ 86 | args = common.BuildEnvironment.build_defaults() 87 | 88 | args[_CMAKE_PATH] = (os.getenv(_CMAKE_PATH_ENV_VAR) or 89 | distutils.spawn.find_executable('cmake')) 90 | args[_CMAKE_FLAGS] = os.getenv(_CMAKE_FLAGS_ENV_VAR) 91 | 92 | return args 93 | 94 | @staticmethod 95 | def add_arguments(parser): 96 | """Add module-specific command line arguments to an argparse parser. 97 | 98 | This will take an argument parser and add arguments appropriate for this 99 | module. It will also set appropriate default values. 100 | 101 | Args: 102 | parser: The argparse.ArgumentParser instance to use. 103 | """ 104 | defaults = BuildEnvironment.build_defaults() 105 | 106 | common.BuildEnvironment.add_arguments(parser) 107 | 108 | parser.add_argument('-b', '--' + _CMAKE_PATH, 109 | help='Path to CMake binary', dest=_CMAKE_PATH, 110 | default=defaults[_CMAKE_PATH]) 111 | parser.add_argument( 112 | '-F', '--' + _CMAKE_FLAGS, help='Flags to use to override CMake flags', 113 | dest=_CMAKE_FLAGS, default=defaults[_CMAKE_FLAGS]) 114 | 115 | def _find_binary(self, binary, additional_paths=None): 116 | """Find a binary from the set of binaries managed by this class. 117 | 118 | This method enables the lookup of a binary path using the name of the 119 | binary to avoid replication of code which searches for binaries. 120 | 121 | This class allows the lookup of... 122 | * BuildEnvironment.CMAKE 123 | 124 | The _find_binary() method in derived classes may add more binaries. 125 | 126 | Args: 127 | binary: Name of the binary. 128 | additional_paths: Additional dictionary to search for binary paths. 129 | 130 | Returns: 131 | String containing the path of binary. 132 | 133 | Raises: 134 | ToolPathError: Binary is not at the specified path. 135 | """ 136 | search_dict = {BuildEnvironment.CMAKE: [self.cmake_path]} 137 | if additional_paths: 138 | search_dict.update(additional_paths) 139 | return BuildEnvironment._check_binary(binary, search_dict[binary]) 140 | 141 | def run_cmake(self, gen='Unix Makefiles'): 142 | """Run cmake based on the specified build environment. 143 | 144 | This will execute cmake using the configured environment, passing it the 145 | flags specified in the cmake_flags property. 146 | 147 | Args: 148 | gen: Optional argument to specify CMake project generator (defaults to 149 | Unix Makefiles) 150 | 151 | Raises: 152 | SubCommandError: CMake invocation failed or returned an error. 153 | ToolPathError: CMake not found in configured build environment or $PATH. 154 | """ 155 | 156 | cmake_path = self._find_binary(BuildEnvironment.CMAKE) 157 | 158 | args = [cmake_path, '-G', gen] 159 | if self.cmake_flags: 160 | args += shlex.split(self.cmake_flags, posix=self._posix) 161 | args.append(self.project_directory) 162 | 163 | self.run_subprocess(args, cwd=self.project_directory) 164 | -------------------------------------------------------------------------------- /buildutil/linux_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright 2014 Google Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | import argparse 18 | import distutils.spawn 19 | import os 20 | import sys 21 | import unittest 22 | sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) 23 | import buildutil.android as android 24 | import buildutil.common as common 25 | import buildutil.common_test as common_test 26 | import buildutil.linux as linux 27 | 28 | 29 | class CMakeMock(common_test.RunCommandMock): 30 | """Verifies cmake command lines.""" 31 | 32 | def __init__(self, test_case, expected, cwd): 33 | """Callable object which verifies cmake command lines. 34 | 35 | Args: 36 | test_case: unitetst.TestCase used to verify arguments. 37 | expected: Expected arguments for cmake. 38 | cwd: Expected working directory. 39 | """ 40 | common_test.RunCommandMock.__init__(self, test_case) 41 | build_environment_defaults = linux.BuildEnvironment.build_defaults() 42 | self.expect([build_environment_defaults[linux._CMAKE_PATH]] + expected, 43 | cwd) 44 | 45 | 46 | class LinuxBuildUtilTest(unittest.TestCase): 47 | """Linux-specific unit tests.""" 48 | 49 | def setUp(self): 50 | self.find_executable = common._find_executable 51 | # Mock out find_executable so all binaries are found. 52 | common._find_executable = ( 53 | lambda name, path=None: path if path else os.path.join('a', 'b', name)) 54 | 55 | def tearDown(self): 56 | common._find_executable = self.find_executable 57 | 58 | def test_build_defaults(self): 59 | d = linux.BuildEnvironment.build_defaults() 60 | # Verify that the linux ones are set. 61 | self.assertIn(linux._CMAKE_FLAGS, d) 62 | self.assertIn(linux._CMAKE_PATH, d) 63 | # Verify that a mandatory superclass one gets set. 64 | self.assertIn(common._PROJECT_DIR, d) 65 | # Verify that a required Android one does not get set. 66 | self.assertNotIn(android._NDK_HOME, d) 67 | 68 | def test_init(self): 69 | d = linux.BuildEnvironment.build_defaults() 70 | b = linux.BuildEnvironment(d) 71 | # Verify that the linux ones are set. 72 | self.assertEqual(b.cmake_flags, d[linux._CMAKE_FLAGS]) 73 | self.assertEqual(b.cmake_path, d[linux._CMAKE_PATH]) 74 | # Verify that a mandatory superclass one gets set. 75 | self.assertEqual(b.project_directory, d[common._PROJECT_DIR]) 76 | # Verify that a required Android one does not get set. 77 | self.assertNotIn(android._NDK_HOME, vars(b)) 78 | 79 | def test_add_arguments(self): 80 | p = argparse.ArgumentParser() 81 | linux.BuildEnvironment.add_arguments(p) 82 | args = ['--' + linux._CMAKE_FLAGS, 'a', '--' + linux._CMAKE_PATH, 'b'] 83 | argobj = p.parse_args(args) 84 | d = vars(argobj) 85 | self.assertEqual('a', d[linux._CMAKE_FLAGS]) 86 | self.assertEqual('b', d[linux._CMAKE_PATH]) 87 | self.assertEqual(os.getcwd(), d[common._PROJECT_DIR]) 88 | self.assertNotIn(android._NDK_HOME, d) 89 | 90 | def test_run_cmake(self): 91 | d = linux.BuildEnvironment.build_defaults() 92 | b = linux.BuildEnvironment(d) 93 | # Mock the call to run_subprocess. 94 | b.run_subprocess = CMakeMock(self, ['-G', 'b', 'c', 'd', 'e'], 'e') 95 | b.cmake_flags = 'c d' 96 | b.project_directory = 'e' 97 | b.run_cmake(gen='b') 98 | 99 | if __name__ == '__main__': 100 | unittest.main() 101 | -------------------------------------------------------------------------------- /disttools/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Source distribution scripts.""" 16 | 17 | import push_package 18 | -------------------------------------------------------------------------------- /disttools/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "package": { 3 | "name": "fplutil", 4 | "url": "http://github.com/google/fplutil.git", 5 | "branch": "develop", 6 | "is_library": 1, 7 | "third_party": 0, 8 | "push": 1 9 | }, 10 | 11 | "dependencies": [ 12 | { 13 | "name": "googletest", 14 | "url": "http://github.com/google/googletest.git", 15 | "branch": "master", 16 | "revision": "13206d6f53aaff844f2d3595a01ac83a29e383db", 17 | "is_library": 1, 18 | "third_party": 1, 19 | "push": 0 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /docs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """Documentation generation scripts.""" 16 | 17 | import generate_docs 18 | -------------------------------------------------------------------------------- /docs/generate_docs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2014 Google Inc. All Rights Reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | $0.py "$@" 16 | -------------------------------------------------------------------------------- /docs/generate_docs.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright 2014 Google Inc. All Rights Reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | python %~dp0\generate_docs.py %* 15 | -------------------------------------------------------------------------------- /docs/py_filter: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # Copyright 2014 Google Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # NOTE: This requires https://github.com/Feneric/doxypypy which filters 17 | # python doc strings so they're understood by doxygen. 18 | # 19 | # git clone https://github.com/Feneric/doxypypy 20 | # cd doxypypy 21 | # sudo python -m setup install 22 | # 23 | python -m doxypypy.doxypypy -a -c $1 24 | -------------------------------------------------------------------------------- /docs/py_filter.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @rem Copyright 2014 Google Inc. All rights reserved. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | 16 | @rem NOTE: This requires https://github.com/Feneric/doxypypy which filters 17 | @rem python doc strings so they're understood by doxygen. 18 | @rem 19 | @rem git clone https://github.com/Feneric/doxypypy 20 | @rem cd doxypypy 21 | @rem python -m setup install 22 | @rem 23 | python -m doxypypy.doxypypy -a -c %1 24 | -------------------------------------------------------------------------------- /docs/src/buildutil/api_reference.md: -------------------------------------------------------------------------------- 1 | buildutil API Reference {#buildutil_api_reference} 2 | ======================= 3 | 4 | `buildutil` consists of the following modules: 5 | 6 | * [common.py][] 7 | * [android.py][] 8 | * [linux.py][] 9 | 10 | The [common.py][] module implements functionality shared across multiple build 11 | environments. 12 | 13 | [android.py][] implements functions to build [Android][] projects, sign APKs, 14 | deploy APKs to [Android][] devices and launch the built applications. 15 | 16 | [linux.py][] implements functions to build applications using [CMake][] and 17 | [make][] on Unix-like operating systems (e.g [Linux][] and [OSX][]). 18 | 19 | Each module implements a [BuildEnvironment][] class which contains functions 20 | to build for a specific build environment. 21 | 22 | Each [BuildEnvironment][] class implements an [add_arguments][] which adds 23 | a set of arguments to an [ArgumentParser][] instance. The arguments parsed by 24 | [ArgumentParser][] can be passed to a [BuildEnvironment][] on construction to 25 | configure the instance. 26 | 27 | After constructing a [BuildEnvironment][] instance, it's possible to build 28 | projects for the selected build environment using methods like the following: 29 | 30 | * [run_make](@ref fplutil.buildutil.common.BuildEnvironment.run_make) 31 | * [run_cmake](@ref fplutil.buildutil.linux.BuildEnvironment.run_cmake) 32 | * [build_all](@ref fplutil.buildutil.android.BuildEnvironment.build_all) 33 | 34 | [ArgumentParser]: @ref argparse.ArgumentParser 35 | [BuildEnvironment]: @ref fplutil.buildutil.common.BuildEnvironment 36 | [add_arguments]: @ref fplutil.buildutil.common.BuildEnvironment.add_arguments 37 | [android.py]: @ref buildutil/android.py 38 | [common.py]: @ref buildutil/common.py 39 | [linux.py]: @ref buildutil/linux.py 40 | [Android]: http://www.android.com 41 | [make]: http://www.gnu.org/software/make 42 | [CMake]: http://www.cmake.org 43 | [Linux]: http://en.m.wikipedia.org/wiki/Linux 44 | [OSX]: http;//www.apple.com/osx 45 | -------------------------------------------------------------------------------- /docs/src/buildutil/examples.md: -------------------------------------------------------------------------------- 1 | Examples {#buildutil_examples} 2 | ======== 3 | 4 | # Android {#buildutil_examples_android} 5 | 6 | The [android](@ref buildutil/android.py) module contains functions that make 7 | it easy to build, deploy and run Android applications. 8 | 9 | For reference the complete source is in 10 | [examples/buildutil/android.py](@ref buildutil_examples_android_code). 11 | 12 | The following code parses arguments to the script and creates an 13 | [android.BuildEnvironment](@ref fplutil.buildutil.android.BuildEnvironment) 14 | instance which is used to perform Android specific build operations... 15 | 16 | ~~~{.py} 17 | parser = argparse.ArgumentParser() 18 | buildutil.android.BuildEnvironment.add_arguments(parser) 19 | args = parser.parse_args() 20 | 21 | env = buildutil.android.BuildEnvironment(args) 22 | ~~~ 23 | 24 | The following code then copies the NDK `native-plasma` sample to the example 25 | directory... 26 | 27 | ~~~{.py} 28 | samplename = 'native-plasma' 29 | samplepath = os.path.join(env.ndk_home, 'samples', samplename) 30 | shutil.rmtree(samplename, True) 31 | shutil.copytree(samplepath, samplename) 32 | ~~~ 33 | 34 | The `native-plasma` application is built using `ndk-build` to build the native 35 | (C/C++) component and `ant` to build the Java component and APK... 36 | 37 | ~~~{.py} 38 | (rc, errmsg) = env.build_all() 39 | ~~~ 40 | 41 | Finally, the resultant APK is archived in a zip file... 42 | 43 | ~~~{.py} 44 | env.make_archive(['apks'], 'output.zip', exclude=['objs', 'objs-debug']) 45 | ~~~ 46 | 47 | # Linux {#buildutil_examples_linux} 48 | 49 | The [linux](@ref buildutil/linux.py) module contains functions that make it 50 | easy to build applications that use [cmake][] in conjunction with the [make][] 51 | generator for Unix-like operating systems (e.g [Linux][] and [OSX][]). 52 | 53 | For reference the complete source is in 54 | [examples/buildutil/linux.py](@ref buildutil_examples_linux_code). 55 | 56 | The following code, parses arguments to the script and creates an 57 | [linux.BuildEnvironment](@ref fplutil.buildutil.linux.BuildEnvironment) 58 | instance which is used to perform Linux specific build operations... 59 | 60 | ~~~{.py} 61 | parser = argparse.ArgumentParser() 62 | buildutil.linux.BuildEnvironment.add_arguments(parser) 63 | args = parser.parse_args() 64 | 65 | env = buildutil.linux.BuildEnvironment(args) 66 | ~~~ 67 | 68 | The example application prints the preprocessor `MESSAGE` to the standard 69 | output stream. So this is passed as a flag to [CMake][]... 70 | 71 | ~~~{.py} 72 | env.cmake_flags = '-DMESSAGE="Hello, World!"' 73 | ~~~ 74 | 75 | The application is built by running [CMake][] followed by [make][]... 76 | 77 | ~~~{.py} 78 | env.run_cmake() 79 | env.run_make() 80 | ~~~ 81 | 82 | Finally, the build artifacts are archived in a zip file called `output.zip`... 83 | 84 | ~~~{.py} 85 | env.make_archive(['Hello'], 'output.zip') 86 | ~~~ 87 | 88 |
89 | 90 | [make]: http://www.gnu.org/software/make 91 | [CMake]: http://www.cmake.org 92 | [Linux]: http://en.m.wikipedia.org/wiki/Linux 93 | [OSX]: http://www.apple.com/osx 94 | -------------------------------------------------------------------------------- /docs/src/buildutil/examples_android.md: -------------------------------------------------------------------------------- 1 | Android Buildutil Example {#buildutil_examples_android_code} 2 | ========================= 3 | 4 | @include android/build.py 5 | -------------------------------------------------------------------------------- /docs/src/buildutil/examples_linux.md: -------------------------------------------------------------------------------- 1 | Linux Buildutil Example {#buildutil_examples_linux_code} 2 | ======================= 3 | 4 | @include linux/build.py 5 | -------------------------------------------------------------------------------- /docs/src/buildutil/overview.md: -------------------------------------------------------------------------------- 1 | buildutil {#buildutil_overview} 2 | ========= 3 | 4 | `buildutil` contains a set of [Python][] modules which can simplify the process 5 | of automating builds of C/C++ applications for [Android][] and [Linux][]. 6 | 7 | Many builds require the following steps to be performed: 8 | * Configuration 9 | * Build 10 | * Archive of artifacts 11 | 12 | Some build environments - like [autoconf][], [automake][] and [make][] - 13 | require each of these steps to be executed manually, others - like [CMake][] - 14 | perform the configuration step and generate scripts that are executed as part 15 | of another build environment. Artifact collection can be part of the build 16 | scripts (e.g make install) or part of the continuous automation system 17 | depending upon the build environment. 18 | 19 | `buildutil` provides a set of modules that simplify the process of writing 20 | continuous automation scripts that use [CMake][] to support [Linux][], 21 | [OSX][] and [Windows][] in addition to [Ant][] and [NDK Build][] for 22 | [Android][]. This allows developers to write cross-platform turnkey scripts 23 | that are trivial to execute from a continuous automation system like 24 | [Jenkins][], [Buildbot][], [Travis-CI][] etc. 25 | 26 | In order to use this module, all [prerequisites](@ref fplutil_prerequisites) 27 | should be installed. 28 | 29 | For more information about this module see the following: 30 | 31 | * [Example](@ref buildutil_examples_android) of building an Android 32 | application using `buildutil`. 33 | * [Example](@ref buildutil_examples_linux) of building a Linux 34 | application using `buildutil`. 35 | * [Common](@ref buildutil/common.py), [Android](@ref buildutil/android.py) 36 | and [Linux](@ref buildutil/linux.py) API reference. 37 | 38 | [Android]: http://www.android.com 39 | [Ant]: http://ant.apache.org 40 | [Buildbot]: http://www.buildbot.net 41 | [CMake]: http://www.cmake.org 42 | [Jenkins]: htttp://www.jenkins-ci.org 43 | [Linux]: http://en.m.wikipedia.org/wiki/Linux 44 | [NDK Build]: http://developer.android.com/tools/sdk/ndk/index.html 45 | [OSX]: http://www.apple.com/osx 46 | [Travis-CI]: http://www.travis-ci.org 47 | [Windows]: http://windows.microsoft.com 48 | [autoconf]: http://www.gnu.org/software/autoconf 49 | [automake]: http://www.gnu.org/software/automake 50 | [make]: http://www.gnu.org/software/make 51 | [Python]: http://www.python.org 52 | -------------------------------------------------------------------------------- /docs/src/contributing.md: -------------------------------------------------------------------------------- 1 | ../../CONTRIBUTING -------------------------------------------------------------------------------- /docs/src/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/src/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: $title 9 | $title 10 | 11 | 12 | 13 | $treeview 14 | $search 15 | $mathjax 16 | 17 | 18 | $extrastylesheet 19 | 104 | 105 | 106 |
107 | 108 | 109 |
110 | 111 | 112 | 113 | 114 | 115 | 116 | 119 | 120 | 130 | 131 | 132 | 133 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 |
121 |
$projectname 122 |  $projectnumber 123 |
124 |
$projectbrief
125 |
126 | An open source project by 127 | FPL. 128 |
129 |
134 |
$projectbrief
135 |
$searchbox
146 |
147 | 148 | 149 | -------------------------------------------------------------------------------- /docs/src/html_overlay/fpl_logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/html_overlay/fpl_logo_small.png -------------------------------------------------------------------------------- /docs/src/html_overlay/ftv2mnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/html_overlay/ftv2mnode.png -------------------------------------------------------------------------------- /docs/src/html_overlay/ftv2pnode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/html_overlay/ftv2pnode.png -------------------------------------------------------------------------------- /docs/src/index.md: -------------------------------------------------------------------------------- 1 | fplutil {#fplutil} 2 | ======= 3 | 4 | fplutil is a set of small libraries and tools that can be useful when 5 | developing applications for Android and other platforms. 6 | 7 | Download the latest release from the 8 | [fplutil github page](http://github.com/google/fplutil) or the 9 | [releases page](https://github.com/google/fplutil/releases). 10 | 11 | **Important**: fplutil uses submodules to reference other components it depends 12 | upon so to download the source use: 13 | 14 | ~~~{.sh} 15 | git clone --recursive https://github.com/google/fplutil.git 16 | ~~~ 17 | 18 | * Discuss fplutil with other developers and users on the 19 | [fplutil Google Group][]. 20 | * File issues on the [fplutil Issues Tracker][] 21 | or post your questions to [stackoverflow.com][] with a mention of 22 | **fplutil**. 23 | 24 | Before getting started, make sure all 25 | [prerequisites](@ref fplutil_prerequisites) are installed and configured. 26 | 27 | # Components 28 | 29 | * [build_all_android][] is an all-in-one build script that allows you to 30 | build, install and run native (C/C++) Android apps from the command line. 31 | This is ideal for build automation, but can also be in a developer’s 32 | compile/run loop. 33 | * [buildutil][] performs the configuration, build and archive steps 34 | of [Android][] and [Linux][] C/C++ applications using a suite of 35 | [Python][] modules. This suite of modules can automate builds in a 36 | continuous integration environment. 37 | * [android_ndk_perf][] is a desktop tool that enables native (C/C++) 38 | developers to measure the CPU utilization of their applications on 39 | [Android][], guiding their optimization efforts. 40 | * [libfplutil][] enables C/C++ developers to write traditional applications 41 | (like [Hello World][]) using "main()" and "printf()" on [Android][]. 42 | 43 | [Android]: http://www.android.com 44 | [Linux]: http://en.m.wikipedia.org/wiki/Linux 45 | [Python]: http://www.python.org 46 | [android_ndk_perf]: @ref android_ndk_perf 47 | [build_all_android]: @ref build_all_android 48 | [buildutil]: @ref buildutil_overview 49 | [fplutil Google Group]: http://groups.google.com/group/fplutil 50 | [fplutil Issues Tracker]: http://github.com/google/fplutil/issues 51 | [fplutil]: index.html 52 | [libfplutil]: @ref libfplutil_overview 53 | [stackoverflow.com]: http://stackoverflow.com/search?q=fplutil 54 | [Hello World]: http://en.wikipedia.org/wiki/%22Hello,_world!%22_program 55 | -------------------------------------------------------------------------------- /docs/src/libfplutil/examples.md: -------------------------------------------------------------------------------- 1 | Example {#libfplutil_example} 2 | ======= 3 | 4 | `examples/libfplutil_example` is a sample application which prints 5 | "Hello World" to the Android log. It's as possible to compile the application 6 | for other platforms and see "Hello World" printed to the standard output 7 | stream. 8 | 9 | The following sections will describe: 10 | 11 | * Setting up the build environment. 12 | * Building the sample. 13 | * Installing the sample. 14 | * Running the sample. 15 | 16 | # Before Getting Started {#libfplutil_example_preparation} 17 | 18 | * Install the [Android SDK][]. 19 | * Install the [Android NDK][]. 20 | * Install [Python][] (optionally required to build with fplutil's build 21 | tools). 22 | 23 | # Build, Install and Run with fplutil {#libfplutil_example_build_fplutil} 24 | 25 | Building, installing and running the application using fplutil's build tool 26 | consists of the following steps: 27 | 28 | * Open a command line. 29 | * Change into the example directory. 30 | * Run [fplutil][]'s [build_all_android][] 31 | 32 | For example, the following will build the application APK in debug, install 33 | the APK on an attached Android device and execute the application: 34 | 35 | ~~~{.sh} 36 | cd examples/libfplutil_example 37 | ../../bin/build_all_android -T debug -i -r 38 | ~~~ 39 | 40 | Which should display: 41 | 42 | --------- beginning of /dev/log/main 43 | --------- beginning of /dev/log/system 44 | I/main ( 550): Hello, World! 45 | 46 | # Building manually with ndk-build {#libfplutil_example_build_ndkbuild} 47 | 48 | The following steps *only* need to be performed if [build_all_android][] 49 | isn't sufficient for your build environment. 50 | 51 | To build the shared library that constitutes the native component of the 52 | application: 53 | 54 | * Open a terminal. 55 | * Change into the example directory. 56 | * Run ndk-build. 57 | 58 | For example: 59 | 60 | ~~~{.sh} 61 | cd examples/libfplutil_example 62 | ndk-build 63 | ~~~ 64 | 65 | ## Packaging the Application 66 | 67 | This will create a shared library in the `libfplutil_example/libs` directory 68 | which needs to be packaged into an APK before it can be deployed to a device. 69 | To do this you need to: 70 | 71 | * Create an [Android Ant][] project. 72 | * Build a *debug* APK to avoid the [APK Signing] step. 73 | 74 | For example, the following generates a project to build against 75 | [Android API Level][] 18 and builds an APK: 76 | 77 | ~~~{.sh} 78 | android update project --path . --target android-18 --name libfplutil_example 79 | ant debug 80 | ~~~ 81 | 82 | This results in the application's APK in `bin/libfplutil_example-debug.apk`. 83 | 84 | ## Deploying the Application 85 | 86 | To run this application: 87 | 88 | * Deploy the APK to an Android device. 89 | * Run the application on the Android device. 90 | 91 | For example: 92 | 93 | ~~~{.sh} 94 | adb install bin/libfplutil_example-debug.apk 95 | adb shell am start -S -n com.google.fpl.libfplutil.example/android.app.NativeActivity 96 | ~~~ 97 | 98 | ## Running the Application 99 | 100 | Finally, it's possible to view the application's output using `adb logcat`: 101 | 102 | ~~~{.sh} 103 | adb logcat -s main 104 | ~~~ 105 | 106 | Which should display: 107 | 108 | --------- beginning of /dev/log/main 109 | --------- beginning of /dev/log/system 110 | I/main ( 550): Hello, World! 111 | 112 |
113 | 114 | [fplutil]: index.html 115 | [Python]: http://www.python.org 116 | [Android Ant]: http://developer.android.com/tools/building/building-cmdline.html 117 | [Android NDK]: http://developer.android.com/tools/sdk/ndk/index.html 118 | [Android SDK]: http://developer.android.com/sdk/index.html 119 | [APK Signing]: http://developer.android.com/tools/publishing/app-signing.html 120 | [Android API Level]: http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels 121 | [build_all_android]: @ref build_all_android 122 | -------------------------------------------------------------------------------- /docs/src/libfplutil/linking.md: -------------------------------------------------------------------------------- 1 | Linking Applications with libfplutil {#libfplutil_linking} 2 | ==================================== 3 | 4 | By default the linker will not link an application against `libfplutil_main` 5 | or `libfplutil_print` as the application will not typically reference symbols 6 | in the libraries. Therefore the linker must be instructed to *always* link 7 | against the libraries. This can be achieved by using: 8 | 9 | * `LOCAL_WHOLE_STATIC_LIBRARIES` when using [Android NDK][] makefiles. 10 | * `--whole-archive` linker flag when directly using the compiler toolchain. 11 | 12 | For example, a build target in an [Android NDK][] makefile which builds an 13 | application that links against both `libfplutil_main` and `libfplutil_print` 14 | may look like this: 15 | 16 | ~~~{.mk} 17 | include $(CLEAR_VARS) 18 | LOCAL_MODULE:=myapp 19 | LOCAL_SRC_FILES:=$(LOCAL_PATH)/main.c 20 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 21 | libfplutil_print 22 | LOCAL_ARM_MODE:=arm 23 | include $(BUILD_SHARED_LIBRARY) 24 | 25 | $(call import-add-path,path/to/fplutil) 26 | $(call import-module,android/native_app_glue) 27 | $(call import-module,libfplutil/jni) 28 | ~~~ 29 | 30 | `LOCAL_WHOLE_STATIC_LIBRARIES` adds `--whole-archive` to the linker command 31 | line for each of the listed libraries. 32 | 33 | # Linking with libfplutil_print {#libfplutil_linking_print} 34 | 35 | When using the Android make system (ndk-build), linking `libfplutil_print` will 36 | automatically wrap calls to stdio and iostreams. When imported using 37 | `import-module`, the module exports the appropriate flags for the compiler and 38 | linker: 39 | 40 | ~~~{.mk} 41 | $(call import-module,libfplutil/jni) 42 | ~~~ 43 | 44 | When using the toolchain directly, to link against `libfplutil_print`, you must 45 | manually wrap the functions it implements manually. To wrap functions, pass 46 | the corresponding `--wrap=` option on your link line. 47 | 48 | For example: 49 | 50 | ~~~{.mk} 51 | LDFLAGS+= -Wl,--wrap=perror,--wrap=fflush,--wrap=fprintf,--wrap=vprintf \ 52 | -Wl,--wrap=putc,--wrap=fputc,--wrap=putchar,--wrap=puts \ 53 | -Wl,--wrap=fputs,--wrap=fwrite,--wrap=write,--wrap=writev \ 54 | -Wl,--wrap=printf 55 | CFLAGS+= -fno-builtin-printf -fno-builtin-fprintf \ 56 | -fno-builtin-fflush -fno-builtin-perror -fno-builtin-vprintf \ 57 | -fno-builtin-putc -fno-builtin-putchar -fno-builtin-fputc \ 58 | -fno-builtin-fputs -fno-builtin-puts -fno-builtin-fwrite \ 59 | -fno-builtin-write -fno-builtin-writev 60 | ~~~ 61 | 62 |
63 | 64 | [Android NDK]: http://developer.android.com/tools/sdk/ndk/index.html 65 | [dummy]: dummy 66 | -------------------------------------------------------------------------------- /docs/src/libfplutil/main.md: -------------------------------------------------------------------------------- 1 | Using libfplutil_main {#libfplutil_main} 2 | ===================== 3 | 4 | `libfplutil_main` implements an Android [NativeActivity][] entry point 5 | `android_main()` which calls the traditional C/C++ entry point `int main()`. 6 | This makes it possible to write an application with a `int main()` entry point 7 | (just like any standard C application), link against this library 8 | (see [Linking][]) and have it run on Android. 9 | 10 | For example, the following prints "Hello World" to the Android log: 11 | 12 | ~~~{.c} 13 | #include 14 | 15 | int main(int argc, char *argv[]) { 16 | __android_log_print(ANDROID_LOG_VERBOSE, "test", "Hello World"); 17 | return 0; 18 | } 19 | ~~~ 20 | 21 | # Event Processing # {#libfplutil_main_events} 22 | 23 | Android applications must process system events otherwise they trigger an 24 | "Application Not Responding" dialog ([ANR][]) which prompts the user to 25 | close the application. For long running tasks the `ProcessAndroidEvents()` 26 | function makes it easy to process events and avoid the [ANR][] dialog. 27 | 28 | For example: 29 | 30 | ~~~{.c} 31 | #include 32 | 33 | int main(int argc, char *argv[]) { 34 | int complete = 0; 35 | __android_log_print(ANDROID_LOG_VERBOSE, "test", "Long running task..."); 36 | while (!complete) { 37 | // Performing part of a task that takes a long time, set "complete" 38 | // when finished. 39 | // Process events to avoid ANR. 40 | ProcessAndroidEvents(0); 41 | } 42 | __android_log_print(ANDROID_LOG_VERBOSE, "test", "Task complete!"); 43 | return 0; 44 | } 45 | ~~~ 46 | 47 |
48 | 49 | [ANR]: http://developer.android.com/training/articles/perf-anr.html 50 | [Linking]: @ref libfplutil_linking 51 | [NativeActivity]: http://developer.android.com/reference/android/app/NativeActivity.html -------------------------------------------------------------------------------- /docs/src/libfplutil/overview.md: -------------------------------------------------------------------------------- 1 | libfplutil Overview {#libfplutil_overview} 2 | =================== 3 | 4 | [libfplutil][] enables C/C++ developers to write traditional applications 5 | (like [Hello World][]) using "main()" and "printf()" on [Android][]. 6 | 7 | [libfplutil][] consists of a native (C/C++) [Android NDK][] module that builds 8 | the following static libraries: 9 | 10 | * [libfplutil_main][] 11 | * [libfplutil_print][] 12 | 13 | As mentioned in the [fplutil package description][], these libraries ease the 14 | development of C/C++ applications for Android. 15 | 16 | ## Before Reading On 17 | 18 | In order to use this module, all [prerequisites](@ref fplutil_prerequisites) 19 | should be installed and you should already be familiar with C/C++, 20 | the [Android NDK][] and [adb][]. 21 | 22 | ## Contents 23 | 24 | For more information about this module see the following: 25 | 26 | * [libfplutil_main][] description and use cases. 27 | * [libfplutil_print][] description and use cases. 28 | * An [example](@ref libfplutil_example) which demonstrates how to use 29 | [libfplutil_main][] and [libfplutil_print][] in an application. 30 | * An [API reference](@ref libfplutil/include/fplutil/main.h) for 31 | [libfplutil_main][] 32 | * An [API reference](@ref libfplutil/include/fplutil/print.h) for 33 | [libfplutil_print][] 34 | 35 | [Android]: http://www.android.com 36 | [adb]: http://developer.android.com/tools/help/adb.html 37 | [libfplutil]: @ref libfplutil_overview 38 | [Android NDK]: http://developer.android.com/tools/sdk/ndk/index.html 39 | [libfplutil_main]: @ref libfplutil_main 40 | [libfplutil_print]: @ref libfplutil_print 41 | [fplutil package description]: index.html 42 | [Linking]: #libfplutil_linking 43 | [ANR]: http://developer.android.com/training/articles/perf-anr.html 44 | [Android SDK]: http://developer.android.com/sdk/index.html 45 | [NativeActivity]: http://developer.android.com/reference/android/app/NativeActivity.html 46 | [Hello World]: http://en.wikipedia.org/wiki/%22Hello,_world!%22_program -------------------------------------------------------------------------------- /docs/src/libfplutil/print.md: -------------------------------------------------------------------------------- 1 | Using libfplutil_print {#libfplutil_print} 2 | ====================== 3 | 4 | `libfplutil_print` implements a set of wrappers for functions that write to 5 | the standard output stream. This enables applications that write to the 6 | terminal using printf to have their output redirected to the Android log. 7 | 8 | Using both `libfplutil_main` and `libfplutil_print` makes it possible to 9 | compile and run non-interactive command line applications on Android devices. 10 | 11 | It's possible to use `libfplutil_print` without `libfplutil_main` in 12 | conjunction with [NativeActivity][] by implementing an `android_main` entry 13 | point or using `printf` in libraries that are called from Java modules. 14 | However, the typical use case is to use `libfplutil_print` in conjunction with 15 | `libfplutil_main` so that C/C++ applications can easily be cross compiled 16 | to multiple platforms including Android. 17 | 18 | For example, the canonical C "Hello World" application will compile and run on 19 | Android simply by linking with both `libfplutil_print` and `libfplutil_main`: 20 | 21 | ~~~{.c} 22 | #include 23 | 24 | int main(int argc, char *argv[]) { 25 | printf("Hello World\n"); 26 | return 0; 27 | } 28 | ~~~ 29 | 30 | The above application, when compiled and linked against `libfplutil_print` and 31 | `libfplutil_main` (see [Linking][]) 32 | will print "Hello World" to the Android log which can be viewed using [adb][]'s 33 | [logcat][] command. 34 | 35 | # Customizing the Log Tag {#libfplutil_print_tag} 36 | 37 | By default, the tag used to annontate log messages is "main", this can be 38 | modified using the `SetAndroidLogWrapperTag()` function. For example: 39 | 40 | ~~~{.c} 41 | #include "fplutil/print.h" 42 | #include "fplutil/main.h" 43 | 44 | int main(int argc, char **argv) { 45 | SetAndroidLogWrapperTag("my_application"); 46 | printf("Print to the log from printf\n"); 47 | std::cout << "Print to the log from a stream" << std::endl; 48 | return 0; 49 | } 50 | ~~~ 51 | 52 | Prints the following to Android's log: 53 | 54 | Print to the log from printf 55 | Print to the log from a stream 56 | 57 | All log messages from the application will be prefixed with the tag, 58 | "my_application" so they can optionally extracted from [adb][] [logcat][] using 59 | 60 | ~~~{.sh} 61 | adb logcat -s "my_application" 62 | ~~~ 63 | 64 | In addition to changing the tag, it's possible to modify the log priority 65 | `SetAndroidLogWrapperPriority()`. 66 | 67 | # Configuring Buffering {#libfplutil_print_buffering} 68 | 69 | Each Android log message is terminated with a newline, so in order to simulate 70 | printf behavior where newlines are explicit, `libfplutil_print` will buffer 71 | messages up to 256 bytes before writing a line to the log. The size of this 72 | buffer can be modified using `SetAndroidLogWrapperBufferSize()`. 73 | 74 | For example, after increasing the buffer size to 1KB, the following will print 75 | a line longer than 256 bytes to a single log message: 76 | 77 | ~~~{.c} 78 | #include "fplutil/print.h" 79 | #include "fplutil/main.h" 80 | 81 | int main(int argc, char **argv) { 82 | SetAndroidLogWrapperBufferSize(1024); 83 | for (i = 0; i < 256; i++) { 84 | printf("*"); 85 | } 86 | printf("A long line\n"); 87 | return 0; 88 | } 89 | ~~~ 90 | 91 | # Redirecting Output {#libfplutil_print_redirection} 92 | 93 | `libfplutil_print` captures all output to the standard output stream and by 94 | default sends it to the Android log. Applications can capture data sent 95 | to the standard output stream and perform further processing before sending it 96 | to the log. This can be useful when logging to files or annotating log 97 | messages with custom logic. 98 | 99 | For example: 100 | 101 | ~~~{.c} 102 | #include 103 | #include "fplutil/print.h" 104 | #include "fplutil/main.h" 105 | 106 | int CaptureLog(int priority, const char *tag, const char *format, 107 | va_list list) { 108 | // Do something with the message. 109 | return 0; 110 | } 111 | 112 | int main(int argc, char **argv) { 113 | SetAndroidStdioOutputFunction(CaptureLog); 114 | printf("A message to capture\n"); 115 | return 0; 116 | } 117 | ~~~ 118 | 119 |
120 | 121 | [adb]: http://developer.android.com/tools/help/adb.html 122 | [logcat]: http://developer.android.com/tools/help/logcat.html 123 | [Linking]: @ref libfplutil_linking 124 | [NativeActivity]: http://developer.android.com/reference/android/app/NativeActivity.html -------------------------------------------------------------------------------- /docs/src/readme.md: -------------------------------------------------------------------------------- 1 | ../../readme.md -------------------------------------------------------------------------------- /docs/src/tested_ios_sdk_versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdks": [ 3 | { 4 | "version": "iOS 8.3", 5 | "simulator": "iphonesimulator8.3" 6 | }, 7 | { 8 | "version": "iOS 8.4", 9 | "simulator": "iphonesimulator8.4" 10 | }, 11 | { 12 | "version": "iOS 9.1", 13 | "simulator": "iphonesimulator9.1" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /docs/src/tools/android_ndk_perf_visualize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/tools/android_ndk_perf_visualize.png -------------------------------------------------------------------------------- /docs/src/tools/android_ndk_perf_visualize_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/tools/android_ndk_perf_visualize_chart.png -------------------------------------------------------------------------------- /docs/src/tools/android_ndk_perf_visualize_details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/tools/android_ndk_perf_visualize_details.png -------------------------------------------------------------------------------- /docs/src/tools/android_ndk_perf_visualize_legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/tools/android_ndk_perf_visualize_legend.png -------------------------------------------------------------------------------- /docs/src/tools/android_ndk_perf_visualize_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/docs/src/tools/android_ndk_perf_visualize_summary.png -------------------------------------------------------------------------------- /docs/update_code_snippets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright 2014 Google Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """This file updates code snippets in docs from code in test files. 17 | 18 | To use put the following in your md file where you would like the code to be: 19 | 20 | 21 | 22 | In the CPP (or CC) file include the following wrapped around the code: 23 | /// @doxysnippetstart DocFile.md NAME 24 | /// @doxysnippetend 25 | """ 26 | 27 | import argparse 28 | import os 29 | import re 30 | import shutil 31 | import sys 32 | import tempfile 33 | 34 | DOXYSNIPPETEND_RE = re.compile(r'.*\@doxysnippetend.*') 35 | CPPDOXYSNIPPETSTART_RE = re.compile( 36 | r'.*\@doxysnippetstart\s+(?P\S+)\s+(?P\S+).*') 37 | MDDOXYSNIPPETSTART_RE = re.compile(r'.*\@doxysnippetstart\s+(?P\S+).*') 38 | 39 | 40 | def find_file(name, path): 41 | """File the first file within a given path. 42 | 43 | Args: 44 | name: Name of the file to search for. 45 | path: Root of the path to search in. 46 | 47 | Returns: 48 | Full path of the given filename or None if not found. 49 | """ 50 | for root, dirs, files in os.walk(path): 51 | if name in files: 52 | return os.path.join(root, name) 53 | return None 54 | 55 | 56 | def parse_cpp_files(test_directory): 57 | """Parse cpp files looking for snippet marks. 58 | 59 | Args: 60 | test_directory: Directory to look for cpp files in. 61 | 62 | Returns: 63 | Tuple of file_list and snippet_list where file_list is a list of files that need to be 64 | updated with documentation and snippet_list is a dictionary of lists 65 | indexed by string tokens / identifiers. The lists in the snippet_list dictionary 66 | contain lines of code snippets to be inserted at points identified by the 67 | token that indexes the set of lines. 68 | """ 69 | file_list = [] 70 | snippet_list = {} 71 | for path, dirs, files in os.walk(test_directory): 72 | for cpp_file in files: 73 | if not re.match(r'.*\.c(pp|c)$', cpp_file): continue 74 | parse_lines = False 75 | snippet_lines = [] 76 | token = '' 77 | md_file = '' 78 | cpp_file_path = os.path.join(path, cpp_file) 79 | try: 80 | with open(cpp_file_path, 'r') as ccfile: 81 | for line in ccfile: 82 | match = CPPDOXYSNIPPETSTART_RE.match(line) 83 | if match: 84 | parse_lines = True 85 | group_dict = match.groupdict() 86 | md_file = group_dict['md_file'] 87 | token = group_dict['token'] 88 | if md_file not in file_list: 89 | file_list.append(md_file) 90 | elif DOXYSNIPPETEND_RE.match(line): 91 | parse_lines = False 92 | snippet_list[token] = snippet_lines 93 | elif parse_lines: 94 | snippet_lines.append(line) 95 | except IOError as e: 96 | print 'ERROR: Failed to open file %s: %s' % (cpp_file, e.strerror) 97 | if parse_lines is True: 98 | print 'WARNING: Count not find end of %s. Skipping.' % (token) 99 | return (file_list, snippet_list) 100 | 101 | 102 | def update_md_files(md_directory, file_list, snippet_list): 103 | """Update md files from snippets. 104 | 105 | Args: 106 | md_directory: Directory to look for md files in. 107 | snippet_list: Array of snippets to put into the md files. 108 | """ 109 | for md_file in file_list: 110 | path = find_file(md_file, md_directory) 111 | if not path: 112 | print >> sys.stderr, 'WARNING: Cannot find %s, skipping.' % md_file 113 | continue 114 | new_file_handle = tempfile.NamedTemporaryFile(delete=False) 115 | temp_file_name = new_file_handle.name 116 | write_lines = True 117 | try: 118 | with open(path, 'r') as mdfile: 119 | for line in mdfile: 120 | match = MDDOXYSNIPPETSTART_RE.match(line) 121 | if match: 122 | token = match.groupdict()['token'] 123 | new_file_handle.write(line) 124 | if snippet_list.has_key(token): 125 | write_lines = False 126 | for snippet_line in snippet_list[token]: 127 | new_file_handle.write(snippet_line) 128 | elif DOXYSNIPPETEND_RE.match(line): 129 | write_lines = True 130 | new_file_handle.write(line) 131 | elif write_lines: 132 | new_file_handle.write(line) 133 | except IOError as e: 134 | print >> sys.stderr, ( 135 | 'ERROR: Failed to open file %s: %s' % (md_file, e.strerror)) 136 | os.remove(path) 137 | continue 138 | if write_lines is False: 139 | print >> sys.stderr, 'WARNING: Count not find end of %s.' % (token) 140 | new_file_handle.close() 141 | os.remove(path) 142 | shutil.move(temp_file_name, path) 143 | 144 | 145 | def main(): 146 | parser = argparse.ArgumentParser( 147 | description=('Update code snippet docs.')) 148 | parser.add_argument( 149 | '-t', '--test-directory', required=True, 150 | help='Source directory for the test files.') 151 | parser.add_argument( 152 | '-m', '--md-directory', required=True, 153 | help='Source directory for the doxygen files.') 154 | 155 | args = parser.parse_known_args()[0] 156 | 157 | update_md_files(args.md_directory, *parse_cpp_files(args.test_directory)) 158 | 159 | if __name__ == '__main__': 160 | sys.exit(main()) 161 | -------------------------------------------------------------------------------- /examples/buildutil_example/android/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright 2014 Google Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """@file build.py Android example build script. 17 | 18 | Copies an NDK sample to the current directory and builds it. 19 | 20 | Run 'build.py --help' for options. 21 | """ 22 | 23 | import argparse 24 | import os 25 | import shutil 26 | import sys 27 | sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 28 | os.pardir)) 29 | import buildutil.android 30 | import buildutil.common 31 | 32 | 33 | def main(): 34 | # Parse arguments and create the build environment. 35 | parser = argparse.ArgumentParser() 36 | buildutil.android.BuildEnvironment.add_arguments(parser) 37 | args = parser.parse_args() 38 | env = buildutil.android.BuildEnvironment(args) 39 | 40 | # Clean the git working copy. 41 | env.git_clean() 42 | 43 | # Copy one of the NDK samples here and build it 44 | samplename = 'native-plasma' 45 | samplepath = os.path.join(env.ndk_home, 'samples', samplename) 46 | shutil.rmtree(samplename, True) 47 | shutil.copytree(samplepath, samplename) 48 | 49 | # Build the sample. 50 | (rc, errmsg) = env.build_all() 51 | if (rc == 0): 52 | # Archive the sample built in the apks directory to output.zip. 53 | env.make_archive(['apks'], 'output.zip', exclude=['objs', 'objs-debug']) 54 | else: 55 | print >> sys.stderr, errmsg 56 | 57 | return rc 58 | 59 | if __name__ == '__main__': 60 | sys.exit(main()) 61 | -------------------------------------------------------------------------------- /examples/buildutil_example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # CMakeLists project file for the linux build example. 16 | cmake_minimum_required(VERSION 2.8) 17 | project (Hello) 18 | 19 | option(MESSAGE "what to print" OFF) # Simple example of passing cmake options. 20 | if(MESSAGE) 21 | # If this cmake option is set, pass to make. 22 | add_definitions(-DMESSAGE="${MESSAGE}") 23 | endif() 24 | # Build a binary called Hello from main.c. 25 | add_executable(Hello main.c) 26 | -------------------------------------------------------------------------------- /examples/buildutil_example/linux/build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright 2014 Google Inc. All rights reserved. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | """@file build.py Linux example build script. 17 | 18 | Builds a tiny example using cmake. 19 | 20 | Run 'build.py --help' for options. 21 | """ 22 | 23 | import argparse 24 | import os 25 | import sys 26 | sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, 27 | os.pardir)) 28 | import buildutil.common 29 | import buildutil.linux 30 | 31 | 32 | def main(): 33 | parser = argparse.ArgumentParser() 34 | buildutil.linux.BuildEnvironment.add_arguments(parser) 35 | args = parser.parse_args() 36 | 37 | retval = -1 38 | 39 | env = buildutil.linux.BuildEnvironment(args) 40 | 41 | # Add cmake flags specific to our test build. 42 | env.cmake_flags = '-DMESSAGE="Hello, World!"' 43 | 44 | try: 45 | env.git_clean() 46 | env.run_cmake() 47 | env.run_make() 48 | env.make_archive(['Hello'], 'output.zip') 49 | 50 | retval = 0 51 | 52 | except buildutil.common.Error as e: 53 | print >> sys.stderr, 'Caught buildutil error: %s' % e.error_message 54 | retval = e.error_code 55 | 56 | except IOError as e: 57 | print >> sys.stderr, 'Caught IOError for file %s: %s' % (e.filename, 58 | e.strerror) 59 | retval = -1 60 | 61 | return retval 62 | 63 | if __name__ == '__main__': 64 | sys.exit(main()) 65 | -------------------------------------------------------------------------------- /examples/buildutil_example/linux/main.c: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | /// @file main.c Example application built by buildutil. 16 | #include 17 | 18 | // Very simple linux build example. MESSAGE is defined on the make command line 19 | // based on the cmake_flags set in the build.py. 20 | int main(int argc, char **argv) 21 | { 22 | printf("%s\n", MESSAGE); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /examples/libfplutil_example/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 18 | 22 | 23 | 24 | 25 | 27 | 29 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/libfplutil_example/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | # --- project --- 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE:=libfplutil_example 20 | LOCAL_SRC_FILES:=$(LOCAL_PATH)/main.c 21 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 22 | libfplutil_print 23 | LOCAL_ARM_MODE:=arm 24 | include $(BUILD_SHARED_LIBRARY) 25 | 26 | $(call import-add-path,$(abspath $(LOCAL_PATH)/../../)) 27 | 28 | $(call import-module,android/native_app_glue) 29 | $(call import-module,libfplutil/jni) 30 | -------------------------------------------------------------------------------- /examples/libfplutil_example/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | APP_STL:=c++_static 18 | APP_MODULES:=libfplutil_example 19 | 20 | -------------------------------------------------------------------------------- /examples/libfplutil_example/main.c: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include "fplutil/print.h" 17 | #include "fplutil/main.h" 18 | 19 | // Very simple example that just logs "Hello, World!" to the Android log. 20 | 21 | int main(int argc, char **argv) { 22 | printf("Hello, World!\n"); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /fbx_common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | cmake_minimum_required(VERSION 2.8.12) 15 | 16 | project(fbx_common) 17 | 18 | # Include common setup for FBX projects. 19 | include("cmake_fbx.txt") 20 | 21 | # Output library files into `obj`. 22 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obj) 23 | 24 | # Set compile options for FBX programs. 25 | fbx_compile_options() 26 | 27 | # Source files for the library. 28 | set(fbx_common_SRCS 29 | include/fbx_common/fbx_common.h 30 | src/fbx_common.cpp) 31 | 32 | # Create the executable for mesh_pipeline. 33 | add_library(fbx_common ${fbx_common_SRCS}) 34 | 35 | # Add common link libraries and include directories. 36 | fbx_configure_target(fbx_common) 37 | -------------------------------------------------------------------------------- /fbx_common/include/fbx_common/fbx_sdk_no_warnings.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_FBX_SDK_NO_WARNINGS 16 | #define FPLUTIL_FBX_SDK_NO_WARNINGS 17 | 18 | // Suppress warnings in external header. 19 | #if defined(__GNUC__) 20 | #pragma GCC diagnostic push 21 | #pragma GCC diagnostic ignored "-Wignored-qualifiers" 22 | #pragma GCC diagnostic ignored "-Wunused-parameter" 23 | #pragma GCC diagnostic ignored "-Wpedantic" 24 | #pragma GCC diagnostic ignored "-Wunused-value" 25 | #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 26 | #pragma GCC diagnostic ignored "-Wnull-dereference" 27 | #endif // defined(__GNUC__) 28 | 29 | #if defined(__clang__) 30 | #pragma clang diagnostic push 31 | #pragma clang diagnostic ignored "-Wignored-qualifiers" 32 | #pragma clang diagnostic ignored "-Wunused-parameter" 33 | #pragma clang diagnostic ignored "-Wpedantic" 34 | #pragma clang diagnostic ignored "-Wunused-value" 35 | #pragma clang diagnostic ignored "-Wmissing-field-initializers" 36 | #pragma clang diagnostic ignored "-Wnull-dereference" 37 | #endif // defined(__clang__) 38 | 39 | #include 40 | 41 | #if defined(__clang__) 42 | #pragma clang diagnostic pop 43 | #endif // defined(__clang__) 44 | 45 | #if defined(__GNUC__) 46 | #pragma GCC diagnostic pop 47 | #endif // defined(__GNUC__) 48 | 49 | #endif // FPLUTIL_FBX_SDK_NO_WARNINGS 50 | -------------------------------------------------------------------------------- /libfplutil/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | cmake_minimum_required(VERSION 2.8.12) 15 | 16 | project(fplutil) 17 | 18 | option(fplutil_build_tests "Build tests for this project." ON) 19 | option(fplutil_build_library "Build library with file utils, etc.." ON) 20 | 21 | # Output library files into `obj`. 22 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/obj) 23 | 24 | # Get locations of dependencies and set common build settings. 25 | include("${CMAKE_CURRENT_LIST_DIR}/../buildutil/cmake_common.txt") 26 | set_common_build_variables() 27 | 28 | # Includes for this project. 29 | include_directories(src) 30 | include_directories(include) 31 | 32 | # Source files for the fplutil library. 33 | set(fplutil_SRCS 34 | src/file_utils.cpp 35 | src/string_utils.cpp) 36 | 37 | # Library. 38 | if(fplutil_build_library) 39 | add_library(fplutil ${fplutil_SRCS}) 40 | endif() 41 | 42 | # Tests. 43 | if(fplutil_build_tests) 44 | add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit_tests) 45 | endif() 46 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/android_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_ANDROID_UTILS_H 16 | #define FPLUTIL_ANDROID_UTILS_H 17 | 18 | #ifdef __ANDROID__ 19 | #include 20 | #include 21 | #endif 22 | 23 | namespace fplutil { 24 | 25 | #ifdef __ANDROID__ 26 | /// @class JniObject 27 | /// 28 | /// @brief A helper class wrapping jobject. 29 | /// The class provides misc helper functions to access methods in the attached 30 | /// object and maintains a local/global reference of the attached object. 31 | class JniObject { 32 | public: 33 | JniObject() : global_ref_(false), obj_(nullptr) {} 34 | virtual ~JniObject() { CleanUp(); } 35 | 36 | /// @brief Copy constructors. 37 | JniObject(jobject obj) : global_ref_(false) { obj_ = obj; } 38 | JniObject(jstring str) : global_ref_(false) { obj_ = str; } 39 | 40 | /// @brief Add a global refrence to the object. 41 | void AddGlobalReference(); 42 | 43 | /// @brief Method accessors to the object for variable return types. 44 | /// 45 | /// @param[in] method A method name. 46 | /// @param[in] signature A JNI style method signature. 47 | void CallVoidMethod(const char* method, const char* signature, ...); 48 | int32_t CallIntMethod(const char* method, const char* signature, ...); 49 | jobject CallObjectMethod(const char* method, const char* signature, ...); 50 | std::string CallStringMethod(const char* method, const char* signature, ...); 51 | 52 | /// @brief Set JNIEnv variable to the class. The function needs to be invoked 53 | /// on each thread before using the class on that thread. 54 | static void SetEnv(JNIEnv* env); 55 | 56 | /// @brief Static utility methods. 57 | 58 | /// @brief Call static method that returns an object. 59 | /// @param[in] cls A class name. 60 | /// @param[in] method A method name. 61 | /// @param[in] signature A JNI style method signature. 62 | static jobject CallStaticObjectMethod(const char* cls, const char* method, 63 | const char* signature, ...); 64 | 65 | /// @brief Create an object. 66 | /// 67 | /// @param[in] cls A class name to create. 68 | /// @param[in] signature A JNI style method signature of a constructor. 69 | static jobject CreateObject(const char* cls, const char* signature, ...); 70 | 71 | /// @brief Create a jstring from std::string. 72 | /// 73 | /// @param[in] string A string to convert. 74 | static jstring CreateString(std::string& str) { 75 | return GetEnv()->NewStringUTF(str.c_str()); 76 | } 77 | 78 | /// @brief Getter of the jobject attached to the class. 79 | jobject get_object() { return static_cast(obj_); } 80 | 81 | protected: 82 | static JNIEnv* GetEnv(); 83 | jmethodID GetMethodId(const char* method, const char* signature); 84 | void CleanUp(); 85 | bool global_ref_; 86 | void* obj_; 87 | }; 88 | 89 | /// @class JniClass 90 | /// 91 | /// @brief Helper class wrapping jclass object. 92 | class JniClass : JniObject { 93 | public: 94 | JniClass() {} 95 | ~JniClass() {} 96 | 97 | /// @brief Find a class. 98 | /// 99 | /// @param[in] cls A class name to find. 100 | bool FindClass(const char* cls) { 101 | CleanUp(); 102 | obj_ = static_cast(GetEnv()->FindClass(cls)); 103 | return obj_ != nullptr; 104 | } 105 | 106 | /// @brief Getter of the jclass object. 107 | jclass get_class() { return static_cast(obj_); } 108 | }; 109 | 110 | #endif // __ANDROID__ 111 | } // namespace fplutils 112 | 113 | #endif // FPLUTIL_ANDROID_UTILS_H 114 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/file_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_FILE_UTILS_H 16 | #define FPLUTIL_FILE_UTILS_H 17 | 18 | #include 19 | 20 | namespace fplutil { 21 | 22 | enum CaseSensitivity { 23 | // Use the default case sensitivity of the operating system. 24 | kOsDefaultCaseSensitivity, 25 | 26 | // Case must match. 27 | kCaseSensitive, 28 | 29 | // All comparisons are performed independent of case. 30 | kCaseInsensitive, 31 | }; 32 | 33 | /// Ensure that `s` has a directory slash on the end of it. 34 | std::string FormatAsDirectoryName(const std::string& s); 35 | 36 | /// Remove the last `.` from `s`, and any text after it. 37 | std::string RemoveExtensionFromName(const std::string& s); 38 | 39 | /// Remove all text up to and including the last `/` or `\` in `s`. 40 | std::string RemoveDirectoryFromName(const std::string& s); 41 | 42 | /// Remove both the extention and directory from name. 43 | std::string BaseFileName(const std::string& s); 44 | 45 | /// Remove the file from the string and return the directory. 46 | std::string DirectoryName(const std::string& s); 47 | 48 | /// Return just the extension of the file. That is, everything after the '.'. 49 | std::string FileExtension(const std::string& s); 50 | 51 | /// Return true if the specified file starts with a slash. 52 | bool AbsoluteFileName(const std::string& s); 53 | 54 | /// Return true if the specified file exists. Can be absolute or relative path. 55 | /// Use the file system's default case sensitivity. 56 | bool FileExists(const std::string& file_name); 57 | 58 | /// Return true if the specified file exists. Can be absolute or relative path. 59 | /// Use the specified case sensitivity. 60 | bool FileExists(const std::string& file_name, CaseSensitivity case_sensitivity); 61 | 62 | /// Create the sequence of directories specified by `dir`. 63 | /// @param dir Directory to create. Can be and absolute path, or a path 64 | /// relative to the current directory. 65 | /// @return true iff the directory was created successfully. 66 | bool CreateDirectory(const std::string& dir); 67 | 68 | /// Copy a file from one location to another. Does *not* create the directory 69 | /// for the target file, so will fail if it doesn't exist. 70 | /// @return true iff the file was successfully copied. 71 | bool CopyFile(const std::string& target_file_name, 72 | const std::string& source_file_name); 73 | 74 | } // namespace fplutil 75 | 76 | #endif // FPLUTIL_FILE_UTILS_H 77 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/main.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_MAIN_H 16 | #define FPLUTIL_MAIN_H 17 | 18 | /// @file 19 | /// Header for libfplutil_main. 20 | /// 21 | /// libfplutil_main makes it easy to build traditional C/C++ 22 | /// applications for Android that use an `int main()` entry point. 23 | /// 24 | /// Linking this library adds functionality to call a standard C main() from 25 | /// Android's NativeActivity NDK entry point, android_main(). This helps 26 | /// you by by making it very easy to resuse existing programs with a C main() 27 | /// entry point. 28 | /// 29 | /// For example, this code: 30 | /// 31 | /// @code{.c} 32 | /// #include "fplutil/main.h" 33 | /// 34 | /// int main(int argc, char **argv) { 35 | /// ... do stuff ... 36 | /// return 0; 37 | /// } 38 | /// @endcode 39 | /// 40 | /// will launch, "do stuff", and exit the NativeActivity on return from main(). 41 | /// The android_main() is implemented inside this library for you. 42 | /// 43 | /// If "do stuff" requires nontrivial amounts of time, such as entering a main 44 | /// loop and looping forever, then it is advisable to add a call the 45 | /// ProcessAndroidEvents() function below periodically, which will minimally 46 | /// service events on the native activity looper. 47 | /// 48 | /// For more information see `ndk/sources/android/native_app_glue`. 49 | 50 | #if defined(ANDROID) || defined(__ANDROID__) 51 | 52 | #if defined(__cplusplus) 53 | extern "C" { 54 | #endif // defined(__cplusplus) 55 | 56 | /// This should be implemented by the application including this header. 57 | extern int main(int argc, char** argv); 58 | 59 | /// Process android events on the main NativeActivity thread ALooper. 60 | /// 61 | /// This waits for and processes any pending events from the Android SDK being 62 | /// passed into the NDK. The call will block up to maxWait milliseconds for 63 | /// pending Android events. 64 | /// 65 | /// @param maxWait 0 returns immediately, -1 blocks indefinitely until an 66 | /// event arrives. 67 | void ProcessAndroidEvents(int maxWait); 68 | 69 | #if defined(__cplusplus) 70 | } 71 | #endif // defined(__cplusplus) 72 | 73 | #endif // defined(ANDROID) || defined(__ANDROID__) 74 | #endif // FPLUTIL_MAIN_H 75 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/print.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_PRINT_H 16 | #define FPLUTIL_PRINT_H 17 | 18 | /// @file 19 | /// Header for libfplutil_print. 20 | /// 21 | /// libfplutil_print makes it easy to redirect writes to the standard output 22 | /// stream to the Android log. 23 | 24 | #if defined(ANDROID) || defined(__ANDROID__) 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #if defined(__cplusplus) 31 | extern "C" { 32 | #endif // defined(__cplusplus) 33 | 34 | /// This is the function signature to use if you would like to intercept 35 | /// printf calls in your code. See SetAndroidLogOutputFunction(). 36 | /// 37 | /// The first two parameters to this function are the log priority and tag, 38 | /// respectively. The remaining ones are the same as for the stdio function 39 | /// vprintf(), and overall the expected semantics for this function are the 40 | /// same as for vprintf(). Please see: 41 | /// http://pubs.opengroup.org/onlinepubs/9699919799/functions/vfprintf.html 42 | /// 43 | /// @param priority Android log priority. 44 | /// @param tag Tag to display before the logged string. 45 | /// @param format printf format string. 46 | /// @param list Additional list of arguments referenced by the printf format 47 | /// string. 48 | typedef int (*AndroidLogOutputFunction)(int priority, const char *tag, 49 | const char *format, va_list list); 50 | 51 | /// Set the tag used for log output by the wrappers. This can used when 52 | /// filtering the output of "adb logcat" to distinguish the log messages from 53 | /// this application vs. other applications and the rest of the system. 54 | /// Note that this pointer is simply assigned so it must have permanent 55 | /// lifetime. 56 | /// 57 | /// @param tag A null terminated C string to use as the log tag. 58 | /// Default is "main". 59 | /// 60 | /// @return 0 on success, -1 if tag is null or an empty string. 61 | int SetAndroidLogWrapperTag(const char *tag); 62 | 63 | /// Set the priority used for log output by the wrappers. 64 | /// 65 | /// @param priority An android log priority, as described in the Android NDK 66 | /// header file android/log.h. Default is ANDROID_LOG_INFO 67 | /// from that file. 68 | void SetAndroidLogWrapperPriority(int priority); 69 | 70 | /// Set the buffer size for the wrappers. Default is 256 bytes. Setting this to 71 | /// zero will force unbuffered output, which may have unexpected formatting 72 | /// such as additional newlines as text is immediately sent to the log. Nonzero 73 | /// values will accumulate writes until a newline is encountered or the buffer 74 | /// size is reached. 75 | /// 76 | /// Buffering is done to allow multiple stdio calls to output on the same line, 77 | /// as per normal behavior of stdio. So, something like this: 78 | /// 79 | /// @code{.c} 80 | /// for (i = 0; i < 5; ++i) { 81 | /// printf("%c", '1' + i); 82 | /// } 83 | /// @endcode 84 | /// 85 | /// would output: 86 | /// 87 | /// @code{.c} 88 | /// 12345 89 | /// @endcode 90 | /// 91 | /// and not five separate log lines, which is the unbuffered behavior. 92 | /// 93 | /// @param size The number of bytes to use for buffering. 0 sets unbuffered 94 | /// mode. Default is 256 bytes. 95 | /// 96 | /// @return 0 on success, -1 if buffer allocation failed (nonfatal, buffer is 97 | /// unchanged) 98 | int SetAndroidLogWrapperBufferSize(size_t size); 99 | 100 | /// Set the function called when these wrappers perform output. This defaults 101 | /// to __android_log_vprint(), which will cause the output to go to the Android 102 | /// log. You may intercept the output yourself by setting this function. Do not 103 | /// call any stdio output functions or use C++ std::cout/cerr from the function 104 | /// you set here, or infinite recursion will result. 105 | /// 106 | /// @param func A function pointer of typedef AndroidLogOutputFunction to use 107 | /// for stdio output. 108 | void SetAndroidStdioOutputFunction(AndroidLogOutputFunction func); 109 | 110 | /// An internal function that will behave like a snprintf-based version of 111 | /// perror. Used by __wrap_perror() and factored out/exposed to be testable. 112 | /// 113 | /// Output should look equivalent to what you would expect for: 114 | /// 115 | /// @code{.c} 116 | /// sprintf(msgout, "%s: %s", msg, strerror(err)); 117 | /// @endcode 118 | /// 119 | /// or 120 | /// 121 | /// @code{.c} 122 | /// strcpy(msgout, strerror(err)); 123 | /// @endcode 124 | /// 125 | /// depending on the value of msg. 126 | /// 127 | /// @param msg An optional message to prepend to the error to be printed. 128 | /// May be NULL. 129 | /// @param err The error value to be printed (via strerror). Error value 130 | /// behavior is the same as for strerror. 131 | /// @param msgout The output buffer. Must not be NULL. 132 | /// @param outsize The size of the memory pointed to by the output buffer. 133 | /// msgout will be null-terminated to this length. 134 | /// 135 | /// @return 0 on success, -1 on error. 136 | int AndroidPerrorMsg(const char *msg, int err, char *msgout, size_t outsize); 137 | 138 | #if defined(__cplusplus) 139 | } // extern "C" 140 | #endif // defined(__cplusplus) 141 | 142 | #endif // defined(ANDROID) || defined(__ANDROID__) 143 | #endif // FPLUTIL_PRINT_H 144 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/string_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_STRING_UTILS_H 16 | #define FPLUTIL_STRING_UTILS_H 17 | 18 | #include 19 | 20 | namespace fplutil { 21 | 22 | /// Return `source` as a_string_in_snake_case. 23 | /// https://en.wikipedia.org/wiki/Snake_case 24 | std::string SnakeCase(const std::string& source); 25 | 26 | /// Return `source` as AStringInCamelCase. 27 | /// https://en.wikipedia.org/wiki/CamelCase 28 | std::string CamelCase(const std::string& source); 29 | 30 | } // namespace fplutil 31 | 32 | #endif // FPLUTIL_STRING_UTILS_H 33 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/variable_size.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_VARIABLE_SIZE_H_ 16 | #define FPLUTIL_VARIABLE_SIZE_H_ 17 | 18 | #include 19 | 20 | namespace fplutil { 21 | 22 | /// @brief Calculates the size of a variable-size class, taking into account 23 | /// type alignment. 24 | /// 25 | /// A variable-size class is one that is contiguous in memory, but has members 26 | /// (often arrays) of variable size. For example, a variable-size spline class 27 | /// might end in an array of nodes that is not always the same length. 28 | /// 29 | /// Why use a variable-size class? Why not just use std::vector? 30 | /// (1) Often, memory layout is critical to performance. The spline, for 31 | /// example, might have some class-wide member variables in addition to its 32 | /// array of nodes. For cache-performance reasons, it's critical that 33 | /// both of these reside one piece of contiguous memory. 34 | /// (2) std::vectors and other dynamically-sized types require multiple 35 | /// memory allocations per-class. For classes that are allocated thousands 36 | /// of times on start-up, this can be a measurable cost overhead. 37 | /// (3) Memory is often passed around from one processor to another, or across 38 | /// the network. When all data is contiguous in memory, this becomes 39 | /// simpler. 40 | /// (4) From a low-level point of view, data is tidiest when each class is 41 | /// contained in one chunk of memory. Some people never look at the memory 42 | /// inspector in the debugger, but it is a powerful tool so other people do 43 | /// spend significant time there. A simpler memory layout is nice when 44 | /// things go wrong with memory (e.g. memory corruption). 45 | class VariableSizeCalculator { 46 | public: 47 | explicit VariableSizeCalculator(size_t base_size) 48 | : size_(base_size), alignment_(1) {} 49 | 50 | /// Add a raw chunk of memory of size `alloc_size` to the class. 51 | /// Return the offset of the *start* of the chunk of memory. 52 | size_t Raw(size_t alloc_size, size_t alignment) { 53 | const size_t mask = alignment - 1; 54 | const size_t aligned = (size_ + mask) & ~mask; 55 | size_ = aligned + alloc_size; 56 | alignment_ = alignment_ > alignment ? alignment_ : alignment; // =std::max() 57 | return aligned; 58 | } 59 | 60 | /// Add a type T to the class. 61 | /// Return the offet to the *start* of T. 62 | template 63 | size_t Type() { return Raw(sizeof(T), alignof(T)); } 64 | 65 | /// Add an array T[count] to the size. 66 | /// Return the offset of the *start* of the array. 67 | template 68 | size_t Array(size_t count) { return Raw(sizeof(T) * count, alignof(T)); } 69 | 70 | /// Return the current size of class. 71 | size_t size() const { return size_; } 72 | 73 | /// Return the required alignment of this class. 74 | /// This equals the maximum required alignment of the class's member 75 | /// variables. 76 | size_t alignment() const { return alignment_; } 77 | 78 | private: 79 | /// Current total size of the class. 80 | size_t size_; 81 | 82 | /// Current required alignment of the class. 83 | size_t alignment_; 84 | }; 85 | 86 | class VariableSizeBuilder { 87 | public: 88 | VariableSizeBuilder(void* base, size_t base_size) 89 | : base_(static_cast(base)), size_(base_size) {} 90 | 91 | /// Add a raw chunk of memory of size `alloc_size` to the class. 92 | /// Return the offset of the *start* of the chunk of memory. 93 | void* Raw(size_t alloc_size, size_t alignment) { 94 | return base_ + size_.Raw(alloc_size, alignment); 95 | } 96 | 97 | /// Add a type T to the class. 98 | /// Return the offet to the *start* of T. 99 | template 100 | T* Type() { return static_cast(Raw(sizeof(T), alignof(T))); } 101 | 102 | /// Add an array T[count] to the size. 103 | /// Return the offset of the *start* of the array. 104 | template 105 | T* Array(size_t count) { 106 | return static_cast(Raw(sizeof(T) * count, alignof(T))); 107 | } 108 | 109 | /// Return a pointer past the current end of the class. 110 | uint8_t* End() const { return base_ + size(); } 111 | 112 | /// Return the current size of class. 113 | size_t size() const { return size_.size(); } 114 | 115 | private: 116 | uint8_t* base_; 117 | 118 | VariableSizeCalculator size_; 119 | }; 120 | 121 | } // namespace fplutil 122 | 123 | #endif // FPLUTIL_VARIABLE_SIZE_H_ 124 | 125 | -------------------------------------------------------------------------------- /libfplutil/include/fplutil/version.h: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef FPLUTIL_VERSION_H 16 | #define FPLUTIL_VERSION_H 17 | 18 | #define FPLUTIL_VERSION_PREFIX "fplutil " 19 | #define FPLUTIL_VERSION_MAJOR 1 20 | #define FPLUTIL_VERSION_MINOR 1 21 | #define FPLUTIL_VERSION_REVISION 0 22 | #define FPLUTIL_STRING_EXPAND(X) #X 23 | #define FPLUTIL_STRING(X) FPLUTIL_STRING_EXPAND(X) 24 | 25 | // clang-format off 26 | #define FPLUTIL_VERSION_STRING \ 27 | (FPLUTIL_VERSION_PREFIX \ 28 | FPLUTIL_STRING(FPLUTIL_VERSION_MAJOR) "." \ 29 | FPLUTIL_STRING(FPLUTIL_VERSION_MINOR) "." \ 30 | FPLUTIL_STRING(FPLUTIL_VERSION_REVISION)) 31 | // clang-format on 32 | 33 | #if defined(__cplusplus) 34 | } 35 | #endif // defined(__cplusplus) 36 | 37 | #endif // FPLUTIL_VERSION_H 38 | -------------------------------------------------------------------------------- /libfplutil/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_MODULE:=libfplutil_print 19 | LOCAL_SRC_FILES:=\ 20 | src/print.c \ 21 | src/print_cxx.cc 22 | LOCAL_C_INCLUDES:=$(LOCAL_PATH)/include 23 | LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/include 24 | # Cause the linker to substitute our implementations for these functions, at 25 | # a .so-wide level. 26 | LOCAL_EXPORT_LDFLAGS:=\ 27 | -Wl,--wrap=perror,--wrap=fflush,--wrap=fprintf,--wrap=vprintf \ 28 | -Wl,--wrap=printf,--wrap=putc,--wrap=fputc,--wrap=putchar,--wrap=puts \ 29 | -Wl,--wrap=fputs,--wrap=fwrite,--wrap=write,--wrap=writev 30 | # Need this to prevent auto-use of builtin functions. 31 | LOCAL_EXPORT_CFLAGS:= -fno-builtin-printf -fno-builtin-fprintf \ 32 | -fno-builtin-fflush -fno-builtin-perror -fno-builtin-vprintf \ 33 | -fno-builtin-putc -fno-builtin-putchar -fno-builtin-fputc \ 34 | -fno-builtin-fputs -fno-builtin-puts -fno-builtin-fwrite \ 35 | -fno-builtin-write -fno-builtin-writev 36 | LOCAL_EXPORT_LDLIBS:=-llog -landroid -latomic 37 | LOCAL_CFLAGS:=-fPIC -Wall -Wextra -W 38 | LOCAL_CXXFLAGS:=-fPIC -std=c++98 -Wall -Wextra -W 39 | LOCAL_ARM_MODE:=arm 40 | include $(BUILD_STATIC_LIBRARY) 41 | 42 | include $(CLEAR_VARS) 43 | LOCAL_MODULE:=libfplutil_main 44 | LOCAL_SRC_FILES:=src/main.c 45 | LOCAL_C_INCLUDES:=\ 46 | $(LOCAL_PATH)/include \ 47 | $(NDK_ROOT)/sources/android/native_app_glue 48 | LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/include 49 | LOCAL_EXPORT_LDLIBS:=-llog -landroid -latomic 50 | LOCAL_CFLAGS:=-fPIC -std=c99 -Wall -Wextra -W 51 | LOCAL_ARM_MODE:=arm 52 | LOCAL_STATIC_LIBRARIES:=android_native_app_glue 53 | include $(BUILD_STATIC_LIBRARY) 54 | 55 | include $(CLEAR_VARS) 56 | LOCAL_MODULE:=libfplutil 57 | LOCAL_SRC_FILES:=\ 58 | src/android_utils.cpp \ 59 | src/string_utils.cpp 60 | LOCAL_C_INCLUDES:=\ 61 | $(LOCAL_PATH)/include 62 | LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/include 63 | LOCAL_EXPORT_LDLIBS:=-llog -landroid -latomic 64 | LOCAL_CFLAGS:=-fPIC -std=c99 -Wall -Wextra -W 65 | LOCAL_ARM_MODE:=arm 66 | include $(BUILD_STATIC_LIBRARY) 67 | 68 | $(call import-module,android/native_app_glue) 69 | -------------------------------------------------------------------------------- /libfplutil/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | APP_STL:=c++_static 18 | APP_MODULES:=libfplutil_print libfplutil_main 19 | NDK_MODULE_PATH:=$(NDK_ROOT)/sources/android 20 | -------------------------------------------------------------------------------- /libfplutil/jni/libs/googletest/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | LOCAL_PATH := $(call my-dir)/.. 17 | 18 | PROJECT_ROOT := $(LOCAL_PATH)/../../.. 19 | include $(PROJECT_ROOT)/buildutil/android_common.mk 20 | 21 | # NDK support of other archs (ie. x86 and mips) are only available after 22 | # android-9 23 | libgtest_sdk_version:=$(if $(subst,arm,,$(TARGET_ARCH)),9,8) 24 | 25 | GTEST_INCLUDE_DIRS := \ 26 | $(DEPENDENCIES_GTEST_DIR)/include \ 27 | $(DEPENDENCIES_GTEST_DIR)/../.. 28 | 29 | GMOCK_INCLUDE_DIRS := \ 30 | $(DEPENDENCIES_GMOCK_DIR)/include \ 31 | $(DEPENDENCIES_GMOCK_DIR)/../.. 32 | 33 | include $(CLEAR_VARS) 34 | LOCAL_MODULE := libgtest 35 | LOCAL_EXPORT_LDLIBS := -llog -latomic 36 | LOCAL_SRC_FILES := $(DEPENDENCIES_GTEST_DIR)/src/gtest-all.cc 37 | LOCAL_CPP_EXTENSION := .cc 38 | LOCAL_CFLAGS := $(FPL_CFLAGS) 39 | LOCAL_C_INCLUDES := \ 40 | $(DEPENDENCIES_GTEST_DIR) \ 41 | $(GTEST_INCLUDE_DIRS) 42 | LOCAL_EXPORT_C_INCLUDES := $(GTEST_INCLUDE_DIRS) 43 | LOCAL_SDK_VERSION := $(libgtest_sdk_version) 44 | include $(BUILD_STATIC_LIBRARY) 45 | 46 | include $(CLEAR_VARS) 47 | LOCAL_MODULE := libgmock 48 | LOCAL_EXPORT_LDLIBS := -llog -latomic 49 | LOCAL_SRC_FILES := $(DEPENDENCIES_GMOCK_DIR)/src/gmock-all.cc 50 | LOCAL_CPP_EXTENSION := .cc 51 | LOCAL_CFLAGS := $(FPL_CFLAGS) 52 | LOCAL_C_INCLUDES := \ 53 | $(DEPENDENCIES_GMOCK_DIR) \ 54 | $(GMOCK_INCLUDE_DIRS) \ 55 | $(GTEST_INCLUDE_DIRS) 56 | LOCAL_EXPORT_C_INCLUDES := \ 57 | $(GMOCK_INCLUDE_DIRS) \ 58 | $(GTEST_INCLUDE_DIRS) 59 | LOCAL_SDK_VERSION := $(libgtest_sdk_version) 60 | include $(BUILD_STATIC_LIBRARY) 61 | -------------------------------------------------------------------------------- /libfplutil/jni/libs/googletest/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi armeabi-v7a mips x86 x86_64 17 | APP_STL:=c++_static 18 | APP_MODULES:=libgtest 19 | APP_CPPFLAGS += -std=c++11 -Wno-literal-suffix 20 | 21 | -------------------------------------------------------------------------------- /libfplutil/src/android_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifdef __ANDROID__ 16 | 17 | #include "fplutil/android_utils.h" 18 | 19 | #include 20 | 21 | namespace { 22 | pthread_key_t g_env_pthread_key; 23 | 24 | void InitializeEnvThreadLocal() { 25 | static bool g_thread_local_initialized = []() { 26 | pthread_key_create(&g_env_pthread_key, nullptr); 27 | return true; 28 | }(); 29 | (void) g_thread_local_initialized; 30 | } 31 | 32 | } // namespace 33 | 34 | namespace fplutil { 35 | 36 | JNIEnv* JniObject::GetEnv() { 37 | InitializeEnvThreadLocal(); 38 | return static_cast(pthread_getspecific(g_env_pthread_key)); 39 | } 40 | 41 | void JniObject::SetEnv(JNIEnv* env) { 42 | InitializeEnvThreadLocal(); 43 | pthread_setspecific(g_env_pthread_key, env); 44 | } 45 | 46 | jobject JniObject::CreateObject(const char* cls_name, const char* signature, 47 | ...) { 48 | JniClass cls; 49 | jobject obj = nullptr; 50 | JNIEnv* env = GetEnv(); 51 | if (cls.FindClass(cls_name)) { 52 | jmethodID mid = env->GetMethodID(cls.get_class(), "", signature); 53 | va_list args; 54 | va_start(args, signature); 55 | obj = env->NewObjectV(cls.get_class(), mid, args); 56 | va_end(args); 57 | } 58 | return obj; 59 | } 60 | 61 | jobject JniObject::CallStaticObjectMethod(const char* cls_name, 62 | const char* method, 63 | const char* signature, ...) { 64 | JniClass cls; 65 | jobject obj = nullptr; 66 | JNIEnv* env = GetEnv(); 67 | if (cls.FindClass(cls_name)) { 68 | va_list args; 69 | va_start(args, signature); 70 | jmethodID mid = env->GetStaticMethodID(cls.get_class(), method, signature); 71 | obj = env->CallStaticObjectMethodV(cls.get_class(), mid, args); 72 | va_end(args); 73 | } 74 | return obj; 75 | } 76 | 77 | void JniObject::CallVoidMethod(const char* method, const char* signature, ...) { 78 | va_list args; 79 | va_start(args, signature); 80 | auto mid = GetMethodId(method, signature); 81 | GetEnv()->CallVoidMethodV(static_cast(obj_), mid, args); 82 | va_end(args); 83 | return; 84 | } 85 | 86 | int32_t JniObject::CallIntMethod(const char* method, const char* signature, 87 | ...) { 88 | va_list args; 89 | va_start(args, signature); 90 | auto mid = GetMethodId(method, signature); 91 | auto ret = GetEnv()->CallIntMethodV(static_cast(obj_), mid, args); 92 | va_end(args); 93 | return ret; 94 | } 95 | 96 | jobject JniObject::CallObjectMethod(const char* method, const char* signature, 97 | ...) { 98 | va_list args; 99 | va_start(args, signature); 100 | auto mid = GetMethodId(method, signature); 101 | auto ret = GetEnv()->CallObjectMethodV(static_cast(obj_), mid, args); 102 | va_end(args); 103 | return ret; 104 | } 105 | 106 | std::string JniObject::CallStringMethod(const char* method, 107 | const char* signature, ...) { 108 | va_list args; 109 | JNIEnv* env = GetEnv(); 110 | va_start(args, signature); 111 | auto mid = GetMethodId(method, signature); 112 | auto jstr = env->CallObjectMethodV(static_cast(obj_), mid, args); 113 | va_end(args); 114 | // Convert jstring to std::string. 115 | auto str = env->GetStringUTFChars(static_cast(jstr), NULL); 116 | std::string ret = str; 117 | env->ReleaseStringUTFChars(static_cast(jstr), str); 118 | env->DeleteLocalRef(jstr); 119 | return ret; 120 | } 121 | 122 | void JniObject::AddGlobalReference() { 123 | JNIEnv* env = GetEnv(); 124 | env->NewGlobalRef(static_cast(obj_)); 125 | env->DeleteLocalRef(static_cast(obj_)); 126 | global_ref_ = true; 127 | } 128 | 129 | jmethodID JniObject::GetMethodId(const char* method, const char* signature) { 130 | JNIEnv* env = GetEnv(); 131 | jclass cls = env->GetObjectClass(static_cast(obj_)); 132 | jmethodID mid = env->GetMethodID(cls, method, signature); 133 | env->DeleteLocalRef(cls); 134 | return mid; 135 | } 136 | 137 | void JniObject::CleanUp() { 138 | if (obj_) { 139 | JNIEnv* env = GetEnv(); 140 | if (global_ref_) { 141 | env->DeleteGlobalRef(static_cast(obj_)); 142 | } else { 143 | env->DeleteLocalRef(static_cast(obj_)); 144 | } 145 | } 146 | } 147 | 148 | } // namespace fplutil 149 | 150 | #endif // __ANDROID__ 151 | -------------------------------------------------------------------------------- /libfplutil/src/main.c: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "fplutil/main.h" 23 | #include "fplutil/version.h" 24 | 25 | // See android.app.Activity. 26 | enum AndroidAppActivityResults { 27 | ANDROID_APP_ACTIVITY_RESULT_CANCELED = 0, 28 | ANDROID_APP_ACTIVITY_RESULT_FIRST_USER = 1, 29 | ANDROID_APP_ACTIVITY_RESULT_OK = -1, 30 | }; 31 | 32 | static struct android_app* gApp = 0; 33 | static pthread_t gMainTID; 34 | const char kFplUtilMainVersionString[] = FPLUTIL_VERSION_STRING; 35 | 36 | // 37 | // Wait for and process any pending Android events from NativeActivity. 38 | // 39 | void ProcessAndroidEvents(int msec) 40 | { 41 | if (pthread_equal(pthread_self(), gMainTID)) { 42 | struct android_poll_source* source = NULL; 43 | int events; 44 | int looperId = ALooper_pollAll(msec, NULL, &events, (void**)&source); 45 | 46 | if (looperId >= 0 && source) { 47 | source->process(gApp, source); 48 | } 49 | } else { 50 | __android_log_print(ANDROID_LOG_ERROR, "fplutil", 51 | "Attempted to call ProcessAndroidEvents() from non-main thread"); 52 | assert(0); 53 | } 54 | } 55 | 56 | // Android native activity entry point. 57 | void android_main(struct android_app* state) { 58 | // Make sure android native glue isn't stripped. 59 | app_dummy(); 60 | 61 | // Set state variables for ProcessAndroidEvents(). 62 | gApp = state; 63 | gMainTID = pthread_self(); 64 | 65 | static char *argv[] = {"AndroidApp"}; 66 | int result = main(1, argv); 67 | 68 | // Pass the return code from main back to the Activity. 69 | ANativeActivity * const activity = state->activity; 70 | { 71 | jobject nativeActivityObject = activity->clazz; 72 | jclass nativeActivityClass; 73 | jmethodID setResult; 74 | JNIEnv *env = activity->env; 75 | JavaVM *javaVm = activity->vm; 76 | int returnResult = result == 0 ? ANDROID_APP_ACTIVITY_RESULT_OK : 77 | result > 0 ? result + ANDROID_APP_ACTIVITY_RESULT_FIRST_USER : 78 | ANDROID_APP_ACTIVITY_RESULT_CANCELED; 79 | (*javaVm)->AttachCurrentThread(javaVm, &env, NULL); 80 | nativeActivityClass = (*env)->GetObjectClass(env, nativeActivityObject); 81 | setResult = (*env)->GetMethodID(env, nativeActivityClass, "setResult", 82 | "(I)V"); 83 | (*env)->CallVoidMethod(env, nativeActivityObject, setResult, returnResult); 84 | (*javaVm)->DetachCurrentThread(javaVm); 85 | } 86 | 87 | // Finish the activity and exit the app. 88 | for ( ; ; ) { 89 | struct android_poll_source* source = NULL; 90 | int looperId; 91 | int events; 92 | // Signal app completion. 93 | ANativeActivity_finish(activity); 94 | // Pump the event loop. 95 | while ((looperId = ALooper_pollAll(-1, NULL, &events, 96 | (void**)&source)) >= 0) { 97 | switch (looperId) { 98 | case LOOPER_ID_MAIN: 99 | // drop through 100 | case LOOPER_ID_INPUT: 101 | if (source) { 102 | source->process(state, source); 103 | } 104 | break; 105 | default: 106 | // >= LOOPER_ID_USER so this is a user data source which this doesn't 107 | // know how to process. 108 | break; 109 | } 110 | // If the NativeActivity is waiting for the application thread to 111 | // complete, exit this function. 112 | if (state->destroyRequested) { 113 | break; 114 | } 115 | } 116 | } 117 | } 118 | 119 | -------------------------------------------------------------------------------- /libfplutil/src/print_cxx.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | extern "C" { 18 | 19 | void AndroidPrintfCxxInit() { 20 | // Normally std::cerr is unbuffered and flushes each write immediately. For 21 | // this to work with our wrappers we need to disable this behavior as we only 22 | // do our own buffering optionally, and also since it will result in spurious 23 | // linefeeds in the log as Android will add a \n after each flush, unlike 24 | // std::cerr would expect. 25 | std::cerr.unsetf(std::ios::unitbuf); 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /libfplutil/src/string_utils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include "fplutil/string_utils.h" 17 | 18 | namespace fplutil { 19 | 20 | static const char kSpaceChars[] = { '_', ' ' }; 21 | 22 | static inline bool IsSpace(char c) { 23 | for (size_t i = 0; i < sizeof(kSpaceChars) / sizeof(kSpaceChars[0]); ++i) { 24 | if (c == kSpaceChars[i]) return true; 25 | } 26 | return false; 27 | } 28 | 29 | static inline bool CanAppendSnakeBar(const std::string& s) { 30 | return s.size() > 0 && !IsSpace(s.back()); 31 | } 32 | 33 | std::string SnakeCase(const std::string& source) { 34 | std::string snake; 35 | snake.reserve(2 * source.size()); 36 | 37 | bool prev_is_digit = false; 38 | for (size_t i = 0; i < source.size(); ++i) { 39 | const char c = source[i]; 40 | 41 | // When transitioning to or from a string of digits, we want to insert '_'. 42 | const bool is_digit = isdigit(c) != 0; 43 | const bool is_digit_transition = is_digit != prev_is_digit; 44 | prev_is_digit = is_digit; 45 | 46 | // Convert spaces to underbars. 47 | if (IsSpace(c)) { 48 | if (CanAppendSnakeBar(snake)) snake += '_'; 49 | continue; 50 | } 51 | 52 | // Convert upper case letters into '_' + lower case letter. 53 | if (isupper(c) || is_digit_transition) { 54 | if (CanAppendSnakeBar(snake)) snake += '_'; 55 | // tolower() returns digits unchanged. 56 | snake += static_cast(tolower(c)); continue; 57 | } 58 | 59 | // Send through as-is. 60 | snake += c; 61 | } 62 | 63 | // Remove trailing underbar. There should be at most one since we never 64 | // output double underbars. 65 | if (snake.size() > 0 && snake.back() == '_') { 66 | snake.resize(snake.size() - 1); 67 | } 68 | assert(snake.size() == 0 || snake.back() != '_'); 69 | 70 | return snake; 71 | } 72 | 73 | std::string CamelCase(const std::string& source) { 74 | std::string camel; 75 | camel.reserve(source.size()); 76 | 77 | bool capitalize_next = true; 78 | for (size_t i = 0; i < source.size(); ++i) { 79 | const char c = source[i]; 80 | 81 | // Skip spaces, but flag the next letter as start of new word. 82 | if (IsSpace(c)) { 83 | capitalize_next = true; 84 | continue; 85 | } 86 | 87 | // If flagged for capitalization, capitalize and clear flag. 88 | if (capitalize_next) { 89 | camel += static_cast(toupper(c)); 90 | capitalize_next = false; 91 | continue; 92 | } 93 | 94 | // Send through as-is. 95 | camel += c; 96 | } 97 | return camel; 98 | } 99 | 100 | } // namespace fplutil 101 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | cmake_minimum_required(VERSION 2.8.12) 15 | 16 | option( 17 | gtest_force_shared_crt 18 | "Use shared (DLL) run-time lib even when Google Test is built as static lib." 19 | ON) 20 | 21 | # Import gtest if it's not already present. 22 | if(NOT TARGET gtest) 23 | set_compiler_flags_for_external_libraries() 24 | add_subdirectory(${dependencies_gtest_dir} googletest) 25 | restore_compiler_flags() 26 | endif() 27 | 28 | # Set some variables describing file locations. 29 | set(GUNIT_INCDIR "${dependencies_gtest_dir}/include") 30 | if(EXISTS "${dependencies_gtest_dir}/../../third_party") 31 | set(GUNIT_HACK_INCDIR "${dependencies_gtest_dir}/../..") 32 | endif() 33 | set(GTEST_LIBDIR "${dependencies_gtest_dir}") 34 | 35 | # Include helper functions and macros used by Google Test. 36 | include(${GTEST_LIBDIR}/cmake/internal_utils.cmake) 37 | config_compiler_and_linker() 38 | string(REPLACE "-W4" "-W3" cxx_default "${cxx_default}") 39 | string(REPLACE "-Wshadow" "" cxx_default "${cxx_default}") 40 | string(REPLACE "-Wextra" "" cxx_default "${cxx_default}") 41 | 42 | # This is the directory into which the executables are built. 43 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 44 | 45 | include_directories(${GUNIT_INCDIR} 46 | ${GUNIT_HACK_INCDIR} 47 | ${CMAKE_CURRENT_SOURCE_DIR}) 48 | 49 | # Common libraries for tests. 50 | if(NOT MSVC) 51 | find_package(Threads) 52 | endif() 53 | 54 | set(COMMON_LIBS "gtest;${CMAKE_THREAD_LIBS_INIT}") 55 | 56 | # Extra .cpp files to compile for tests 57 | set(SUPPORT_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../src/string_utils.cpp") 58 | 59 | # PUT ADDITIONAL UNIT TEST BINARIES BELOW! 60 | # The commands should be of the form: 61 | # 62 | # test_executable() 63 | # 64 | # Where is the name of the output test executable and the 65 | # basename of the source file for the test. For example, 66 | # test_executable(CallbackTests) generates an executable called CallbackTests 67 | # which is the result of compiling test_CallbackTests.cc along with any files 68 | # specified by the SUPPORT_SRCS variable. 69 | 70 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) 71 | function(test_executable name) 72 | cxx_executable_with_flags(test_${name} "${cxx_default}" "${COMMON_LIBS}" 73 | ${CMAKE_CURRENT_SOURCE_DIR}/test_${name}/test_${name}.cc ${SUPPORT_SRCS} 74 | ${ARGN}) 75 | endfunction() 76 | 77 | test_executable(index_allocator) 78 | test_executable(intrusive_list) 79 | test_executable(string) 80 | test_executable(variable_size) 81 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_index_allocator/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_index_allocator/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_index_allocator 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) 23 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 24 | libfplutil_print libgtest 25 | LOCAL_LDLIBS:=-llog -landroid 26 | LOCAL_ARM_MODE:=arm 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 30 | 31 | $(call import-module,android/native_app_glue) 32 | $(call import-module,libfplutil/jni) 33 | $(call import-module,libfplutil/jni/libs/googletest) 34 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_index_allocator/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_index_allocator 21 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_intrusive_list/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_intrusive_list/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_intrusive_list 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) 23 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 24 | libfplutil_print libgtest 25 | LOCAL_LDLIBS:=-llog -landroid 26 | LOCAL_ARM_MODE:=arm 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 30 | 31 | $(call import-module,android/native_app_glue) 32 | $(call import-module,libfplutil/jni) 33 | $(call import-module,libfplutil/jni/libs/googletest) 34 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_intrusive_list/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_intrusive_list 21 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_main 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) 23 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 24 | libfplutil_print libgtest 25 | LOCAL_LDLIBS:=-llog -landroid 26 | LOCAL_ARM_MODE:=arm 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 30 | 31 | $(call import-module,android/native_app_glue) 32 | $(call import-module,libfplutil/jni) 33 | $(call import-module,libfplutil/jni/libs/googletest) 34 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_main 21 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_main/test_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include "gtest/gtest.h" 17 | #include "fplutil/print.h" 18 | #include "fplutil/main.h" 19 | 20 | int main(int argc, char **argv) { 21 | // Do a stderr and stdout test print immediately for visual validation. 22 | std::cerr << "test main, stderr" << std::endl; 23 | printf("test main, stdout\n"); 24 | 25 | ::testing::InitGoogleTest(&argc, argv); 26 | return RUN_ALL_TESTS(); 27 | } 28 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_perrormsg/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_perrormsg/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_perrormsg 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) 23 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 24 | libfplutil_print libgtest 25 | LOCAL_LDLIBS:=-llog -landroid 26 | LOCAL_ARM_MODE:=arm 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 30 | 31 | $(call import-module,android/native_app_glue) 32 | $(call import-module,libfplutil/jni) 33 | $(call import-module,libfplutil/jni/libs/googletest) 34 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_perrormsg/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_perrormsg 21 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_perrormsg/test_perrormsg.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | #include "gtest/gtest.h" 18 | #include "fplutil/print.h" 19 | #include "fplutil/main.h" 20 | 21 | class PerrorMsgTests : public ::testing::Test { 22 | public: 23 | static const size_t BUFSIZE = 512; 24 | static char expected[BUFSIZE]; 25 | static char actual[BUFSIZE]; 26 | 27 | protected: 28 | virtual void SetUp() {} 29 | virtual void TearDown() {} 30 | }; 31 | 32 | const size_t PerrorMsgTests::BUFSIZE; 33 | char PerrorMsgTests::expected[PerrorMsgTests::BUFSIZE]; 34 | char PerrorMsgTests::actual[PerrorMsgTests::BUFSIZE]; 35 | 36 | TEST_F(PerrorMsgTests, TestWithMessage) { 37 | const char *testmsg = "Testing 1 2 3"; 38 | 39 | snprintf(PerrorMsgTests::expected, PerrorMsgTests::BUFSIZE, "%s: %s", testmsg, 40 | strerror(EINTR)); 41 | AndroidPerrorMsg(testmsg, EINTR, PerrorMsgTests::actual, 42 | PerrorMsgTests::BUFSIZE); 43 | EXPECT_STREQ(PerrorMsgTests::expected, PerrorMsgTests::actual); 44 | } 45 | 46 | TEST_F(PerrorMsgTests, TestWithoutMessage) { 47 | strncpy(PerrorMsgTests::expected, strerror(EBADF), PerrorMsgTests::BUFSIZE); 48 | *(PerrorMsgTests::expected + PerrorMsgTests::BUFSIZE - 1) = '\0'; 49 | AndroidPerrorMsg(NULL, EBADF, PerrorMsgTests::actual, 50 | PerrorMsgTests::BUFSIZE); 51 | EXPECT_STREQ(PerrorMsgTests::expected, PerrorMsgTests::actual); 52 | } 53 | 54 | TEST_F(PerrorMsgTests, TestErrnoRange) { 55 | const char *testmsg = "E R R O R"; 56 | int i; 57 | 58 | // Currently both glibc and bionic define valid errno values 59 | // as small positive ints. This range should cover them, though 60 | // this is *not* a standardized value. If this test fails, check the 61 | // current errno range in your android NDK. 62 | for (i = -10000; i < 10000; ++i) { 63 | snprintf(PerrorMsgTests::expected, PerrorMsgTests::BUFSIZE, "%s: %s", 64 | testmsg, strerror(i)); 65 | AndroidPerrorMsg(testmsg, i, PerrorMsgTests::actual, 66 | PerrorMsgTests::BUFSIZE); 67 | EXPECT_STREQ(PerrorMsgTests::expected, PerrorMsgTests::actual); 68 | 69 | strncpy(PerrorMsgTests::expected, strerror(i), PerrorMsgTests::BUFSIZE); 70 | *(PerrorMsgTests::expected + PerrorMsgTests::BUFSIZE - 1) = '\0'; 71 | AndroidPerrorMsg(NULL, i, PerrorMsgTests::actual, PerrorMsgTests::BUFSIZE); 72 | EXPECT_STREQ(PerrorMsgTests::expected, PerrorMsgTests::actual); 73 | } 74 | } 75 | 76 | TEST_F(PerrorMsgTests, TestBigger) { 77 | char big[PerrorMsgTests::BUFSIZE + 10]; 78 | int i; 79 | 80 | for (i = 0; i < sizeof(big); ++i) { 81 | big[i] = 'x'; 82 | } 83 | *(big + sizeof(big) - 1) = '\0'; 84 | 85 | snprintf(PerrorMsgTests::expected, PerrorMsgTests::BUFSIZE, "%s: %s", big, 86 | strerror(ENOSPC)); 87 | AndroidPerrorMsg(big, ENOSPC, PerrorMsgTests::actual, 88 | PerrorMsgTests::BUFSIZE); 89 | EXPECT_STREQ(PerrorMsgTests::expected, PerrorMsgTests::actual); 90 | EXPECT_EQ(0, 91 | strncmp(big, PerrorMsgTests::actual, PerrorMsgTests::BUFSIZE - 1)); 92 | } 93 | 94 | int main(int argc, char **argv) { 95 | ::testing::InitGoogleTest(&argc, argv); 96 | return RUN_ALL_TESTS(); 97 | } 98 | 99 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_stdio/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_stdio/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_stdio 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) 23 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 24 | libfplutil_print libgtest 25 | LOCAL_LDLIBS:=-llog -landroid 26 | LOCAL_ARM_MODE:=arm 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 30 | 31 | $(call import-module,android/native_app_glue) 32 | $(call import-module,libfplutil/jni) 33 | $(call import-module,libfplutil/jni/libs/googletest) 34 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_stdio/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_stdio 21 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_string/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_string/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_string 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) \ 23 | $(PROJECT_ROOT)/libfplutil/src/string_utils.cpp 24 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 25 | libfplutil_print libgtest 26 | LOCAL_LDLIBS:=-llog -landroid 27 | LOCAL_ARM_MODE:=arm 28 | include $(BUILD_SHARED_LIBRARY) 29 | 30 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 31 | 32 | $(call import-module,android/native_app_glue) 33 | $(call import-module,libfplutil/jni) 34 | $(call import-module,libfplutil/jni/libs/googletest) 35 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_string/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2014 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_string 21 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_string/test_string.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "gtest/gtest.h" 16 | #include "fplutil/string_utils.h" 17 | 18 | using fplutil::SnakeCase; 19 | using fplutil::CamelCase; 20 | 21 | class StringTests : public ::testing::Test { 22 | public: 23 | 24 | protected: 25 | virtual void SetUp() {} 26 | virtual void TearDown() {} 27 | }; 28 | 29 | struct StringVariant { 30 | const char* snake; // Snake-case version of string. 31 | const char* camel; // Camel-case version of same string. 32 | const char* bars; // Mixed-up version of string, with extra underbars. 33 | const char* spaces; // Mixed-up version of string, with extra spaces. 34 | const char* extra; // Mixed-up version of string, with extra bars and spaces. 35 | }; 36 | 37 | static const StringVariant kTestStrings[] = { 38 | { "word", "Word", "__word", " word", "_ word" }, 39 | { "two_words", "TwoWords", "Two__words__", "Two words ", "Two words_ " }, 40 | { "three_of_em", "ThreeOfEm", "three_OfEm", "three OfEm", "_three_ OfEm " }, 41 | { "a_b_c_mart", "ABCMart", "_a_BC__Mart____", " a BC Mart ", 42 | "_ a BC__Mart " }, 43 | { "1_digit", "1Digit", "1__Digit", "1 Digit", " 1 Digit__" }, 44 | { "99_digit", "99Digit", "__99Digit", " 99Digit", "99_ Digit " }, 45 | { "digit_123", "Digit123", "Digit_123_", "Digit 123 ", "Digit 123 __" }, 46 | }; 47 | 48 | TEST_F(StringTests, Snake_FromSnake) { 49 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 50 | EXPECT_EQ(kTestStrings[i].snake, SnakeCase(kTestStrings[i].snake)); 51 | } 52 | } 53 | 54 | TEST_F(StringTests, Snake_FromCamel) { 55 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 56 | EXPECT_EQ(kTestStrings[i].snake, SnakeCase(kTestStrings[i].camel)); 57 | } 58 | } 59 | 60 | TEST_F(StringTests, Snake_FromBars) { 61 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 62 | EXPECT_EQ(kTestStrings[i].snake, SnakeCase(kTestStrings[i].bars)); 63 | } 64 | } 65 | 66 | TEST_F(StringTests, Snake_FromSpaces) { 67 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 68 | EXPECT_EQ(kTestStrings[i].snake, SnakeCase(kTestStrings[i].spaces)); 69 | } 70 | } 71 | 72 | TEST_F(StringTests, Snake_FromExtra) { 73 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 74 | EXPECT_EQ(kTestStrings[i].snake, SnakeCase(kTestStrings[i].extra)); 75 | } 76 | } 77 | 78 | TEST_F(StringTests, Camel_FromSnake) { 79 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 80 | EXPECT_EQ(kTestStrings[i].camel, CamelCase(kTestStrings[i].snake)); 81 | } 82 | } 83 | 84 | TEST_F(StringTests, Camel_FromCamel) { 85 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 86 | EXPECT_EQ(kTestStrings[i].camel, CamelCase(kTestStrings[i].camel)); 87 | } 88 | } 89 | 90 | TEST_F(StringTests, Camel_FromBars) { 91 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 92 | EXPECT_EQ(kTestStrings[i].camel, CamelCase(kTestStrings[i].bars)); 93 | } 94 | } 95 | 96 | TEST_F(StringTests, Camel_FromSpaces) { 97 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 98 | EXPECT_EQ(kTestStrings[i].camel, CamelCase(kTestStrings[i].spaces)); 99 | } 100 | } 101 | 102 | TEST_F(StringTests, Camel_FromExtra) { 103 | for (size_t i = 0; i < sizeof(kTestStrings) / sizeof(kTestStrings[0]); ++i) { 104 | EXPECT_EQ(kTestStrings[i].camel, CamelCase(kTestStrings[i].extra)); 105 | } 106 | } 107 | 108 | int main(int argc, char **argv) { 109 | ::testing::InitGoogleTest(&argc, argv); 110 | return RUN_ALL_TESTS(); 111 | } 112 | 113 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_variable_size/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 17 | 21 | 22 | 23 | 24 | 26 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_variable_size/jni/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:=$(call my-dir)/.. 16 | 17 | PROJECT_ROOT:=$(LOCAL_PATH)/../../.. 18 | 19 | # --- project --- 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE:=test_variable_size 22 | LOCAL_SRC_FILES:=$(wildcard $(LOCAL_PATH)/test_*.cc) 23 | LOCAL_WHOLE_STATIC_LIBRARIES:=android_native_app_glue libfplutil_main \ 24 | libfplutil_print libgtest 25 | LOCAL_LDLIBS:=-llog -landroid 26 | LOCAL_ARM_MODE:=arm 27 | include $(BUILD_SHARED_LIBRARY) 28 | 29 | $(call import-add-path,$(abspath $(PROJECT_ROOT))) 30 | 31 | $(call import-module,android/native_app_glue) 32 | $(call import-module,libfplutil/jni) 33 | $(call import-module,libfplutil/jni/libs/googletest) 34 | -------------------------------------------------------------------------------- /libfplutil/unit_tests/test_variable_size/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2016 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | APP_PLATFORM:=android-9 16 | APP_ABI:=armeabi-v7a 17 | # Library uses STLPort so verify gnustl compatibility here. 18 | APP_STL:=c++_static 19 | APP_CPPFLAGS+=-std=c++11 -Wno-literal-suffix 20 | APP_MODULES:=test_variable_size 21 | -------------------------------------------------------------------------------- /libs/cardboard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/libs/cardboard.jar -------------------------------------------------------------------------------- /libs/libprotobuf-java-2.6-nano.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/libs/libprotobuf-java-2.6-nano.jar -------------------------------------------------------------------------------- /perf/bin/LICENSE: -------------------------------------------------------------------------------- 1 | COPYING -------------------------------------------------------------------------------- /perf/bin/android-16/arch-arm/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.1.2_r2.1 2 | -------------------------------------------------------------------------------- /perf/bin/android-16/arch-arm/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-16/arch-arm/perf -------------------------------------------------------------------------------- /perf/bin/android-16/arch-x86/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.1.2_r2.1 2 | -------------------------------------------------------------------------------- /perf/bin/android-16/arch-x86/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-16/arch-x86/perf -------------------------------------------------------------------------------- /perf/bin/android-16/darwin-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.1.2_r2.1 2 | -------------------------------------------------------------------------------- /perf/bin/android-16/darwin-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-16/darwin-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-16/linux-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.1.2_r2.1 2 | -------------------------------------------------------------------------------- /perf/bin/android-16/linux-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-16/linux-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-17/arch-arm/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.2.2_r1.2 2 | -------------------------------------------------------------------------------- /perf/bin/android-17/arch-arm/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-17/arch-arm/perf -------------------------------------------------------------------------------- /perf/bin/android-17/arch-mips/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.2.2_r1.2 2 | -------------------------------------------------------------------------------- /perf/bin/android-17/arch-mips/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-17/arch-mips/perf -------------------------------------------------------------------------------- /perf/bin/android-17/arch-x86/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.2.2_r1.2 2 | -------------------------------------------------------------------------------- /perf/bin/android-17/arch-x86/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-17/arch-x86/perf -------------------------------------------------------------------------------- /perf/bin/android-17/darwin-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.2.2_r1.2 2 | -------------------------------------------------------------------------------- /perf/bin/android-17/darwin-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-17/darwin-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-17/linux-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.2.2_r1.2 2 | -------------------------------------------------------------------------------- /perf/bin/android-17/linux-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-17/linux-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-18/arch-arm/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.3.1_r1 2 | -------------------------------------------------------------------------------- /perf/bin/android-18/arch-arm/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-18/arch-arm/perf -------------------------------------------------------------------------------- /perf/bin/android-18/arch-mips/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.3.1_r1 2 | -------------------------------------------------------------------------------- /perf/bin/android-18/arch-mips/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-18/arch-mips/perf -------------------------------------------------------------------------------- /perf/bin/android-18/arch-x86/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.3.1_r1 2 | -------------------------------------------------------------------------------- /perf/bin/android-18/arch-x86/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-18/arch-x86/perf -------------------------------------------------------------------------------- /perf/bin/android-18/darwin-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.3.1_r1 2 | -------------------------------------------------------------------------------- /perf/bin/android-18/darwin-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-18/darwin-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-18/linux-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.3.1_r1 2 | -------------------------------------------------------------------------------- /perf/bin/android-18/linux-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-18/linux-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-19/arch-arm/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.4.4_r2 2 | -------------------------------------------------------------------------------- /perf/bin/android-19/arch-arm/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-19/arch-arm/perf -------------------------------------------------------------------------------- /perf/bin/android-19/arch-mips/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.4.4_r2 2 | -------------------------------------------------------------------------------- /perf/bin/android-19/arch-mips/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-19/arch-mips/perf -------------------------------------------------------------------------------- /perf/bin/android-19/arch-x86/build_info: -------------------------------------------------------------------------------- 1 | perf built from https://android.googlesource.com/platform/manifest branch android-4.4.4_r2 2 | -------------------------------------------------------------------------------- /perf/bin/android-19/arch-x86/perf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-19/arch-x86/perf -------------------------------------------------------------------------------- /perf/bin/android-19/darwin-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.4.4_r2 2 | -------------------------------------------------------------------------------- /perf/bin/android-19/darwin-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-19/darwin-x86/perfhost -------------------------------------------------------------------------------- /perf/bin/android-19/linux-x86/build_info: -------------------------------------------------------------------------------- 1 | perfhost built from https://android.googlesource.com/platform/manifest branch android-4.4.4_r2 2 | -------------------------------------------------------------------------------- /perf/bin/android-19/linux-x86/perfhost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/perf/bin/android-19/linux-x86/perfhost -------------------------------------------------------------------------------- /perf/build/build@/b225d8b17ee61f0cfe4fb14e7153826183872b00.patch: -------------------------------------------------------------------------------- 1 | diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk 2 | index 5b9f8f3..cdeead3 100644 3 | --- a/core/combo/HOST_darwin-x86.mk 4 | +++ b/core/combo/HOST_darwin-x86.mk 5 | @@ -70,18 +70,37 @@ $(warning *****************************************************) 6 | $(error Stop.) 7 | endif 8 | 9 | -HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) 10 | -HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) 11 | - 12 | -HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables 13 | -HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 14 | +ifeq ($(mac_sdk_version),10.6) 15 | + gcc_darwin_version := 10 16 | +else 17 | + gcc_darwin_version := 11 18 | +endif 19 | 20 | +HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1 21 | +HOST_TOOLCHAIN_PREFIX := $(HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version) 22 | +# Don't do anything if the toolchain is not there 23 | +ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)-gcc))) 24 | +HOST_CC := $(HOST_TOOLCHAIN_PREFIX)-gcc 25 | +HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++ 26 | +ifeq ($(mac_sdk_version),10.8) 27 | +# Mac SDK 10.8 no longer has stdarg.h, etc 28 | +host_toolchain_header := $(HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include 29 | +HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header) 30 | +endif 31 | +else 32 | HOST_CC := gcc 33 | HOST_CXX := g++ 34 | +endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists 35 | HOST_AR := $(AR) 36 | HOST_STRIP := $(STRIP) 37 | HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@ 38 | 39 | +HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) 40 | +HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) 41 | + 42 | +HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables 43 | +HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 44 | + 45 | HOST_SHLIB_SUFFIX := .dylib 46 | HOST_JNILIB_SUFFIX := .jnilib 47 | 48 | -------------------------------------------------------------------------------- /perf/build/build@/b34d556982095a8fe84273ffceadd80f41325acf.patch: -------------------------------------------------------------------------------- 1 | diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk 2 | index ba61cbf..0b0714c 100644 3 | --- a/core/combo/HOST_darwin-x86.mk 4 | +++ b/core/combo/HOST_darwin-x86.mk 5 | @@ -36,7 +36,7 @@ endif # BUILD_HOST_static 6 | 7 | build_mac_version := $(shell sw_vers -productVersion) 8 | 9 | -mac_sdk_versions_supported := 10.6 10.7 10.8 10 | +mac_sdk_versions_supported := 10.8 10.7 10.6 11 | ifneq ($(strip $(MAC_SDK_VERSION)),) 12 | mac_sdk_version := $(MAC_SDK_VERSION) 13 | ifeq ($(filter $(mac_sdk_version),$(mac_sdk_versions_supported)),) 14 | -------------------------------------------------------------------------------- /perf/build/build@/ed7d36d0b422b3cb6f15e62c3c88d4f0ad96a613.patch: -------------------------------------------------------------------------------- 1 | diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk 2 | index 198c53f..1952434 100644 3 | --- a/core/combo/HOST_darwin-x86.mk 4 | +++ b/core/combo/HOST_darwin-x86.mk 5 | @@ -29,37 +29,77 @@ HOST_GLOBAL_CFLAGS += -m32 6 | HOST_GLOBAL_LDFLAGS += -m32 7 | endif # BUILD_HOST_64bit 8 | 9 | -# Use the Mac OSX SDK 10.5 if the build host is 10.6 10 | build_mac_version := $(shell sw_vers -productVersion) 11 | -ifneq ($(filter 10.6.%, $(build_mac_version)),) 12 | -sdk_105_root := /Developer/SDKs/MacOSX10.5.sdk 13 | -ifeq ($(wildcard $(sdk_105_root)),) 14 | + 15 | +mac_sdk_versions_supported := 10.6 10.7 10.8 16 | +ifneq ($(strip $(MAC_SDK_VERSION)),) 17 | +mac_sdk_version := $(MAC_SDK_VERSION) 18 | +ifeq ($(filter $(mac_sdk_version),$(mac_sdk_versions_supported)),) 19 | +$(warning ****************************************************************) 20 | +$(warning * MAC_SDK_VERSION $(MAC_SDK_VERSION) isn't one of the supported $(mac_sdk_versions_supported)) 21 | +$(warning ****************************************************************) 22 | +$(error Stop.) 23 | +endif 24 | +else 25 | +mac_sdk_versions_installed := $(shell xcodebuild -showsdks | grep macosx | sort | sed -e "s/.*macosx//g") 26 | +mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported))) 27 | +ifeq ($(mac_sdk_version),) 28 | +mac_sdk_version := $(firstword $(mac_sdk_versions_supported)) 29 | +endif 30 | +endif 31 | + 32 | +mac_sdk_path := $(shell xcode-select -print-path) 33 | +# try /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk 34 | +# or /Volume/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk 35 | +mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk 36 | +ifeq ($(wildcard $(mac_sdk_root)),) 37 | +# try legacy /Developer/SDKs/MacOSX10.?.sdk 38 | +mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk 39 | +endif 40 | +ifeq ($(wildcard $(mac_sdk_root)),) 41 | $(warning *****************************************************) 42 | -$(warning * You are building on Mac OSX 10.6.) 43 | -$(warning * Can not find SDK 10.5 at $(sdk_105_root)) 44 | +$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root)) 45 | $(warning *****************************************************) 46 | $(error Stop.) 47 | endif 48 | 49 | -HOST_GLOBAL_CFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5 50 | -HOST_GLOBAL_LDFLAGS += -isysroot $(sdk_105_root) -mmacosx-version-min=10.5 51 | -endif # build_mac_version is 10.6 52 | - 53 | -HOST_GLOBAL_CFLAGS += -fPIC 54 | -HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 55 | +ifeq ($(mac_sdk_version),10.6) 56 | + gcc_darwin_version := 10 57 | +else 58 | + gcc_darwin_version := 11 59 | +endif 60 | 61 | +HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1 62 | +HOST_TOOLCHAIN_PREFIX := $(HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version) 63 | +# Don't do anything if the toolchain is not there 64 | +ifneq (,$(strip $(wildcard $(HOST_TOOLCHAIN_PREFIX)-gcc))) 65 | +HOST_CC := $(HOST_TOOLCHAIN_PREFIX)-gcc 66 | +HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++ 67 | +ifeq ($(mac_sdk_version),10.8) 68 | +# Mac SDK 10.8 no longer has stdarg.h, etc 69 | +host_toolchain_header := $(HOST_TOOLCHAIN_ROOT)/lib/gcc/i686-apple-darwin$(gcc_darwin_version)/4.2.1/include 70 | +HOST_GLOBAL_CFLAGS += -isystem $(host_toolchain_header) 71 | +endif 72 | +else 73 | HOST_CC := $(CC) 74 | HOST_CXX := $(CXX) 75 | +endif # $(HOST_TOOLCHAIN_PREFIX)-gcc exists 76 | HOST_AR := $(AR) 77 | HOST_STRIP := $(STRIP) 78 | HOST_STRIP_COMMAND = $(HOST_STRIP) --strip-debug $< -o $@ 79 | 80 | +HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) 81 | +HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) 82 | + 83 | +HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables 84 | +HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error 85 | + 86 | HOST_SHLIB_SUFFIX := .dylib 87 | HOST_JNILIB_SUFFIX := .jnilib 88 | 89 | HOST_GLOBAL_CFLAGS += \ 90 | -include $(call select-android-config-h,darwin-x86) 91 | -ifneq ($(filter 10.7.%, $(build_mac_version)),) 92 | +ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),) 93 | HOST_RUN_RANLIB_AFTER_COPYING := false 94 | else 95 | HOST_RUN_RANLIB_AFTER_COPYING := true 96 | @@ -87,17 +127,14 @@ $(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \ 97 | endef 98 | 99 | define transform-host-o-to-shared-lib-inner 100 | -$(call darwin-extract-and-include-whole-static-libs) 101 | $(hide) $(PRIVATE_CXX) \ 102 | -dynamiclib -single_module -read_only_relocs suppress \ 103 | $(HOST_GLOBAL_LD_DIRS) \ 104 | $(HOST_GLOBAL_LDFLAGS) \ 105 | $(PRIVATE_ALL_OBJECTS) \ 106 | - $(if $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), `find $(PRIVATE_INTERMEDIATES_DIR)/WHOLE -name '*.o' 2>/dev/null`) \ 107 | + $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 108 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 109 | - $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 110 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 111 | - $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 112 | $(PRIVATE_LDLIBS) \ 113 | -o $@ \ 114 | -install_name @rpath/$(notdir $@) \ 115 | @@ -116,9 +153,7 @@ $(hide) $(PRIVATE_CXX) \ 116 | $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ 117 | $(PRIVATE_ALL_OBJECTS) \ 118 | $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ 119 | - $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \ 120 | $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ 121 | - $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ 122 | $(PRIVATE_LDFLAGS) \ 123 | $(PRIVATE_LDLIBS) \ 124 | $(HOST_LIBGCC) 125 | -------------------------------------------------------------------------------- /perf/build/external@elfutils/101941576c52a1270c9c2d63ea95d48729d6cf96.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libdw/Android.mk b/libdw/Android.mk 2 | index 0822ced..471f4e4 100755 3 | --- a/libdw/Android.mk 4 | +++ b/libdw/Android.mk 5 | @@ -127,7 +127,7 @@ LOCAL_C_INCLUDES := \ 6 | $(LOCAL_PATH)/../libelf 7 | 8 | ifeq ($(HOST_OS),darwin) 9 | - LOCAL_CFLAGS += -fnested-functions 10 | + LOCAL_CFLAGS += #-fnested-functions 11 | LOCAL_SRC_FILES += \ 12 | ../host-darwin-fixup/getline.c 13 | endif 14 | diff --git a/libdwfl/Android.mk b/libdwfl/Android.mk 15 | index f742b5c..2f21a9e 100755 16 | --- a/libdwfl/Android.mk 17 | +++ b/libdwfl/Android.mk 18 | @@ -60,7 +60,7 @@ LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE 19 | LOCAL_CFLAGS += -Wno-pointer-arith 20 | 21 | ifeq ($(HOST_OS),darwin) 22 | - LOCAL_CFLAGS += -fnested-functions 23 | + LOCAL_CFLAGS += #-fnested-functions 24 | endif 25 | 26 | # to fix machine-dependent issues 27 | diff --git a/libelf/Android.mk b/libelf/Android.mk 28 | index 95ccadf..34c6f33 100755 29 | --- a/libelf/Android.mk 30 | +++ b/libelf/Android.mk 31 | @@ -152,7 +152,7 @@ LOCAL_CFLAGS += -DHAVE_CONFIG_H -std=gnu99 -D_GNU_SOURCE 32 | LOCAL_CFLAGS += -Wno-pointer-arith 33 | 34 | ifeq ($(HOST_OS),darwin) 35 | - LOCAL_CFLAGS += -fnested-functions 36 | + LOCAL_CFLAGS += #-fnested-functions 37 | endif 38 | 39 | # to fix machine-dependent issues 40 | -------------------------------------------------------------------------------- /perf/build/external@linux-tools-perf/2db19c77b59c71eef27e9876d4c09ceb6966608d.patch: -------------------------------------------------------------------------------- 1 | diff --git a/builtin-sched.c b/builtin-sched.c 2 | index 4d68763..52548e3 100644 3 | --- a/builtin-sched.c 4 | +++ b/builtin-sched.c 5 | @@ -29,6 +29,8 @@ 6 | #include 7 | #include 8 | 9 | +#include 10 | + 11 | static char const *input_name = "perf.data"; 12 | 13 | static char default_sort_order[] = "avg, max, switch, runtime"; 14 | diff --git a/util/include/linux/added/rbtree.h b/util/include/linux/added/rbtree.h 15 | index 70c4bba..01bd2d4 100644 16 | --- a/util/include/linux/added/rbtree.h 17 | +++ b/util/include/linux/added/rbtree.h 18 | @@ -103,6 +103,8 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, 19 | #endif 20 | /* ANDROID_CHANGE_END */ 21 | 22 | +#include 23 | + 24 | struct rb_node 25 | { 26 | unsigned long rb_parent_color; 27 | -------------------------------------------------------------------------------- /perf/build/external@linux-tools-perf/48630d72aea6bab5223eb2538c34d87c1500d7f6.patch: -------------------------------------------------------------------------------- 1 | diff --git a/builtin-sched.c b/builtin-sched.c 2 | index 4d68763..52548e3 100644 3 | --- a/builtin-sched.c 4 | +++ b/builtin-sched.c 5 | @@ -29,6 +29,8 @@ 6 | #include 7 | #include 8 | 9 | +#include 10 | + 11 | static char const *input_name = "perf.data"; 12 | 13 | static char default_sort_order[] = "avg, max, switch, runtime"; 14 | diff --git a/util/include/linux/added/rbtree.h b/util/include/linux/added/rbtree.h 15 | index 70c4bba..01bd2d4 100644 16 | --- a/util/include/linux/added/rbtree.h 17 | +++ b/util/include/linux/added/rbtree.h 18 | @@ -103,6 +103,8 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, 19 | #endif 20 | /* ANDROID_CHANGE_END */ 21 | 22 | +#include 23 | + 24 | struct rb_node 25 | { 26 | unsigned long rb_parent_color; 27 | -------------------------------------------------------------------------------- /perf/build/external@linux-tools-perf/8a1715044713722b9fa01419a2148a4a2a67aae5.patch: -------------------------------------------------------------------------------- 1 | diff --git a/builtin-sched.c b/builtin-sched.c 2 | index 4d68763..52548e3 100644 3 | --- a/builtin-sched.c 4 | +++ b/builtin-sched.c 5 | @@ -29,6 +29,8 @@ 6 | #include 7 | #include 8 | 9 | +#include 10 | + 11 | static char const *input_name = "perf.data"; 12 | 13 | static char default_sort_order[] = "avg, max, switch, runtime"; 14 | diff --git a/util/include/linux/added/rbtree.h b/util/include/linux/added/rbtree.h 15 | index 70c4bba..01bd2d4 100644 16 | --- a/util/include/linux/added/rbtree.h 17 | +++ b/util/include/linux/added/rbtree.h 18 | @@ -103,6 +103,8 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, 19 | #endif 20 | /* ANDROID_CHANGE_END */ 21 | 22 | +#include 23 | + 24 | struct rb_node 25 | { 26 | unsigned long rb_parent_color; 27 | -------------------------------------------------------------------------------- /perf/build/frameworks@native/9c7db08049e1d36c2f60dd703f27c432bc8cfbc5.patch: -------------------------------------------------------------------------------- 1 | diff --git a/opengl/tests/Android.mk b/opengl/tests/Android.mk 2 | index 3ae3b4e..7e52d3e 100644 3 | --- a/opengl/tests/Android.mk 4 | +++ b/opengl/tests/Android.mk 5 | @@ -41,4 +41,3 @@ dirs += \ 6 | 7 | endif # JAVA_SUPPORT platform 8 | 9 | -include $(call all-named-subdir-makefiles, $(dirs)) 10 | -------------------------------------------------------------------------------- /perf/build/frameworks@native/ac9a96da65f6eae4513654adaad8a457d1c1575c.patch: -------------------------------------------------------------------------------- 1 | diff --git a/opengl/tests/Android.mk b/opengl/tests/Android.mk 2 | index 3ae3b4e..7e52d3e 100644 3 | --- a/opengl/tests/Android.mk 4 | +++ b/opengl/tests/Android.mk 5 | @@ -41,4 +41,3 @@ dirs += \ 6 | 7 | endif # JAVA_SUPPORT platform 8 | 9 | -include $(call all-named-subdir-makefiles, $(dirs)) 10 | -------------------------------------------------------------------------------- /perf/tools/LICENSE: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Chromium Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/LICENSE-d3.v3.min.js.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2014, Michael Bostock 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * The name Michael Bostock may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/LICENSE-jquery.txt: -------------------------------------------------------------------------------- 1 | Copyright 2005, 2014 jQuery Foundation and other contributors, 2 | https://jquery.org/ 3 | 4 | This software consists of voluntary contributions made by many 5 | individuals. For exact contribution history, see the revision history 6 | available at https://github.com/jquery/jquery 7 | 8 | The following license applies to all parts of this software except as 9 | documented below: 10 | 11 | ==== 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining 14 | a copy of this software and associated documentation files (the 15 | Software), to deal in the Software without restriction, including 16 | without limitation the rights to use, copy, modify, merge, publish, 17 | distribute, sublicense, and/or sell copies of the Software, and to 18 | permit persons to whom the Software is furnished to do so, subject to 19 | the following conditions: 20 | 21 | The above copyright notice and this permission notice shall be 22 | included in all copies or substantial portions of the Software. 23 | 24 | THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 27 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 28 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 29 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | 32 | ==== 33 | 34 | All files located in the node_modules and external directories are 35 | externally maintained libraries used by this software which have their 36 | own licenses; we recommend you read them, as their terms may differ from 37 | the terms above. 38 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/LICENSE-sammy.js.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008 Aaron Quint, Quirkey NYC, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf-vis: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | $0.py "$@" 6 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf-vis-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fplutil perf 6 | 80 | 82 | 83 | 84 |
85 | 88 |
89 | 92 |
93 |
94 |
95 |
Summary here
96 | 103 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf-vis.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 | @rem Use of this source code is governed by a BSD-style license that can be 3 | @rem found in the LICENSE file. 4 | python %~dp0\perf-vis.py %* 5 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing_json: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | $0.py "$@" 6 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing_json.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright (c) 2014 The Chromium Authors. All rights reserved. 2 | @rem Use of this source code is governed by a BSD-style license that can be 3 | @rem found in the LICENSE file. 4 | python %~dp0\perf_to_tracing_json.py %* 5 | -------------------------------------------------------------------------------- /perf/tools/telemetry/telemetry/core/platform/profiler/perf_vis/perf_to_tracing_json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style license that can be 4 | # found in the LICENSE file. 5 | 6 | import json 7 | import sys 8 | from collections import deque 9 | from optparse import OptionParser 10 | 11 | # Line reading helper. 12 | class LineReader: 13 | def __init__(self, fp): 14 | self.fp = fp 15 | self.line = None 16 | 17 | def peek(self): 18 | if self.line == None: 19 | self.line = self.fp.readline() 20 | return self.line 21 | 22 | def next(self): 23 | self.line = None 24 | 25 | class StackFrameNode: 26 | def __init__(self, stack_id, name, dso): 27 | self.stack_id = stack_id 28 | self.parent_id = 0 29 | self.name = name 30 | self.dso = dso 31 | self.children = {} 32 | 33 | def ToDict(self, out_dict): 34 | if self.stack_id: 35 | node_dict = {} 36 | node_dict['name'] = self.name 37 | node_dict['category'] = self.dso 38 | if self.parent_id: 39 | node_dict['parent'] = self.parent_id 40 | 41 | out_dict[self.stack_id] = node_dict 42 | 43 | for child in self.children.values(): 44 | child.ToDict(out_dict) 45 | return out_dict 46 | 47 | class PerfSample: 48 | def __init__(self, stack_id, ts, cpu, tid, weight, type, comm): 49 | self.stack_id = stack_id 50 | self.ts = ts 51 | self.cpu = cpu 52 | self.tid = tid 53 | self.weight = weight 54 | self.type = type 55 | self.comm = comm 56 | 57 | def ToDict(self): 58 | ret = {} 59 | ret['ts'] = self.ts * 1000000.0 # Timestamp in us 60 | ret['tid'] = self.tid # Thread id 61 | ret['cpu'] = self.cpu # Sampled CPU 62 | ret['weight'] = self.weight # Sample weight 63 | ret['name'] = self.type # Sample type 64 | ret['comm'] = self.comm # Command 65 | assert self.stack_id != 0 66 | if self.stack_id: 67 | ret['sf'] = self.stack_id # Stack frame id 68 | return ret 69 | 70 | def Main(args): 71 | parser = OptionParser() 72 | parser.add_option("-l", "--limit-samples", dest="limit_samples", default=0, 73 | type="int", help="Limit number of samples processed") 74 | (options, args) = parser.parse_args() 75 | 76 | fp = open(args[0]) 77 | reader = LineReader(fp) 78 | 79 | samples = [] 80 | root_chain = StackFrameNode(0, 'root', '[unknown]') 81 | next_stack_id = 1 82 | tot_period = 0 83 | saved_period = 0 84 | 85 | # Parse samples header. 86 | while True: 87 | l = reader.peek() 88 | reader.next() # Eat line 89 | if not l: 90 | break 91 | 92 | # Skip comments 93 | if len(l) >= 1 and l[0] == '#': 94 | continue 95 | 96 | # TODO(vmiura): Parse these in a more readable way. 97 | l = l.strip() 98 | toks = l.split('\t') 99 | samp_command = toks[0] 100 | samp_tid = int(toks[1]) 101 | samp_cpu = int(toks[2][1:-1]) 102 | samp_ts = float(toks[3][0:-1]) 103 | samp_period = int(toks[5]) 104 | samp_type = toks[4][0:-1] 105 | tot_period += samp_period 106 | 107 | # Parse call chain. 108 | chain = deque() 109 | while True: 110 | l = reader.peek() 111 | reader.next() # Eat line 112 | if l and l.strip() != '': 113 | # TODO(vmiura): Parse these in a more readable way. 114 | toks1 = l.strip().split(' ', 1) 115 | toks2 = toks1[1].rsplit(' ', 1) 116 | cs_name = toks2[0] 117 | cs_dso = toks2[1][1:-1] 118 | chain.appendleft((cs_name, cs_dso)) 119 | else: 120 | # Done reading call chain. Add to stack frame tree. 121 | seen_syms = set() 122 | stack_frame = root_chain 123 | for call in chain: 124 | if call not in seen_syms: # Cull recursing methods. 125 | seen_syms.add(call) 126 | if call in stack_frame.children: 127 | stack_frame = stack_frame.children[call] 128 | else: 129 | new_node = StackFrameNode(next_stack_id, call[0], call[1]) 130 | next_stack_id += 1 131 | new_node.parent_id = stack_frame.stack_id 132 | stack_frame.children[call] = new_node 133 | stack_frame = new_node 134 | 135 | # Save sample. 136 | sample = PerfSample(stack_frame.stack_id, 137 | samp_ts, 138 | samp_cpu, 139 | samp_tid, 140 | samp_period, 141 | samp_type, 142 | samp_command) 143 | samples.append(sample) 144 | saved_period += samp_period 145 | break 146 | if options.limit_samples and len(samples) >= options.limit_samples: 147 | break 148 | 149 | #print "// Num Samples:", len(samples) 150 | #print "// Tot period:", tot_period 151 | #print "// Saved period:", saved_period 152 | 153 | trace_dict = {} 154 | trace_dict['samples'] = [s.ToDict() for s in samples] 155 | trace_dict['stackFrames'] = root_chain.ToDict({}) 156 | trace_dict['traceEvents'] = [] 157 | 158 | json.dump(trace_dict, sys.stdout, indent=1) 159 | 160 | if __name__ == '__main__': 161 | sys.exit(Main(sys.argv[1:])) 162 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | fplutil Version 1.1.0 2 | ===================== 3 | 4 | # fplutil {#fplutil_readme} 5 | 6 | fplutil is a set of small libraries and tools that can be useful when 7 | developing applications for Android and other platforms. 8 | 9 | * **build_all_android** is an all-in-one build script that allows you to 10 | build, install and run native (C/C++) Android apps from the command line. 11 | This is ideal for build automation, but can also be in a developer’s 12 | compile/run loop. 13 | * **buildutil** performs the configuration, build and archive steps 14 | of [Android][] and [Linux][] C/C++ applications using a suite of 15 | [Python][] modules. This suite of modules can automate builds in a 16 | continuous integration environment. 17 | * **android_ndk_perf** is a desktop tool that enables native (C/C++) 18 | developers to measure the CPU utilization of their applications on 19 | [Android][], guiding their optimization efforts. 20 | * **libfplutil** enables C/C++ developers to write traditional applications 21 | (like [Hello World][]) using "main()" and "printf()" on [Android][]. 22 | 23 | Goto fplutil's [landing page][] for documentation. 24 | 25 | * Discuss fplutil with other developers and users on the 26 | [fplutil Google Group][]. 27 | * File issues on the [fplutil Issues Tracker][] 28 | or post your questions to [stackoverflow.com][] with a mention of 29 | **fplutil**. 30 | 31 | **Important**: fplutil uses submodules to reference other components it depends 32 | upon so to download the source use: 33 | 34 | git clone --recursive https://github.com/google/fplutil.git 35 | 36 | To contribute to this project see [CONTRIBUTING][]. 37 | 38 | For applications on Google Play that integrate these libraries, usage is 39 | tracked. This tracking is done automatically using the embedded version string 40 | (kFplUtilVersionString). Aside from consuming a few extra bytes in your 41 | application binary, it shouldn't affect your application at all. We use this 42 | information to let us know if fplutil libraries are useful and if we should 43 | continue to invest in them. Since this is open source, you are free to remove 44 | the version string but we would appreciate if you would leave it in. 45 | 46 | [Android]: http://www.android.com 47 | [Linux]: http://en.m.wikipedia.org/wiki/Linux 48 | [Python]: http://www.python.org 49 | [fplutil Google Group]: https://groups.google.com/forum/#!forum/fplutil 50 | [fplutil Issues Tracker]: http://github.com/google/fplutil/issues 51 | [stackoverflow.com]: http://stackoverflow.com/search?q=fplutil 52 | [landing page]: http://google.github.io/fplutil 53 | [Hello World]: http://en.wikipedia.org/wiki/%22Hello,_world!%22_program 54 | [CONTRIBUTING]: http://github.com/google/fplutil/blob/master/CONTRIBUTING 55 | -------------------------------------------------------------------------------- /setuputil/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/fplutil/ac0118ad7fedf054c2645efdb13f52788c183d12/setuputil/__init__.py -------------------------------------------------------------------------------- /setuputil/common.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2016 Google Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | 18 | import os 19 | 20 | BASE_DIR = os.path.expanduser("~") 21 | 22 | LINUX = "LINUX" 23 | LINUX_32 = LINUX + "32" 24 | LINUX_64 = LINUX + "64" 25 | MAC = "MAC" 26 | WINDOWS = "WINDOWS" 27 | WINDOWS_32 = WINDOWS + "32" 28 | WINDOWS_64 = WINDOWS + "64" 29 | 30 | 31 | class Setup(object): 32 | """Base class for installing prerequisites for Linux, Mac OS X and Windows. 33 | 34 | Attributes: 35 | bash_profile_changed: A boolean indicating whether or not the bash profile 36 | has been edited by the script, and the user should call source. 37 | cwebp_path: A string of the path to the location of the cwebp directory. 38 | cmake_path: A string of the path to the location of the cmake directory. 39 | 40 | Raises: 41 | BadDirectoryError: If a path given in the cwebp, cmake or ant flag does not 42 | exist. 43 | """ 44 | 45 | def __init__(self, options): 46 | self.bash_profile_changed = False 47 | self.bash_profile = os.path.join(BASE_DIR, ".bash_profile") # Unused in 48 | # Windows 49 | self.cwebp_path = os.path.join(BASE_DIR, options.cwebp_location) 50 | if not os.path.isdir(self.cwebp_path): 51 | raise BadDirectoryError("--cwebp", self.cwebp_path) 52 | self.cmake_path = os.path.join(BASE_DIR, options.cmake_location) 53 | if not os.path.isdir(self.cmake_path): 54 | raise BadDirectoryError("--cmake", self.cmake_path) 55 | self.ant_path = os.path.join(BASE_DIR, options.ant_location) 56 | if not os.path.isdir(self.ant_path): 57 | raise BadDirectoryError("--ant", self.ant_path) 58 | 59 | def has_bash_changed(self): 60 | """Returns wheter or not the bash profile has been changed.""" 61 | return self.bash_profile_changed 62 | 63 | 64 | class SystemUnsupportedError(Exception): 65 | """Raised when an OS is unrecognised or unsupported.""" 66 | 67 | def __init__(self, system): 68 | Exception.__init__(self) 69 | self.system = system 70 | 71 | 72 | class VersionUnsupportedError(Exception): 73 | """Raised when the version of an OS is unrecognised or unsupported.""" 74 | 75 | def __init__(self, version): 76 | Exception.__init__(self) 77 | self.version = version 78 | 79 | 80 | class VersionTooHighError(Exception): 81 | """Raised when the OS version is greater than the highest supported.""" 82 | 83 | def __init__(self, version): 84 | Exception.__init__(self) 85 | self.version = version 86 | 87 | 88 | class VersionTooLowError(Exception): 89 | """Raised when the OS version is less than the lowest supported.""" 90 | 91 | def __init__(self, version): 92 | Exception.__init__(self) 93 | self.version = version 94 | 95 | 96 | class BadDirectoryError(Exception): 97 | """Raised when a directory given through a command line flag doesn't exist.""" 98 | 99 | def __init__(self, flag, directory): 100 | Exception.__init__(self) 101 | self.flag = flag 102 | self.directory = directory 103 | 104 | 105 | class InstallInterruptError(Exception): 106 | """Raised when installation of a program was interrupted by the user.""" 107 | 108 | def __init__(self, program, instructions=""): 109 | Exception.__init__(self) 110 | self.program = program 111 | self.instructions = instructions 112 | 113 | 114 | class InstallFailedError(Exception): 115 | """Raised when installation fails for reasons other than user interrupt.""" 116 | 117 | def __init__(self, program, link="", instructions=""): 118 | Exception.__init__(self) 119 | self.program = program 120 | self.link = link 121 | self.instructions = instructions 122 | 123 | 124 | class FileDownloadError(Exception): 125 | """Raised when a file was unable to download.""" 126 | 127 | def __init__(self, link, instructions=""): 128 | Exception.__init__(self) 129 | self.link = link 130 | self.instructions = instructions 131 | 132 | 133 | class UnknownFileTypeError(Exception): 134 | """Raised when the extension of a file is unrecognised.""" 135 | 136 | def __init__(self, filetype, instructions): 137 | Exception.__init__(self) 138 | self.filetype = filetype 139 | self.instructions = instructions 140 | 141 | 142 | class ExtractionError(Exception): 143 | """Raised when a compressed file was unable to be extracted.""" 144 | 145 | def __init__(self, filepath): 146 | Exception.__init__(self) 147 | self.filepath = filepath 148 | 149 | 150 | class CommandFailedError(Exception): 151 | """Raised when a subprocess fails for unforseeable reasons.""" 152 | 153 | def __init__(self, command, link): 154 | Exception.__init__(self) 155 | self.command = command 156 | self.link = link 157 | 158 | 159 | class PermissionDeniedError(Exception): 160 | """Raised when the script was not able to gain the correct permissions.""" 161 | 162 | def __init__(self, program, instructions): 163 | Exception.__init__(self) 164 | self.program = program 165 | self.instructions = instructions 166 | 167 | 168 | class WebbrowserFailedError(Exception): 169 | """Raised when a url was unable to be opened in the webbrowser.""" 170 | 171 | def __init__(self, pagename, link): 172 | Exception.__init__(self) 173 | self.pagename = pagename 174 | self.link = link 175 | -------------------------------------------------------------------------------- /setuputil/linux.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright 2014 Google Inc. All Rights Reserved. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import logging 18 | import os 19 | import subprocess 20 | 21 | import common 22 | 23 | 24 | """Contains all necessary methods for setting up Linux.""" 25 | 26 | # Programs required for Linux installation. 27 | # Program name: package_name 28 | LINUX_PROGRAMS = { 29 | "autoconf": "autoconf", 30 | "automake": "automake", 31 | "cmake": "cmake", 32 | "ImageMagick": "imagemagick", 33 | "OpenGL": "libglapi-mesa", 34 | "GLU": "libglu1-mesa-dev", 35 | "libtool": "libtool", 36 | "OSS Proxy Daemon": "osspd", 37 | "Python": "python", 38 | "Ragel": "ragel", 39 | "crwebp": "webp", 40 | "Java 1.7": "openjdk-7-jdk", 41 | "ant": "ant"} 42 | 43 | 44 | class LinuxSetup(object): 45 | """Contains all necessary methods for setting up Linux.""" 46 | 47 | def linux_requirements(self): 48 | """Installs all necessary linux programs. 49 | 50 | If the program has already been intalled, it will be skipped. 51 | 52 | Raises: 53 | VersionUnsupportedError: If Linux version is not Debian based. 54 | PermissiondDeniedError: If sudo permissions are not granted. 55 | BadDirectoryError: If a path given in the cwebp, cmake or ant flag does 56 | not exist. 57 | """ 58 | if not os.path.isfile("/etc/debian_version"): 59 | raise common.VersionUnsupportedError("Non Debian based") 60 | 61 | logging.info("Installing:\n + " + "\n + ".join(LINUX_PROGRAMS.keys()) 62 | + "\nSudo may prompt you for your password") 63 | try: 64 | subprocess.call("sudo apt-get update", shell=True) 65 | subprocess.call("sudo apt-get install " + 66 | " ".join(LINUX_PROGRAMS.values()), shell=True) 67 | except subprocess.CalledProcessError: 68 | raise common.PermissionDeniedError("Linux programs", "Please enter your " 69 | "password to install the necessary " 70 | "Linux programs\n") 71 | 72 | def setup_all(self): 73 | """Perform all necessary setup.""" 74 | self.linux_requirements() 75 | logging.info("Linux setup complete") 76 | --------------------------------------------------------------------------------