mirror of https://github.com/axmolengine/axmol.git
finish angle dependencies auto copy for win32, make flatbuffers dep header only
This commit is contained in:
parent
e58b7c292a
commit
489fb1a50a
|
@ -37,7 +37,6 @@ THE SOFTWARE.
|
||||||
#include "editor-support/cocostudio/CSParseBinary_generated.h"
|
#include "editor-support/cocostudio/CSParseBinary_generated.h"
|
||||||
|
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
#include "flatbuffers/util.h"
|
|
||||||
|
|
||||||
#include "editor-support/cocostudio/FlatBuffersSerialize.h"
|
#include "editor-support/cocostudio/FlatBuffersSerialize.h"
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,6 @@
|
||||||
#include "editor-support/cocostudio/CCComExtensionData.h"
|
#include "editor-support/cocostudio/CCComExtensionData.h"
|
||||||
|
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
#include "flatbuffers/util.h"
|
|
||||||
|
|
||||||
#include "editor-support/cocostudio/FlatBuffersSerialize.h"
|
#include "editor-support/cocostudio/FlatBuffersSerialize.h"
|
||||||
|
|
||||||
|
|
|
@ -62,9 +62,6 @@
|
||||||
#include "editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldExReader.h"
|
#include "editor-support/cocostudio/WidgetReader/TextFieldReader/TextFieldExReader.h"
|
||||||
|
|
||||||
#include "flatbuffers/flatbuffers.h"
|
#include "flatbuffers/flatbuffers.h"
|
||||||
#include "flatbuffers/util.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
using namespace cocos2d::ui;
|
using namespace cocos2d::ui;
|
||||||
|
@ -328,10 +325,9 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithOpaque(void* opaque,
|
||||||
std::string outFullPath = FileUtils::getInstance()->fullPathForFilename(flatbuffersFileName);
|
std::string outFullPath = FileUtils::getInstance()->fullPathForFilename(flatbuffersFileName);
|
||||||
size_t pos = outFullPath.find_last_of('.');
|
size_t pos = outFullPath.find_last_of('.');
|
||||||
std::string convert = outFullPath.substr(0, pos).append(".csb");
|
std::string convert = outFullPath.substr(0, pos).append(".csb");
|
||||||
auto save = flatbuffers::SaveFile(convert.c_str(),
|
auto save = FileUtils::writeBinaryToFile(thiz->_builder->GetBufferPointer(),
|
||||||
reinterpret_cast<const char *>(thiz->_builder->GetBufferPointer()),
|
|
||||||
thiz->_builder->GetSize(),
|
thiz->_builder->GetSize(),
|
||||||
true);
|
convert);
|
||||||
if (!save)
|
if (!save)
|
||||||
{
|
{
|
||||||
return "couldn't save files!";
|
return "couldn't save files!";
|
||||||
|
@ -1668,10 +1664,8 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFileForLanguageData
|
||||||
|
|
||||||
auto langSet = CreateLanguageSet(*_builder, _builder->CreateVector(langItemList));
|
auto langSet = CreateLanguageSet(*_builder, _builder->CreateVector(langItemList));
|
||||||
_builder->Finish(langSet);
|
_builder->Finish(langSet);
|
||||||
bool isSuccess = flatbuffers::SaveFile(flatBuffersFilePath.c_str(),
|
bool isSuccess = FileUtils::writeBinaryToFile(_builder->GetBufferPointer(),
|
||||||
reinterpret_cast<const char *>(_builder->GetBufferPointer()),
|
_builder->GetSize(), flatBuffersFilePath);
|
||||||
_builder->GetSize(),
|
|
||||||
true);
|
|
||||||
|
|
||||||
if (isSuccess)
|
if (isSuccess)
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -497,27 +497,7 @@ void FileUtils::writeStringToFile(std::string dataStr, const std::string& fullPa
|
||||||
|
|
||||||
bool FileUtils::writeDataToFile(const Data& data, const std::string& fullPath) const
|
bool FileUtils::writeDataToFile(const Data& data, const std::string& fullPath) const
|
||||||
{
|
{
|
||||||
size_t size = 0;
|
return FileUtils::writeBinaryToFile(data.getBytes(), data.getSize(), fullPath);
|
||||||
const char* mode = "wb";
|
|
||||||
|
|
||||||
CCASSERT(!fullPath.empty() && data.getSize() != 0, "Invalid parameters.");
|
|
||||||
|
|
||||||
auto fileutils = FileUtils::getInstance();
|
|
||||||
do
|
|
||||||
{
|
|
||||||
// Read the file from hardware
|
|
||||||
FILE *fp = fopen(fullPath.c_str(), mode);
|
|
||||||
CC_BREAK_IF(!fp);
|
|
||||||
size = data.getSize();
|
|
||||||
|
|
||||||
fwrite(data.getBytes(), size, 1, fp);
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} while (0);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileUtils::writeDataToFile(Data data, const std::string& fullPath, std::function<void(bool)> callback) const
|
void FileUtils::writeDataToFile(Data data, const std::string& fullPath, std::function<void(bool)> callback) const
|
||||||
|
@ -527,6 +507,28 @@ void FileUtils::writeDataToFile(Data data, const std::string& fullPath, std::fun
|
||||||
}, std::move(callback), std::move(data));
|
}, std::move(callback), std::move(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileUtils::writeBinaryToFile(const void* data, size_t dataSize, const std::string& fullPath)
|
||||||
|
{
|
||||||
|
const char* mode = "wb";
|
||||||
|
|
||||||
|
CCASSERT(!fullPath.empty() && dataSize > 0, "Invalid parameters.");
|
||||||
|
|
||||||
|
auto fileutils = FileUtils::getInstance();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// Read the file from hardware
|
||||||
|
FILE* fp = fopen(fullPath.c_str(), mode);
|
||||||
|
CC_BREAK_IF(!fp);
|
||||||
|
fwrite(data, dataSize, 1, fp);
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} while (0);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool FileUtils::init()
|
bool FileUtils::init()
|
||||||
{
|
{
|
||||||
DECLARE_GUARD;
|
DECLARE_GUARD;
|
||||||
|
|
|
@ -543,6 +543,11 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool writeDataToFile(const Data& data, const std::string& fullPath) const;
|
virtual bool writeDataToFile(const Data& data, const std::string& fullPath) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save data to file
|
||||||
|
*/
|
||||||
|
static bool writeBinaryToFile(const void* data, size_t dataSize, const std::string& fullPath);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Data into a file, done async off the main cocos thread.
|
* Write Data into a file, done async off the main cocos thread.
|
||||||
|
|
|
@ -432,3 +432,13 @@ if(WINDOWS)
|
||||||
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
|
set_target_properties(${APP_NAME} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
|
||||||
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
|
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/Classes/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
add_custom_command(TARGET ${APP_NAME}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
${COCOS2DX_ROOT_PATH}/external/angle/prebuilt/win32/libGLESv2.dll
|
||||||
|
${COCOS2DX_ROOT_PATH}/external/angle/prebuilt/win32/libEGL.dll
|
||||||
|
${COCOS2DX_ROOT_PATH}/external/angle/prebuilt/win32/d3dcompiler_47.dll
|
||||||
|
$<TARGET_FILE_DIR:${APP_NAME}>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue