Merge pull request #2955 from sbc100/nacl_develop_fixes

closed #2318: Adding Native Client support for develop branch and some warnings fixes.
This commit is contained in:
James Chen 2013-06-20 18:58:40 -07:00
commit dc802ced1e
27 changed files with 138 additions and 482 deletions

View File

@ -4,8 +4,9 @@ env:
matrix:
- GEN_JSB=YES
- PLATFORM=linux DEBUG=1
# Native client port doesn't support c++ 11 fully, it seems that it doesn't support lambda, please refer to https://github.com/cocos2d/cocos2d-x/blob/develop/samples/Cpp/TestCpp/Classes/ActionsTest/ActionsTest.cpp#L982
# - PLATFORM=nacl DEBUG=1
# Since switching to C++11 only the ARM version of the nactive client
# port currently builds. TODO(sbc): Re-enable all architectures.
- PLATFORM=nacl DEBUG=1 NACL_ARCH=arm
- PLATFORM=android
- PLATFORM=emscripten DEBUG=1
global:
@ -24,6 +25,7 @@ env:
script:
- export NACL_SDK_ROOT=$HOME/bin/nacl_sdk/pepper_canary
- export PATH=$PATH:$NACL_SDK_ROOT/toolchain/linux_x86_newlib/bin
- export PATH=$PATH:$NACL_SDK_ROOT/toolchain/linux_arm_newlib/bin
- export NDK_ROOT=$HOME/bin/android-ndk
- export PYTHON=/usr/bin/python
- export LLVM=$HOME/bin/clang+llvm-3.2/bin

View File

@ -1,16 +1,17 @@
#!/bin/bash
# Build script to build all components for Native Client.
#
# By default this script will only build debug versions.
# Pass "all" as an argument to build clean and also build
# release config.
# By default this script will build the 'all' target in
# both debug and release configurations. Pass "clean" to
# clean all configuration.
#
# Before running this script you need to set NACL_SDK_ROOT
# and add the NaCl compiler bin folder to your path.
#
# There are several libraries from naclports that are
# prerequisite for building cocos2dx on NaCl. The simplest
# way to build them is to checkout naclports and run:
# prerequisite for building cocos2dx on NaCl. These ship
# with recent versions of the NaCl SDK or you can build
# them yourself by checking out naclports and running:
# $ make png tiff freetype xml2 freealut jpeg vorbis ogg
if [ -z "$NACL_SDK_ROOT" ]; then
@ -32,11 +33,13 @@ mkdir -p $OUTPUT_RELEASE
export MAKEFLAGS="-j10 PLATFORM=nacl"
if [ "$1" = "clean" ]; then
make DEBUG=1 clean
make DEBUG=0 clean
exit 0
fi
make NACL_ARCH=x86_64 DEBUG=1 $*
make NACL_ARCH=x86_64 DEBUG=0 $*
make DEBUG=1 all
make DEBUG=0 all
make NACL_ARCH=i686 DEBUG=1 $*
make NACL_ARCH=i686 DEBUG=0 $*
if [ "${NACL_GLIBC:-}" != "1" ]; then
make NACL_ARCH=arm DEBUG=1 $*
make NACL_ARCH=arm DEBUG=0 $*
fi

View File

@ -40,7 +40,7 @@ public:
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setDelegate(AccelerometerDelegate* pDelegate) {CC_UNUSED_PARAM(pDelegate);};
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
};

View File

