Browse Source

make AngelScript an optional module, you can use -DENABLE_ANGELSCRIPT=0 to disable it.

StevenZhang 12 years ago
parent
commit
a17baf2695

+ 1 - 0
Docs/GettingStarted.dox

@@ -139,6 +139,7 @@ A number of build options can be defined explicitly when invoking the above cmak
 |-DENABLE_SAMPLES=1                           |to build the C++ sample applications|
 |-DENABLE_TOOLS=1                             |to build the tools (only useful for Raspberry Pi build because this option is already enabled by default for other Desktop platforms)|
 |-DENABLE_DOCS=1                              |to build the docs when building all the targets|
+|-DENABLE_ANGELSCRIPT=0                       |to disable AngelScript scripting support|
 |-DENABLE_SSE=0                               |to disable SSE instruction set|
 |-DENABLE_MINIDUMPS=0                         |to disable minidumps on crash (VS only)|
 |-DUSE_OPENGL=1                               |to use OpenGL instead of Direct3D (only useful for VS on Windows platform because this option is enabled by default for other platforms)|

+ 1 - 0
Docs/Urho3D.dox

@@ -67,6 +67,7 @@ Urho3D development, contributions and bugfixes by:
 - Paul Noome
 - Vladimir Pobedinsky
 - Miika Santala
+- Steven Zhang
 - Firegorilla
 - Magic.Lixin
 - amadeus_osa

+ 3 - 1
Readme.txt

@@ -27,6 +27,7 @@ Urho3D development, contributions and bugfixes by:
 - Paul Noome
 - Vladimir Pobedinsky
 - Miika Santala
+- Steven Zhang
 - Firegorilla
 - Magic.Lixin
 - amadeus_osa
@@ -404,6 +405,7 @@ cmake_xxxx batch files or shell scripts.
 |                      | because this option is already enabled by default for |
 |                      | other Desktop platforms)                              |
 |-DENABLE_DOCS=1       |to build the docs when building all the targets        |
