diff --git a/.travis.yml b/.travis.yml index 1e67e468bf..762cbcbf06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,8 @@ language: cpp env: matrix: - GEN_JSB=YES - - PLATFORM=linux DEBUG=1 + - PLATFORM=linux DEBUG=1 CC_COMPILER=gcc CXX_COMPILER=g++ + - PLATFORM=linux DEBUG=1 CC_COMPILER=clang CXX_COMPILER=clang++ # Since switching to C++11 only the ARM version of the nactive client # port currently builds. TODO(sbc): Re-enable all architectures. # Disabled travis-ci build for native client port since it doesn't support std::thread, std::mutex. @@ -23,6 +24,8 @@ env: 9lV+vgJQDRcFe7dKwtC86vk10EU7Ym2bhVmhMxi/AlmJXgavjmPVdizRT7rh X2Ry/Nb6hGRkH3WS0T3D/KG1+e7lP/TMB9bvo6/locLJ2A6Z1YI= script: +- export CC=$CC_COMPILER +- export CXX=$CXX_COMPILER - tools/travis-scripts/run-script.sh before_install: - tools/travis-scripts/before-install.sh diff --git a/AUTHORS b/AUTHORS index 789a85cf74..f5895c2f29 100644 --- a/AUTHORS +++ b/AUTHORS @@ -356,6 +356,7 @@ Developers: ThePickleMan Adding 'rotationIsDir' property to ParticleSystem. + DrawNode supports to draw triangle, quad bezier, cubic bezier. Jianghua (jxhgzs) Adding an additional transform for CCNode. @@ -519,6 +520,7 @@ Developers: Correcting the type detecting order for Lua CCBProxy::getNodeTypeName. Casting variables to their own type, and print warning info if no corresponding lua callback function instead of crash. fix of WebSocket url parse error for 'ws://domain.com/websocket' pattern. + Fixed a bug that Websocket doesn't support send/receive data which larger than 4096 bytes. musikov Fixing a bug that missing precision when getting strokeColor and fontFillColor @@ -657,6 +659,7 @@ Developers: xhcnb Device::setAccelerometerEnabled needs to be invoked before adding ACC listener. + Fixed a bug that it will get wrong custom properties when use different count custom properties in CocosBuilder. bopohaa Fixed a bug that Webp test crashes. @@ -704,6 +707,10 @@ Developers: daltomi Fixed a typo in Director class. Removed an unnecessary boolean flag in CCFontAtlasCache.cpp. + + v1ctor + ControlSlider supports to set selected thumb sprite. + ControlButton supports to set scale ratio of touchdown state Retired Core Developers: WenSheng Yang diff --git a/CHANGELOG b/CHANGELOG index 303268968a..420e678c08 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ cocos2d-x-3.0final ?.? ? [All] [FIX] Crash was triggered if there is not `textureFileName`section in particle plist file. + [FIX] ControlSlider doesn't support to set selected thumb sprite. + [FIX] ControlButton doesn't support to set scale ratio of touchdown state. + [FIX] Websocket doesn't support send/receive data which larger than 4096 bytes. + [NEW] DrawNode supports to draw triangle, quad bezier, cubic bezier. cocos2d-x-3.0beta Jan.7 2014 [All] [NEW] New label: shadow, outline, glow support diff --git a/cocos/2d/CCDirector.cpp b/cocos/2d/CCDirector.cpp index 277859644d..428772a367 100644 --- a/cocos/2d/CCDirector.cpp +++ b/cocos/2d/CCDirector.cpp @@ -948,17 +948,20 @@ void Director::createStatsLabel() */ float factor = EGLView::getInstance()->getDesignResolutionSize().height / 320.0f; - _FPSLabel = new LabelAtlas; + _FPSLabel = LabelAtlas::create(); + _FPSLabel->retain(); _FPSLabel->setIgnoreContentScaleFactor(true); _FPSLabel->initWithString("00.0", texture, 12, 32 , '.'); _FPSLabel->setScale(factor); - _SPFLabel = new LabelAtlas; + _SPFLabel = LabelAtlas::create(); + _SPFLabel->retain(); _SPFLabel->setIgnoreContentScaleFactor(true); _SPFLabel->initWithString("0.000", texture, 12, 32, '.'); _SPFLabel->setScale(factor); - _drawsLabel = new LabelAtlas; + _drawsLabel = LabelAtlas::create(); + _drawsLabel->retain(); _drawsLabel->setIgnoreContentScaleFactor(true); _drawsLabel->initWithString("000", texture, 12, 32, '.'); _drawsLabel->setScale(factor); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 42e568cb7a..b920a311c2 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -456,6 +456,86 @@ void DrawNode::drawPolygon(Point *verts, int count, const Color4F &fillColor, fl free(extrude); } +void DrawNode::drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color) +{ + unsigned int vertex_count = 2*3; + ensureCapacity(vertex_count); + + Color4B col = Color4B(color); + V2F_C4B_T2F a = {Vertex2F(p1.x, p1.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F b = {Vertex2F(p2.x, p2.y), col, Tex2F(0.0, 0.0) }; + V2F_C4B_T2F c = {Vertex2F(p3.x, p3.y), col, Tex2F(0.0, 0.0) }; + + V2F_C4B_T2F_Triangle *triangles = (V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount); + V2F_C4B_T2F_Triangle triangle = {a, b, c}; + triangles[0] = triangle; + + _bufferCount += vertex_count; + _dirty = true; +} + +void DrawNode::drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color) +{ + unsigned int vertex_count = (segments + 1) * 3; + ensureCapacity(vertex_count); + + Tex2F texCoord = Tex2F(0.0, 0.0); + Color4B col = Color4B(color); + Vertex2F vertex; + Vertex2F firstVertex = Vertex2F(from.x, from.y); + Vertex2F lastVertex = Vertex2F(to.x, to.y); + + float t = 0; + for(unsigned int i = segments + 1; i > 0; i--) + { + float x = powf(1 - t, 3) * from.x + 3.0f * powf(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * to.x; + float y = powf(1 - t, 3) * from.y + 3.0f * powf(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * to.y; + vertex = Vertex2F(x, y); + + V2F_C4B_T2F a = {firstVertex, col, texCoord }; + V2F_C4B_T2F b = {lastVertex, col, texCoord }; + V2F_C4B_T2F c = {vertex, col, texCoord }; + V2F_C4B_T2F_Triangle triangle = {a, b, c}; + ((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle; + + lastVertex = vertex; + t += 1.0f / segments; + _bufferCount += 3; + } + _dirty = true; +} + +void DrawNode::drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color) +{ + unsigned int vertex_count = (segments + 1) * 3; + ensureCapacity(vertex_count); + + Tex2F texCoord = Tex2F(0.0, 0.0); + Color4B col = Color4B(color); + Vertex2F vertex; + Vertex2F firstVertex = Vertex2F(from.x, from.y); + Vertex2F lastVertex = Vertex2F(to.x, to.y); + + float t = 0; + for(unsigned int i = segments + 1; i > 0; i--) + { + float x = powf(1 - t, 2) * from.x + 2.0f * (1 - t) * t * control.x + t * t * to.x; + float y = powf(1 - t, 2) * from.y + 2.0f * (1 - t) * t * control.y + t * t * to.y; + vertex = Vertex2F(x, y); + + V2F_C4B_T2F a = {firstVertex, col, texCoord }; + V2F_C4B_T2F b = {lastVertex, col, texCoord }; + V2F_C4B_T2F c = {vertex, col, texCoord }; + V2F_C4B_T2F_Triangle triangle = {a, b, c}; + ((V2F_C4B_T2F_Triangle *)(_buffer + _bufferCount))[0] = triangle; + + lastVertex = vertex; + t += 1.0f / segments; + _bufferCount += 3; + } + _dirty = true; +} + void DrawNode::clear() { _bufferCount = 0; diff --git a/cocos/2d/CCDrawNode.h b/cocos/2d/CCDrawNode.h index 6563c3ebfa..2624eeee0b 100644 --- a/cocos/2d/CCDrawNode.h +++ b/cocos/2d/CCDrawNode.h @@ -63,6 +63,15 @@ public: * @endcode */ void drawPolygon(Point *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor); + + /** draw a triangle with color */ + void drawTriangle(const Point &p1, const Point &p2, const Point &p3, const Color4F &color); + + /** draw a cubic bezier curve with color and number of segments */ + void drawCubicBezier(const Point& from, const Point& control1, const Point& control2, const Point& to, unsigned int segments, const Color4F &color); + + /** draw a quadratic bezier curve with color and number of segments */ + void drawQuadraticBezier(const Point& from, const Point& control, const Point& to, unsigned int segments, const Color4F &color); /** Clear the geometry in the node's buffer. */ void clear(); diff --git a/cocos/2d/CCLabelAtlas.cpp b/cocos/2d/CCLabelAtlas.cpp index ddbf4df8f2..200bec0641 100644 --- a/cocos/2d/CCLabelAtlas.cpp +++ b/cocos/2d/CCLabelAtlas.cpp @@ -43,15 +43,30 @@ NS_CC_BEGIN //CCLabelAtlas - Creation & Init +LabelAtlas* LabelAtlas::create() +{ + LabelAtlas* ret = new LabelAtlas(); + if (ret) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + + return ret; +} + LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap) { - LabelAtlas *pRet = new LabelAtlas(); - if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap)) + LabelAtlas* ret = new LabelAtlas(); + if(ret && ret->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap)) { - pRet->autorelease(); - return pRet; + ret->autorelease(); + return ret; } - CC_SAFE_DELETE(pRet); + CC_SAFE_DELETE(ret); return nullptr; } diff --git a/cocos/2d/CCLabelAtlas.h b/cocos/2d/CCLabelAtlas.h index a55abf1c36..47064c14c7 100644 --- a/cocos/2d/CCLabelAtlas.h +++ b/cocos/2d/CCLabelAtlas.h @@ -52,23 +52,11 @@ A more flexible class is LabelBMFont. It supports variable width characters and class CC_DLL LabelAtlas : public AtlasNode, public LabelProtocol { public: - /** - * @js ctor - */ - LabelAtlas() - :_string("") - {} - /** - * @js NA - * @lua NA - */ - virtual ~LabelAtlas() - { - _string.clear(); - } - + /** creates an empty LabelAtlas, user need to call initWithString(...) later to make this object work properly **/ + static LabelAtlas* create(); + /** creates the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - static LabelAtlas * create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); + static LabelAtlas* create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap); /** creates the LabelAtlas with a string and a configuration file @since v2.0 @@ -98,6 +86,15 @@ public: #endif protected: + LabelAtlas() + :_string("") + {} + + virtual ~LabelAtlas() + { + _string.clear(); + } + // string to render std::string _string; // the first char in the charmap diff --git a/cocos/2d/CCMenuItem.cpp b/cocos/2d/CCMenuItem.cpp index d097e1d30a..f137404176 100644 --- a/cocos/2d/CCMenuItem.cpp +++ b/cocos/2d/CCMenuItem.cpp @@ -348,9 +348,8 @@ bool MenuItemAtlasFont::initWithString(const std::string& value, const std::stri bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback) { CCASSERT( value.size() != 0, "value length must be greater than 0"); - LabelAtlas *label = new LabelAtlas(); + LabelAtlas *label = LabelAtlas::create(); label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap); - label->autorelease(); if (MenuItemLabel::initWithLabel(label, callback)) { // do something ? diff --git a/cocos/2d/CCTextureCache.cpp b/cocos/2d/CCTextureCache.cpp index c3526f0b46..4af449c8bf 100644 --- a/cocos/2d/CCTextureCache.cpp +++ b/cocos/2d/CCTextureCache.cpp @@ -183,7 +183,7 @@ void TextureCache::loadImage() break; } _imageInfoMutex.unlock(); - if(infoSize > 0 && pos < infoSize) + if(infoSize == 0 || pos < infoSize) generateImage = true; } diff --git a/cocos/2d/platform/CCImageCommon_cpp.h b/cocos/2d/platform/CCImageCommon_cpp.h index 6c5c7a2d96..40eeca0ae7 100644 --- a/cocos/2d/platform/CCImageCommon_cpp.h +++ b/cocos/2d/platform/CCImageCommon_cpp.h @@ -376,7 +376,7 @@ namespace ////////////////////////////////////////////////////////////////////////// Image::Image() -: _data(0) +: _data(nullptr) , _dataLen(0) , _width(0) , _height(0) @@ -391,10 +391,7 @@ Image::Image() Image::~Image() { - if (_data != nullptr) - { - free(_data); - } + CC_SAFE_FREE(_data); } bool Image::initWithImageFile(const std::string& path) @@ -1539,7 +1536,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData) }while(false); - if (!ret) + if (ret) { const unsigned char tgaSuffix[] = ".tga"; for(int i = 0; i < 4; ++i) @@ -1556,6 +1553,7 @@ bool Image::initWithTGAData(tImageTGA* tgaData) if (tgaData->imageData != nullptr) { free(tgaData->imageData); + _data = nullptr; } } diff --git a/cocos/gui/UITextAtlas.cpp b/cocos/gui/UITextAtlas.cpp index 491ad1af80..7d1eed08c2 100644 --- a/cocos/gui/UITextAtlas.cpp +++ b/cocos/gui/UITextAtlas.cpp @@ -30,52 +30,6 @@ namespace gui { static const int LABELATLAS_RENDERER_Z = (-1); - -UICCLabelAtlas::UICCLabelAtlas() -{ - -} - -UICCLabelAtlas::~UICCLabelAtlas() -{ - -} - -UICCLabelAtlas* UICCLabelAtlas::create() -{ - UICCLabelAtlas *pRet = new UICCLabelAtlas(); - if(pRet) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - - return nullptr; -} - -void UICCLabelAtlas::setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) -{ - initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap); -} - -void UICCLabelAtlas::setProperty(const std::string& string, Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) -{ - initWithString(string, texture, itemWidth, itemHeight, startCharMap); -} - -void UICCLabelAtlas::draw() -{ - if (!_textureAtlas) - { - return; - } - - AtlasNode::draw(); -} - - - TextAtlas::TextAtlas(): _labelAtlasRenderer(nullptr), _stringValue(""), @@ -84,7 +38,6 @@ _itemWidth(0), _itemHeight(0), _startCharMap("") { - } TextAtlas::~TextAtlas() @@ -106,7 +59,7 @@ TextAtlas* TextAtlas::create() void TextAtlas::initRenderer() { - _labelAtlasRenderer = UICCLabelAtlas::create(); + _labelAtlasRenderer = LabelAtlas::create(); Node::addChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1); } @@ -117,7 +70,7 @@ void TextAtlas::setProperty(const std::string& stringValue, const std::string& c _itemWidth = itemWidth; _itemHeight = itemHeight; _startCharMap = startCharMap; - _labelAtlasRenderer->setProperty(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); + _labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); updateAnchorPoint(); labelAtlasScaleChangedWithSize(); } diff --git a/cocos/gui/UITextAtlas.h b/cocos/gui/UITextAtlas.h index 89f28a8b10..99933fcb2e 100644 --- a/cocos/gui/UITextAtlas.h +++ b/cocos/gui/UITextAtlas.h @@ -30,32 +30,7 @@ THE SOFTWARE. NS_CC_BEGIN namespace gui { - -/** - * @js NA - * @lua NA - */ -class UICCLabelAtlas : public LabelAtlas -{ -public: - /** - * Default constructor - */ - UICCLabelAtlas(); - /** - * Default destructor - */ - virtual ~UICCLabelAtlas(); - - /** - * Allocates and initializes. - */ - static UICCLabelAtlas* create(); - void setProperty(const std::string& string, const std::string& charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - void setProperty(const std::string& string, Texture2D *texture, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); - virtual void draw(void) override; -}; /** * @js NA * @lua NA @@ -108,7 +83,7 @@ protected: virtual Widget* createCloneInstance() override; virtual void copySpecialProperties(Widget* model) override; protected: - UICCLabelAtlas* _labelAtlasRenderer; + LabelAtlas* _labelAtlasRenderer; std::string _stringValue; std::string _charMapFileName; int _itemWidth; diff --git a/cocos/network/WebSocket.cpp b/cocos/network/WebSocket.cpp index 3a77d75868..5e17487567 100644 --- a/cocos/network/WebSocket.cpp +++ b/cocos/network/WebSocket.cpp @@ -37,6 +37,8 @@ #include "libwebsockets.h" +#define WS_WRITE_BUFFER_SIZE 2048 + NS_CC_BEGIN namespace network { @@ -44,7 +46,7 @@ namespace network { class WsMessage { public: - WsMessage() : what(0), obj(NULL){} + WsMessage() : what(0), obj(nullptr){} unsigned int what; // message type void* obj; }; @@ -112,7 +114,7 @@ public: // Implementation of WsThreadHelper WsThreadHelper::WsThreadHelper() : _subThreadInstance(nullptr) -, _ws(NULL) +, _ws(nullptr) , _needQuit(false) { _UIWsMessageQueue = new std::list(); @@ -181,7 +183,7 @@ void WsThreadHelper::joinSubThread() void WsThreadHelper::update(float dt) { - WsMessage *msg = NULL; + WsMessage *msg = nullptr; // Returns quickly if no message std::lock_guard lk(_UIWsMessageQueueMutex); @@ -221,6 +223,9 @@ WebSocket::WebSocket() , _delegate(nullptr) , _SSLConnection(0) , _wsProtocols(nullptr) +, _pendingFrameDataLen(0) +, _currentDataLen(0) +, _currentData(nullptr) { } @@ -238,7 +243,7 @@ WebSocket::~WebSocket() bool WebSocket::init(const Delegate& delegate, const std::string& url, - const std::vector* protocols/* = NULL*/) + const std::vector* protocols/* = nullptr*/) { bool ret = false; bool useSSL = false; @@ -497,12 +502,13 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, case LWS_CALLBACK_CLIENT_WRITEABLE: { + std::lock_guard lk(_wsHelper->_subThreadWsMessageQueueMutex); std::list::iterator iter = _wsHelper->_subThreadWsMessageQueue->begin(); int bytesWrite = 0; - for (; iter != _wsHelper->_subThreadWsMessageQueue->end(); ++iter) + for (; iter != _wsHelper->_subThreadWsMessageQueue->end();) { WsMessage* subThreadMsg = *iter; @@ -511,44 +517,64 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, { Data* data = (Data*)subThreadMsg->obj; - unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING - + data->len + LWS_SEND_BUFFER_POST_PADDING]; + const size_t c_bufferSize = WS_WRITE_BUFFER_SIZE; + + size_t remaining = data->len - data->issued; + size_t n = std::min(remaining, c_bufferSize ); + CCLOG("[websocket:send] total: %d, sent: %d, remaining: %d, buffer size: %d", data->len, data->issued, remaining, n); + + unsigned char* buf = new unsigned char[LWS_SEND_BUFFER_PRE_PADDING + n + LWS_SEND_BUFFER_POST_PADDING]; + + memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes + data->issued, n); - memset(&buf[LWS_SEND_BUFFER_PRE_PADDING], 0, data->len); - memcpy((char*)&buf[LWS_SEND_BUFFER_PRE_PADDING], data->bytes, data->len); + int writeProtocol; - enum libwebsocket_write_protocol writeProtocol; - - if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what) - { - writeProtocol = LWS_WRITE_TEXT; + if (data->issued == 0) { + if (WS_MSG_TO_SUBTRHEAD_SENDING_STRING == subThreadMsg->what) + { + writeProtocol = LWS_WRITE_TEXT; + } + else + { + writeProtocol = LWS_WRITE_BINARY; + } + + // If we have more than 1 fragment + if (data->len > c_bufferSize) + writeProtocol |= LWS_WRITE_NO_FIN; + } else { + // we are in the middle of fragments + writeProtocol = LWS_WRITE_CONTINUATION; + // and if not in the last fragment + if (remaining != n) + writeProtocol |= LWS_WRITE_NO_FIN; } - else - { - writeProtocol = LWS_WRITE_BINARY; - } - - bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], data->len, writeProtocol); - + + bytesWrite = libwebsocket_write(wsi, &buf[LWS_SEND_BUFFER_PRE_PADDING], n, (libwebsocket_write_protocol)writeProtocol); + CCLOG("[websocket:send] bytesWrite => %d", bytesWrite); + + // Buffer overrun? if (bytesWrite < 0) { - CCLOGERROR("%s", "libwebsocket_write error..."); + break; } - if (bytesWrite < data->len) + // Do we have another fragments to send? + else if (remaining != n) { - CCLOGERROR("Partial write LWS_CALLBACK_CLIENT_WRITEABLE\n"); + data->issued += n; + break; + } + // Safely done! + else + { + CC_SAFE_DELETE_ARRAY(data->bytes); + CC_SAFE_DELETE(data); + CC_SAFE_DELETE_ARRAY(buf); + _wsHelper->_subThreadWsMessageQueue->erase(iter++); + CC_SAFE_DELETE(subThreadMsg); } - - CC_SAFE_DELETE_ARRAY(data->bytes); - CC_SAFE_DELETE(data); - CC_SAFE_DELETE_ARRAY(buf); } - - CC_SAFE_DELETE(subThreadMsg); } - - _wsHelper->_subThreadWsMessageQueue->clear(); - /* get notified as soon as we can write again */ @@ -577,32 +603,64 @@ int WebSocket::onSocketCallback(struct libwebsocket_context *ctx, { if (in && len > 0) { - WsMessage* msg = new WsMessage(); - msg->what = WS_MSG_TO_UITHREAD_MESSAGE; - - char* bytes = NULL; - Data* data = new Data(); - - if (lws_frame_is_binary(wsi)) + // Accumulate the data (increasing the buffer as we go) + if (_currentDataLen == 0) { - - bytes = new char[len]; - data->isBinary = true; + _currentData = new char[len]; + memcpy (_currentData, in, len); + _currentDataLen = len; } else { - bytes = new char[len+1]; - bytes[len] = '\0'; - data->isBinary = false; + char *new_data = new char [_currentDataLen + len]; + memcpy (new_data, _currentData, _currentDataLen); + memcpy (new_data + _currentDataLen, in, len); + CC_SAFE_DELETE_ARRAY(_currentData); + _currentData = new_data; + _currentDataLen = _currentDataLen + len; } - memcpy(bytes, in, len); + _pendingFrameDataLen = libwebsockets_remaining_packet_payload (wsi); + + if (_pendingFrameDataLen > 0) + { + //CCLOG("%ld bytes of pending data to receive, consider increasing the libwebsocket rx_buffer_size value.", _pendingFrameDataLen); + } - data->bytes = bytes; - data->len = len; - msg->obj = (void*)data; - - _wsHelper->sendMessageToUIThread(msg); + // If no more data pending, send it to the client thread + if (_pendingFrameDataLen == 0) + { + WsMessage* msg = new WsMessage(); + msg->what = WS_MSG_TO_UITHREAD_MESSAGE; + + char* bytes = nullptr; + Data* data = new Data(); + + if (lws_frame_is_binary(wsi)) + { + + bytes = new char[_currentDataLen]; + data->isBinary = true; + } + else + { + bytes = new char[_currentDataLen+1]; + bytes[_currentDataLen] = '\0'; + data->isBinary = false; + } + + memcpy(bytes, _currentData, _currentDataLen); + + data->bytes = bytes; + data->len = _currentDataLen; + msg->obj = (void*)data; + + CC_SAFE_DELETE_ARRAY(_currentData); + _currentData = nullptr; + _currentDataLen = 0; + + _wsHelper->sendMessageToUIThread(msg); + } } } break; diff --git a/cocos/network/WebSocket.h b/cocos/network/WebSocket.h index d9363bb666..738abf2c2f 100644 --- a/cocos/network/WebSocket.h +++ b/cocos/network/WebSocket.h @@ -62,9 +62,9 @@ public: */ struct Data { - Data():bytes(NULL), len(0), isBinary(false){} + Data():bytes(nullptr), len(0), issued(0), isBinary(false){} char* bytes; - ssize_t len; + ssize_t len, issued; bool isBinary; }; @@ -112,7 +112,7 @@ public: */ bool init(const Delegate& delegate, const std::string& url, - const std::vector* protocols = NULL); + const std::vector* protocols = nullptr); /** * @brief Sends string data to websocket server. @@ -153,6 +153,10 @@ private: unsigned int _port; std::string _path; + size_t _pendingFrameDataLen; + unsigned int _currentDataLen; + char *_currentData; + friend class WsThreadHelper; WsThreadHelper* _wsHelper; diff --git a/cocos/scripting/auto-generated b/cocos/scripting/auto-generated index f387eb216f..f7835c1364 160000 --- a/cocos/scripting/auto-generated +++ b/cocos/scripting/auto-generated @@ -1 +1 @@ -Subproject commit f387eb216fd0849b8482203c76b5a8ce1b99471b +Subproject commit f7835c13644591879f5a995074ccc8faf70c355e diff --git a/cocos/scripting/lua/bindings/Lua_web_socket.cpp b/cocos/scripting/lua/bindings/Lua_web_socket.cpp index 8301c75d8f..4d3b8ae715 100644 --- a/cocos/scripting/lua/bindings/Lua_web_socket.cpp +++ b/cocos/scripting/lua/bindings/Lua_web_socket.cpp @@ -102,18 +102,22 @@ void LuaWebSocket::onMessage(WebSocket* ws, const WebSocket::Data& data) LuaWebSocket* luaWs = dynamic_cast(ws); if (NULL != luaWs) { if (data.isBinary) { - int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); - if (0 != nHandler) { - SendBinaryMessageToLua(nHandler, (const unsigned char*)data.bytes, data.len); + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); + if (0 != handler) { + SendBinaryMessageToLua(handler, (const unsigned char*)data.bytes, data.len); } } else{ - int nHandler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); - if (0 != nHandler) { - CommonScriptData commonData(nHandler,data.bytes); - ScriptEvent event(kCommonEvent,(void*)&commonData); - ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event); + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this,ScriptHandlerMgr::HandlerType::WEBSOCKET_MESSAGE); + if (0 != handler) + { + LuaStack* stack = LuaEngine::getInstance()->getLuaStack(); + if (nullptr != stack) + { + stack->pushString(data.bytes,data.len); + stack->executeFunctionByHandler(handler, 1); + } } } } diff --git a/extensions/GUI/CCControlExtension/CCControlButton.cpp b/extensions/GUI/CCControlExtension/CCControlButton.cpp index 4bd03a0fde..9312c82995 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.cpp +++ b/extensions/GUI/CCControlExtension/CCControlButton.cpp @@ -80,13 +80,13 @@ bool ControlButton::initWithLabelAndBackgroundSprite(Node* node, Scale9Sprite* b _parentInited = true; _isPushed = false; - _zoomOnTouchDown = true; // Adjust the background image by default setAdjustBackgroundImage(true); setPreferredSize(Size::ZERO); // Zooming button by default _zoomOnTouchDown = true; + _scaleRatio = 1.1f; // Set the default anchor point ignoreAnchorPointForPosition(false); @@ -199,7 +199,7 @@ void ControlButton::setHighlighted(bool enabled) needsLayout(); if( _zoomOnTouchDown ) { - float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? 1.1f : 1.0f; + float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? _scaleRatio : 1.0f; Action *zoomAction = ScaleTo::create(0.05f, scaleValue); zoomAction->setTag(kZoomActionTag); runAction(zoomAction); diff --git a/extensions/GUI/CCControlExtension/CCControlButton.h b/extensions/GUI/CCControlExtension/CCControlButton.h index 7ab0e1a284..d4208c0566 100644 --- a/extensions/GUI/CCControlExtension/CCControlButton.h +++ b/extensions/GUI/CCControlExtension/CCControlButton.h @@ -226,6 +226,8 @@ protected: /** Adjust the button zooming on touchdown. Default value is YES. */ CC_PROPERTY(bool, _zoomOnTouchDown, ZoomOnTouchDown); + /** Scale ratio button on touchdown. Default value 1.1f */ + CC_SYNTHESIZE(float, _scaleRatio, ScaleRatio); CC_PROPERTY_PASS_BY_REF(Point, _labelAnchorPoint, LabelAnchorPoint); diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.cpp b/extensions/GUI/CCControlExtension/CCControlSlider.cpp index bafd327d69..ace6ef2cec 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.cpp +++ b/extensions/GUI/CCControlExtension/CCControlSlider.cpp @@ -40,6 +40,7 @@ ControlSlider::ControlSlider() , _minimumAllowedValue(0.0f) , _maximumAllowedValue(0.0f) , _thumbSprite(NULL) +, _selectedThumbSprite(NULL) , _progressSprite(NULL) , _backgroundSprite(NULL) { @@ -49,6 +50,7 @@ ControlSlider::ControlSlider() ControlSlider::~ControlSlider() { CC_SAFE_RELEASE(_thumbSprite); + CC_SAFE_RELEASE(_selectedThumbSprite); CC_SAFE_RELEASE(_progressSprite); CC_SAFE_RELEASE(_backgroundSprite); } @@ -57,6 +59,21 @@ ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFil { // Prepare background for slider Sprite *backgroundSprite = Sprite::create(bgFile); + + // Prepare progress for slider + Sprite *progressSprite = Sprite::create(progressFile); + + // Prepare thumb (menuItem) for slider + Sprite *thumbSprite = Sprite::create(thumbFile); + + return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite); +} + +ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile, + const char* selectedThumbSpriteFile) +{ + // Prepare background for slider + Sprite *backgroundSprite = Sprite::create(bgFile); // Prepare progress for slider Sprite *progressSprite = Sprite::create(progressFile); @@ -64,7 +81,10 @@ ControlSlider* ControlSlider::create(const char* bgFile, const char* progressFil // Prepare thumb (menuItem) for slider Sprite *thumbSprite = Sprite::create(thumbFile); - return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite); + // Prepare selected thumb (menuItem) for slider + Sprite *selectedThumbSprite = Sprite::create(selectedThumbSpriteFile); + + return ControlSlider::create(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite); } ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite) @@ -75,19 +95,39 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS return pRet; } - bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite) +ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite) +{ + ControlSlider *pRet = new ControlSlider(); + pRet->initWithSprites(backgroundSprite, pogressSprite, thumbSprite, selectedThumbSprite); + pRet->autorelease(); + return pRet; +} + +bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite) +{ + Sprite* selectedThumbSprite = Sprite::createWithTexture(thumbSprite->getTexture(), + thumbSprite->getTextureRect()); + selectedThumbSprite->setColor(Color3B::GRAY); + return this->initWithSprites(backgroundSprite, progressSprite, thumbSprite, selectedThumbSprite); +} + + bool ControlSlider::initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite) { if (Control::init()) { - CCASSERT(backgroundSprite, "Background sprite must be not nil"); - CCASSERT(progressSprite, "Progress sprite must be not nil"); - CCASSERT(thumbSprite, "Thumb sprite must be not nil"); + CCASSERT(backgroundSprite, "Background sprite must be not nil"); + CCASSERT(progressSprite, "Progress sprite must be not nil"); + CCASSERT(thumbSprite, "Thumb sprite must be not nil"); + CCASSERT(selectedThumbSprite, "Thumb sprite must be not nil"); ignoreAnchorPointForPosition(false); this->setBackgroundSprite(backgroundSprite); this->setProgressSprite(progressSprite); this->setThumbSprite(thumbSprite); + this->setSelectedThumbSprite(selectedThumbSprite); // Defines the content size Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox()); @@ -108,6 +148,10 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS _thumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2)); addChild(_thumbSprite); + _selectedThumbSprite->setPosition(Point(0.0f, this->getContentSize().height / 2)); + _selectedThumbSprite->setVisible(false); + addChild(_selectedThumbSprite); + // Init default values _minimumValue = 0.0f; _maximumValue = 1.0f; @@ -227,7 +271,8 @@ void ControlSlider::onTouchEnded(Touch *pTouch, Event *pEvent) void ControlSlider::needsLayout() { - if (NULL == _thumbSprite || NULL == _backgroundSprite || NULL == _progressSprite) + if (NULL == _thumbSprite || NULL == _selectedThumbSprite || NULL == _backgroundSprite + || NULL == _progressSprite) { return; } @@ -237,6 +282,7 @@ void ControlSlider::needsLayout() Point pos = _thumbSprite->getPosition(); pos.x = percent * _backgroundSprite->getContentSize().width; _thumbSprite->setPosition(pos); + _selectedThumbSprite->setPosition(pos); // Stretches content proportional to newLevel Rect textureRect = _progressSprite->getTextureRect(); @@ -247,7 +293,8 @@ void ControlSlider::needsLayout() void ControlSlider::sliderBegan(Point location) { this->setSelected(true); - this->getThumbSprite()->setColor(Color3B::GRAY); + _thumbSprite->setVisible(false); + _selectedThumbSprite->setVisible(true); setValue(valueForLocation(location)); } @@ -262,7 +309,8 @@ void ControlSlider::sliderEnded(Point location) { setValue(valueForLocation(_thumbSprite->getPosition())); } - this->getThumbSprite()->setColor(Color3B::WHITE); + _thumbSprite->setVisible(true); + _selectedThumbSprite->setVisible(false); this->setSelected(false); } diff --git a/extensions/GUI/CCControlExtension/CCControlSlider.h b/extensions/GUI/CCControlExtension/CCControlSlider.h index 2a9f782e2d..9d5f2bc2ff 100644 --- a/extensions/GUI/CCControlExtension/CCControlSlider.h +++ b/extensions/GUI/CCControlExtension/CCControlSlider.h @@ -58,6 +58,22 @@ public: * @see initWithSprites */ static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite); + + /** + * Creates slider with a background filename, a progress filename, a thumb + * and a selected thumb image filename. + */ + static ControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile, + const char* selectedThumbSpriteFile); + + /** + * Creates a slider with a given background sprite and a progress bar, a thumb + * and a selected thumb . + * + * @see initWithSprites + */ + static ControlSlider* create(Sprite * backgroundSprite, Sprite* pogressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite); /** * @js ctor */ @@ -68,15 +84,27 @@ public: */ virtual ~ControlSlider(); + /** + * Initializes a slider with a background sprite, a progress bar and a thumb + * item. + * + * @param backgroundSprite Sprite, that is used as a background. + * @param progressSprite Sprite, that is used as a progress bar. + * @param thumbSprite Sprite, that is used as a thumb. + */ + virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite); + /** * Initializes a slider with a background sprite, a progress bar and a thumb * item. * - * @param backgroundSprite Sprite, that is used as a background. - * @param progressSprite Sprite, that is used as a progress bar. - * @param thumbSprite Sprite, that is used as a thumb. + * @param backgroundSprite Sprite, that is used as a background. + * @param progressSprite Sprite, that is used as a progress bar. + * @param thumbSprite Sprite, that is used as a thumb. + * @param selectedThumbSprite Sprite, that is used as a selected thumb. */ - virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite); + virtual bool initWithSprites(Sprite * backgroundSprite, Sprite* progressSprite, Sprite* thumbSprite, + Sprite* selectedThumbSprite); virtual void needsLayout(); @@ -116,8 +144,10 @@ protected: // maybe this should be read-only CC_SYNTHESIZE_RETAIN(Sprite*, _thumbSprite, ThumbSprite); + CC_SYNTHESIZE_RETAIN(Sprite*, _selectedThumbSprite, SelectedThumbSprite); CC_SYNTHESIZE_RETAIN(Sprite*, _progressSprite, ProgressSprite); CC_SYNTHESIZE_RETAIN(Sprite*, _backgroundSprite, BackgroundSprite); + }; // end of GUI group diff --git a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp index 63959537d8..6ebcc144cc 100644 --- a/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp +++ b/samples/Cpp/TestCpp/Classes/CocosDenshionTest/CocosDenshionTest.cpp @@ -4,17 +4,17 @@ #include "extensions/GUI/CCControlExtension/CCControlSlider.h" // android effect only support ogg -#if (CC_TARGET_PLATFORM == CC_PLATFOR_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #define EFFECT_FILE "effect2.ogg" -#elif( CC_TARGET_PLATFORM == CC_PLATFOR_MARMALADE) +#elif( CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) #define EFFECT_FILE "effect1.raw" #else #define EFFECT_FILE "effect1.wav" #endif // CC_PLATFOR_ANDROID -#if (CC_TARGET_PLATFORM == CC_PLATFOR_WIN32) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #define MUSIC_FILE "music.mid" -#elif (CC_TARGET_PLATFORM == CC_PLATFOR_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFOR_LINUX ) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_BLACKBERRY || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX ) #define MUSIC_FILE "background.ogg" #else #define MUSIC_FILE "background.mp3" diff --git a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 9a751b8d97..61aa2aa0b2 100644 --- a/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/samples/Cpp/TestCpp/Classes/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -302,6 +302,14 @@ DrawNodeTest::DrawNodeTest() draw->drawSegment(Point(20,s.height), Point(20,s.height/2), 10, Color4F(0, 1, 0, 1)); draw->drawSegment(Point(10,s.height/2), Point(s.width/2, s.height/2), 40, Color4F(1, 0, 1, 0.5)); + + // Draw triangle + draw->drawTriangle(Point(10, 10), Point(70, 30), Point(100, 140), Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + + // Draw some beziers + draw->drawQuadraticBezier(Point(s.width - 150, s.height - 150), Point(s.width - 70, s.height - 10), Point(s.width - 10, s.height - 10), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); + + draw->drawCubicBezier(Point(s.width - 250, 40), Point(s.width - 70, 100), Point(s.width - 30, 250), Point(s.width - 10, s.height - 50), 10, Color4F(CCRANDOM_0_1(), CCRANDOM_0_1(), CCRANDOM_0_1(), 0.5)); } string DrawNodeTest::title() const diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index 1c1ae1084a..0bbb8cc63a 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -25,6 +25,7 @@ static std::function createFunctions[] = { CL(LayerExtendedBlendOpacityTest), CL(LayerBug3162A), CL(LayerBug3162B), + CL(LayerColorOccludeBug), }; static int sceneIdx=-1; @@ -954,3 +955,27 @@ std::string LayerBug3162B::subtitle() const { return "u and m layer color is effected/diseffected with b layer"; } + +std::string LayerColorOccludeBug::title() const +{ + return "Layer Color Occlude Bug Test"; +} + +std::string LayerColorOccludeBug::subtitle() const +{ + return "Layer Color Should not occlude titles and any sprites"; +} + +void LayerColorOccludeBug::onEnter() +{ + LayerTest::onEnter(); + Director::getInstance()->setDepthTest(true); + _layer = LayerColor::create(Color4B(0, 80, 95, 255)); + addChild(_layer); +} + +void LayerColorOccludeBug::onExit() +{ + LayerTest::onExit(); + Director::getInstance()->setDepthTest(false); +} diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h index 61a8602200..61b4f6fc2c 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h @@ -202,6 +202,19 @@ private: LayerColor* _layer[3]; }; +class LayerColorOccludeBug : public LayerTest +{ +public: + CREATE_FUNC(LayerColorOccludeBug); + virtual void onEnter() override; + virtual void onExit() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; + +private: + LayerColor* _layer; +}; + class LayerTestScene : public TestScene { public: diff --git a/tools/jenkins-scripts/create-job.py b/tools/jenkins-scripts/create-job.py index ef3e386368..1aac211cdf 100644 --- a/tools/jenkins-scripts/create-job.py +++ b/tools/jenkins-scripts/create-job.py @@ -19,7 +19,7 @@ r = requests.get(api_get_pr) pr = r.json() #forge a payload -payload = {"action":"open","number":"","pull_request":""} +payload = {"action":"opened","number":"","pull_request":""} payload['number']=pr_num payload['pull_request']=pr diff --git a/tools/jenkins-scripts/gen_jsb.sh b/tools/jenkins-scripts/gen_jsb.sh new file mode 100755 index 0000000000..1e8fc1b084 --- /dev/null +++ b/tools/jenkins-scripts/gen_jsb.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +# Generate JS and Lua bindings for Cocos2D-X +# ... using Android NDK system headers +# ... and automatically update submodule references +# ... and push these changes to remote repos + +# Dependencies +# +# For bindings generator: +# (see ../../../tojs/genbindings.sh and ../../../tolua/genbindings.sh +# ... for the defaults used if the environment is not customized) +# +# * $PYTHON_BIN +# * $CLANG_ROOT +# * $NDK_ROOT +# +echo "[test]start generate js binding..." +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +COCOS2DX_ROOT="$DIR"/../.. +TOJS_ROOT=$COCOS2DX_ROOT/tools/tojs +TOLUA_ROOT=$COCOS2DX_ROOT/tools/tolua +GENERATED_WORKTREE="$COCOS2DX_ROOT"/cocos/scripting/auto-generated + + +# Exit on error +set -e + +generate_bindings_glue_codes() +{ + echo "Create auto-generated jsbinding glue codes." + pushd "$TOJS_ROOT" + ./genbindings.sh + popd + + echo "Create auto-generated luabinding glue codes." + pushd "$TOLUA_ROOT" + ./genbindings.sh + popd +} + +# Update submodule of auto-gen Binding repo. +pushd "$GENERATED_WORKTREE" + +echo "Delete all directories and files except '.git' and 'README.md'." +ls -a | grep -E -v ^\[.\]\{1,2\}$ | grep -E -v ^\.git$ | grep -E -v ^README\.md$ | xargs -I{} rm -rf {} +popd + + + +# 1. Generate JS bindings +generate_bindings_glue_codes + +echo +echo Bindings generated successfully +echo + + diff --git a/tools/jenkins-scripts/ghprb.py b/tools/jenkins-scripts/ghprb.py index c2c20c1939..3f258e4401 100755 --- a/tools/jenkins-scripts/ghprb.py +++ b/tools/jenkins-scripts/ghprb.py @@ -38,9 +38,8 @@ def main(): action = payload['action'] print 'action: ' + action - - pr = payload['pull_request'] + url = pr['html_url'] print "url:" + url pr_desc = '

pr#' + str(pr_num) + ' is '+ action +'

' @@ -61,7 +60,18 @@ def main(): if((action != 'opened') and (action != 'synchronize')): print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered' return(0) + + r = requests.get(pr['url']+"/commits") + commits = r.json() + last_commit = commits[len(commits)-1] + message = last_commit['commit']['message'] + pattern = re.compile("\[ci(\s+)skip\]", re.I) + result = pattern.search(message) + if result is not None: + print 'skip build for pull request #' + str(pr_num) + return(0) + data = {"state":"pending", "target_url":target_url} access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} @@ -79,6 +89,7 @@ def main(): print "git clean -xdf" os.system("git clean -xdf") + #fetch pull request to local repo git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/head" os.system(git_fetch_pr) @@ -91,6 +102,10 @@ def main(): git_update_submodule = "git submodule update --init --force" os.system(git_update_submodule) + # Generate binding glue codes + if(platform.system() == 'Darwin'): + os.system("tools/jenkins-scripts/gen_jsb.sh") + #make temp dir print "current dir is" + os.environ['WORKSPACE'] os.system("cd " + os.environ['WORKSPACE']);