├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── build.cmd ├── build.sh ├── configure-gui.cmd ├── configure-mingw.cmd ├── configure-mostly-clean.sh ├── configure-ninja.cmd ├── configure-nmake.cmd ├── devterminal.cmd ├── package.cmd └── src ├── .gitignore ├── CMakeLists.txt ├── DownloadScript.cmake ├── InstallTreeSuperBuildPrefix.cmake ├── SDL-add-ons.cmake ├── SDL2-2.0.4.zip ├── osvr_json_to_c └── CMakeLists.txt └── packaging ├── launcher.sh └── setup.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /build*/ 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "android-cmake"] 2 | path = android-cmake 3 | url = https://github.com/OSVR/android-cmake.git 4 | branch = with-updates-merged 5 | [submodule "src/libfunctionality"] 6 | path = src/libfunctionality 7 | url = https://github.com/OSVR/libfunctionality.git 8 | branch = master 9 | [submodule "src/jsoncpp"] 10 | path = src/jsoncpp 11 | url = https://github.com/vrpn/jsoncpp.git 12 | [submodule "src/boost"] 13 | path = src/boost 14 | url = https://github.com/MysticTreeGames/Boost-for-Android 15 | [submodule "src/hidapi"] 16 | path = src/hidapi 17 | url = https://github.com/signal11/hidapi 18 | [submodule "src/libusb"] 19 | path = src/libusb 20 | url = https://github.com/libusb/libusb 21 | [submodule "src/OSVR-Core"] 22 | path = src/OSVR-Core 23 | url = https://github.com/OSVR/OSVR-Core.git 24 | branch = master 25 | fetchRecurseSubmodules = true 26 | [submodule "src/android_sensor_tracker"] 27 | path = src/android_sensor_tracker 28 | url = https://github.com/OSVR/OSVR-Android-Plugins.git 29 | [submodule "src/OSVR-RenderManager"] 30 | path = src/OSVR-RenderManager 31 | url = https://github.com/sensics/OSVR-RenderManager.git 32 | [submodule "src/OSVR-Unity-Rendering"] 33 | path = src/OSVR-Unity-Rendering 34 | url = https://github.com/OSVR/OSVR-Unity-Rendering.git 35 | branch = d3d_capi 36 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(OSVR-Android LANGUAGES) 3 | 4 | if(CMAKE_CROSSCOMPILING) 5 | message(FATAL_ERROR "Don't specify a toolchain for this super-build: use your native build tool, the nested builds automatically will have the toolchain specified!") 6 | endif() 7 | 8 | include(ExternalProject) 9 | 10 | ### 11 | # Configuration 12 | ### 13 | if(NOT ANDROID_ABI) 14 | set(ANDROID_ABI "armeabi-v7a" CACHE STRING "Android ABI to build all projects with - see android-cmake docs for details") 15 | set_property(CACHE ANDROID_ABI PROPERTY STRINGS "armeabi" "armeabi-v7a" "armeabi-v7a with NEON" "armeabi-v7a with VFPV3" "armeabi-v6 with VFP" "x86" "mips" "arm64-v8a" "x86_64" "mips64") 16 | endif() 17 | 18 | # ndk-build doesn't like decorated ABI strings. 19 | if("${ANDROID_ABI}" MATCHES "armeabi-v7a" AND NOT "${ANDROID_ABI}" STREQUAL "armeabi-v7a") 20 | set(ANDROID_BARE_NDK_ABI "armeabi-v7a") 21 | else() 22 | set(ANDROID_BARE_NDK_ABI "${ANDROID_ABI}") 23 | endif() 24 | 25 | # This is the only one that supports rtti and exceptions, 26 | # except for libc++ which isn't supported by android-cmake yet. 27 | #set(ANDROID_STL gnustl_static) 28 | 29 | # well, except this one seems to work fine 30 | if(NOT ANDROID_STL) 31 | set(ANDROID_STL gnustl_shared) 32 | endif() 33 | 34 | if(NOT ANDROID_TOOLCHAIN_NAME AND ANDROID_ABI MATCHES "armeabi") 35 | set(ANDROID_TOOLCHAIN_NAME "arm-linux-androideabi-4.9" CACHE STRING "Android Toolchain name") 36 | set_property(CACHE ANDROID_TOOLCHAIN_NAME PROPERTY STRINGS "arm-linux-androideabi-4.9" "arm-linux-androideabi-clang3.7" "arm-linux-androideabi-clang3.6") 37 | endif() 38 | 39 | if(NOT ANDROID_NATIVE_API_LEVEL) 40 | set(ANDROID_NATIVE_API_LEVEL "24" CACHE STRING "Android Native API Level") 41 | endif() 42 | 43 | # Optional, externally-built osvr_json_to_c instance 44 | 45 | set(CMAKE_MAP_IMPORTED_CONFIG_RELEASE RELWITHDEBINFO) 46 | find_package(osvr) 47 | unset(CMAKE_MAP_IMPORTED_CONFIG_RELEASE) 48 | if(NOT TARGET osvr::osvr_json_to_c) 49 | find_program(OSVR_JSON_TO_C_COMMAND NAMES osvr_json_to_c) 50 | endif() 51 | 52 | if(WIN32) 53 | set(MAKEFILE_GENERATOR "MinGW Makefiles") 54 | else() 55 | set(MAKEFILE_GENERATOR "Unix Makefiles") 56 | endif() 57 | if(NOT ANDROID_GENERATOR) 58 | find_program(NINJA_COMMAND ninja) 59 | if(NINJA_COMMAND) 60 | set(ANDROID_GENERATOR "Ninja" CACHE STRING "The CMake generator to use when building projects.") 61 | else() 62 | set(ANDROID_GENERATOR "${MAKEFILE_GENERATOR}" CACHE STRING "The CMake generator to use when building projects.") 63 | endif() 64 | endif() 65 | set_property(CACHE ANDROID_GENERATOR PROPERTY STRINGS "${MAKEFILE_GENERATOR}" "Ninja") 66 | 67 | ### 68 | # Options that we pass through to OSVR-Core 69 | ### 70 | include("${CMAKE_CURRENT_SOURCE_DIR}/src/OSVR-Core/cmake-local/osvrBuildOptions.cmake") 71 | set(OSVR_CORE_PASSTHROUGH_OPTIONS) 72 | foreach(opt ${OSVR_BUILD_OPTIONS}) 73 | list(APPEND OSVR_CORE_PASSTHROUGH_OPTIONS "-DBUILD_${opt}=${BUILD_${opt}}") 74 | endforeach() 75 | 76 | list(APPEND OSVR_CORE_PASSTHROUGH_OPTIONS "-DOSVR_COMMON_IN_PROCESS_IMAGING=1") 77 | list(APPEND OSVR_CORE_PASSTHROUGH_OPTIONS "-DBUILD_CLIENT_EXAMPLES=0") 78 | list(APPEND OSVR_CORE_PASSTHROUGH_OPTIONS "-DBUILD_SERVER_EXAMPLES=0") 79 | list(APPEND OSVR_CORE_PASSTHROUGH_OPTIONS "-DBUILD_HEADER_DEPENDENCY_TESTS=0") 80 | list(APPEND OSVR_CORE_PASSTHROUGH_OPTIONS "-DBUILD_WITH_OPENCV=0") 81 | 82 | ### 83 | # NDK finding - using environment and CMake variables as a hint 84 | ### 85 | if(NOT ANDROID_NDK) 86 | get_filename_component(ANDROID_NDK "$ENV{ANDROID_NDK}" ABSOLUTE) 87 | set(ANDROID_NDK "${ANDROID_NDK}" CACHE PATH "The root directory of an Android NDK" FORCE) 88 | endif() 89 | 90 | if(ANDROID_NDK) 91 | set(ANDROID_NDK_HINT ${ANDROID_NDK}) 92 | endif() 93 | 94 | if(WIN32) 95 | set(NDK_BUILD_SUFFIX .cmd) 96 | endif() 97 | find_program(ANDROID_NDK_BUILD 98 | NAMES 99 | ndk-build${NDK_BUILD_SUFFIX} 100 | HINTS 101 | ${ANDROID_NDK_HINT} 102 | DOC "Root directory of android NDK") 103 | 104 | 105 | if(NOT ANDROID_NDK_BUILD) 106 | message(FATAL_ERROR "Need the Android NDK path set, by finding the ndk-build command!") 107 | endif() 108 | 109 | ### 110 | # Build config handling 111 | ### 112 | if(NOT CMAKE_CONFIGURATION_TYPES) 113 | # Single config generator 114 | if(NOT CMAKE_BUILD_TYPE) 115 | # no config set. 116 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) 117 | endif() 118 | 119 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 120 | # OK config set 121 | set(ANDROID_BUILD_TYPE ${CMAKE_BUILD_TYPE}) 122 | else()# bad config set 123 | message(STATUS "${CMAKE_BUILD_TYPE} is not a valid build type for the Android toolchain - must be Release or Debug.") 124 | set(ANDROID_BUILD_TYPE Release) 125 | endif() 126 | 127 | message(STATUS "Android build config: ${ANDROID_BUILD_TYPE}") 128 | else() 129 | # Multi-config generator - will need generator expression 130 | set(CMAKE_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "" FORCE) 131 | set(ANDROID_BUILD_TYPE $) 132 | endif() 133 | 134 | ### 135 | # Setting some variables and properties 136 | ### 137 | 138 | # Excerpted/modified from the code we added to detect CrystaX in android-cmake 139 | if(EXISTS "${ANDROID_NDK}/RELEASE.TXT") 140 | file(STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_GENERIC_RELEASE_FULL LIMIT_COUNT 1 REGEX "[^ ]+") 141 | if(ANDROID_NDK_GENERIC_RELEASE_FULL AND ANDROID_NDK_GENERIC_RELEASE_FULL MATCHES "crystax-ndk") 142 | set(ANDROID_CRYSTAX_NDK ON) 143 | endif() 144 | endif() 145 | 146 | set(ANDROID_TOOLCHAIN "${CMAKE_CURRENT_SOURCE_DIR}/android-cmake/android.toolchain.cmake") 147 | file(TO_NATIVE_PATH "${ANDROID_TOOLCHAIN}" ANDROID_TOOLCHAIN_NATIVE_PATH) 148 | 149 | set(ANDROID_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install") 150 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ANDROID_INSTALL_DIR}") 151 | 152 | set(HOST_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/host-install") 153 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${HOST_INSTALL_DIR}") 154 | 155 | get_filename_component(ANDROID_NDK ${ANDROID_NDK_BUILD} DIRECTORY CACHE) 156 | 157 | if(WIN32) 158 | list(APPEND CMAKE_PREFIX_PATH "${ANDROID_NDK}/prebuilt/windows-x86_64") 159 | endif() 160 | 161 | set(ANDROID_NDK_BUILD_WITH_ARGS 162 | "${ANDROID_NDK_BUILD}" 163 | NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN_NAME} 164 | APP_ABI=${ANDROID_BARE_NDK_ABI} 165 | "NDK_OUT=" 166 | "NDK_APP_DST_DIR=/lib" 167 | ) 168 | 169 | set(ANDROID_CMAKE_PREFIX_PATH) 170 | set(ANDROID_COMMON_CMAKE_ARGS) 171 | # Internal utility macro for generating COMMON_CMAKE_ARGS 172 | macro(_osvr_android_update_common_cmake_args) 173 | set(COMMON_CMAKE_ARGS 174 | "-DCMAKE_INSTALL_PREFIX:PATH=${ANDROID_INSTALL_DIR}" 175 | "-DCMAKE_PREFIX_PATH:PATH=${ANDROID_CMAKE_PREFIX_PATH}" 176 | "-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${ANDROID_TOOLCHAIN}" 177 | #"-DANDROID_TOOLCHAIN_NAME:STRING=${ANDROID_TOOLCHAIN_NAME}" 178 | "-DANDROID_NDK:PATH=${ANDROID_NDK}" 179 | "-DANDROID_STL:STRING=${ANDROID_STL}" 180 | "-DANDROID_ABI:STRING=${ANDROID_ABI}" 181 | "-DCMAKE_BUILD_TYPE:STRING=${ANDROID_BUILD_TYPE}" 182 | "-DANDROID_NATIVE_API_LEVEL:STRING=${ANDROID_NATIVE_API_LEVEL}" 183 | "-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}" 184 | ${ANDROID_COMMON_CMAKE_ARGS} 185 | ) 186 | endmacro() 187 | 188 | # Creates/updates the COMMON_CMAKE_ARGS, after adding the given argument 189 | macro(osvr_android_add_common_cmake_arg _arg) 190 | list(APPEND ANDROID_COMMON_CMAKE_ARGS ${_arg}) 191 | _osvr_android_update_common_cmake_args() 192 | endmacro() 193 | 194 | # Creates/updates the COMMON_CMAKE_ARGS, after adding the given path to the 195 | # ANDROID_CMAKE_PREFIX_PATH (the list that gets passed to Android CMake builds) 196 | macro(osvr_android_add_to_common_prefix_path _newpath) 197 | list(APPEND ANDROID_CMAKE_PREFIX_PATH ${_newpath}) 198 | _osvr_android_update_common_cmake_args() 199 | endmacro() 200 | 201 | # Initial run to generate COMMON_CMAKE_ARGS, only have one entry for the prefix path 202 | osvr_android_add_to_common_prefix_path("${ANDROID_INSTALL_DIR}") 203 | 204 | 205 | if(ANDROID_TOOLCHAIN_NAME) 206 | message(STATUS "Using toolchain ${ANDROID_TOOLCHAIN_NAME}") 207 | list(APPEND ANDROID_NDK_BUILD_WITH_ARGS 208 | "NDK_TOOLCHAIN=${ANDROID_TOOLCHAIN_NAME}") 209 | osvr_android_add_common_cmake_arg("-DANDROID_TOOLCHAIN_NAME:STRING=${ANDROID_TOOLCHAIN_NAME}") 210 | endif() 211 | 212 | if("${ANDROID_STL}" MATCHES "c\\+\\+_") 213 | 214 | if(NOT ANDROID_LIBCXX_VERSION AND NOT ("${ANDROID_TOOLCHAIN_NAME}" MATCHES "clang") AND NOT ("${ANDROID_TOOLCHAIN_NAME}" MATCHES "clang")) 215 | message(STATUS "Specified a GCC toolchain with libc++ - setting a default ANDROID_LIBCXX_VERSION for you.") 216 | set(ANDROID_LIBCXX_VERSION 3.7) 217 | endif() 218 | if(ANDROID_LIBCXX_VERSION) 219 | message(STATUS "Passing ANDROID_LIBCXX_VERSION=${ANDROID_LIBCXX_VERSION}") 220 | osvr_android_add_common_cmake_arg("-DANDROID_LIBCXX_VERSION:STRING=${ANDROID_LIBCXX_VERSION}") 221 | endif() 222 | endif() 223 | 224 | if(ANDROID_EXTRA_CXX_FLAGS) 225 | message(STATUS "Passing along ANDROID_EXTRA_CXX_FLAGS=${ANDROID_EXTRA_CXX_FLAGS} as CMAKE_CXX_FLAGS") 226 | osvr_android_add_common_cmake_arg("-DCMAKE_CXX_FLAGS:STRING=${ANDROID_EXTRA_CXX_FLAGS}") 227 | endif() 228 | 229 | ### 230 | # Find/use make/ninja 231 | ### 232 | if("${ANDROID_GENERATOR}" STREQUAL "MinGW Makefiles") 233 | find_program(ANDROID_NDK_MAKE 234 | NAMES 235 | make.exe 236 | make 237 | mingw32-make 238 | HINTS 239 | ${ANDROID_NDK}/prebuilt/windows-x86_64/bin) 240 | if(NOT ANDROID_NDK_MAKE) 241 | message(FATAL_ERROR "Need the location of a make executable - usually bundled with the NDK!") 242 | endif() 243 | osvr_android_add_common_cmake_arg("-DCMAKE_MAKE_PROGRAM=${ANDROID_NDK_MAKE}") 244 | endif() 245 | 246 | if("${ANDROID_GENERATOR}" STREQUAL "Ninja") 247 | if(NOT NINJA_COMMAND) 248 | message(FATAL_ERROR "Ninja generator was selected, so need the location of a ninja executable in NINJA_COMMAND! (or switch to the makefiles generator)") 249 | endif() 250 | osvr_android_add_common_cmake_arg("-DCMAKE_MAKE_PROGRAM=${NINJA_COMMAND}") 251 | endif() 252 | 253 | ### 254 | # Find other host programs 255 | ### 256 | find_package(PythonInterp REQUIRED) 257 | 258 | ### 259 | # Messages regarding config 260 | ### 261 | if(ANDROID_CRYSTAX_NDK) 262 | message(STATUS "Using a CrystaX NDK") 263 | # Use shared libcrystax consistently for all modules. 264 | osvr_android_add_common_cmake_arg("-DANDROID_CRYSTAX_NDK_SHARED_LIBCRYSTAX=ON") 265 | else() 266 | message(STATUS "Using a standard (Google) Android NDK") 267 | endif() 268 | message(STATUS "ANDROID_NDK: ${ANDROID_NDK}") 269 | message(STATUS "ANDROID_ABI: ${ANDROID_ABI}") 270 | 271 | # Go into the subdirectory with the projects in it 272 | add_subdirectory(src) 273 | 274 | ### 275 | # Bundle stuff up 276 | ### 277 | set(CPACK_GENERATOR TGZ) 278 | include(CPack) 279 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OSVR-Android-Build 2 | Super-build and submodules for building OSVR for Android. 3 | 4 | This repository should be cloned with `--recursive`, or you need to run 5 | 6 | ```sh 7 | git submodule update --init --recursive 8 | ``` 9 | 10 | in the root directory. (You may want to do the latter after updating this repo, as well, to make sure the submodules are all up to date - make sure that any changes you've made in those repos has been committed on a named branch first.) 11 | 12 | ## Requirements 13 | - The latest [CMake][] (3.2.2 verified to work 22-May-2015) 14 | - The latest [CrystaX NDK][] (10.3.2 verified to work 05-May-2017) 15 | - There is some code to theoretically support the upstream Android NDK, but it does not work at this time and is not recommended unless you want to help hack on the build system. Anyway, the CrystaX NDK appears to provide other benefits besides reducing dependencies (it comes with Boost already compiled), so it will most likely remain the targeted NDK. 16 | - Python 2.x (often - always? - included in an NDK) 17 | - Boost installed on your system for your host compiler (not the android compiler) - specifically we need Boost.ProgramOptions. 18 | - Optional: Ninja build system installed to somewhere on your path (can be used instead of makefiles) 19 | 20 | [CMake]: http://cmake.org 21 | [CrystaX NDK]: https://www.crystax.net/android/ndk 22 | 23 | ## Build Overview 24 | This repository's primary contents, besides the submodules, is a CMake build system using the [ExternalProject][] functionality to control nested configuration and build processes - the so-called "super-build". You should configure it using your **standard, native platform build platform** (Visual Studio, MinGW, Unix Makefiles, Ninja, whatever suits you). With the correct setting of things like the `ANDROID_NDK` variable in the super-build's CMake configuration (command line or GUI), **the build will automatically set up the cross-compilation toolchain of nested builds** as required. 25 | 26 | Essentially, the super-build is a sort of meta-project or outer shell around the nested builds, with configuration, build, and install of the nested builds as targets in the super-build. 27 | 28 | > A bit more details: The OSVR build process requires a host-format (that is, not cross-compiled for Android) tool binary (`osvr_json_to_c`). On non-cross-compilation builds, it's just built as part of the standard build process then used, but this of course does not work when cross-compiling. This super-project includes a nested build just for that tool and its dependency, which uses whatever CMake generator you use for the super-build which of course assumes that it can build binaries that your machine can run. The Android nested builds automatically have their `CMAKE_TOOLCHAIN_FILE` and related options set appropriately by the super-build, as well as having this native tool substituted in. 29 | 30 | **Important development note:** As with all Git repos with submodules, if you are going to make changes to a submodule's contents, be sure to check out/create a named branch first, as the submodule process checks out a specific commit (a "detached HEAD"). 31 | 32 | [ExternalProject]: http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html 33 | 34 | 35 | ## Build/usage instructions 36 | - Download and unpack the NDK somewhere convenient. 37 | - Set the ANDROID_NDK environment variable to point to where you unpacked the NDK. On Linux when using the BASH shell, you do this like: **export ANDROID_NDK=~/crystax-ndk-1.10.0** (assuming that you put the NDK in your home directory, otherwise adjust the path) and on Windows you do it it under Properties/Advanced system settings/Advanced/Environment Variables/User variables. 38 | - Clone the repository and submodules. 39 | - Run CMake/CMake GUI on the top-level directory: 40 | - setting the build/binary directory to a different directory 41 | - specifying the required variables: 42 | - `ANDROID_NDK` - the location of the NDK (the root of it) 43 | - optionally specifying these to override defaults: 44 | - `ANDROID_ABI` 45 | - `CMAKE_BUILD_TYPE` - Only for single-configuration CMake generators (so, not for Visual Studio or XCode, but yes for makefiles including NMake) - either `Release` or `Debug`, default is `Release` 46 | - `CMAKE_PREFIX_PATH` - passed along to nested host builds to help them find dependencies. 47 | - any of the `BUILD_` options: these get passed through to the OSVR-Core cross-build. 48 | - If using the GUI, "Configure" and "Generate". 49 | - In the build directory chosen, open the solution/project and build it (the default target), or run `make` or your other build tool (depending on the CMake generator you chose) 50 | - Build products are installed into your binary directory, in a subdirectory called `install` 51 | - Either: 52 | - Copy the desired files directly and individually to your Android device, or 53 | - Run `cpack` in the binary dir/build the "package" target to get a `.tar.gz` file containing just the runtime files, copy that to your Android device and unpack it. 54 | - Optional (but recommended) step: from a shell (`ssh`, for instance) on the device or over `adb`, run the command `sh setup.sh` in the root directory of the OSVR tree. See below for details. You'll then have a number of executable files (actually symlinks, but that's not important) in the root directory of the OSVR tree on the device for starting bundled apps/tools. 55 | 56 | ## Build scripts 57 | 58 | ### Windows 59 | Running some `configure` script followed by `build.cmd` results in a complete build of the OSVR-Core and dependencies, with the binary tree in the `build` directory. For the inner Android builds, Ninja will be used if it is found on your path, otherwise makefiles compatible with the `make` included in the NDK will be used. 60 | 61 | Since these are scripts, your Android NDK needs to be findable somehow: primarily either setting the environment variable `%ANDROID_NDK%` in the console you use to build or passing `-DANDROID_NDK=c:/myndkpath` as a command line argument to configure. 62 | 63 | All configure scripts set up a Release-mode build unless you specify otherwise. Ninja is the fastest, in this case because it's the only system that will take advantage of parallelism without contortions. 64 | 65 | #### Configure scripts 66 | 67 | - `configure-nmake.cmd` - Run from a Visual Studio command prompt. 68 | - Super-build is driven by Microsoft `nmake` 69 | - Host binaries are compiled with Visual Studio compilers using `nmake` 70 | - Does not require `%ANDROID_NDK%` to be set in the environment. 71 | - `configure-ninja.cmd` - Run from either a Visual Studio command prompt or a command prompt with MinGW(64) compilers accessible, and with ninja in your path. 72 | - Super-build is driven by ninja. 73 | - Host binaries are compiled with whatever compilers CMake can find, driven by ninja. 74 | - Does not require `%ANDROID_NDK%` to be set in the environment. 75 | - `configure-mingw.cmd` - Run from a command prompt with MinGW(64) compilers accessible. 76 | - Super-build is driven by `make` found in the NDK. 77 | - Host binaries are compiled with MinGW, driven by the NDK's `make`. 78 | - **Requires `%ANDROID_NDK%` to be set in the environment** (so the super-build's make can be found statically). 79 | 80 | #### Post-configure scripts 81 | Once you've run a configure script, you can proceed to run these scripts, as desired, in the same console for safety's sake. 82 | 83 | - `build.cmd` - Regardless of build system and compilers chosen, runs a full build, which involves building host binaries and installing them to the `build/host-install` prefix, and building Android binaries and installing them to the `build/install` prefix. 84 | - `package.cmd` - Following a build, packages up just the runtime pieces (suitable to run a server and test clients) of the Android build in a `.tar.gz` file in `build/` 85 | 86 | ### Not Windows 87 | 88 | "Not Windows" systems are expected to have an NDK, as well as some suitable host compiler and `make` installed (by default). 89 | 90 | - `configure-mostly-clean.sh` is a script used by CI compilation of this distribution, and you can use it too. 91 | - If there is already a build tree in `build/`, it mostly wipes it out, excluding the super-build configuration and the OpenCV-Android SDK download. (hence "mostly-clean") 92 | - It then ensures `build/` exists and runs `cmake` to generate/update a build tree there, passing along any command-line arguments you provide. 93 | - `build.sh` - Uses CMake to invoke whatever build system was generated in `build/`. Yes, this means it's often just a fancy way to say `make`. 94 | 95 | ## On-device convenience scripts 96 | The build includes some simple scripts intended for running on the device that are optional but make testing/usage easier. They require Busybox to be installed and in the path. If you can't/don't want to use them, you can just read them to see what they're doing. 97 | 98 | - `setup.sh` in the root directory of the tree takes care of setting executable permissions on the binaries and scripts (in case you built on Windows or otherwise couldn't preserve the desired permissions during file creation/transfer), and also creates symlinks in the tree root to `bin/launcher.sh` for simple starting of various applications. 99 | - `launcher.sh` located under `bin` is a wrapper/launcher script, designed to be used by creating a symlink in the root of the tree (which `setup.sh` does). It uses the name that it's invoked with (that is, the symlink name) to specify which binary to run, after it sets up library paths appropriately and sets the current working directory to be the `bin` directory. 100 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | cmake --build "%~dp0build" 2 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | BUILDROOT=$(cd $(dirname $0) && pwd)/build 3 | cmake --build "${BUILDROOT}" "$@" 4 | -------------------------------------------------------------------------------- /configure-gui.cmd: -------------------------------------------------------------------------------- 1 | pushd "%~dp0/build" 2 | cmake-gui .. %* 3 | popd 4 | -------------------------------------------------------------------------------- /configure-mingw.cmd: -------------------------------------------------------------------------------- 1 | 2 | @mkdir "%~dp0build" 3 | pushd "%~dp0build" 4 | cmake .. -G "MinGW Makefiles" "-DCMAKE_MAKE_PROGRAM=%ANDROID_NDK%\prebuilt\windows-x86_64\bin\make.exe" %* 5 | popd 6 | -------------------------------------------------------------------------------- /configure-mostly-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | BUILDROOT=$(cd $(dirname $0) && pwd)/build 3 | if [ -e "${BUILDROOT}/src" ]; then 4 | ( 5 | cd "${BUILDROOT}/src" 6 | # Delete all the projects except the big OpenCV download. 7 | ls | grep prefix | grep -v OpenCV | xargs rm -rf 8 | ) 9 | fi 10 | 11 | rm -rf "${BUILDROOT}/install" 12 | rm -rf "${BUILDROOT}/host-install" 13 | 14 | mkdir -p "${BUILDROOT}" 15 | ( 16 | cd "${BUILDROOT}" && cmake .. "$@" 17 | ) 18 | -------------------------------------------------------------------------------- /configure-ninja.cmd: -------------------------------------------------------------------------------- 1 | 2 | @mkdir "%~dp0build" 3 | pushd "%~dp0build" 4 | cmake .. -G "Ninja" %* 5 | popd 6 | -------------------------------------------------------------------------------- /configure-nmake.cmd: -------------------------------------------------------------------------------- 1 | 2 | @mkdir "%~dp0build" 3 | pushd "%~dp0build" 4 | cmake .. -G "NMake Makefiles" %* 5 | popd 6 | -------------------------------------------------------------------------------- /devterminal.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | if exist %1 set ANDROID_NDK=%1 3 | 4 | echo Hoping your ANDROID_NDK is %ANDROID_NDK% 5 | set PATH=%ANDROID_NDK%\prebuilt\windows-x86_64\bin;%ANDROID_NDK%;%PATH% 6 | 7 | cd /d "%~dp0" 8 | 9 | echo. 10 | 11 | echo You're in the source tree right now, with ANDROID_NDK set 12 | echo and on your path, as well as the prebuilt windows tools (for make, etc) 13 | echo. 14 | 15 | echo Run configure to generate a build tree in the build directory. 16 | echo You can edit the configuration with configure-gui 17 | echo You can build by running build, or by changing into 18 | echo the build directory and running make. 19 | 20 | cmd /k 21 | -------------------------------------------------------------------------------- /package.cmd: -------------------------------------------------------------------------------- 1 | pushd "%~dp0build" 2 | CPack 3 | popd 4 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | /OpenCV-*-android-sdk.zip 2 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # See URLs below for more documentation on ExternalProject 2 | # http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html 3 | # http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html 4 | 5 | # Since what OSVR-Core depends on varies based on build configurations, we 6 | # accumulate the dependencies in this variable. 7 | set(osvr_dep_targets) 8 | 9 | # Stores the paths to the build stamp files we want to delete if we build the "force_rebuild" target 10 | set(force_build_stamps) 11 | set(force_build_targets) 12 | 13 | # pass the external project target name, then any steps you want to 14 | # force in addition to just "build" 15 | function(add_ep_to_force _target) 16 | ExternalProject_Get_Property(${_target} STAMP_DIR) 17 | foreach(step build ${ARGN}) 18 | list(APPEND force_build_stamps "${STAMP_DIR}/${_target}-${step}") 19 | endforeach() 20 | set(force_build_targets ${force_build_targets} ${_target} PARENT_SCOPE) 21 | set(force_build_stamps "${force_build_stamps}" PARENT_SCOPE) 22 | endfunction() 23 | 24 | if(BUILD_SERVER) 25 | ### 26 | # Host (native, not Android) projects from source 27 | ### 28 | set(HOST_PREFIX_PATH ${CMAKE_PREFIX_PATH}) 29 | 30 | if(TARGET osvr::osvr_json_to_c) 31 | message(STATUS "Using host osvr_json_to_c from build at ${osvr_DIR}") 32 | set(OSVR_JSON_TO_C_COMMAND $) 33 | # dummy target 34 | add_custom_target(osvr_json_to_c_host) 35 | elseif(OSVR_JSON_TO_C_COMMAND AND EXISTS "${OSVR_JSON_TO_C_COMMAND}") 36 | message(STATUS "Using specified host osvr_json_to_c ${OSVR_JSON_TO_C_COMMAND}") 37 | # dummy target 38 | add_custom_target(osvr_json_to_c_host) 39 | else() 40 | # need to build it ourselves 41 | ExternalProject_Add(jsoncpp_host 42 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp" 43 | CMAKE_ARGS 44 | "-DCMAKE_INSTALL_PREFIX=${HOST_INSTALL_DIR}" 45 | -DJSONCPP_WITH_CMAKE_PACKAGE=ON 46 | -DBUILD_SHARED_LIBS=OFF 47 | -DBUILD_STATIC_LIBS=ON 48 | -DJSONCPP_WITH_TESTS=OFF 49 | -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF 50 | "-DCMAKE_PREFIX_PATH=${HOST_PREFIX_PATH}" 51 | BUILD_IN_SOURCE 0) 52 | add_ep_to_force(jsoncpp_host) 53 | list(APPEND HOST_PREFIX_PATH "${HOST_INSTALL_DIR}") 54 | 55 | ExternalProject_Add(osvr_json_to_c_host 56 | DEPENDS jsoncpp_host 57 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/osvr_json_to_c" 58 | CMAKE_ARGS 59 | "-DCMAKE_INSTALL_PREFIX=${HOST_INSTALL_DIR}" 60 | "-DCMAKE_PREFIX_PATH=${HOST_PREFIX_PATH}" 61 | "-DOSVR_CORE_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core") 62 | 63 | set(OSVR_JSON_TO_C_COMMAND "${HOST_INSTALL_DIR}/bin/osvr_json_to_c") 64 | list(APPEND osvr_dep_targets osvr_json_to_c_host) 65 | add_ep_to_force(osvr_json_to_c_host) 66 | endif() 67 | endif() 68 | 69 | ### 70 | # Android Binary SDKs 71 | ### 72 | 73 | # OpenCV has a binary SDK for Android - just download and unpack. 74 | set(OPENCV_VERSION 2.4.11) 75 | set(SHA1 ACFB4789B78752AE5C52CC5C151E2AE3DD006CEF) 76 | set(FN OpenCV-${OPENCV_VERSION}-android-sdk.zip) 77 | # Use our own script to download, since ExternalProject re-downloads too often. 78 | add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FN}" 79 | # Downlaod the file if we need it. 80 | COMMAND "${CMAKE_COMMAND}" 81 | "-DEXTERNAL_LOCATION=${CMAKE_CURRENT_SOURCE_DIR}/${FN}" 82 | "-DLOCAL_LOCATION=${CMAKE_CURRENT_BINARY_DIR}/${FN}" 83 | "-DURL=http://downloads.sourceforge.net/project/opencvlibrary/opencv-android/${OPENCV_VERSION}/${FN}" 84 | "-DSHA1=${SHA1}" 85 | -P "${CMAKE_CURRENT_SOURCE_DIR}/DownloadScript.cmake" 86 | # Once we have it, copy it to the source tree to save download time. 87 | COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${FN}" "${CMAKE_CURRENT_SOURCE_DIR}/${FN}" 88 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/DownloadScript.cmake" 89 | VERBATIM) 90 | add_custom_target(OpenCV_Download DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${FN}") 91 | 92 | ExternalProject_Add(OpenCV 93 | DEPENDS OpenCV_Download 94 | # URL http://downloads.sourceforge.net/project/opencvlibrary/opencv-android/${OPENCV_VERSION}/OpenCV-${OPENCV_VERSION}-android-sdk.zip 95 | URL "${CMAKE_CURRENT_BINARY_DIR}/${FN}" 96 | URL_HASH SHA1=${SHA1} 97 | CONFIGURE_COMMAND "" 98 | BUILD_COMMAND "" 99 | INSTALL_COMMAND "") 100 | 101 | # Find out where OpenCV was extracted so we can extend the prefix path. 102 | ExternalProject_Get_Property(OpenCV SOURCE_DIR) 103 | set(OpenCV_DIR "${SOURCE_DIR}/sdk/native/jni") 104 | 105 | # SDL 2.0 has a source zip file for Android. 106 | #set(SHA1 00b2abe02de0ab1c9565955d56e6ac66bd342c07) 107 | #set(FN SDL2-2.0.4.zip) 108 | # Use our own script to download, since ExternalProject re-downloads too often. 109 | #add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FN}" 110 | # # Downlaod the file if we need it. 111 | # COMMAND "${CMAKE_COMMAND}" 112 | # "-DEXTERNAL_LOCATION=${CMAKE_CURRENT_SOURCE_DIR}/${FN}" 113 | # "-DLOCAL_LOCATION=${CMAKE_CURRENT_BINARY_DIR}/${FN}" 114 | # "-DSHA1=${SHA1}" 115 | # "-DURL=http://www.libsdl.org/release/${FN}" 116 | # "-DANDROID_FORCE_ARM_BUILD=ON" 117 | # -P "${CMAKE_CURRENT_SOURCE_DIR}/DownloadScript.cmake" 118 | # # Once we have it, copy it to the source tree to save download time. 119 | # DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/DownloadScript.cmake" 120 | # VERBATIM) 121 | # add_custom_target(SDL2_Download DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${FN}") 122 | 123 | # Instructions at end of https://wiki.libsdl.org/Android indicate that this 124 | # is experimental but should work (toolchain is defined in the COMMON_CMAKE_ARGS). 125 | # @todo Why is it having a problem finding wchar_t? 126 | #message(STATUS "Making SDL2 with SDL_SHARED=FALSE") 127 | #ExternalProject_Add(SDL2 128 | # URL "${CMAKE_CURRENT_BINARY_DIR}/${FN}" 129 | # URL_HASH SHA1=${SHA1} 130 | # INSTALL_DIR "${ANDROID_INSTALL_DIR}" 131 | # DEPENDS SDL2_Download 132 | # CMAKE_GENERATOR "${ANDROID_GENERATOR}" 133 | # CMAKE_ARGS 134 | # ${COMMON_CMAKE_ARGS} 135 | # -DSDL_SHARED=FALSE 136 | # -C ${CMAKE_CURRENT_SOURCE_DIR}/SDL-add-ons.cmake 137 | #) 138 | 139 | ### 140 | # Conditionally build Boost 141 | ### 142 | if(NOT ANDROID_CRYSTAX_NDK) 143 | # In this case, we need boost. 144 | if(WIN32) 145 | # and msys bash 146 | find_program(SH_COMMAND NAMES bash.exe dash.exe ash.sh sh.exe) 147 | if(NOT SH_COMMAND) 148 | message(FATAL_ERROR "Missing msys sh - needed to build Boost. Either set SH_COMMAND or use the CrystaX NDK (which includes boost)") 149 | endif() 150 | set(SH_COMMAND_ARGS --login -i) 151 | else() 152 | set(SH_COMMAND sh) 153 | set(SH_COMMAND_ARGS) 154 | endif() 155 | ExternalProject_Add(Boost 156 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/boost" 157 | CONFIGURE_COMMAND "" 158 | BUILD_COMMAND "${SH_COMMAND}" ${SH_COMMAND_ARGS} -c "./build-android.sh ${ANDROID_NDK}" 159 | BUILD_IN_SOURCE 1) 160 | # TODO call osvr_android_add_to_common_prefix_path - might be something like this 161 | #ExternalProject_Get_Property(Boost SOURCE_DIR) 162 | #osvr_android_add_to_common_prefix_path("${SOURCE_DIR}") 163 | endif() 164 | 165 | ### 166 | # Android builds from source 167 | ### 168 | 169 | ExternalProject_Add(jsoncpp 170 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/jsoncpp" 171 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 172 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 173 | CMAKE_ARGS 174 | ${COMMON_CMAKE_ARGS} 175 | -DJSONCPP_WITH_CMAKE_PACKAGE=ON 176 | -DBUILD_SHARED_LIBS=ON 177 | -DBUILD_STATIC_LIBS=OFF 178 | "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}" # Have to pass in "host" python 179 | -DJSONCPP_WITH_TESTS=OFF 180 | -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF 181 | # put any others here 182 | BUILD_IN_SOURCE 0) 183 | add_ep_to_force(jsoncpp) 184 | 185 | if(BUILD_SERVER) 186 | ExternalProject_Add(libfunctionality 187 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libfunctionality" 188 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 189 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 190 | CMAKE_ARGS ${COMMON_CMAKE_ARGS} -DBUILD_TESTING=OFF # put any others here 191 | BUILD_IN_SOURCE 0) 192 | list(APPEND osvr_dep_targets libfunctionality) 193 | add_ep_to_force(libfunctionality) 194 | endif() 195 | 196 | if(BUILD_SERVER_PLUGINS) 197 | ExternalProject_Add(libusb 198 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libusb" 199 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 200 | CONFIGURE_COMMAND ${ANDROID_NDK_BUILD_WITH_ARGS} clean -C "/android/jni" 201 | BUILD_COMMAND ${ANDROID_NDK_BUILD_WITH_ARGS} -C "/android/jni" 202 | INSTALL_COMMAND "${CMAKE_COMMAND}" -E make_directory "/include/libusb-1.0" 203 | COMMAND "${CMAKE_COMMAND}" -E copy_if_different "/libusb/libusb.h" "/include/libusb-1.0/libusb.h" 204 | BUILD_IN_SOURCE 0) 205 | list(APPEND osvr_dep_targets libusb) 206 | endif() 207 | 208 | ### 209 | # Flags that will be used not only by OSVR-Core but by any plugins: 210 | 211 | # Must set this, to avoid finding MinGW or other local, native OpenCV's 212 | osvr_android_add_common_cmake_arg("-DOpenCV_DIR=${OpenCV_DIR}") 213 | 214 | # Indicate where osvr_json_to_c is for ease of use 215 | osvr_android_add_common_cmake_arg("-DOSVR_JSON_TO_C_COMMAND=${OSVR_JSON_TO_C_COMMAND}") 216 | 217 | 218 | ExternalProject_Add(OSVR-Core 219 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core" 220 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 221 | DEPENDS jsoncpp OpenCV ${osvr_dep_targets} 222 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 223 | CMAKE_ARGS 224 | ${COMMON_CMAKE_ARGS} 225 | "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}" # Have to pass in "host" python TODO is this actually needed? 226 | "-DLIBUSB1_LIBRARY=${ANDROID_INSTALL_DIR}/lib/libusb1.0.so" # TODO cmake should be able to find this for us. 227 | "-DVRPN_HIDAPI_SOURCE_ROOT=${CMAKE_CURRENT_SOURCE_DIR}/hidapi" # Let VRPN build HIDAPI for us. 228 | ${OSVR_CORE_PASSTHROUGH_OPTIONS} 229 | BUILD_IN_SOURCE 0) 230 | add_ep_to_force(OSVR-Core) 231 | 232 | ExternalProject_Add(OSVR-RenderManager 233 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/OSVR-RenderManager" 234 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 235 | DEPENDS OSVR-Core #SDL2 236 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 237 | CMAKE_ARGS 238 | ${COMMON_CMAKE_ARGS} 239 | "-DEIGEN3_INCLUDE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core/vendor/eigen" 240 | "-DVRPN_INCLUDE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core/vendor/vrpn" 241 | "-DVRPN_LIBRARY:PATH=${CMAKE_CURRENT_BINARY_DIR}/OSVR-Core-prefix/src/OSVR-Core-build/bin/libvrpnserver.a" 242 | "-DQUATLIB_INCLUDE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core/vendor/vrpn/quat" 243 | "-DQUATLIB_LIBRARY:PATH=${CMAKE_CURRENT_BINARY_DIR}/OSVR-Core-prefix/src/OSVR-Core-build/bin/libquat.a" 244 | "-DCMAKE_CXX_FLAGS:STRING=-std=c++11" 245 | BUILD_IN_SOURCE 0) 246 | add_ep_to_force(OSVR-RenderManager) 247 | 248 | ExternalProject_Add(OSVR-Unity-Rendering 249 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Unity-Rendering" 250 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 251 | DEPENDS OSVR-Core OSVR-RenderManager #SDL2 252 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 253 | CMAKE_ARGS 254 | ${COMMON_CMAKE_ARGS} 255 | "-DEIGEN3_INCLUDE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core/vendor/eigen" 256 | "-DVRPN_INCLUDE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core/vendor/vrpn" 257 | "-DVRPN_LIBRARY:PATH=${CMAKE_CURRENT_BINARY_DIR}/OSVR-Core-prefix/src/OSVR-Core-build/bin/libvrpnserver.a" 258 | "-DQUATLIB_INCLUDE_DIR:PATH=${CMAKE_CURRENT_SOURCE_DIR}/OSVR-Core/vendor/vrpn/quat" 259 | "-DQUATLIB_LIBRARY:PATH=${CMAKE_CURRENT_BINARY_DIR}/OSVR-Core-prefix/src/OSVR-Core-build/bin/libquat.a" 260 | "-DCMAKE_CXX_FLAGS:STRING=-std=c++11" 261 | BUILD_IN_SOURCE 0) 262 | add_ep_to_force(OSVR-Unity-Rendering) 263 | 264 | if(BUILD_SERVER_PLUGINS) 265 | ExternalProject_Add(android_sensor_tracker 266 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android_sensor_tracker/com_osvr_android_sensorTracker" 267 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 268 | DEPENDS OSVR-Core 269 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 270 | CMAKE_ARGS 271 | ${COMMON_CMAKE_ARGS} 272 | BUILD_IN_SOURCE 0) 273 | add_ep_to_force(android_sensor_tracker) 274 | 275 | ExternalProject_Add(org_osvr_android_moverio 276 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android_sensor_tracker/org_osvr_android_moverio" 277 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 278 | DEPENDS OSVR-Core 279 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 280 | CMAKE_ARGS 281 | ${COMMON_CMAKE_ARGS} 282 | BUILD_IN_SOURCE 0) 283 | add_ep_to_force(org_osvr_android_moverio) 284 | 285 | ExternalProject_Add(jniImaging 286 | SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android_sensor_tracker/com_osvr_android_jniImaging" 287 | INSTALL_DIR "${ANDROID_INSTALL_DIR}" 288 | DEPENDS OSVR-Core 289 | CMAKE_GENERATOR "${ANDROID_GENERATOR}" 290 | CMAKE_ARGS 291 | ${COMMON_CMAKE_ARGS} 292 | BUILD_IN_SOURCE 0) 293 | add_ep_to_force(jniImaging) 294 | endif() 295 | 296 | # Add the custom target to delete the build stamps 297 | add_custom_target(force_rebuild 298 | COMMAND "${CMAKE_COMMAND}" -E remove -f ${force_build_stamps} 299 | COMMENT "Clearing build stamps to force rebuild of:\n${force_build_targets}" 300 | VERBATIM) 301 | 302 | set_target_properties(force_rebuild 303 | PROPERTIES 304 | EXCLUDE_FROM_ALL 305 | TRUE) 306 | message(STATUS "To tell the build system to proceed to build a subproject that you might have changed directly, build the force_rebuild target then the target you want.") 307 | message(STATUS "Projects: ${force_build_targets}") 308 | 309 | configure_file(packaging/setup.sh ${ANDROID_INSTALL_DIR}/setup.sh COPYONLY) 310 | configure_file(packaging/launcher.sh ${ANDROID_INSTALL_DIR}/bin/launcher.sh COPYONLY) 311 | configure_file(InstallTreeSuperBuildPrefix.cmake ${ANDROID_INSTALL_DIR}/lib/cmake/osvr/osvrConfigSuperBuildPrefix.cmake COPYONLY) 312 | install(DIRECTORY ${ANDROID_INSTALL_DIR}/bin/ DESTINATION bin) 313 | install(DIRECTORY ${ANDROID_INSTALL_DIR}/lib/ DESTINATION lib 314 | FILES_MATCHING 315 | PATTERN *.so) 316 | install(DIRECTORY ${ANDROID_INSTALL_DIR}/share/osvrcore/ DESTINATION share/osvrcore 317 | FILES_MATCHING 318 | PATTERN *.json) 319 | install(PROGRAMS ${ANDROID_INSTALL_DIR}/setup.sh DESTINATION .) 320 | -------------------------------------------------------------------------------- /src/DownloadScript.cmake: -------------------------------------------------------------------------------- 1 | # input: 2 | # SHA1 - the SHA1 hash of the file 3 | # EXTERNAL_LOCATION - an optional variable, for if the user wants to specify where they already have the file. 4 | # LOCAL_LOCATION - where the file should be downloaded or copied to. 5 | # URL - the download location. 6 | string(TOLOWER "${SHA1}" SHA1) 7 | 8 | message(STATUS "SHA1 ${SHA1}") 9 | message(STATUS "LOCAL_LOCATION ${LOCAL_LOCATION}") 10 | 11 | if(EXISTS "${LOCAL_LOCATION}") 12 | file(SHA1 "${LOCAL_LOCATION}" _actual_hash) 13 | string(TOLOWER "${_actual_hash}" _actual_hash) 14 | if("${_actual_hash}" STREQUAL "${SHA1}") 15 | message(STATUS "Already-downloaded file ${LOCAL_LOCATION} matches expected hash, using it.") 16 | #set(_FILE_LOCATION "${LOCAL_LOCATION}") 17 | return() 18 | else() 19 | message(STATUS "Already-downloaded file ${LOCAL_LOCATION} exists but does not match hash (actual ${_actual_hash}).") 20 | endif() 21 | endif() 22 | 23 | 24 | message(STATUS "EXTERNAL_LOCATION ${EXTERNAL_LOCATION}") 25 | if(EXTERNAL_LOCATION AND EXISTS "${EXTERNAL_LOCATION}") 26 | file(SHA1 "${EXTERNAL_LOCATION}" _actual_hash) 27 | string(TOLOWER "${_actual_hash}" _actual_hash) 28 | if("${_actual_hash}" STREQUAL "${SHA1}") 29 | message(STATUS "File ${EXTERNAL_LOCATION} matches expected hash, using it.") 30 | #set(_FILE_LOCATION "${EXTERNAL_LOCATION}") 31 | execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${EXTERNAL_LOCATION}" "${LOCAL_LOCATION}") 32 | return() 33 | else() 34 | message(STATUS "Externally-specified file ${EXTERNAL_LOCATION} exists but does not match hash.") 35 | endif() 36 | endif() 37 | 38 | 39 | message(STATUS "Downloading from ${URL}") 40 | set(_DL_DEST "${LOCAL_LOCATION}.tmp") 41 | file(DOWNLOAD 42 | "${URL}" 43 | "${_DL_DEST}" 44 | STATUS _status 45 | LOG _log) 46 | list(GET _status 0 _status_code) 47 | list(GET _status 1 _status_string) 48 | if(NOT _status_code EQUAL 0) 49 | message(FATAL_ERROR "error: downloading '${URL}' failed 50 | status_code: ${_status_code} 51 | status_string: ${_status_string} 52 | log: ${_log}") 53 | endif() 54 | message(STATUS "Download complete, checking hash.") 55 | file(SHA1 "${_DL_DEST}" _actual_hash) 56 | string(TOLOWER "${_actual_hash}" _actual_hash) 57 | if(_actual_hash STREQUAL "${SHA1}") 58 | message(STATUS "Download complete, hash matches.") 59 | execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${_DL_DEST}" "${LOCAL_LOCATION}") 60 | #set(_FILE_LOCATION "${LOCAL_LOCATION}") 61 | else() 62 | message(FATAL_ERROR "Download completed successfully, but hash did not match!") 63 | endif() 64 | -------------------------------------------------------------------------------- /src/InstallTreeSuperBuildPrefix.cmake: -------------------------------------------------------------------------------- 1 | # Injected by OSVR-Android-Build. 2 | # We might be in an install directory with a host-install peer directory, 3 | # where a host-executable osvr_json_to_c might live. 4 | 5 | # Compute the installation prefix relative to this file. 6 | get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) 7 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 8 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 9 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 10 | 11 | set(_OSVR_POSSIBLE_OSVR_JSON_TO_C_LOCATION "${_IMPORT_PREFIX}/../host-install/bin/osvr_json_to_c") 12 | if(CMAKE_HOST_WIN32) 13 | set(_OSVR_POSSIBLE_OSVR_JSON_TO_C_LOCATION "${_OSVR_POSSIBLE_OSVR_JSON_TO_C_LOCATION}.exe") 14 | endif() 15 | if(EXISTS "${_OSVR_POSSIBLE_OSVR_JSON_TO_C_LOCATION}") 16 | # By just setting in cache, this allows an override, if desired. 17 | set(OSVR_JSON_TO_C_EXECUTABLE "${_OSVR_POSSIBLE_OSVR_JSON_TO_C_LOCATION}" CACHE FILEPATH "") 18 | endif() 19 | -------------------------------------------------------------------------------- /src/SDL-add-ons.cmake: -------------------------------------------------------------------------------- 1 | # Set an environment variable defining another C flag, which is needed for compiling. 2 | set(ENV{CFLAGS} "-DGL_GLEXT_PROTOTYPES") 3 | 4 | -------------------------------------------------------------------------------- /src/SDL2-2.0.4.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSVR/OSVR-Android-Build/eb64aab31dbb2842b69df931a1d8333df81f2884/src/SDL2-2.0.4.zip -------------------------------------------------------------------------------- /src/osvr_json_to_c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # A silly build file to build just the osvr_json_to_c tool out of an OSVR-Core source directory. 2 | cmake_minimum_required(VERSION 3.0) 3 | project(osvr_json_to_c) 4 | 5 | ### 6 | # Make sure we have OSVR-Core source 7 | ### 8 | find_path(OSVR_CORE_SOURCE_DIR devtools/osvr_json_to_c.cpp) 9 | if(NOT OSVR_CORE_SOURCE_DIR OR NOT EXISTS "${OSVR_CORE_SOURCE_DIR}/devtools/osvr_json_to_c.cpp") 10 | message(FATAL_ERROR "Need OSVR_CORE_SOURCE_DIR set to the root of an OSVR-Core source tree!") 11 | endif() 12 | 13 | ### 14 | # Some setup from the main OSVR-Core build system 15 | ### 16 | list(APPEND CMAKE_MODULE_PATH "${OSVR_CORE_SOURCE_DIR}/cmake" "${OSVR_CORE_SOURCE_DIR}/cmake-local" "${OSVR_CORE_SOURCE_DIR}") 17 | include(MapImportedReleaseVariants) 18 | include(MSVCMultipleProcessCompile) 19 | 20 | include(SetDefaultBuildType) 21 | set_default_build_type(RelWithDebInfo) 22 | 23 | include(CMakeBoostHelper) 24 | if(WIN32) 25 | option(Boost_USE_STATIC_LIBS "Build with Boost's static libraries?" ON) 26 | endif() 27 | 28 | ### 29 | # Deps 30 | ### 31 | find_package(jsoncpp REQUIRED) 32 | if(TARGET jsoncpp_lib_static AND NOT TARGET jsoncpp_lib) 33 | add_library(jsoncpp_lib INTERFACE) 34 | target_link_libraries(jsoncpp_lib INTERFACE jsoncpp_lib_static) 35 | endif() 36 | find_package(Boost REQUIRED COMPONENTS program_options) 37 | 38 | ### 39 | # Build and install 40 | ### 41 | add_executable(osvr_json_to_c "${OSVR_CORE_SOURCE_DIR}/devtools/osvr_json_to_c.cpp") 42 | 43 | target_include_directories(osvr_json_to_c PRIVATE ${Boost_INCLUDE_DIRS}) 44 | target_link_libraries(osvr_json_to_c jsoncpp_lib ${Boost_PROGRAM_OPTIONS_LIBRARIES}) 45 | install(TARGETS osvr_json_to_c 46 | RUNTIME DESTINATION bin) 47 | -------------------------------------------------------------------------------- /src/packaging/launcher.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | root=$(cd $(dirname $0) && pwd) 3 | app=$(basename $0) 4 | realapp=${root}/bin/${app} 5 | echo "root=${root} -- app=${app}" 6 | ( 7 | cd ${root}/bin 8 | LD_LIBRARY_PATH=${root}/lib:${LD_LIBRARY_PATH} ${realapp} "$@" 9 | ) -------------------------------------------------------------------------------- /src/packaging/setup.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh -x 2 | root=$(cd $(dirname $0) && pwd) 3 | launcher=${root}/bin/launcher.sh 4 | TOOLBOX=$(which toolbox) 5 | if which chmod > /dev/null; then 6 | CHMOD=$(which chmod) 7 | else 8 | CHMOD="${TOOLBOX} chmod" 9 | fi 10 | 11 | 12 | if which ln > /dev/null; then 13 | LN=$(which ln) 14 | else 15 | LN="${TOOLBOX} ln" 16 | fi 17 | 18 | make_executable() { 19 | $CHMOD 775 $@ 20 | } 21 | 22 | make_executable ${launcher} 23 | 24 | for app in osvr_server osvr_print_tree AnalogCallback_cpp ButtonCallback_cpp DisplayParameter_cpp PathTreeExport TrackerCallback_cpp; do 25 | if [ -e ${root}/bin/${app} ]; then 26 | make_executable ${root}/bin/${app} 27 | rm -f ${root}/${app} 28 | $LN -s ${launcher} ${root}/${app} 29 | make_executable ${root}/${app} 30 | else 31 | rm -f ${root}/${app} 32 | fi 33 | done 34 | --------------------------------------------------------------------------------