@ -57,7 +57,7 @@ NS_CC_BEGIN
class BitmapDC
{
public:
BitmapDC() : _data(NULL), _cachedSize(0), _cachedFont(NULL)
BitmapDC() : _data(NULL), _cachedFont(NULL)
{
libError = FT_Init_FreeType(&_library);
iInterval = szFont_kenning;
@ -343,24 +343,24 @@ public:
fontfile += ".ttf" ;
}
iError = openFont(fontfile, fontSize, fontfileOrig);
iError = openFont(fontfile, fontfileOrig);
// try with fonts prefixed
if (iError && !startsWith(fontfile,"fonts/") )
{
fontfile = std::string("fonts/") + fontfile;
iError = openFont(fontfile, fontSize, fontfileOrig);
iError = openFont(fontfile, fontfileOrig);
}
if (iError)
{
// try lowercase version
std::transform(fontfile.begin(), fontfile.end(), fontfile.begin(), ::tolower);
iError = openFont(fontfile, fontSize, fontfileOrig);
iError = openFont(fontfile, fontfileOrig);
if (iError)
{
// try default font
CCLOG("font missing (%s) falling back to default font", fontfileOrig.c_str());
iError = openFont("fonts/Marker Felt.ttf", fontSize, fontfileOrig);
iError = openFont("fonts/Marker Felt.ttf", fontfileOrig);
if (iError)
CCLOG("default font missing (fonts/Marker Felt.ttf)");
}
@ -423,10 +423,9 @@ private:
/**
* Attempt to open font file, and cache it if successful.
*/
int openFont(const std::string& fontName, uint fontSize, const std::string& fontNameOrig);
int openFont(const std::string& fontName, const std::string& fontNameOrig);
std::string fileNameExtension(const std::string& pathName);
uint _cachedSize;
FT_Face _cachedFont;
std::string _cachedFontname;
std::string _cachedFontnameOrig;
@ -501,17 +500,14 @@ bool BitmapDC::startsWith(const std::string& str, const std::string& what)
return result ;
}
int BitmapDC::openFont(const std::string& fontName, uint fontSize, const std::string& fontNameOrig)
int BitmapDC::openFont(const std::string& fontName, const std::string& fontNameOrig)
{
// try to satisfy request based on currently cached font.
if (_cachedSize == fontSize)
{
if (fontNameOrig == _cachedFontnameOrig)
return 0;
if (fontNameOrig == _cachedFontnameOrig)
return 0;
if (fontName == _cachedFontname)
return 0;
}
if (fontName == _cachedFontname)
return 0;
FT_Face face;
int iError = FT_New_Face(_library, fontName.c_str(), 0, &face);
@ -526,7 +522,6 @@ int BitmapDC::openFont(const std::string& fontName, uint fontSize, const std::st
_cachedFontnameOrig = fontNameOrig;
_cachedFontname = fontName;
_cachedFont = face;
_cachedSize = fontSize;
return 0;
}

View File

@ -26,11 +26,10 @@ THE SOFTWARE.
#include "CCInstance.h"
#include "CCApplication.h"
#include "CCEGLView.h"
#include <ppapi/cpp/instance.h>
#include <ppapi/cpp/module.h>
#ifndef OLD_NACL_MOUNTS
#include "nacl_io/nacl_io.h"
#endif
#include <nacl_io/nacl_io.h>
#include <errno.h>
#include <fcntl.h>
@ -42,9 +41,6 @@ THE SOFTWARE.
USING_NS_CC;
CocosPepperInstance::CocosPepperInstance(PP_Instance instance) : pp::Instance(instance),
#ifdef OLD_NACL_MOUNTS
_runner(NULL),
#endif
_running(false)
{
RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
@ -78,14 +74,10 @@ void CocosPepperInstance::DidChangeView(const pp::View& view)
bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* argv[])
{
CCLog("CocosPepperInstance::Init");
#ifdef OLD_NACL_MOUNTS
_runner = new MainThreadRunner(this);
#else
CCLOG("%p %p", (void*)pp_instance(), (void*)pp::Module::Get()->get_browser_interface());
nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface());
CCLOG("done nacl_mounts_init_ppapi");
CCLog("CocosPepperInstance::Init: %x %p", pp_instance(),
pp::Module::Get()->get_browser_interface());
nacl_io_init_ppapi(pp_instance(),
pp::Module::Get()->get_browser_interface());
umount("/");
int rtn = mount("Resources", /* source. Use relative URL */
@ -100,7 +92,6 @@ bool CocosPepperInstance::Init(uint32_t argc, const char* argn[], const char* ar
return false;
}
#endif
return true;
}

View File

@ -29,23 +29,13 @@ THE SOFTWARE.
#include <ppapi/cpp/input_event.h>
#include <pthread.h>
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/MainThreadRunner.h"
#endif
extern "C" void* cocos_main(void* arg);
class CocosPepperInstance : public pp::Instance {
public:
explicit CocosPepperInstance(PP_Instance instance);
virtual ~CocosPepperInstance()
{
#ifdef OLD_NACL_MOUNTS
if (_runner)
delete _runner;
#endif
}
virtual ~CocosPepperInstance() {}
virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]);
@ -55,9 +45,6 @@ public:
pp::Size Size() { return _size; }
#ifdef OLD_NACL_MOUNTS
MainThreadRunner* _runner;
#endif
private:
pp::Size _size;
pthread_t _cocos_thread;

View File

@ -2,18 +2,33 @@
# when building for Native Client. It defines a set of variables that all
# cocos2dx projects have in common.
ifeq ($(NACL_SDK_ROOT),)
$(error $$NACL_SDK_ROOT not set)
endif
NACL_SDK_VERSION_MIN=27.186236
VERSION_CHECK:=$(shell $(NACL_SDK_ROOT)/tools/getos.py --check-version=$(NACL_SDK_VERSION_MIN) 2>&1)
ifneq ($(VERSION_CHECK),)
$(error $(VERSION_CHECK))
endif
all:
ifeq ($(NACL_GLIBC),1)
NACL_LIBC = glibc
else
NACL_LIBC = newlib
endif
NACL_ARCH ?= x86_64
NACL_AR ?= $(NACL_ARCH)-nacl-ar
NACL_CC ?= $(NACL_ARCH)-nacl-gcc
NACL_CXX ?= $(NACL_ARCH)-nacl-g++
CCFLAGS += -Wall -Werror
CCFLAGS += -Wall -Werror -Wno-deprecated-declarations
# GCC 4.6 is primary platform for cocos2d v.3, because it's default compiler for Android,
# Blackberry, some Linux distributions.It supports all important features of c++11, but have
# no flag "-std=c++11" (which was turned on in version 4.7).
CXXFLAGS += -Wall -Werror -std=gnu++0x
CXXFLAGS += -Wall -Werror -Wno-deprecated-declarations -std=gnu++0x
ARFLAGS = cr
THIS_MAKEFILE := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
@ -38,6 +53,14 @@ OUT_DIR ?= obj
OBJ_DIR ?= $(OUT_DIR)/$(NACL_ARCH)
LIB_DIR ?= $(COCOS_ROOT)/lib/nacl/$(ARCH_DIR)
NMF_FLAGS = --objdump=i686-nacl-objdump
NMF_FLAGS += -L$(NACL_SDK_ROOT)/toolchain/linux_x86_$(NACL_LIBC)/x86_64-nacl/lib32/
NMF_FLAGS += -L$(NACL_SDK_ROOT)/toolchain/linux_x86_$(NACL_LIBC)/x86_64-nacl/lib64/
NMF_FLAGS += -L$(NACL_SDK_ROOT)/lib/$(NACL_LIBC)_x86_32/Release
NMF_FLAGS += -L$(NACL_SDK_ROOT)/lib/$(NACL_LIBC)_x86_64/Release
NMF_FLAGS += -L$(NACLPORTS_ROOT)/lib/$(NACL_LIBC)_x86_32/Release
NMF_FLAGS += -L$(NACLPORTS_ROOT)/lib/$(NACL_LIBC)_x86_64/Release
ifdef USE_BOX2D
DEFINES += -DCC_ENABLE_BOX2D_INTEGRATION=1
else
@ -95,16 +118,9 @@ CCFLAGS += -Wno-psabi
CXXFLAGS += -Wno-psabi
endif
ifdef NACL_MOUNTS
DEFINES += -DOLD_NACL_MOUNTS
STATICLIBS += -lnacl-mounts
else
STATICLIBS += -lnacl_io
endif
SOUNDLIBS := -lalut -lopenal -lvorbisfile -lvorbis -logg
STATICLIBS += $(SOUNDLIBS) -lfreetype -lxml2 -lwebp -lpng -ljpeg -ltiff -llua -lchipmunk
STATICLIBS += -lppapi_gles2 -lppapi -lppapi_cpp -lnosys
STATICLIBS += -lnacl_io -lppapi_gles2 -lppapi -lppapi_cpp
SHAREDLIBS += -lpthread -lcocosdenshion -lcocos2d -lz
OBJECTS := $(SOURCES:.cpp=.o)

View File

@ -311,6 +311,7 @@ namespace sigslot {
class _connection_base1
{
public:
virtual ~_connection_base1() {};
virtual has_slots<mt_policy>* getdest() const = 0;
virtual void emit(arg1_type) = 0;
virtual _connection_base1<arg1_type, mt_policy>* clone() = 0;
@ -321,6 +322,7 @@ namespace sigslot {
class _connection_base2
{
public:
virtual ~_connection_base2() {};
virtual has_slots<mt_policy>* getdest() const = 0;
virtual void emit(arg1_type, arg2_type) = 0;
virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone() = 0;
@ -331,6 +333,7 @@ namespace sigslot {
class _connection_base3
{
public:
virtual ~_connection_base3() {};
virtual has_slots<mt_policy>* getdest() const = 0;
virtual void emit(arg1_type, arg2_type, arg3_type) = 0;
virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone() = 0;
@ -341,6 +344,7 @@ namespace sigslot {
class _connection_base4
{
public:
virtual ~_connection_base4() {};
virtual has_slots<mt_policy>* getdest() const = 0;
virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) = 0;
virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone() = 0;
@ -352,6 +356,7 @@ namespace sigslot {
class _connection_base5
{
public:
virtual ~_connection_base5() {};
virtual has_slots<mt_policy>* getdest() const = 0;
virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type,
arg5_type) = 0;
@ -366,6 +371,7 @@ namespace sigslot {
class _connection_base6
{
public:
virtual ~_connection_base6() {};
virtual has_slots<mt_policy>* getdest() const = 0;
virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
arg6_type) = 0;

View File

@ -59,9 +59,38 @@ EXTENSIONS_SOURCES = ../CCBReader/CCBFileLoader.cpp \
../spine/Slot.cpp \
../spine/SlotData.cpp \
../spine/extension.cpp \
../spine/spine-cocos2dx.cpp \
../spine/CCSkeleton.cpp \
../spine/CCSkeletonAnimation.cpp \
../spine/spine-cocos2dx.cpp
../CCArmature/CCArmature.cpp \
../CCArmature/CCBone.cpp \
../CCArmature/animation/CCArmatureAnimation.cpp \
../CCArmature/animation/CCProcessBase.cpp \
../CCArmature/animation/CCTween.cpp \
../CCArmature/datas/CCDatas.cpp \
../CCArmature/display/CCBatchNode.cpp \
../CCArmature/display/CCDecorativeDisplay.cpp \
../CCArmature/display/CCDisplayFactory.cpp \
../CCArmature/display/CCDisplayManager.cpp \
../CCArmature/display/CCShaderNode.cpp \
../CCArmature/display/CCSkin.cpp \
../CCArmature/external_tool/GLES-Render.cpp \
../CCArmature/external_tool/Json/CSContentJsonDictionary.cpp \
../CCArmature/external_tool/Json/lib_json/json_value.cpp \
../CCArmature/external_tool/Json/lib_json/json_reader.cpp \
../CCArmature/external_tool/Json/lib_json/json_writer.cpp \
../CCArmature/physics/CCColliderDetector.cpp \
../CCArmature/physics/CCPhysicsWorld.cpp \
../CCArmature/utils/CCArmatureDataManager.cpp \
../CCArmature/utils/CCDataReaderHelper.cpp \
../CCArmature/utils/CCSpriteFrameCacheHelper.cpp \
../CCArmature/utils/CCTransformHelp.cpp \
../CCArmature/utils/CCTweenFunction.cpp \
../CCArmature/utils/CCUtilMath.cpp \
../Components/CCComAttribute.cpp \
../Components/CCComAudio.cpp \
../Components/CCComController.cpp \
../Components/CCInputDelegate.cpp
all:

View File

@ -27,7 +27,7 @@ $(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(NMF): $(TARGET)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe --objdump=i686-nacl-objdump -L$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/x86_64-nacl/lib/ -s $(BIN_DIR)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe -s $(BIN_DIR) $(NMF_FLAGS)
run: all
/bin/cp -ar ../Resources/ .

View File

@ -9,70 +9,13 @@
#include <unistd.h>
#include <string>
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/UrlLoaderJob.h"
#endif
#include "fcntl.h"
#include "sys/stat.h"
USING_NS_CC;
AppDelegate g_app;
#ifdef OLD_NACL_MOUNTS
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
{
CCLOG("Downloading %d files...", num_files);
for (int i = 0; i < num_files; i++)
{
std::vector<char> data;
const char* filename = filenames[i];
std::string url = "Resources/";
url += filename;
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
UrlLoaderJob *job = new UrlLoaderJob;
job->set_url(url);
job->set_dst(&data);
runner->RunJob(job);
CCLOG("Got %d bytes", data.size());
CCLOG("Writing file: %s", filename);
int fd = open(filename, O_CREAT | O_WRONLY);
if (fd == -1)
{
CCLOG("Error writing file: %s", filename);
continue;
}
write(fd, &data[0], data.size());
close(fd);
}
}
#endif
void* cocos_main(void* arg)
{
fprintf(stderr, "in cocos_main\n");
#ifdef OLD_NACL_MOUNTS
// TODO(sbc): remove this hack an replace with some kind of URL mount
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
mkdir("ipad", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
mkdir("iphone", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
const char* filenames[] = { "ipad/HelloWorld.png",
"ipad/CloseSelected.png",
"ipad/CloseNormal.png",
"iphone/HelloWorld.png",
"iphone/CloseSelected.png",
"iphone/CloseNormal.png",
"fonts/Marker Felt.ttf" };
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
#endif
fprintf(stderr, "calling application->run\n");
int rtn = Application::sharedApplication()->run();
fprintf(stderr, "app run returned: %d\n", rtn);
return NULL;

View File

@ -33,7 +33,7 @@ $(OBJ_DIR)/%.o: %.cpp
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(NMF): $(TARGET)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe --objdump=i686-nacl-objdump -L$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/x86_64-nacl/lib/ -s $(BIN_DIR)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe $(NMF_FLAGS) -s $(BIN_DIR)
run: all
/bin/cp -ar ../Resources/ .

View File

@ -10,73 +10,15 @@
#include <string>
#include "AL/alc.h"
#include "fcntl.h"
#include "sys/stat.h"
USING_NS_CC;
AppDelegate g_app;
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/UrlLoaderJob.h"
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
{
CCLOG("Downloading %d files...", num_files);
for (int i = 0; i < num_files; i++)
{
std::vector<char> data;
const char* filename = filenames[i];
std::string url = "Resources/";
url += filename;
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
UrlLoaderJob *job = new UrlLoaderJob;
job->set_url(url);
job->set_dst(&data);
runner->RunJob(job);
CCLOG("Got %d bytes", data.size());
CCLOG("Writing file: %s", filename);
int fd = open(filename, O_CREAT | O_WRONLY);
if (fd == -1)
{
CCLOG("Error writing file: %s", filename);
continue;
}
write(fd, &data[0], data.size());
close(fd);
}
}
#endif
void* cocos_main(void* arg)
{
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
fprintf(stderr, "in cocos_main\n");
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
#ifdef OLD_NACL_MOUNTS
// TODO(sbc): remove this hack an replace with some kind of URL mount
mkdir("hd", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
mkdir("sd", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
const char* filenames[] = { "hd/CloseNormal.png",
"sd/CloseNormal.png",
"hd/CloseSelected.png",
"sd/CloseSelected.png",
"hd/Target.png",
"sd/Target.png",
"hd/Player.png",
"sd/Player.png",
"hd/Projectile.png",
"sd/Projectile.png",
"pew-pew-lei.wav",
"fonts/Marker Felt.ttf" };
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
#endif
fprintf(stderr, "calling application->run\n");
int rtn = Application::sharedApplication()->run();
fprintf(stderr, "app run returned: %d\n", rtn);

View File

@ -51,6 +51,9 @@ CurrentLanguageTest::CurrentLanguageTest()
case kLanguageNorwegian:
labelLanguage->setString("current language is Norwegian");
break;
case kLanguagePolish:
labelLanguage->setString("current language is Polish");
break;
}
addChild(labelLanguage);

View File

@ -3,7 +3,7 @@
#include "NotificationCenterTest/NotificationCenterTest.h"
#include "ControlExtensionTest/CCControlSceneManager.h"
#include "CocosBuilderTest/CocosBuilderTest.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
#include "NetworkTest/HttpClientTest.h"
#endif
#include "TableViewTest/TableViewTestScene.h"
@ -43,7 +43,7 @@ static struct {
pScene->release();
}
}},
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN) && (CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
{ "HttpClientTest", [](Object *sender){ runHttpClientTest();}
},
#endif

View File

@ -33,11 +33,13 @@ struct {
{ "CocosDenshionTest", []() { return new CocosDenshionTestScene(); } },
{ "ConfigurationTest", []() { return new ConfigurationTestScene(); } },
#if (CC_TARGET_PLATFORM != CC_PLATFORM_EMSCRIPTEN)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_NACL)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE)
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
{ "CurlTest", []() { return new CurlTestScene(); } },
#endif
#endif
#endif
#endif
{ "CurrentLanguageTest", []() { return new CurrentLanguageTestScene(); } },
{ "DrawPrimitivesTest", [](){return new DrawPrimitivesTestScene();} },

View File

@ -143,7 +143,7 @@ $(OBJ_DIR)/%.o: ../%.c $(CORE_MAKEFILE_LIST)
$(LOG_CC)$(NACL_CC) -MMD $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(NMF): $(TARGET)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe --objdump=i686-nacl-objdump -L$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/x86_64-nacl/lib/ -s $(BIN_DIR)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe $(NMF_FLAGS) -s $(BIN_DIR)
PACKAGE_ROOT = $(OUT_DIR)/package
@ -156,6 +156,7 @@ package: all
/bin/cp res/package_index.html $(PACKAGE_ROOT)/index.html
zipfile: package
rm -f $(OUT_DIR)/$(APP_NAME).zip
cd $(PACKAGE_ROOT) && zip -r ../$(APP_NAME).zip .
run: all

View File

@ -15,7 +15,7 @@
<embed
width=800
height=640
src="bin/debug/TestCpp.nmf"
src="bin/release/TestCpp.nmf"
type="application/x-nacl" />
</div>
</body>

View File

@ -8,129 +8,17 @@
#include <stdio.h>
#include <unistd.h>
#include <string>
#include <fcntl.h>
#include <sys/stat.h>
#include <AL/alc.h>
USING_NS_CC;
AppDelegate g_app;
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/UrlLoaderJob.h"
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
{
CCLOG("Downloading %d files...", num_files);
for (int i = 0; i < num_files; i++)
{
std::vector<char> data;
const char* filename = filenames[i];
std::string url = "Resources/";
url += filename;
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
UrlLoaderJob *job = new UrlLoaderJob;
job->set_url(url);
job->set_dst(&data);
runner->RunJob(job);
CCLOG("Got %d bytes", data.size());
CCLOG("Writing file: %s", filename);
int fd = open(filename, O_CREAT | O_WRONLY);
if (fd == -1)
{
assert("error writing file");
CCLOG("Error writing file: %s", filename);
continue;
}
write(fd, &data[0], data.size());
close(fd);
}
}
#endif
void* cocos_main(void* arg)
{
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
fprintf(stderr, "in cocos_main %p\n", instance);
fprintf(stderr, "in cocos_main: %p\n", instance);
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
#ifdef OLD_NACL_MOUNTS
// TODO(sbc): remove this hack an replace with some kind of URL mount
const char* dirnames[] = { "Images", "extensions", "fonts", "ccb",
"zwoptex", "Particles", "Shaders", "TileMaps" };
for (size_t i = 0; i < sizeof(dirnames)/sizeof(char*); i++)
mkdir(dirnames[i], S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
const char* filenames[] = { "Images/grossini.png",
"Images/close.png",
"Images/ball.png",
"Images/paddle.png",
"Images/grossinis_sister1.png",
"Images/grossinis_sister2.png",
"Images/grossini_dance_01.png",
"Images/background1.png",
"Images/background2.png",
"Images/background3.png",
"Images/f1.png",
"Images/f2.png",
"Images/r1.png",
"Images/r2.png",
"Images/b1.png",
"Images/b2.png",
"Images/blocks.png",
"Images/Icon.png",
"Images/streak.png",
"Images/fire.png",
"Images/white-512x512.png",
"Images/test_1021x1024_rgb888.pvr.gz",
"Images/test_1021x1024.png",
"Images/grossini_dance_atlas.png",
"Images/powered.png",
"Images/background.png",
"TileMaps/levelmap.tga",
"TileMaps/tiles.png",
"fps_images.png",
"Shaders/example_Monjori.vsh",
"Shaders/example_Monjori.fsh",
"Shaders/example_Mandelbrot.vsh",
"Shaders/example_Mandelbrot.fsh",
"Shaders/example_Julia.vsh",
"Shaders/example_Julia.fsh",
"Shaders/example_Plasma.vsh",
"Shaders/example_Plasma.fsh",
"Shaders/example_Heart.vsh",
"Shaders/example_Heart.fsh",
"Shaders/example_Flower.vsh",
"Shaders/example_Flower.fsh",
"Shaders/example_Blur.fsh",
"Shaders/example_HorizontalColor.vsh",
"Shaders/example_HorizontalColor.fsh",
"Particles/SmallSun.plist",
"Particles/LavaFlow.plist",
"fonts/arial.ttf",
"fonts/west_england-64.fnt",
"fonts/west_england-64.png",
"fonts/Thonburi.ttf",
"fonts/Marker Felt.ttf",
"ccb/HelloCocosBuilder.ccbi",
"ccb/burst.png",
"effect1.wav",
"background.mp3",
"extensions/sliderTrack.png",
"extensions/sliderProgress.png",
"extensions/sliderThumb.png",
"extensions/background.png",
"extensions/ribbon.png",
"zwoptex/grossini.plist",
"zwoptex/grossini.png" };
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
#endif
fprintf(stderr, "calling application->run\n");
int rtn = Application::sharedApplication()->run();
fprintf(stderr, "app run returned: %d\n", rtn);

View File

@ -17,6 +17,7 @@ SOURCES = main.cpp \
../Classes/AppDelegate.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/CCLuaEngine.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/CCLuaStack.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/CCLuaValue.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/LuaCocos2d.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/tolua_fix.c \
@ -59,7 +60,7 @@ $(OBJ_DIR)/%.o: $(COCOS_ROOT)/%.c
$(LOG_CC)$(NACL_CC) -MMD $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(NMF): $(TARGET)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe --objdump=i686-nacl-objdump -L$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/x86_64-nacl/lib/ -s $(BIN_DIR)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe $(NMF_FLAGS) -s $(BIN_DIR)
run: all
/bin/cp -ar ../Resources/ .

View File

@ -17,62 +17,11 @@ USING_NS_CC;
AppDelegate g_app;
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/UrlLoaderJob.h"
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
{
CCLOG("Downloading %d files...", num_files);
for (int i = 0; i < num_files; i++)
{
std::vector<char> data;
const char* filename = filenames[i];
std::string url = "Resources/";
url += filename;
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
UrlLoaderJob *job = new UrlLoaderJob;
job->set_url(url);
job->set_dst(&data);
runner->RunJob(job);
CCLOG("Got %d bytes", data.size());
CCLOG("Writing file: %s", filename);
int fd = open(filename, O_CREAT | O_WRONLY);
if (fd == -1)
{
CCLOG("Error writing file: %s", filename);
continue;
}
write(fd, &data[0], data.size());
close(fd);
}
}
#endif
void* cocos_main(void* arg)
{
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
fprintf(stderr, "in cocos_main\n");
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
#ifdef OLD_NACL_MOUNTS
// TODO(sbc): remove this hack an replace with some kind of URL mount
mkdir("fonts", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
const char* filenames[] = { "hello.lua",
"hello2.lua",
"farm.jpg",
"land.png",
"menu1.png",
"menu2.png",
"crop.png",
"dog.png",
"effect1.wav",
"background.ogg",
"fonts/Marker Felt.ttf" };
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
#endif
fprintf(stderr, "calling application->run\n");
int rtn = Application::sharedApplication()->run();
fprintf(stderr, "app run returned: %d\n", rtn);

View File

@ -17,6 +17,7 @@ SOURCES = main.cpp \
../Classes/AppDelegate.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/CCLuaEngine.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/CCLuaStack.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/CCLuaValue.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/LuaCocos2d.cpp \
$(COCOS_ROOT)/scripting/lua/cocos2dx_support/tolua_fix.c \
@ -30,7 +31,7 @@ SOURCES += $(addprefix $(COCOS_ROOT)/extensions/, $(EXTENSIONS_SOURCES))
include $(COCOS_ROOT)/cocos2dx/proj.nacl/cocos2dx.mk
CXXFLAGS += -Wno-multichar
STATICLIBS += -llua -lnosys
STATICLIBS += -llua
SHAREDLIBS += -lbox2d
APP_NAME = TestLua
@ -39,28 +40,28 @@ NMF = $(BIN_DIR)/$(APP_NAME).nmf
all: $(NMF)
$(TARGET): $(OBJECTS) $(LIB_DIR)/libcocos2d.a
$(TARGET): $(OBJECTS) $(LIB_DIR)/libcocos2d.a $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_LINK)$(NACL_CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)
$(OBJ_DIR)/%.o: %.cpp
$(OBJ_DIR)/%.o: %.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(OBJ_DIR)/%.o: ../%.cpp
$(OBJ_DIR)/%.o: ../%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(OBJ_DIR)/%.o: $(COCOS_ROOT)/%.cpp
$(OBJ_DIR)/%.o: $(COCOS_ROOT)/%.cpp $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CXX)$(NACL_CXX) -MMD $(CXXFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(OBJ_DIR)/%.o: $(COCOS_ROOT)/%.c
$(OBJ_DIR)/%.o: $(COCOS_ROOT)/%.c $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(LOG_CC)$(NACL_CC) -MMD $(CCFLAGS) $(INCLUDES) $(DEFINES) -c $< -o $@
$(NMF): $(TARGET)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe --objdump=i686-nacl-objdump -L$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/x86_64-nacl/lib/ -s $(BIN_DIR)
$(NACL_SDK_ROOT)/tools/create_nmf.py -o $@ $(BIN_DIR)/*.nexe $(NMF_FLAGS) -s $(BIN_DIR)
run: all
/bin/cp -ar ../Resources/ .

View File

@ -10,128 +10,15 @@
#include <string>
#include <AL/alc.h>
#ifdef OLD_NACL_MOUNTS
#include "nacl-mounts/base/UrlLoaderJob.h"
#include "fcntl.h"
#include "sys/stat.h"
#endif
USING_NS_CC;
AppDelegate g_app;
#ifdef OLD_NACL_MOUNTS
void downloadFiles(MainThreadRunner* runner, const char** filenames, int num_files)
{
CCLOG("Downloading %d files...", num_files);
for (int i = 0; i < num_files; i++)
{
std::vector<char> data;
const char* filename = filenames[i];
std::string url = "Resources/";
url += filename;
CCLOG("Downloading: %s -> %s", url.c_str(), filename);
UrlLoaderJob *job = new UrlLoaderJob;
job->set_url(url);
job->set_dst(&data);
runner->RunJob(job);
CCLOG("Got %d bytes", data.size());
CCLOG("Writing file: %s", filename);
int fd = open(filename, O_CREAT | O_WRONLY);
if (fd == -1)
{
CCLOG("Error writing file: %s", filename);
continue;
}
write(fd, &data[0], data.size());
close(fd);
}
}
#endif
void* cocos_main(void* arg)
{
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
fprintf(stderr, "in cocos_main\n");
CocosPepperInstance* instance = (CocosPepperInstance*)arg;
alSetPpapiInfo(instance->pp_instance(), pp::Module::Get()->get_browser_interface());
#ifdef OLD_NACL_MOUNTS
// TODO(sbc): remove this hack an replace with some kind of URL mount
const char* dirnames[] = { "Images", "extensions", "fonts", "ccb",
"zwoptex", "Particles", "Shaders", "luaScript",
"luaScript/ActionsTest" };
for (size_t i = 0; i < sizeof(dirnames)/sizeof(char*); i++)
mkdir(dirnames[i], S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
const char* filenames[] = { "Images/grossini.png",
"Images/close.png",
"Images/grossinis_sister1.png",
"Images/grossinis_sister2.png",
"Images/grossini_dance_01.png",
"Images/background1.png",
"Images/background2.png",
"Images/background3.png",
"Images/f1.png",
"Images/f2.png",
"Images/r1.png",
"Images/r2.png",
"Images/b1.png",
"Images/b2.png",
"Images/blocks.png",
"Images/Icon.png",
"Images/streak.png",
"Images/fire.png",
"Images/white-512x512.png",
"Images/test_1021x1024_rgb888.pvr.gz",
"Images/test_1021x1024.png",
"Images/grossini_dance_atlas.png",
"fps_images.png",
"Shaders/example_Monjori.vsh",
"Shaders/example_Monjori.fsh",
"Shaders/example_Mandelbrot.vsh",
"Shaders/example_Mandelbrot.fsh",
"Shaders/example_Julia.vsh",
"Shaders/example_Julia.fsh",
"Shaders/example_Plasma.vsh",
"Shaders/example_Plasma.fsh",
"Shaders/example_Heart.vsh",
"Shaders/example_Heart.fsh",
"Shaders/example_Flower.vsh",
"Shaders/example_Flower.fsh",
"Shaders/example_Blur.fsh",
"Shaders/example_HorizontalColor.vsh",
"Shaders/example_HorizontalColor.fsh",
"Particles/SmallSun.plist",
"Particles/LavaFlow.plist",
"fonts/arial.ttf",
"fonts/west_england-64.fnt",
"fonts/west_england-64.png",
"fonts/Thonburi.ttf",
"fonts/Marker Felt.ttf",
"ccb/HelloCocosBuilder.ccbi",
"ccb/burst.png",
"effect1.wav",
"background.mp3",
"extensions/sliderTrack.png",
"extensions/sliderProgress.png",
"extensions/sliderThumb.png",
"extensions/background.png",
"extensions/ribbon.png",
"zwoptex/grossini.plist",
"zwoptex/grossini.png",
"luaScript/mainMenu.lua",
"luaScript/helper.lua",
"luaScript/testResource.lua",
"luaScript/ActionsTest/ActionsTest.lua",
"luaScript/ActionsTest/ActionsName.lua",
"luaScript/controller.lua" };
downloadFiles(instance->_runner, filenames, sizeof(filenames)/sizeof(char*));
#endif
fprintf(stderr, "calling application->run\n");
int rtn = Application::sharedApplication()->run();
fprintf(stderr, "app run returned: %d\n", rtn);

View File

@ -1 +1 @@
dbd2489ec371acee75754f90ef7b4d8201a00223
e110ce7b59357a987fd5383cd1aa89f254db2d45

View File

@ -180,11 +180,13 @@ static int io_popen (lua_State *L) {
}
#ifndef __native_client__
static int io_tmpfile (lua_State *L) {
FILE **pf = newfile(L);
*pf = tmpfile();
return (*pf == NULL) ? pushresult(L, 0, NULL) : 1;
}
#endif
static FILE *getiofile (lua_State *L, int findex) {
@ -486,7 +488,9 @@ static const luaL_Reg iolib[] = {
{"output", io_output},
{"popen", io_popen},
{"read", io_read},
#ifndef __native_client__
{"tmpfile", io_tmpfile},
#endif
{"type", io_type},
{"write", io_write},
{NULL, NULL}

View File

@ -35,10 +35,12 @@ static int os_pushresult (lua_State *L, int i, const char *filename) {
}
#ifndef __native_client__
static int os_execute (lua_State *L) {
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
return 1;
}
#endif
static int os_remove (lua_State *L) {
@ -221,7 +223,9 @@ static const luaL_Reg syslib[] = {
{"clock", os_clock},
{"date", os_date},
{"difftime", os_difftime},
#ifndef __native_client__
{"execute", os_execute},
#endif
{"exit", os_exit},
{"getenv", os_getenv},
{"remove", os_remove},

View File

@ -71,8 +71,10 @@ if [ "$PLATFORM"x = "linux"x ]; then
fi
if [ "$PLATFORM"x = "nacl"x ]; then
# NaCl compilers are built for 32-bit linux so we need to install
# the runtime support for this.
sudo apt-get update
sudo apt-get install libc6:i386
sudo apt-get install libc6:i386 libstdc++6:i386
echo "Download nacl_sdk ..."
wget http://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip
echo "Decompress nacl_sdk.zip"