Revision: 37175
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37175
Author:   campbellbarton
Date:     2011-06-04 14:12:55 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
CMake option 'WITH_HEADLESS' to build blender in headless mode (no x11/xlib) 
with NULL ghost classe.

Modified Paths:
--------------
    trunk/blender/CMakeLists.txt
    trunk/blender/intern/ghost/CMakeLists.txt
    trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp
    trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp
    trunk/blender/source/creator/CMakeLists.txt
    trunk/blender/source/creator/creator.c

Added Paths:
-----------
    trunk/blender/intern/ghost/intern/GHOST_DisplayManagerNULL.h
    trunk/blender/intern/ghost/intern/GHOST_SystemNULL.h
    trunk/blender/intern/ghost/intern/GHOST_WindowNULL.h

Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt        2011-06-04 14:10:34 UTC (rev 37174)
+++ trunk/blender/CMakeLists.txt        2011-06-04 14:12:55 UTC (rev 37175)
@@ -98,6 +98,10 @@
 option(WITH_BULLET        "Enable Bullet (Physics Engine)" ON)
 option(WITH_GAMEENGINE    "Enable Game Engine" ON)
 option(WITH_PLAYER        "Build Player" OFF)
+
+option(WITH_HEADLESS      "Build without graphical support (renderfarm, server 
mode only)" OFF)
+mark_as_advanced(WITH_HEADLESS)
+
 # (unix defaults to OpenMP On)
 if(UNIX AND NOT APPLE)
        option(WITH_OPENMP        "Enable OpenMP (has to be supported by the 
compiler)" ON)
@@ -205,6 +209,11 @@
        message(FATAL_ERROR "WITH_PYTHON_MODULE requires WITH_PYTHON_INSTALL to 
be OFF")
 endif()
 
+# may as well build python module without a UI
+if(WITH_PYTHON_MODULE)
+       set(WITH_HEADLESS ON)
+endif()
+
 # remove old vars
 unset(WITH_INSTALL CACHE)
 
@@ -409,15 +418,19 @@
                unset(JEMALLOC)
        endif()
 
-       find_package(X11 REQUIRED)
-       find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h 
${X11_INC_SEARCH_PATH})
-       mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
-
        # OpenSuse needs lutil, ArchLinux not, for now keep, can avoid by using 
--as-needed
-       set(LLIBS "-lutil -lc -lm -lpthread -lstdc++ ${X11_X11_LIB}")
+       set(LLIBS "-lutil -lc -lm -lpthread -lstdc++")
 
-       if(WITH_X11_XINPUT)
-               list(APPEND LLIBS ${X11_Xinput_LIB})
+       if(NOT WITH_HEADLESS)
+               find_package(X11 REQUIRED)
+               find_path(X11_XF86keysym_INCLUDE_PATH X11/XF86keysym.h 
${X11_INC_SEARCH_PATH})
+               mark_as_advanced(X11_XF86keysym_INCLUDE_PATH)
+
+               list(APPEND LLIBS ${X11_X11_LIB})
+
+               if(WITH_X11_XINPUT)
+                       list(APPEND LLIBS ${X11_Xinput_LIB})
+               endif()
        endif()
 
        if(CMAKE_SYSTEM_NAME MATCHES "Linux")

Modified: trunk/blender/intern/ghost/CMakeLists.txt
===================================================================
--- trunk/blender/intern/ghost/CMakeLists.txt   2011-06-04 14:10:34 UTC (rev 
37174)
+++ trunk/blender/intern/ghost/CMakeLists.txt   2011-06-04 14:12:55 UTC (rev 
37175)
@@ -89,7 +89,42 @@
        intern/GHOST_WindowManager.h
 )
 