+|-DENABLE_ANGELSCRIPT=0|to disable AngelScript scripting support               |
 |-DENABLE_SSE=0        |to disable SSE instruction set                         |
 |-DENABLE_MINIDUMPS=0  |to disable minidumps on crash (VS only)                |
 |-DUSE_OPENGL=1        |to use OpenGL instead of Direct3D (only useful for VS  |
@@ -546,4 +548,4 @@ V1.1    - Object and scene model refactoring.
         - Added OpenGL and cross-platform support.
         - Switched to kNet library for networking.
 
-V1.0    - Original release.
+V1.0    - Original release.

+ 5 - 0
Source/CMake/Modules/Urho3D-CMake-magic.cmake

@@ -91,6 +91,11 @@ if (NOT IOS AND NOT ANDROID AND NOT RASPI AND USE_OPENGL)
     add_definitions (-DGLEW_NO_GLU)
 endif ()
 
+# Add definition for AngelScript
+if (ENABLE_ANGELSCRIPT)
+    add_definitions (-DENABLE_ANGELSCRIPT)
+endif ()
+
 # Add definition for Lua and LuaJIT
 if (ENABLE_LUAJIT)
     add_definitions (-DENABLE_LUAJIT)

+ 11 - 1
Source/CMakeLists.txt

@@ -33,6 +33,11 @@ endif ()
 # Set CMake modules search path
 set (CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules)
 
+# Enable AngelScript by default
+if (NOT DEFINED ENABLE_ANGELSCRIPT)
+    set (ENABLE_ANGELSCRIPT 1)
+endif ()
+
 # Include Urho3D cmake module
 include (Urho3D-CMake-magic)
 
@@ -78,9 +83,14 @@ file (GLOB CMAKE_SCRIPTS ${PROJECT_ROOT_DIR}/${SCRIPT_PATTERN})
 install (FILES ${CMAKE_SCRIPTS} DESTINATION ${DEST_SHARE_DIR}/Scripts PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 
 # Add targets
-foreach (TARGET AngelScript Bullet Civetweb Detour FreeType JO kNet LZ4 PugiXml Recast SDL StanHull STB)
+foreach (TARGET Bullet Civetweb Detour FreeType JO kNet LZ4 PugiXml Recast SDL StanHull STB)
     add_subdirectory (ThirdParty/${TARGET})
 endforeach ()
+
+if (ENABLE_ANGELSCRIPT)
+    add_subdirectory(ThirdParty/AngelScript)
+endif ()
+
 if (ENABLE_LUA)
     add_subdirectory (Engine/LuaScript)
     add_subdirectory (ThirdParty/Lua${JIT})

+ 7 - 1
Source/Engine/CMakeLists.txt

@@ -101,7 +101,13 @@ foreach (TARGET ${STATIC_LIBRARY_TARGETS})
 endforeach ()
 
 # Define source files
-foreach (SOURCE Audio Container Core Engine Graphics Input IO Math Navigation Network Physics Resource Scene Script UI)
+set (SOURCES Audio Container Core Engine Graphics Input IO Math Navigation Network Physics Resource Scene UI)
+
+if (ENABLE_ANGELSCRIPT)
+    set (SOURCES ${SOURCES} Script)
+endif ()
+
+foreach (SOURCE ${SOURCES})
     add_subdirectory (${SOURCE})
     install (DIRECTORY ${SOURCE}/ DESTINATION ${DEST_INCLUDE_DIR} USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN *.h)    # Note: the trailing slash is significant
     source_group ("Source Files\\${SOURCE}" FILES ${${SOURCE}_CPP_FILES})

+ 62 - 60
Source/Samples/CMakeLists.txt

@@ -1,60 +1,62 @@
-#
-# Copyright (c) 2008-2013 the Urho3D project.
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
-#
-
-# Set project name
-project (Urho3D-Samples)
-
-# Find Urho3D library
-find_package (Urho3D REQUIRED)
-include_directories (${URHO3D_INCLUDE_DIR})
-
-# Include common to all samples
-set (COMMON_SAMPLE_H_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Sample.h" "${CMAKE_CURRENT_SOURCE_DIR}/Sample.inl")
-
-# Define dependency libs
-set (INCLUDE_DIRS_ONLY ${CMAKE_CURRENT_SOURCE_DIR})
-
-# Add samples
-add_subdirectory (01_HelloWorld)
-add_subdirectory (02_HelloGUI)
-add_subdirectory (03_Sprites)
-add_subdirectory (04_StaticScene)
-add_subdirectory (05_AnimatingScene)
-add_subdirectory (06_SkeletalAnimation)
-add_subdirectory (07_Billboards)
-add_subdirectory (08_Decals)
-add_subdirectory (09_MultipleViewports)
-add_subdirectory (10_RenderToTexture)
-add_subdirectory (11_Physics)
-add_subdirectory (12_PhysicsStressTest)
-add_subdirectory (13_Ragdolls)
-add_subdirectory (14_SoundEffects)
-add_subdirectory (15_Navigation)
-add_subdirectory (16_Chat)
-add_subdirectory (17_SceneReplication)
-add_subdirectory (18_CharacterDemo)
-add_subdirectory (19_VehicleDemo)
-add_subdirectory (20_HugeObjectCount)
-add_subdirectory (21_AngelScriptIntegration)
-if (ENABLE_LUA)
-    add_subdirectory (22_LuaIntegration)
-endif ()
+#
+# Copyright (c) 2008-2013 the Urho3D project.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+
+# Set project name
+project (Urho3D-Samples)
+
+# Find Urho3D library
+find_package (Urho3D REQUIRED)
+include_directories (${URHO3D_INCLUDE_DIR})
+
+# Include common to all samples
+set (COMMON_SAMPLE_H_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Sample.h" "${CMAKE_CURRENT_SOURCE_DIR}/Sample.inl")
+
+# Define dependency libs
+set (INCLUDE_DIRS_ONLY ${CMAKE_CURRENT_SOURCE_DIR})
+
+# Add samples
+add_subdirectory (01_HelloWorld)
+add_subdirectory (02_HelloGUI)
+add_subdirectory (03_Sprites)
+add_subdirectory (04_StaticScene)
+add_subdirectory (05_AnimatingScene)
+add_subdirectory (06_SkeletalAnimation)
+add_subdirectory (07_Billboards)
+add_subdirectory (08_Decals)
+add_subdirectory (09_MultipleViewports)
+add_subdirectory (10_RenderToTexture)
+add_subdirectory (11_Physics)
+add_subdirectory (12_PhysicsStressTest)
+add_subdirectory (13_Ragdolls)
+add_subdirectory (14_SoundEffects)
+add_subdirectory (15_Navigation)
+add_subdirectory (16_Chat)
+add_subdirectory (17_SceneReplication)
+add_subdirectory (18_CharacterDemo)
+add_subdirectory (19_VehicleDemo)
+add_subdirectory (20_HugeObjectCount)
+if (ENABLE_ANGELSCRIPT)
+    add_subdirectory (21_AngelScriptIntegration)
+endif ()
+if (ENABLE_LUA)
+    add_subdirectory (22_LuaIntegration)
+endif ()

+ 3 - 1
Source/Tools/CMakeLists.txt

@@ -46,7 +46,9 @@ if (NOT IOS AND NOT ANDROID AND ENABLE_TOOLS)
     add_subdirectory (OgreImporter)
     add_subdirectory (PackageTool)
     add_subdirectory (RampGenerator)
-    add_subdirectory (ScriptCompiler)
+    if (ENABLE_ANGELSCRIPT)
+        add_subdirectory (ScriptCompiler)
+    endif ()
 
     # Urho3D non-OpenGL tools
     if (NOT USE_OPENGL)

+ 27 - 6
Source/Tools/Urho3DPlayer/Urho3DPlayer.cpp

@@ -27,14 +27,18 @@
 #include "ProcessUtils.h"
 #include "ResourceCache.h"
 #include "ResourceEvents.h"
-#include "Script.h"
+
+#ifdef ENABLE_ANGELSCRIPT
 #include "ScriptFile.h"
-#include "Urho3DPlayer.h"
+#include "Script.h"
+#endif
 
 #ifdef ENABLE_LUA
 #include "LuaScript.h"
 #endif
 
+#include "Urho3DPlayer.h"
+
 #include "DebugNew.h"
 
 DEFINE_APPLICATION_MAIN(Urho3DPlayer);
@@ -104,11 +108,10 @@ void Urho3DPlayer::Setup()
 
 void Urho3DPlayer::Start()
 {
-#ifdef ENABLE_LUA
     String extension = GetExtension(scriptFileName_);
     if (extension != ".lua")
     {
-#endif
+#ifdef ENABLE_ANGELSCRIPT
         // Instantiate and register the AngelScript subsystem
         context_->RegisterSubsystem(new Script(context_));
 
@@ -124,10 +127,13 @@ void Urho3DPlayer::Start()
             SubscribeToEvent(scriptFile_, E_RELOADFAILED, HANDLER(Urho3DPlayer, HandleScriptReloadFailed));
             return;
         }
-#ifdef ENABLE_LUA
+#else
+        ErrorExit("AngelScript is not enabled!");
+#endif
     }
     else
     {
+#ifdef ENABLE_LUA
         // Instantiate and register the Lua script subsystem
         LuaScript* luaScript = new LuaScript(context_);
         context_->RegisterSubsystem(luaScript);
@@ -138,8 +144,10 @@ void Urho3DPlayer::Start()
             luaScript->ExecuteFunction("Start");
             return;
         }
-    }
+#else
+        ErrorExit("Lua is not enabled!");
 #endif
+    }
 
     // The script was not successfully loaded. Show the last error message and do not run the main loop
     ErrorExit();
@@ -147,12 +155,19 @@ void Urho3DPlayer::Start()
 
 void Urho3DPlayer::Stop()
 {
+#ifdef ENABLE_ANGELSCRIPT
     if (scriptFile_)
     {
         // Execute the optional stop function
         if (scriptFile_->GetFunction("void Stop()"))
             scriptFile_->Execute("void Stop()");
     }
+#else
+    if (false)
+    {
+    }
+#endif
+    
 #ifdef ENABLE_LUA
     else
     {
@@ -165,22 +180,28 @@ void Urho3DPlayer::Stop()
 
 void Urho3DPlayer::HandleScriptReloadStarted(StringHash eventType, VariantMap& eventData)
 {
+#ifdef ENABLE_ANGELSCRIPT
     if (scriptFile_->GetFunction("void Stop()"))
         scriptFile_->Execute("void Stop()");
+#endif
 }
 
 void Urho3DPlayer::HandleScriptReloadFinished(StringHash eventType, VariantMap& eventData)
 {
+#ifdef ENABLE_ANGELSCRIPT
     // Restart the script application after reload
     if (!scriptFile_->Execute("void Start()"))
     {
         scriptFile_.Reset();
         ErrorExit();
     }
+#endif
 }
 
 void Urho3DPlayer::HandleScriptReloadFailed(StringHash eventType, VariantMap& eventData)
 {
+#ifdef ENABLE_ANGELSCRIPT
     scriptFile_.Reset();
     ErrorExit();
+#endif
 }

+ 3 - 0
Source/Tools/Urho3DPlayer/Urho3DPlayer.h

@@ -52,6 +52,9 @@ private:
 
     /// Script file name.
     String scriptFileName_;
+    
+#ifdef ENABLE_ANGELSCRIPT
     /// Script file.
     SharedPtr<ScriptFile> scriptFile_;
+#endif
 };