diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-09-30 01:42:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-09-30 01:42:40 +0400 |
commit | 98ee2a781dd20bb58f72ee5700a11b2dd5124d74 (patch) | |
tree | 44825775e2d4ddc51d2138755b55c46fc17bb617 /source/gameengine/BlenderRoutines | |
parent | 53f0c3b018a995bbada591351568e4bb217dd1df (diff) |
option to build the BGE without python, uses existing python check (cmake and scons)
when python is disabled videotextures are not built.
Diffstat (limited to 'source/gameengine/BlenderRoutines')
-rw-r--r-- | source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 39 | ||||
-rw-r--r-- | source/gameengine/BlenderRoutines/CMakeLists.txt | 7 | ||||
-rw-r--r-- | source/gameengine/BlenderRoutines/SConscript | 6 |
3 files changed, 43 insertions, 9 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1ede16f017e..5b825899739 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -34,6 +34,7 @@ #include <signal.h> #include <stdlib.h> +#include <stdio.h> #ifdef WIN32 // don't show stl-warnings @@ -137,6 +138,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); BLI_strncpy(oldsce, G.sce, sizeof(oldsce)); +#ifndef DISABLE_PYTHON resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path setGamePythonPath(G.sce); @@ -145,6 +147,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw PyGILState_STATE gilstate = PyGILState_Ensure(); PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */ +#endif bgl::InitExtensions(true); @@ -206,8 +209,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); +#ifndef DISABLE_PYTHON CValue::SetDeprecationWarnings(nodepwarnings); - +#endif //lock frame and camera enabled - storing global values int tmp_lay= scene->lay; @@ -288,7 +292,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw if(blenderdata) { BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce)); BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); +#ifndef DISABLE_PYTHON setGamePythonPath(G.sce); +#endif } } // else forget it, we can't find it @@ -365,7 +371,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw networkdevice, startscenename, blscene); - + +#ifndef DISABLE_PYTHON // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); ketsjiengine->SetPythonDictionary(dictionaryobject); @@ -383,6 +390,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON //initialize Dome Settings if(blscene->gm.stereoflag == STEREO_DOME) @@ -398,7 +406,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // convert and add scene sceneconverter->ConvertScene( startscene, +#ifndef DISABLE_PYTHON dictionaryobject, +#endif rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -468,7 +478,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // when exiting the mainloop - +#ifndef DISABLE_PYTHON // Clears the dictionary by hand: // This prevents, extra references to global variables // inside the GameLogic dictionary when the python interpreter is finalized. @@ -488,9 +498,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw } Py_DECREF(gameLogic_keys_new); gameLogic_keys_new = NULL; - +#endif ketsjiengine->StopEngine(); +#ifndef DISABLE_PYTHON exitGamePythonScripting(); +#endif networkdevice->Disconnect(); } if (sceneconverter) @@ -498,9 +510,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw delete sceneconverter; sceneconverter = NULL; } - + +#ifndef DISABLE_PYTHON Py_DECREF(gameLogic_keys); gameLogic_keys = NULL; +#endif } //lock frame and camera enabled - restoring global values if (v3d->scenelock==0){ @@ -555,14 +569,17 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); - Py_DECREF(pyGlobalDict); - if (bfd) BLO_blendfiledata_free(bfd); BLI_strncpy(G.sce, oldsce, sizeof(G.sce)); +#ifndef DISABLE_PYTHON + Py_DECREF(pyGlobalDict); + // Release Python's GIL PyGILState_Release(gilstate); +#endif + } extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, @@ -581,9 +598,11 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); +#ifndef DISABLE_PYTHON // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif bgl::InitExtensions(true); @@ -680,6 +699,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, startscenename, blscene); +#ifndef DISABLE_PYTHON // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); ketsjiengine->SetPythonDictionary(dictionaryobject); @@ -694,13 +714,16 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON if (sceneconverter) { // convert and add scene sceneconverter->ConvertScene( startscene, +#ifndef DISABLE_PYTHON dictionaryobject, +#endif rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -778,6 +801,8 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); +#ifndef DISABLE_PYTHON // Release Python's GIL PyGILState_Release(gilstate); +#endif } diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index ce85c1185b0..f2d6528d797 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -35,12 +35,17 @@ SET(INC ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/glew/include - ${PYTHON_INC} ) IF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_blroutines "${SRC}" "${INC}") #env.BlenderLib ( 'bf_bloutines', sources, Split(incs), [], libtype=['game', 'game2', 'player'], priority=[0, 0, 55] , compileflags=cxxflags) diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 1e8ff3c48e8..f076612e231 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -25,7 +25,11 @@ incs += ' #source/blender/windowmanager' if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') -incs += ' ' + env['BF_PYTHON_INC'] +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] |