-if(APPLE)
+if(WITH_HEADLESS)
+       list(APPEND SRC
+               intern/GHOST_DisplayManagerNULL.h
+               intern/GHOST_SystemNULL.h
+               intern/GHOST_WindowNULL.h
+       )
+       add_definitions(-DWITH_HEADLESS)
+
+       # ack, this is still system dependant
+       if(APPLE)
+               if(WITH_COCOA)
+                       list(APPEND SRC
+                               intern/GHOST_SystemPathsCocoa.mm
+                               intern/GHOST_SystemPathsCocoa.h
+                       )
+               else()
+                       list(APPEND SRC
+                               intern/GHOST_SystemPathsCarbon.cpp
+                               intern/GHOST_SystemPathsCarbon.h
+                       )
+               endif()
+       elseif(UNIX)
+               list(APPEND SRC
+                       intern/GHOST_SystemPathsX11.cpp
+                       intern/GHOST_SystemPathsX11.h
+               )
+       elseif(WIN32)
+
+               list(APPEND SRC
+                       intern/GHOST_SystemPathsWin32.cpp
+
+                       intern/GHOST_SystemPathsWin32.h
+               )
+       endif()
+
+elseif(APPLE)
        if(WITH_COCOA)
                list(APPEND SRC
                        intern/GHOST_DisplayManagerCocoa.mm

Added: trunk/blender/intern/ghost/intern/GHOST_DisplayManagerNULL.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_DisplayManagerNULL.h                
                (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_DisplayManagerNULL.h        
2011-06-04 14:12:55 UTC (rev 37175)
@@ -0,0 +1,51 @@
+/*
+ * $Id:
+ * ***** 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.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_DisplayManagerNULL.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_DisplayManagerNULL class.
+ */
+
+#ifndef _GHOST_DISPLAY_MANAGER_NULL_H_
+#define _GHOST_DISPLAY_MANAGER_NULL_H_
+
+#include "GHOST_DisplayManager.h"
+#include "GHOST_SystemNULL.h"
+
+class GHOST_SystemNULL;
+
+class GHOST_DisplayManagerNULL : public GHOST_DisplayManager
+{
+public:
+       GHOST_DisplayManagerNULL( GHOST_SystemNULL *system ) : 
GHOST_DisplayManager(), m_system(system) { /* nop */ }
+       GHOST_TSuccess getNumDisplays( GHOST_TUns8& numDisplays ) const { 
return GHOST_kFailure; }
+       GHOST_TSuccess getNumDisplaySettings( GHOST_TUns8 display, 
GHOST_TInt32& numSettings ) const{  return GHOST_kFailure; }
+       GHOST_TSuccess getDisplaySetting( GHOST_TUns8 display, GHOST_TInt32 
index, GHOST_DisplaySetting& setting ) const { return GHOST_kFailure; }
+       GHOST_TSuccess getCurrentDisplaySetting( GHOST_TUns8 display, 
GHOST_DisplaySetting& setting ) const { return 
getDisplaySetting(display,GHOST_TInt32(0),setting); }
+       GHOST_TSuccess setCurrentDisplaySetting( GHOST_TUns8 display, const 
GHOST_DisplaySetting& setting ){ return GHOST_kSuccess; }
+
+private :
+       GHOST_SystemNULL * m_system;
+};
+
+#endif /* _GHOST_DISPLAY_MANAGER_NULL_H_ */

Modified: trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp 2011-06-04 14:10:34 UTC 
(rev 37174)
+++ trunk/blender/intern/ghost/intern/GHOST_ISystem.cpp 2011-06-04 14:12:55 UTC 
(rev 37175)
@@ -41,7 +41,9 @@
 
 #include "GHOST_ISystem.h"
 
-#ifdef WIN32
+#ifdef WITH_HEADLESS
+#      include "GHOST_SystemNULL.h"
+#elif defined(WIN32)
 #      include "GHOST_SystemWin32.h"
 #else
 #      ifdef __APPLE__
@@ -63,7 +65,9 @@
 {
        GHOST_TSuccess success;
        if (!m_system) {
-#ifdef WIN32
+#ifdef WITH_HEADLESS
+               m_system = new GHOST_SystemNULL();
+#elif defined(WIN32)
                m_system = new GHOST_SystemWin32 ();
 #else
 #      ifdef __APPLE__

Modified: trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp     2011-06-04 
14:10:34 UTC (rev 37174)
+++ trunk/blender/intern/ghost/intern/GHOST_NDOFManager.cpp     2011-06-04 
14:12:55 UTC (rev 37175)
@@ -81,7 +81,9 @@
 #if 0
                printf("%i client \n", Pid);
 #endif
-               #if defined(_WIN32) || defined(__APPLE__)
+               #if defined(WITH_HEADLESS)
+                       /* do nothing */
+               #elif defined(_WIN32) || defined(__APPLE__)
                        m_DeviceHandle = ndofDeviceOpen((void 
*)&currentNdofValues);    
                #else
                        GHOST_SystemX11 *sys;

Added: trunk/blender/intern/ghost/intern/GHOST_SystemNULL.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemNULL.h                        
        (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemNULL.h        2011-06-04 
14:12:55 UTC (rev 37175)
@@ -0,0 +1,93 @@
+/*
+ * $Id:
+ * ***** 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.
+ *
+ * Contributor(s): Campbell Barton
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ghost/intern/GHOST_SystemNULL.h
+ *  \ingroup GHOST
+ * Declaration of GHOST_SystemNULL class.
+ */
+
+#ifndef _GHOST_SYSTEM_NULL_H_
+#define _GHOST_SYSTEM_NULL_H_
+
+#include "GHOST_System.h"
+#include "../GHOST_Types.h"
+#include "GHOST_DisplayManagerNULL.h"
+#include "GHOST_WindowNULL.h"
+
+class GHOST_WindowNULL;
+
+class GHOST_SystemNULL : public GHOST_System {
+public:
+
+       GHOST_SystemNULL( ) : GHOST_System() { /* nop */ }
+       ~GHOST_SystemNULL() { /* nop */ }
+       bool processEvents(bool waitForEvent) { return false; }
+       int toggleConsole(int action) { return 0; }
+       GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys& keys) const { return 
GHOST_kSuccess; }
+       GHOST_TSuccess getButtons(GHOST_Buttons& buttons) const { return 
GHOST_kSuccess; }
+       GHOST_TUns8 *getClipboard(bool selection) const { return NULL; }
+       void putClipboard(GHOST_TInt8 *buffer, bool selection) const { /* nop 
*/ }
+       GHOST_TUns64 getMilliSeconds( ) const { return 0; }
+       GHOST_TUns8 getNumDisplays( ) const { return GHOST_TUns8(1); }
+       GHOST_TSuccess getCursorPosition( GHOST_TInt32& x, GHOST_TInt32& y ) 
const { return GHOST_kFailure; }
+       GHOST_TSuccess setCursorPosition( GHOST_TInt32 x, GHOST_TInt32 y ) { 
return GHOST_kFailure; }
+       void getMainDisplayDimensions( GHOST_TUns32& width, GHOST_TUns32& 
height ) const { /* nop */ }
+
+       GHOST_TSuccess init() {
+               GHOST_TSuccess success = GHOST_System::init();
+
+               if (success) {
+                       m_displayManager = new GHOST_DisplayManagerNULL(this);
+
+                       if (m_displayManager) {
+                               return GHOST_kSuccess;
+                       }
+               }
+
+               return GHOST_kFailure;
+       }
+
+       GHOST_IWindow* createWindow(
+           const STR_String& title,
+           GHOST_TInt32 left,
+           GHOST_TInt32 top,
+           GHOST_TUns32 width,
+           GHOST_TUns32 height,
+           GHOST_TWindowState state,
+           GHOST_TDrawingContextType type,
+           bool stereoVisual,
+           const GHOST_TUns16 numOfAASamples,
+           const GHOST_TEmbedderWindowID parentWindow
+           ) {
+               return new GHOST_WindowNULL (this, title, left, top, width, 
height, state, parentWindow, type, stereoVisual, 1);
+       }
+};
+
+#endif
+
+
+
+
+
+
+

Added: trunk/blender/intern/ghost/intern/GHOST_WindowNULL.h
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_WindowNULL.h                        
        (rev 0)
+++ trunk/blender/intern/ghost/intern/GHOST_WindowNULL.h        2011-06-04 
14:12:55 UTC (rev 37175)
@@ -0,0 +1,96 @@
+/*
+ * $Id:
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to