[Bf-blender-cvs] [58568d1] HMD_viewport: HMD: Add support of lazil loading udev library

Sergey Sharybin noreply at git.blender.org
Fri Mar 25 10:42:16 CET 2016


Commit: 58568d1bd3824bf7b847ab55952759426afc23f6
Author: Sergey Sharybin
Date:   Fri Mar 25 10:26:01 2016 +0100
Branches: HMD_viewport
https://developer.blender.org/rB58568d1bd3824bf7b847ab55952759426afc23f6

HMD: Add support of lazil loading udev library

This way we can statically link against hidapi libraries but dont'
require static linking against udev or even having specific ABI
version of this library installed on the client machine.

For now the following libraries will try to be loaded:
  libudev.so, libudev.so.0, libudev.so.1 and libudev.so.2

Not future proof since it might be version 3 of udev releases
eventually, good enough for the beginning. We can simply do a
for-loop to query like 100 of ABIs.

Udev wrangler is a bit different from other wranglers we've got,
it has wrapper functions around dlopen-ed symbols, so you can't
check directly if function was loaded or not, but this is the
only way to make external libraries working fine with wrangler
without need of re-compiling the library.

===================================================================

M	CMakeLists.txt
M	build_files/buildbot/config/blender_linux.cmake
M	build_files/cmake/macros.cmake
M	extern/CMakeLists.txt
A	extern/udew/CMakeLists.txt
A	extern/udew/LICENSE
A	extern/udew/README
A	extern/udew/auto/libudev.h
A	extern/udew/auto/udew_gen.sh
A	extern/udew/include/udew.h
A	extern/udew/src/udew.c
M	intern/ghost/CMakeLists.txt
M	intern/ghost/intern/GHOST_OpenHMDManager.cpp

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2823b18..7114f55 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -353,7 +353,11 @@ if(WIN32)
 	option(WITH_INPUT_IME "Enable Input Method Editor (IME) for complex Asian character input" ON)
 endif()
 option(WITH_INPUT_NDOF "Enable NDOF input devices (SpaceNavigator and friends)" ${_init_INPUT_NDOF})
+
 option(WITH_OPENHMD "Enable OpenHMD support in Blender (Head Mounted Displays for VR support)" ON)
+option(WITH_OPENHMD_DYNLOAD "Dynamically load OpenHMD dependencies at runtime" OFF)
+mark_as_advanced(WITH_OPENHMD_DYNLOAD)
+
 option(WITH_RAYOPTIMIZATION	"Enable use of SIMD (SSE) optimizations for the raytracer" ON)
 if(UNIX AND NOT APPLE)
 	option(WITH_INSTALL_PORTABLE "Install redistributeable runtime, otherwise install into CMAKE_INSTALL_PREFIX" ON)
diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake
index 81c7ff0..916626a 100644
--- a/build_files/buildbot/config/blender_linux.cmake
+++ b/build_files/buildbot/config/blender_linux.cmake
@@ -139,13 +139,13 @@ set(OPENVDB_LIBRARY
 	CACHE BOOL "" FORCE
 )
 
-# HMD
+# OpenHMD
 if(GLIBC EQUAL "2.19")
 	set(HIDAPI_LIBRARY
 		/usr/lib${MULTILIB}/libhidapi-hidraw.a
-		/usr/lib/x86_64-linux-gnu/libudev.so
 		CACHE STRING "" FORCE
 	)
+	set(WITH_OPENHMD_DYNLOAD ON CACHE BOOL "" FORCE)
 endif()
 
 # Additional linking libraries
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 1d487b7..4909294 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -476,9 +476,9 @@ function(setup_liblinks
 		endif()
 	endif()
 
-    if(WITH_OPENHMD)
+	if(WITH_OPENHMD)
 		target_link_libraries(${target} ${OPENHMD_LIBRARIES} ${HIDAPI_LIBRARY})
-    endif()
+	endif()
 
 	# We put CLEW and CUEW here because OPENSUBDIV_LIBRARIES dpeends on them..
 	if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
@@ -489,6 +489,9 @@ function(setup_liblinks
 			target_link_libraries(${target} ${CUDA_CUDA_LIBRARY})
 		endif()
 	endif()
+	if(WITH_OPENHMD AND WITH_OPENHMD_DYNLOAD)
+		target_link_libraries(${target} "extern_udew")
+	endif()
 
 	#system libraries with no dependencies such as platform link libs or opengl should go last
 	target_link_libraries(${target}
diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt
index 9e6dc14..fd3e1df 100644
--- a/extern/CMakeLists.txt
+++ b/extern/CMakeLists.txt
@@ -75,6 +75,10 @@ if(WITH_CYCLES OR WITH_COMPOSITOR OR WITH_OPENSUBDIV)
 	endif()
 endif()
 
+if(WITH_OPENHMD AND WITH_OPENHMD_DYNLOAD)
+	add_subdirectory(udew)
+endif()
+
 if(WITH_MOD_BOOLEAN)
 	add_subdirectory(carve)
 endif()
diff --git a/extern/udew/CMakeLists.txt b/extern/udew/CMakeLists.txt
new file mode 100644
index 0000000..f69eede
--- /dev/null
+++ b/extern/udew/CMakeLists.txt
@@ -0,0 +1,38 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2016, Blender Foundation
+# All rights reserved.
+#
+# Contributor(s): Sergey Sharybin.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+	include
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+	include/udew.h
+	src/udew.c
+)
+
+blender_add_lib(extern_udew "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/extern/udew/LICENSE b/extern/udew/LICENSE
new file mode 100644
index 0000000..c753309
--- /dev/null
+++ b/extern/udew/LICENSE
@@ -0,0 +1,174 @@
+
+                               Modified Apache 2.0 License
+
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list