Commit: 80d1d624d378d4d8c03fb26ef286baf5479b6497 Author: Sergey Sharybin Date: Mon Nov 17 16:35:36 2014 +0500 Branches: master https://developer.blender.org/rB80d1d624d378d4d8c03fb26ef286baf5479b6497
Support dynamic loading of SDL libraries This is mainly to address old issue when one need to have SDL library installed in order to use our official builds. Some hip distros already installs SDL, but it's not quite the same across all the variety of the distros. We also now switching to SDL-2.0, most of the distros have it in repositories already, so it shouldn't be huge deal to install it if needed. Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D878 =================================================================== M CMakeLists.txt M SConstruct M build_files/cmake/macros.cmake M build_files/scons/config/linux-config.py M build_files/scons/tools/Blender.py M build_files/scons/tools/btools.py M extern/CMakeLists.txt M extern/SConscript A extern/sdlew/CMakeLists.txt A extern/sdlew/SConscript A extern/sdlew/auto/sdlew_gen.sh A extern/sdlew/auto/strip_comments.sh A extern/sdlew/include/SDL2/SDL.h A extern/sdlew/include/SDL2/SDL_assert.h A extern/sdlew/include/SDL2/SDL_atomic.h A extern/sdlew/include/SDL2/SDL_audio.h A extern/sdlew/include/SDL2/SDL_bits.h A extern/sdlew/include/SDL2/SDL_blendmode.h A extern/sdlew/include/SDL2/SDL_clipboard.h A extern/sdlew/include/SDL2/SDL_config.h A extern/sdlew/include/SDL2/SDL_cpuinfo.h A extern/sdlew/include/SDL2/SDL_endian.h A extern/sdlew/include/SDL2/SDL_error.h A extern/sdlew/include/SDL2/SDL_events.h A extern/sdlew/include/SDL2/SDL_gamecontroller.h A extern/sdlew/include/SDL2/SDL_gesture.h A extern/sdlew/include/SDL2/SDL_haptic.h A extern/sdlew/include/SDL2/SDL_hints.h A extern/sdlew/include/SDL2/SDL_joystick.h A extern/sdlew/include/SDL2/SDL_keyboard.h A extern/sdlew/include/SDL2/SDL_keycode.h A extern/sdlew/include/SDL2/SDL_loadso.h A extern/sdlew/include/SDL2/SDL_log.h A extern/sdlew/include/SDL2/SDL_main.h A extern/sdlew/include/SDL2/SDL_messagebox.h A extern/sdlew/include/SDL2/SDL_mouse.h A extern/sdlew/include/SDL2/SDL_mutex.h A extern/sdlew/include/SDL2/SDL_name.h A extern/sdlew/include/SDL2/SDL_opengl.h A extern/sdlew/include/SDL2/SDL_opengles.h A extern/sdlew/include/SDL2/SDL_opengles2.h A extern/sdlew/include/SDL2/SDL_pixels.h A extern/sdlew/include/SDL2/SDL_platform.h A extern/sdlew/include/SDL2/SDL_power.h A extern/sdlew/include/SDL2/SDL_quit.h A extern/sdlew/include/SDL2/SDL_rect.h A extern/sdlew/include/SDL2/SDL_render.h A extern/sdlew/include/SDL2/SDL_revision.h A extern/sdlew/include/SDL2/SDL_rwops.h A extern/sdlew/include/SDL2/SDL_scancode.h A extern/sdlew/include/SDL2/SDL_shape.h A extern/sdlew/include/SDL2/SDL_stdinc.h A extern/sdlew/include/SDL2/SDL_surface.h A extern/sdlew/include/SDL2/SDL_system.h A extern/sdlew/include/SDL2/SDL_syswm.h A extern/sdlew/include/SDL2/SDL_test.h A extern/sdlew/include/SDL2/SDL_test_assert.h A extern/sdlew/include/SDL2/SDL_test_common.h A extern/sdlew/include/SDL2/SDL_test_compare.h A extern/sdlew/include/SDL2/SDL_test_crc32.h A extern/sdlew/include/SDL2/SDL_test_font.h A extern/sdlew/include/SDL2/SDL_test_fuzzer.h A extern/sdlew/include/SDL2/SDL_test_harness.h A extern/sdlew/include/SDL2/SDL_test_images.h A extern/sdlew/include/SDL2/SDL_test_log.h A extern/sdlew/include/SDL2/SDL_test_md5.h A extern/sdlew/include/SDL2/SDL_test_random.h A extern/sdlew/include/SDL2/SDL_thread.h A extern/sdlew/include/SDL2/SDL_timer.h A extern/sdlew/include/SDL2/SDL_touch.h A extern/sdlew/include/SDL2/SDL_types.h A extern/sdlew/include/SDL2/SDL_version.h A extern/sdlew/include/SDL2/SDL_video.h A extern/sdlew/include/SDL2/begin_code.h A extern/sdlew/include/SDL2/close_code.h A extern/sdlew/include/sdlew.h A extern/sdlew/src/sdlew.c A extern/sdlew/src/sdlew.map M intern/audaspace/intern/AUD_C-API.cpp M source/blender/makesrna/SConscript M source/blender/makesrna/intern/CMakeLists.txt M source/blender/makesrna/intern/SConscript M source/blender/makesrna/intern/rna_userdef.c M source/blenderplayer/CMakeLists.txt M source/creator/CMakeLists.txt M source/creator/blender.map M source/creator/creator.c M source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp M source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp M source/gameengine/GamePlayer/ghost/CMakeLists.txt M source/gameengine/GamePlayer/ghost/GPG_ghost.cpp M source/gameengine/GamePlayer/ghost/SConscript =================================================================== diff --git a/CMakeLists.txt b/CMakeLists.txt index b9e38c3..924684c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -296,6 +296,9 @@ option(WITH_JACK "Enable Jack Support (http://www.jackaudio.org)" ${_in if(UNIX AND NOT APPLE) option(WITH_JACK_DYNLOAD "Enable runtime dynamic Jack libraries loading" OFF) endif() +if(UNIX AND NOT APPLE) + option(WITH_SDL_DYNLOAD "Enable runtime dynamic SDL libraries loading" OFF) +endif() # Compression option(WITH_LZO "Enable fast LZO compression (used for pointcache)" ON) @@ -826,16 +829,23 @@ if(UNIX AND NOT APPLE) endif() if(WITH_SDL) - find_package_wrapper(SDL) - mark_as_advanced( - SDLMAIN_LIBRARY - SDL_INCLUDE_DIR - SDL_LIBRARY - SDL_LIBRARY_TEMP - ) - # unset(SDLMAIN_LIBRARY CACHE) - if(NOT SDL_FOUND) - set(WITH_SDL OFF) + if(WITH_SDL_DYNLOAD) + set(SDLMAIN_LIBRARY) + set(SDL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/extern/sdlew/include/SDL2") + set(SDL_LIBRARY) + set(SDL_LIBRARY_TEMP) + else() + find_package_wrapper(SDL) + mark_as_advanced( + SDLMAIN_LIBRARY + SDL_INCLUDE_DIR + SDL_LIBRARY + SDL_LIBRARY_TEMP + ) + # unset(SDLMAIN_LIBRARY CACHE) + if(NOT SDL_FOUND) + set(WITH_SDL OFF) + endif() endif() endif() @@ -1040,6 +1050,9 @@ if(UNIX AND NOT APPLE) message(FATAL_ERROR "LLVM not found.") endif() + endif() + + if(WITH_LLVM OR WITH_SDL_DYNLOAD) # Fix for conflict with Mesa llvmpipe set(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--version-script=${CMAKE_SOURCE_DIR}/source/creator/blender.map") endif() @@ -2739,6 +2752,7 @@ if(FIRST_RUN) info_cfg_text("Audio:") info_cfg_option(WITH_OPENAL) info_cfg_option(WITH_SDL) + info_cfg_option(WITH_SDL_DYNLOAD) info_cfg_option(WITH_JACK) info_cfg_option(WITH_JACK_DYNLOAD) info_cfg_option(WITH_CODEC_AVI) diff --git a/SConstruct b/SConstruct index 599ea9b..dc60400 100644 --- a/SConstruct +++ b/SConstruct @@ -218,6 +218,8 @@ else: if not env['BF_FANCY']: B.bc.disable() +if env['WITH_BF_SDL_DYNLOAD']: + env['BF_SDL_INC'] = '#extern/sdlew/include/SDL2' # remove install dir so old and new files are not mixed. # NOTE: only do the scripts directory for now, otherwise is too disruptive for developers diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index a6f9b2b..40bea5e 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -221,7 +221,7 @@ macro(SETUP_LIBDIRS) if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs link_directories(${PYTHON_LIBPATH}) endif() - if(WITH_SDL) + if(WITH_SDL AND NOT WITH_SDL_DYNLOAD) link_directories(${SDL_LIBPATH}) endif() if(WITH_CODEC_FFMPEG) @@ -321,7 +321,7 @@ macro(setup_liblinks if(WITH_CODEC_SNDFILE) target_link_libraries(${target} ${SNDFILE_LIBRARIES}) endif() - if(WITH_SDL) + if(WITH_SDL AND NOT WITH_SDL_DYNLOAD) target_link_libraries(${target} ${SDL_LIBRARY}) endif() if(WITH_CODEC_QUICKTIME) @@ -559,6 +559,7 @@ macro(SETUP_BLENDER_SORTED_LIBS) extern_wcwidth extern_libmv extern_glog + extern_sdlew bf_intern_glew_mx ) diff --git a/build_files/scons/config/linux-config.py b/build_files/scons/config/linux-config.py index d460ece..7438aaa 100644 --- a/build_files/scons/config/linux-config.py +++ b/build_files/scons/config/linux-config.py @@ -262,6 +262,6 @@ BF_INSTALLDIR='../install/linux' #Link against pthread PLATFORM_LINKFLAGS = ['-pthread'] -#Fix for LLVM conflict with Mesa llvmpipe -if WITH_BF_LLVM: - PLATFORM_LINKFLAGS += ['-Wl,--version-script=source/creator/blender.map'] +#Fix for LLVM conflict with Mesa llvmpipe, SDL dynload also requires symbols to be hidden. +# TODO(sergey): Move this to SConstruct, so we can have this line depended on user config. +PLATFORM_LINKFLAGS += ['-Wl,--version-script=source/creator/blender.map'] diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index f5118da..afcc1d0 100755 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -143,7 +143,7 @@ def setup_staticlibs(lenv): libincs += Split(lenv['BF_FREETYPE_LIBPATH']) if lenv['WITH_BF_PYTHON']: libincs += Split(lenv['BF_PYTHON_LIBPATH']) - if lenv['WITH_BF_SDL']: + if lenv['WITH_BF_SDL'] and not lenv['WITH_BF_SDL_DYNLOAD']: libincs += Split(lenv['BF_SDL_LIBPATH']) if lenv['WITH_BF_JACK'] and not lenv['WITH_BF_JACK_DYNLOAD']: libincs += Split(lenv['BF_JACK_LIBPATH']) @@ -303,7 +303,7 @@ def setup_syslibs(lenv): if lenv['WITH_BF_ELTOPO']: syslibs += Split(lenv['BF_LAPACK_LIB']) ''' - if lenv['WITH_BF_SDL']: + if lenv['WITH_BF_SDL'] and not lenv['WITH_BF_SDL_DYNLOAD']: syslibs += Split(lenv['BF_SDL_LIB']) if not lenv['WITH_BF_STATICOPENGL']: syslibs += Split(lenv['BF_OPENGL_LIB']) @@ -381,6 +381,9 @@ def creator(env): defs.append('WITH_BINRELOC') if env['WITH_BF_SDL']: + if env['WITH_BF_SDL_DYNLOAD']: + defs.append('WITH_SDL_DYNLOAD') + incs.append('#/extern/sdlew/include') defs.append('WITH_SDL') if env['WITH_BF_LIBMV']: diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index aff8ac4..7857b7b 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -108,7 +108,7 @@ def validate_arguments(args, bc): opts_list = [ 'WITH_BF_FREESTYLE', 'WITH_BF_PYTHON', 'WITH_BF_PYTHON_SAFETY', 'WITH_BF_PYTHON_SECURITY', 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'BF_PYTHON_LIBPATH_ARCH', 'WITH_BF_STATICPYTHON', 'WITH_OSX_STATICPYTHON', 'BF_PYTHON_LIB_STATIC', 'BF_PYTHON_DLL', 'BF_PYTHON_ABI_FLAGS', 'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH', 'WITH_BF_STATICOPENAL', 'BF_OPENAL_LIB_STATIC', - 'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH', + 'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH', 'WITH_BF_SDL_DYNLOAD', 'WITH_BF_JACK', 'BF_JACK', 'BF_JACK_INC', 'BF_JACK_LIB', 'BF_JACK_LIBPATH', 'WITH_BF_JACK_DYNLOAD', 'WITH_BF_SNDFILE', 'BF_SNDFILE', 'BF_SNDFILE_INC', 'BF_SNDFILE_LIB', 'BF_SNDFILE_LIBPATH', 'WITH_BF_STATICSNDFILE', 'BF_SNDFILE_LIB_STATIC', 'BF_PTHREADS', 'BF_PTHREADS_INC', 'BF_PTHREADS_LIB', 'BF_PTHREADS_LIBPATH', @@ -300,6 +300,7 @@ def read_opts(env, cfg, args): ('BF_SDL_INC', 'SDL include path', ''), ('BF_SDL_LIB', 'SDL library', ''), ('BF_SDL_LIBPATH', 'SDL library path', ''), + (BoolVariable('WITH_BF_SDL_DYNLOAD', 'Enable runtime dynamic SDL libraries loading (works only on Linux)', False)), (BoolVariable('WITH_BF_JACK', 'Enable jack support if true', True)), ('BF_JACK', 'jack base path', ''), diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 7e91e19..0ea8aa1 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -90,3 +90,7 @@ endif() if(WITH_GTESTS) add_subdirectory(gtest) endif() + +if(WITH_SDL AND WITH_SDL_DYNLOAD) + add_subdirectory(sdlew) +endif() diff --git a/extern/SConscript b/extern/SConscript index f6b328e..1f94f50 100644 --- a/extern/SConscript +++ b/extern/SConscript @@ -50,3 +50,6 @@ if env['WITH_GHOST_XDND']: # FreeBSD doesn't seems to support XDND protocol if env['OURPLATFORM'] in ('linux', 'openbsd3', 'sunos5', 'aix4', 'aix5'): SConscript(['xdnd/SConscript']) + +if env['WITH_BF_SDL'] and env['WITH_BF_SDL_DYNLOAD']: + SConscript(['sdlew/SConscript']) diff --git a/extern/sdlew/CMakeLists.txt b/extern/sdlew/CMakeLists.txt new file mode 100644 index 0000000..8571ad9 --- /dev/null +++ b/extern/sdlew/CMakeLists.txt @@ -0,0 +1,40 @@ +# ***** 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) 2006, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +set(INC + . + include +) + +set(INC_SYS + +) + +set(SRC + include/sdlew.h + src/sdlew.c +) + +blender_add_lib(extern_sdlew "${SRC}" "${INC}" "${INC_SYS}") diff --git a/extern/sdlew/SConscript b/extern/sdlew/SConscript new file mode 100644 index 0000000..287f9c0 --- /dev/null +++ b/extern/sdlew/SConscript @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# +# ***** 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) 2014, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Sergey Sharybin. +# +# ***** END GPL LICENSE BLOCK ***** + +Import ('env') + +sources = env.Glob('src/sdlew.c') + +incs = 'include' +de @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] http://lists.blender.org/mailman/listinfo/bf-blender-cvs
