diff --git a/native/cocos/Android.mk b/native/cocos/Android.mk index 555b2eb829..d32841381f 100644 --- a/native/cocos/Android.mk +++ b/native/cocos/Android.mk @@ -47,42 +47,8 @@ base/CCScheduler.cpp \ base/csscolorparser.cpp \ base/CCGLUtils.cpp \ base/CCRenderTexture.cpp \ -renderer/Types.cpp \ -renderer/gfx/DeviceGraphics.cpp \ -renderer/gfx/FrameBuffer.cpp \ -renderer/gfx/GFX.cpp \ -renderer/gfx/GFXUtils.cpp \ -renderer/gfx/GraphicsHandle.cpp \ -renderer/gfx/IndexBuffer.cpp \ -renderer/gfx/Program.cpp \ -renderer/gfx/RenderBuffer.cpp \ -renderer/gfx/RenderTarget.cpp \ -renderer/gfx/State.cpp \ -renderer/gfx/Texture.cpp \ -renderer/gfx/Texture2D.cpp \ -renderer/gfx/VertexBuffer.cpp \ -renderer/gfx/VertexFormat.cpp \ -renderer/renderer/BaseRenderer.cpp \ -renderer/renderer/Camera.cpp \ -renderer/renderer/Config.cpp \ -renderer/renderer/Effect.cpp \ -renderer/renderer/InputAssembler.cpp \ -renderer/renderer/Light.cpp \ -renderer/renderer/Model.cpp \ -renderer/renderer/Pass.cpp \ -renderer/renderer/ProgramLib.cpp \ -renderer/renderer/Scene.cpp \ -renderer/renderer/Technique.cpp \ -renderer/renderer/View.cpp \ -renderer/renderer/ForwardRenderer.cpp \ storage/local-storage/LocalStorage-android.cpp \ -scripting/js-bindings/auto/jsb_gfx_auto.cpp \ -scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp \ -scripting/js-bindings/auto/jsb_renderer_auto.cpp \ -scripting/js-bindings/auto/jsb_video_auto.cpp \ -scripting/js-bindings/auto/jsb_webview_auto.cpp \ scripting/js-bindings/auto/jsb_cocos2dx_auto.cpp \ -scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp \ scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.cpp \ scripting/js-bindings/manual/JavaScriptJavaBridge.cpp \ scripting/js-bindings/manual/jsb_opengl_manual.cpp \ @@ -90,10 +56,7 @@ scripting/js-bindings/manual/jsb_opengl_utils.cpp \ scripting/js-bindings/manual/jsb_classtype.cpp \ scripting/js-bindings/manual/jsb_conversions.cpp \ scripting/js-bindings/manual/jsb_cocos2dx_manual.cpp \ -scripting/js-bindings/manual/jsb_cocos2dx_network_manual.cpp \ -scripting/js-bindings/manual/jsb_gfx_manual.cpp \ scripting/js-bindings/manual/jsb_global.cpp \ -scripting/js-bindings/manual/jsb_renderer_manual.cpp \ scripting/js-bindings/manual/jsb_socketio.cpp \ scripting/js-bindings/manual/jsb_websocket.cpp \ scripting/js-bindings/manual/jsb_xmlhttprequest.cpp \ @@ -127,9 +90,73 @@ scripting/js-bindings/event/EventDispatcher.cpp \ ../external/sources/unzip/unzip.cpp \ ../external/sources/ConvertUTF/ConvertUTFWrapper.cpp \ ../external/sources/ConvertUTF/ConvertUTF.c \ -ui/edit-box/EditBox-android.cpp \ +ui/edit-box/EditBox-android.cpp + +# opengl bindings depend on GFXUtils "_JSB_GL_CHECK" +LOCAL_SRC_FILES += \ +renderer/gfx/GFXUtils.cpp + +ifeq ($(USE_GFX_RENDERER),1) +LOCAL_SRC_FILES += \ +renderer/Types.cpp \ +renderer/gfx/DeviceGraphics.cpp \ +renderer/gfx/FrameBuffer.cpp \ +renderer/gfx/GFX.cpp \ +renderer/gfx/GraphicsHandle.cpp \ +renderer/gfx/IndexBuffer.cpp \ +renderer/gfx/Program.cpp \ +renderer/gfx/RenderBuffer.cpp \ +renderer/gfx/RenderTarget.cpp \ +renderer/gfx/State.cpp \ +renderer/gfx/Texture.cpp \ +renderer/gfx/Texture2D.cpp \ +renderer/gfx/VertexBuffer.cpp \ +renderer/gfx/VertexFormat.cpp \ +renderer/renderer/BaseRenderer.cpp \ +renderer/renderer/Camera.cpp \ +renderer/renderer/Config.cpp \ +renderer/renderer/Effect.cpp \ +renderer/renderer/InputAssembler.cpp \ +renderer/renderer/Light.cpp \ +renderer/renderer/Model.cpp \ +renderer/renderer/Pass.cpp \ +renderer/renderer/ProgramLib.cpp \ +renderer/renderer/Scene.cpp \ +renderer/renderer/Technique.cpp \ +renderer/renderer/View.cpp \ +renderer/renderer/ForwardRenderer.cpp \ +scripting/js-bindings/auto/jsb_gfx_auto.cpp \ +scripting/js-bindings/auto/jsb_renderer_auto.cpp \ +scripting/js-bindings/manual/jsb_renderer_manual.cpp \ +scripting/js-bindings/manual/jsb_gfx_manual.cpp +endif # USE_GFX_RENDERER + +ifeq ($(USE_VIDEO),1) +LOCAL_SRC_FILES += \ ui/videoplayer/VideoPlayer-android.cpp \ +scripting/js-bindings/auto/jsb_video_auto.cpp +endif # USE_VIDEO + +ifeq ($(USE_WEB_VIEW),1) +LOCAL_SRC_FILES += \ ui/webview/WebViewImpl-android.cpp \ +scripting/js-bindings/auto/jsb_webview_auto.cpp +endif # USE_WEB_VIEW + +ifeq ($(USE_AUDIO),1) +LOCAL_SRC_FILES += \ +scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp +LOCAL_STATIC_LIBRARIES += audioengine_static +endif # USE_AUDIO + +ifeq ($(USE_NET_WORK),1) +LOCAL_SRC_FILES += \ +scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp \ +scripting/js-bindings/manual/jsb_cocos2dx_network_manual.cpp +LOCAL_STATIC_LIBRARIES += cocos_network_static +LOCAL_STATIC_LIBRARIES += cocos_extension_static +endif # USE_NET_WORK + LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/.. \ @@ -151,7 +178,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/../external/sources \ $(LOCAL_PATH)/renderer -LOCAL_STATIC_LIBRARIES := cocos_freetype2_static LOCAL_STATIC_LIBRARIES += cocos_png_static LOCAL_STATIC_LIBRARIES += cocos_jpeg_static LOCAL_STATIC_LIBRARIES += cocos_tiff_static @@ -159,9 +185,6 @@ LOCAL_STATIC_LIBRARIES += cocos_webp_static LOCAL_STATIC_LIBRARIES += cocos_zlib_static LOCAL_STATIC_LIBRARIES += uv_static LOCAL_STATIC_LIBRARIES += v8_static -LOCAL_STATIC_LIBRARIES += audioengine_static -LOCAL_STATIC_LIBRARIES += cocos_network_static -LOCAL_STATIC_LIBRARIES += cocos_extension_static LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dxandroid_static LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures diff --git a/native/cocos/base/ccConfig.h b/native/cocos/base/ccConfig.h index f5894db46c..318fb4609c 100644 --- a/native/cocos/base/ccConfig.h +++ b/native/cocos/base/ccConfig.h @@ -36,6 +36,28 @@ THE SOFTWARE. * cocos2d (cc) configuration file. */ +// disable module if you didn't need it, this will reduce package size + +#ifndef USE_GFX_RENDERER +#define USE_GFX_RENDERER 0 +#endif + +#ifndef USE_VIDEO +#define USE_VIDEO 1 +#endif + +#ifndef USE_WEB_VIEW +#define USE_WEB_VIEW 1 +#endif + +#ifndef USE_AUDIO +#define USE_AUDIO 1 +#endif + +#ifndef USE_NET_WORK +#define USE_NET_WORK 1 +#endif + /** @def CC_ENABLE_STACKABLE_ACTIONS * If enabled, actions that alter the position property (eg: MoveBy, JumpBy, BezierBy, etc..) will be stacked. * If you run 2 or more 'position' actions at the same time on a node, then end position will be the sum of all the positions. diff --git a/native/cocos/platform/android/CCApplication-android.cpp b/native/cocos/platform/android/CCApplication-android.cpp index 66fbd13af3..f64627ef25 100644 --- a/native/cocos/platform/android/CCApplication-android.cpp +++ b/native/cocos/platform/android/CCApplication-android.cpp @@ -73,13 +73,13 @@ Application::~Application() { EventDispatcher::destroy(); se::ScriptEngine::destroyInstance(); - - // close audio device - cocos2d::experimental::AudioEngine::end(); - delete _renderTexture; _renderTexture = nullptr; +#if USE_AUDIO // close audio device + cocos2d::experimental::AudioEngine::end(); +#endif + Application::_instance = nullptr; } diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp index 77ef4ab254..ced4f32b39 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.cpp @@ -1,5 +1,5 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#if (USE_AUDIO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "audio/include/AudioEngine.h" @@ -804,4 +804,4 @@ bool register_all_audioengine(se::Object* obj) return true; } -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#endif //#if (USE_AUDIO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp index 94216eff35..fad86ba8fd 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp @@ -1,6 +1,6 @@ #pragma once #include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#if (USE_AUDIO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" @@ -45,4 +45,4 @@ SE_DECLARE_FUNC(js_audioengine_AudioEngine_setFinishCallback); SE_DECLARE_FUNC(js_audioengine_AudioEngine_getProfile); SE_DECLARE_FUNC(js_audioengine_AudioEngine_getPlayingAudioCount); -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +#endif //#if (USE_AUDIO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp index a27fb7d22e..59c299849f 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.cpp @@ -1,4 +1,5 @@ #include "scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp" +#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "network/CCDownloader.h" @@ -238,3 +239,4 @@ bool register_all_network(se::Object* obj) return true; } +#endif //#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp index 02f34b2c45..9f9a4f9948 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp @@ -1,5 +1,6 @@ #pragma once #include "base/ccConfig.h" +#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" @@ -13,3 +14,4 @@ SE_DECLARE_FUNC(js_network_Downloader_setOnTaskProgress); SE_DECLARE_FUNC(js_network_Downloader_setOnFileTaskSuccess); SE_DECLARE_FUNC(js_network_Downloader_Downloader); +#endif //#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.cpp index 22c7759bb4..8efe41b1d0 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.cpp @@ -1,4 +1,5 @@ #include "scripting/js-bindings/auto/jsb_gfx_auto.hpp" +#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "renderer/gfx/GFX.h" @@ -1674,3 +1675,4 @@ bool register_all_gfx(se::Object* obj) return true; } +#endif //#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp index 0072a0c254..06d6502654 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp @@ -1,5 +1,6 @@ #pragma once #include "base/ccConfig.h" +#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" @@ -130,3 +131,4 @@ SE_DECLARE_FUNC(js_gfx_Program_init); SE_DECLARE_FUNC(js_gfx_Program_link); SE_DECLARE_FUNC(js_gfx_Program_Program); +#endif //#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp index 62b2fc55be..3e430d2401 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.cpp @@ -1,4 +1,5 @@ #include "scripting/js-bindings/auto/jsb_renderer_auto.hpp" +#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "renderer/renderer/Renderer.h" @@ -2461,3 +2462,4 @@ bool register_all_renderer(se::Object* obj) return true; } +#endif //#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp index bab9f7830e..d215a4a232 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp @@ -1,5 +1,6 @@ #pragma once #include "base/ccConfig.h" +#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" @@ -152,3 +153,4 @@ SE_DECLARE_FUNC(js_renderer_Scene_addLight); SE_DECLARE_FUNC(js_renderer_Scene_removeLight); SE_DECLARE_FUNC(js_renderer_Scene_Scene); +#endif //#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_video_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_video_auto.cpp index 8260e8b227..462fad2595 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_video_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_video_auto.cpp @@ -1,5 +1,5 @@ #include "scripting/js-bindings/auto/jsb_video_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#if (USE_VIDEO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "ui/videoplayer/VideoPlayer.h" @@ -358,4 +358,4 @@ bool register_all_video(se::Object* obj) return true; } -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#endif //#if (USE_VIDEO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_video_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_video_auto.hpp index 023d0e43ab..40e7df83c7 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_video_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_video_auto.hpp @@ -1,6 +1,6 @@ #pragma once #include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#if (USE_VIDEO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" @@ -25,4 +25,4 @@ SE_DECLARE_FUNC(js_video_VideoPlayer_setVisible); SE_DECLARE_FUNC(js_video_VideoPlayer_seekTo); SE_DECLARE_FUNC(js_video_VideoPlayer_VideoPlayer); -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#endif //#if (USE_VIDEO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.cpp b/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.cpp index fdc904f770..6be022ac18 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.cpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.cpp @@ -1,5 +1,5 @@ #include "scripting/js-bindings/auto/jsb_webview_auto.hpp" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#if (USE_WEB_VIEW > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "ui/webview/WebView.h" @@ -682,4 +682,4 @@ bool register_all_webview(se::Object* obj) return true; } -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#endif //#if (USE_WEB_VIEW > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.hpp b/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.hpp index b7f8f07f2c..88cc307b14 100644 --- a/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.hpp +++ b/native/cocos/scripting/js-bindings/auto/jsb_webview_auto.hpp @@ -1,6 +1,6 @@ #pragma once #include "base/ccConfig.h" -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#if (USE_WEB_VIEW > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" @@ -36,4 +36,4 @@ SE_DECLARE_FUNC(js_webview_WebView_getOnDidFinishLoading); SE_DECLARE_FUNC(js_webview_WebView_create); SE_DECLARE_FUNC(js_webview_WebView_WebView); -#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +#endif //#if (USE_WEB_VIEW > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.cpp index a89a258850..fdc7c71c4f 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.cpp @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +#include "base/ccConfig.h" #include "jsb_cocos2dx_network_manual.h" +#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "scripting/js-bindings/manual/jsb_conversions.hpp" #include "scripting/js-bindings/manual/jsb_global.h" #include "network/CCDownloader.h" @@ -77,3 +78,4 @@ bool register_all_cocos2dx_network_manual(se::Object *obj) { _SE(js_cocos2dx_network_Downloader_createDownloadFileTask)); return true; } +#endif //#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp b/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp index e1aa6b7c33..86b6f889a0 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_conversions.cpp @@ -425,31 +425,6 @@ bool seval_to_Size(const se::Value& v, cocos2d::Size* size) // return true; //} -bool seval_to_Rect(const se::Value& v, cocos2d::renderer::Rect* rect) -{ - assert(v.isObject() && rect != nullptr); - se::Object* obj = v.toObject(); - se::Value x; - se::Value y; - se::Value width; - se::Value height; - - bool ok = obj->getProperty("x", &x); - SE_PRECONDITION3(ok && x.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); - ok = obj->getProperty("y", &y); - SE_PRECONDITION3(ok && y.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); - ok = obj->getProperty("w", &width); - SE_PRECONDITION3(ok && width.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); - ok = obj->getProperty("h", &height); - SE_PRECONDITION3(ok && height.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); - rect->x = x.toFloat(); - rect->y = y.toFloat(); - rect->w = width.toFloat(); - rect->h = height.toFloat(); - - return true; -} - bool seval_to_Color3B(const se::Value& v, cocos2d::Color3B* color) { assert(v.isObject() && color != nullptr); @@ -875,29 +850,6 @@ bool seval_to_std_vector_Vec2(const se::Value& v, std::vector* re return false; } -bool seval_to_std_vector_Pass(const se::Value& v, cocos2d::Vector* ret) -{ - assert(ret != nullptr); - assert(v.isObject()); - se::Object* obj = v.toObject(); - assert(obj->isArray()); - uint32_t len = 0; - if (obj->getArrayLength(&len)) - { - se::Value value; - cocos2d::renderer::Pass* pt = nullptr; - for (uint32_t i = 0; i < len; ++i) - { - SE_PRECONDITION3(obj->getArrayElement(i, &value), false, ret->clear()); - pt = static_cast(value.toObject()->getPrivateData()); - ret->pushBack(pt); - } - return true; - } - - return false; -} - //bool seval_to_std_vector_Touch(const se::Value& v, std::vector* ret) //{ // assert(ret != nullptr); @@ -1193,6 +1145,55 @@ bool seval_to_DownloaderHints(const se::Value& v, cocos2d::network::DownloaderHi // return true; //} +#if USE_GFX_RENDERER +bool seval_to_Rect(const se::Value& v, cocos2d::renderer::Rect* rect) +{ + assert(v.isObject() && rect != nullptr); + se::Object* obj = v.toObject(); + se::Value x; + se::Value y; + se::Value width; + se::Value height; + + bool ok = obj->getProperty("x", &x); + SE_PRECONDITION3(ok && x.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); + ok = obj->getProperty("y", &y); + SE_PRECONDITION3(ok && y.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); + ok = obj->getProperty("w", &width); + SE_PRECONDITION3(ok && width.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); + ok = obj->getProperty("h", &height); + SE_PRECONDITION3(ok && height.isNumber(), false, *rect = cocos2d::renderer::Rect::ZERO); + rect->x = x.toFloat(); + rect->y = y.toFloat(); + rect->w = width.toFloat(); + rect->h = height.toFloat(); + + return true; +} + +bool seval_to_std_vector_Pass(const se::Value& v, cocos2d::Vector* ret) +{ + assert(ret != nullptr); + assert(v.isObject()); + se::Object* obj = v.toObject(); + assert(obj->isArray()); + uint32_t len = 0; + if (obj->getArrayLength(&len)) + { + se::Value value; + cocos2d::renderer::Pass* pt = nullptr; + for (uint32_t i = 0; i < len; ++i) + { + SE_PRECONDITION3(obj->getArrayElement(i, &value), false, ret->clear()); + pt = static_cast(value.toObject()->getPrivateData()); + ret->pushBack(pt); + } + return true; + } + + return false; +} + bool seval_to_std_vector_Texture(const se::Value& v, std::vector* ret) { assert(ret != nullptr); @@ -1884,7 +1885,7 @@ bool seval_to_std_vector_ProgramLib_Template(const se::Value& v, std::vector 0 ////////////////////////////////////////////////////////////////////////////////// // native to seval @@ -2046,19 +2047,6 @@ bool Size_to_seval(const cocos2d::Size& v, se::Value* ret) // return true; //} -bool Rect_to_seval(const cocos2d::renderer::Rect& v, se::Value* ret) -{ - assert(ret != nullptr); - se::HandleObject obj(se::Object::createPlainObject()); - obj->setProperty("x", se::Value(v.x)); - obj->setProperty("y", se::Value(v.y)); - obj->setProperty("w", se::Value(v.w)); - obj->setProperty("h", se::Value(v.h)); - ret->setObject(obj); - - return true; -} - bool Color3B_to_seval(const cocos2d::Color3B& v, se::Value* ret) { assert(ret != nullptr); @@ -2441,115 +2429,6 @@ namespace } } - -bool EffectProperty_to_seval(const cocos2d::renderer::Effect::Property& v, se::Value* ret) -{ - assert(ret != nullptr); - - auto type = v.getType(); - if (type == cocos2d::renderer::Technique::Parameter::Type::TEXTURE_2D || type == cocos2d::renderer::Technique::Parameter::Type::TEXTURE_CUBE) - { - auto count = v.getCount(); - if (0 == count) - { - *ret = se::Value::Null; - } - else if (1 == count) - { - se::Value val; - native_ptr_to_seval(v.getTexture(), &val); - *ret = val; - } - else - { - auto texArray = v.getTextureArray(); - se::HandleObject arr(se::Object::createArrayObject(count)); - for (uint8_t i = 0; i < count; ++i) - { - se::Value val; - native_ptr_to_seval(texArray[0], &val); - arr->setArrayElement(i, val); - } - ret->setObject(arr); - } - } - else - { - void* data = v.getValue(); - - switch (type) { - case cocos2d::renderer::Technique::Parameter::Type::INT: - ret->setInt32(*((int32_t*)data)); - break; - case cocos2d::renderer::Technique::Parameter::Type::INT2: - toVec2(data, DataType::INT, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::INT3: - toVec3(data, DataType::INT, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::INT4: - toVec4(data, DataType::INT, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::FLOAT: - ret->setFloat(*((float*)data)); - break; - case cocos2d::renderer::Technique::Parameter::Type::FLOAT2: - toVec2(data, DataType::FLOAT, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::FLOAT3: - toVec3(data, DataType::FLOAT, ret); - case cocos2d::renderer::Technique::Parameter::Type::FLOAT4: - toVec4(data, DataType::FLOAT, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::MAT2: - toMat((float*)data, 4, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::MAT3: - toMat((float*)data, 9, ret); - break; - case cocos2d::renderer::Technique::Parameter::Type::MAT4: - toMat((float*)data, 16, ret); - break; - default: - assert(false); - break; - } - } - - return true; -} - -bool std_unorderedmap_string_EffectProperty_to_seval(const std::unordered_map& v, se::Value* ret) -{ - assert(ret != nullptr); - - se::HandleObject obj(se::Object::createPlainObject()); - bool ok = true; - for (const auto& e : v) - { - const std::string& key = e.first; - const cocos2d::renderer::Effect::Property& value = e.second; - - if (key.empty()) - continue; - - se::Value tmp; - if (!EffectProperty_to_seval(value, &tmp)) - { - ok = false; - ret->setUndefined(); - break; - } - - obj->setProperty(key.c_str(), tmp); - } - - if (ok) - ret->setObject(obj); - - return ok; -} - bool ManifestAsset_to_seval(const cocos2d::extension::ManifestAsset& v, se::Value* ret) { assert(ret != nullptr); @@ -3018,6 +2897,147 @@ bool DownloadTask_to_seval(const cocos2d::network::DownloadTask& v, se::Value* r // return true; //} +bool std_vector_EffectDefine_to_seval(const std::vector& v, se::Value* ret) +{ + assert(ret != nullptr); + se::HandleObject arr(se::Object::createArrayObject(v.size())); + ret->setObject(arr); + + uint32_t i = 0; + for (const auto&valueMap : v) + { + se::Value out = se::Value::Null; + ccvaluemap_to_seval(valueMap, &out); + arr->setArrayElement(i, out); + + ++i; + } + + return true; +} + +#if USE_GFX_RENDERER +bool Rect_to_seval(const cocos2d::renderer::Rect& v, se::Value* ret) +{ + assert(ret != nullptr); + se::HandleObject obj(se::Object::createPlainObject()); + obj->setProperty("x", se::Value(v.x)); + obj->setProperty("y", se::Value(v.y)); + obj->setProperty("w", se::Value(v.w)); + obj->setProperty("h", se::Value(v.h)); + ret->setObject(obj); + + return true; +} + +bool EffectProperty_to_seval(const cocos2d::renderer::Effect::Property& v, se::Value* ret) +{ + assert(ret != nullptr); + + auto type = v.getType(); + if (type == cocos2d::renderer::Technique::Parameter::Type::TEXTURE_2D || type == cocos2d::renderer::Technique::Parameter::Type::TEXTURE_CUBE) + { + auto count = v.getCount(); + if (0 == count) + { + *ret = se::Value::Null; + } + else if (1 == count) + { + se::Value val; + native_ptr_to_seval(v.getTexture(), &val); + *ret = val; + } + else + { + auto texArray = v.getTextureArray(); + se::HandleObject arr(se::Object::createArrayObject(count)); + for (uint8_t i = 0; i < count; ++i) + { + se::Value val; + native_ptr_to_seval(texArray[0], &val); + arr->setArrayElement(i, val); + } + ret->setObject(arr); + } + } + else + { + void* data = v.getValue(); + + switch (type) { + case cocos2d::renderer::Technique::Parameter::Type::INT: + ret->setInt32(*((int32_t*)data)); + break; + case cocos2d::renderer::Technique::Parameter::Type::INT2: + toVec2(data, DataType::INT, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::INT3: + toVec3(data, DataType::INT, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::INT4: + toVec4(data, DataType::INT, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::FLOAT: + ret->setFloat(*((float*)data)); + break; + case cocos2d::renderer::Technique::Parameter::Type::FLOAT2: + toVec2(data, DataType::FLOAT, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::FLOAT3: + toVec3(data, DataType::FLOAT, ret); + case cocos2d::renderer::Technique::Parameter::Type::FLOAT4: + toVec4(data, DataType::FLOAT, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::MAT2: + toMat((float*)data, 4, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::MAT3: + toMat((float*)data, 9, ret); + break; + case cocos2d::renderer::Technique::Parameter::Type::MAT4: + toMat((float*)data, 16, ret); + break; + default: + assert(false); + break; + } + } + + return true; +} + +bool std_unorderedmap_string_EffectProperty_to_seval(const std::unordered_map& v, se::Value* ret) +{ + assert(ret != nullptr); + + se::HandleObject obj(se::Object::createPlainObject()); + bool ok = true; + for (const auto& e : v) + { + const std::string& key = e.first; + const cocos2d::renderer::Effect::Property& value = e.second; + + if (key.empty()) + continue; + + se::Value tmp; + if (!EffectProperty_to_seval(value, &tmp)) + { + ok = false; + ret->setUndefined(); + break; + } + + obj->setProperty(key.c_str(), tmp); + } + + if (ok) + ret->setObject(obj); + + return ok; +} + bool VertexFormat_to_seval(const cocos2d::renderer::VertexFormat& v, se::Value* ret) { assert(false); @@ -3061,28 +3081,9 @@ bool std_vector_TechniqueParameter_to_seval(const std::vector& v, se::Value* ret) -{ - assert(ret != nullptr); - se::HandleObject arr(se::Object::createArrayObject(v.size())); - ret->setObject(arr); - - uint32_t i = 0; - for (const auto&valueMap : v) - { - se::Value out = se::Value::Null; - ccvaluemap_to_seval(valueMap, &out); - arr->setArrayElement(i, out); - - ++i; - } - - return true; -} - bool std_vector_RenderTarget_to_seval(const std::vector& v, se::Value* ret) { assert(false); return true; } - +#endif // USE_GFX_RENDERER > 0 diff --git a/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp b/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp index 47cdef8799..b0e83a68e5 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_conversions.hpp @@ -101,8 +101,6 @@ bool seval_to_Vec3(const se::Value& v, cocos2d::Vec3* pt); bool seval_to_Vec4(const se::Value& v, cocos2d::Vec4* pt); bool seval_to_Mat4(const se::Value& v, cocos2d::Mat4* mat); bool seval_to_Size(const se::Value& v, cocos2d::Size* size); -//bool seval_to_Rect(const se::Value& v, cocos2d::Rect* rect); -bool seval_to_Rect(const se::Value& v, cocos2d::renderer::Rect* rect); bool seval_to_Color3B(const se::Value& v, cocos2d::Color3B* color); bool seval_to_Color4B(const se::Value& v, cocos2d::Color4B* color); bool seval_to_Color3F(const se::Value& v, cocos2d::Color3F* color); @@ -117,7 +115,9 @@ bool seval_to_std_vector_string(const se::Value& v, std::vector* re bool seval_to_std_vector_int(const se::Value& v, std::vector* ret); bool seval_to_std_vector_float(const se::Value& v, std::vector* ret); bool seval_to_std_vector_Vec2(const se::Value& v, std::vector* ret); -bool seval_to_std_vector_Pass(const se::Value& v, cocos2d::Vector* ret); +//bool seval_to_Rect(const se::Value& v, cocos2d::Rect* rect); + + //bool seval_to_std_vector_Touch(const se::Value& v, std::vector* ret); bool seval_to_std_map_string_string(const se::Value& v, std::map* ret); //bool seval_to_Quaternion(const se::Value& v, cocos2d::Quaternion* ret); @@ -131,6 +131,9 @@ bool seval_to_DownloaderHints(const se::Value& v, cocos2d::network::DownloaderHi //bool seval_to_b2Vec2(const se::Value& v, b2Vec2* ret); //bool seval_to_b2AABB(const se::Value& v, b2AABB* ret); +#if USE_GFX_RENDERER +bool seval_to_Rect(const se::Value& v, cocos2d::renderer::Rect* rect); +bool seval_to_std_vector_Pass(const se::Value& v, cocos2d::Vector* ret); bool seval_to_std_vector_Texture(const se::Value& v, std::vector* ret); bool seval_to_std_vector_RenderTarget(const se::Value& v, std::vector* ret); bool seval_to_TextureOptions(const se::Value& v, cocos2d::renderer::Texture::Options* ret); @@ -142,6 +145,8 @@ bool seval_to_TechniqueParameter_not_constructor(const se::Value& v, cocos2d::re bool seval_to_TechniqueParameter(const se::Value& v, cocos2d::renderer::Technique::Parameter* ret); bool seval_to_std_vector_TechniqueParameter(const se::Value& v, std::vector* ret); bool seval_to_std_vector_ProgramLib_Template(const se::Value& v, std::vector* ret); +bool std_vector_RenderTarget_to_seval(const std::vector& v, se::Value* ret); +#endif template bool seval_to_native_ptr(const se::Value& v, T* ret) @@ -265,7 +270,6 @@ bool Vec4_to_seval(const cocos2d::Vec4& v, se::Value* ret); bool Mat4_to_seval(const cocos2d::Mat4& v, se::Value* ret); bool Size_to_seval(const cocos2d::Size& v, se::Value* ret); //bool Rect_to_seval(const cocos2d::Rect& v, se::Value* ret); -bool Rect_to_seval(const cocos2d::renderer::Rect& v, se::Value* ret); bool Color3B_to_seval(const cocos2d::Color3B& v, se::Value* ret); bool Color4B_to_seval(const cocos2d::Color4B& v, se::Value* ret); bool Color3F_to_seval(const cocos2d::Color3F& v, se::Value* ret); @@ -280,8 +284,7 @@ bool std_vector_int_to_seval(const std::vector& v, se::Value* ret); bool std_vector_float_to_seval(const std::vector& v, se::Value* ret); //bool std_vector_Touch_to_seval(const std::vector& v, se::Value* ret); bool std_map_string_string_to_seval(const std::map& v, se::Value* ret); -bool std_unorderedmap_string_EffectProperty_to_seval(const std::unordered_map& v, se::Value* ret); -bool EffectProperty_to_seval(const cocos2d::renderer::Effect::Property& v, se::Value* ret); + //bool uniform_to_seval(const cocos2d::Uniform* v, se::Value* ret); //bool Quaternion_to_seval(const cocos2d::Quaternion& v, se::Value* ret); bool ManifestAsset_to_seval(const cocos2d::extension::ManifestAsset& v, se::Value* ret); @@ -289,11 +292,16 @@ bool ManifestAsset_to_seval(const cocos2d::extension::ManifestAsset& v, se::Valu ////bool Viewport_to_seval(const cocos2d::experimental::Viewport& v, se::Value* ret); bool Data_to_seval(const cocos2d::Data& v, se::Value* ret); bool DownloadTask_to_seval(const cocos2d::network::DownloadTask& v, se::Value* ret); +bool std_vector_EffectDefine_to_seval(const std::vector& v, se::Value* ret); +#if USE_GFX_RENDERER +bool Rect_to_seval(const cocos2d::renderer::Rect& v, se::Value* ret); +bool std_unorderedmap_string_EffectProperty_to_seval(const std::unordered_map& v, se::Value* ret); +bool EffectProperty_to_seval(const cocos2d::renderer::Effect::Property& v, se::Value* ret); bool VertexFormat_to_seval(const cocos2d::renderer::VertexFormat& v, se::Value* ret); bool TechniqueParameter_to_seval(const cocos2d::renderer::Technique::Parameter& v, se::Value* ret); bool std_vector_TechniqueParameter_to_seval(const std::vector& v, se::Value* ret); -bool std_vector_EffectDefine_to_seval(const std::vector& v, se::Value* ret); +#endif template bool native_ptr_to_seval(typename std::enable_if::value,T>::type* v, se::Value* ret, bool* isReturnCachedValue = nullptr) @@ -588,5 +596,3 @@ bool Vector_to_seval(const cocos2d::Vector& v, se::Value* ret) //bool b2Manifold_to_seval(const b2Manifold* v, se::Value* ret); //bool b2AABB_to_seval(const b2AABB& v, se::Value* ret); -bool std_vector_RenderTarget_to_seval(const std::vector& v, se::Value* ret); - diff --git a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp index e708882be4..0726434865 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_gfx_manual.cpp @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +#include "base/ccConfig.h" #include "jsb_gfx_manual.hpp" +#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp" #include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" #include "gfx/GFX.h" @@ -919,3 +920,4 @@ bool jsb_register_gfx_manual(se::Object* global) se::ScriptEngine::getInstance()->clearException(); return true; } +#endif //#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp index 6f965466a1..5d1fdd91bd 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_global.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_global.cpp @@ -796,6 +796,7 @@ bool jsb_global_load_image(const std::string& path, const se::Value& callbackVal size_t pos = std::string::npos; if (path.find("http://") == 0 || path.find("https://") == 0) { +#if USE_NET_WORK auto request = new cocos2d::network::HttpRequest(); request->setRequestType(cocos2d::network::HttpRequest::Type::GET); request->setUrl(path); @@ -815,6 +816,9 @@ bool jsb_global_load_image(const std::string& path, const se::Value& callbackVal }); cocos2d::network::HttpClient::getInstance()->send(request); request->release(); +#else + SE_REPORT_ERROR("can't load remote image if you disable network module!"); +#endif // USE_NET_WORK } else if (path.find("data:") == 0 && (pos = path.find("base64,")) != std::string::npos) { diff --git a/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp b/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp index bddc0a2032..1608d7a12f 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_module_register.cpp @@ -23,20 +23,9 @@ THE SOFTWARE. ****************************************************************************/ -#define USE_VIDEO 1 -#define USE_WEBVIEW 1 -#define USE_AUDIO 1 -#define USE_NET_WORK 1 - -#define USE_GFX_RENDERER 0 - #include "cocos/scripting/js-bindings/manual/jsb_module_register.hpp" #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" -#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp" -#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp" -#include "cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp" -#include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp" #include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp" #include "cocos/scripting/js-bindings/manual/jsb_global.h" @@ -46,12 +35,18 @@ #include "cocos/scripting/js-bindings/manual/jsb_platform.h" #include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.hpp" + + #if USE_GFX_RENDERER +#include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp" +#include "cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp" #include "cocos/scripting/js-bindings/manual/jsb_gfx_manual.hpp" #include "cocos/scripting/js-bindings/manual/jsb_renderer_manual.hpp" #endif #if USE_NET_WORK +#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp" +#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp" #include "cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.hpp" #include "cocos/scripting/js-bindings/manual/jsb_websocket.hpp" #include "cocos/scripting/js-bindings/manual/jsb_socketio.hpp" @@ -66,7 +61,7 @@ #include "cocos/scripting/js-bindings/auto/jsb_video_auto.hpp" #endif -#if USE_WEBVIEW && (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if USE_WEB_VIEW && (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "cocos/scripting/js-bindings/auto/jsb_webview_auto.hpp" #endif @@ -137,7 +132,7 @@ bool jsb_register_all_modules() se->addRegisterCallback(register_all_video); #endif -#if USE_WEBVIEW && (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#if USE_WEB_VIEW && (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) se->addRegisterCallback(register_all_webview); #endif diff --git a/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp b/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp index 3df0012332..6dc7ce62ed 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_renderer_manual.cpp @@ -22,8 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +#include "base/ccConfig.h" #include "jsb_renderer_manual.hpp" +#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp" #include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" #include "renderer/INode.h" @@ -675,3 +676,5 @@ bool jsb_register_renderer_manual(se::Object* global) return true; } + +#endif //#if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_websocket.cpp b/native/cocos/scripting/js-bindings/manual/jsb_websocket.cpp index 1dcb09134b..c050b71171 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_websocket.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_websocket.cpp @@ -22,9 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - +#include "base/ccConfig.h" #include "jsb_websocket.hpp" - +#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "cocos/scripting/js-bindings/jswrapper/SeApi.h" #include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp" #include "cocos/scripting/js-bindings/manual/jsb_global.h" @@ -499,3 +499,4 @@ bool register_all_websocket(se::Object* obj) return true; } +#endif //#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.cpp b/native/cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.cpp index e678a5b4f7..697b212171 100644 --- a/native/cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.cpp +++ b/native/cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.cpp @@ -30,8 +30,9 @@ // Created by James Chen on 5/15/17. // // - +#include "base/ccConfig.h" #include "jsb_xmlhttprequest.hpp" +#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include #include #include @@ -1026,3 +1027,4 @@ bool register_all_xmlhttprequest(se::Object* global) return true; } +#endif //#if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk index 6b3f1356be..4b6e0874f6 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk +++ b/native/templates/js-template-default/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk @@ -10,6 +10,21 @@ APP_LDFLAGS := -latomic APP_SHORT_COMMANDS := true USE_ARM_MODE := 1 + +# MUST be careful to modify this manually +# disable module will speed up compile time, and reduce package size +USE_GFX_RENDERER := 0 +USE_VIDEO := 1 +USE_WEB_VIEW := 1 +USE_AUDIO := 1 +USE_NET_WORK := 1 + +APP_CPPFLAGS += -DUSE_GFX_RENDERER=$(USE_GFX_RENDERER) +APP_CPPFLAGS += -DUSE_VIDEO=${USE_VIDEO} +APP_CPPFLAGS += -DUSE_WEB_VIEW=${USE_WEB_VIEW} +APP_CPPFLAGS += -DUSE_AUDIO=${USE_AUDIO} +APP_CPPFLAGS += -DUSE_NET_WORK=${USE_NET_WORK} + USE_ANY_SDK := 1 ifeq ($(USE_ANY_SDK),1) diff --git a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk index 6b3f1356be..4b6e0874f6 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk +++ b/native/templates/js-template-link/frameworks/runtime-src/proj.android-studio/app/jni/Application.mk @@ -10,6 +10,21 @@ APP_LDFLAGS := -latomic APP_SHORT_COMMANDS := true USE_ARM_MODE := 1 + +# MUST be careful to modify this manually +# disable module will speed up compile time, and reduce package size +USE_GFX_RENDERER := 0 +USE_VIDEO := 1 +USE_WEB_VIEW := 1 +USE_AUDIO := 1 +USE_NET_WORK := 1 + +APP_CPPFLAGS += -DUSE_GFX_RENDERER=$(USE_GFX_RENDERER) +APP_CPPFLAGS += -DUSE_VIDEO=${USE_VIDEO} +APP_CPPFLAGS += -DUSE_WEB_VIEW=${USE_WEB_VIEW} +APP_CPPFLAGS += -DUSE_AUDIO=${USE_AUDIO} +APP_CPPFLAGS += -DUSE_NET_WORK=${USE_NET_WORK} + USE_ANY_SDK := 1 ifeq ($(USE_ANY_SDK),1) diff --git a/native/tools/tojs/cocos2dx_audioengine.ini b/native/tools/tojs/cocos2dx_audioengine.ini index 6988058466..945e708340 100644 --- a/native/tools/tojs/cocos2dx_audioengine.ini +++ b/native/tools/tojs/cocos2dx_audioengine.ini @@ -7,9 +7,9 @@ prefix = audioengine # all classes will be embedded in that namespace target_namespace = jsb -android_headers = +macro_judgement = #if (USE_AUDIO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +android_headers = android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include diff --git a/native/tools/tojs/cocos2dx_network.ini b/native/tools/tojs/cocos2dx_network.ini index 0985e960e2..cb691720a1 100644 --- a/native/tools/tojs/cocos2dx_network.ini +++ b/native/tools/tojs/cocos2dx_network.ini @@ -7,6 +7,8 @@ prefix = network # all classes will be embedded in that namespace target_namespace = jsb +macro_judgement = #if (USE_NET_WORK > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + android_headers = android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include diff --git a/native/tools/tojs/cocos2dx_video.ini b/native/tools/tojs/cocos2dx_video.ini index 0533a4cbcd..5c0bd8a387 100644 --- a/native/tools/tojs/cocos2dx_video.ini +++ b/native/tools/tojs/cocos2dx_video.ini @@ -7,7 +7,7 @@ prefix = video # all classes will be embedded in that namespace target_namespace = jsb -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +macro_judgement = #if (USE_VIDEO > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) android_headers = diff --git a/native/tools/tojs/cocos2dx_webview.ini b/native/tools/tojs/cocos2dx_webview.ini index 028d2d1bc6..dc305d0c21 100644 --- a/native/tools/tojs/cocos2dx_webview.ini +++ b/native/tools/tojs/cocos2dx_webview.ini @@ -7,7 +7,7 @@ prefix = webview # all classes will be embedded in that namespace target_namespace = jsb -macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) +macro_judgement = #if (USE_WEB_VIEW > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && !defined(CC_TARGET_OS_TVOS) android_headers = diff --git a/native/tools/tojs/gfx.ini b/native/tools/tojs/gfx.ini index 4f89531aa1..c5e2b0b857 100644 --- a/native/tools/tojs/gfx.ini +++ b/native/tools/tojs/gfx.ini @@ -7,6 +7,8 @@ prefix = gfx # all classes will be embedded in that namespace target_namespace = gfx +macro_judgement = #if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + android_headers = android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include diff --git a/native/tools/tojs/renderer.ini b/native/tools/tojs/renderer.ini index ce7565c731..379bfd237c 100644 --- a/native/tools/tojs/renderer.ini +++ b/native/tools/tojs/renderer.ini @@ -7,6 +7,8 @@ prefix = renderer # all classes will be embedded in that namespace target_namespace = renderer +macro_judgement = #if (USE_GFX_RENDERER > 0) && (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) + android_headers = android_flags = -target armv7-none-linux-androideabi -D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS -DANDROID -D__ANDROID_API__=14 -gcc-toolchain %(gcc_toolchain_dir)s --sysroot=%(androidndkdir)s/platforms/android-14/arch-arm -idirafter %(androidndkdir)s/sources/android/support/include -idirafter %(androidndkdir)s/sysroot/usr/include -idirafter %(androidndkdir)s/sysroot/usr/include/arm-linux-androideabi -idirafter %(clangllvmdir)s/lib64/clang/5.0/include -I%(androidndkdir)s/sources/cxx-stl/llvm-libc++/include