Merge pull request #2998 from sbc100/emscripten_linux

closed #2333: 1) Share top level Makefile between emscripten, linux and nacl.
2) Remove the dependacy of the emscripten build on /Library/Fonts
(a darwin-only folder).  On non-darwin platforms we use the
ariel.tff that is part of TestCpp.
This commit is contained in:
James Chen 2013-06-25 22:43:16 -07:00
commit 10f4446596
7 changed files with 51 additions and 35 deletions

View File

@ -1,6 +1,6 @@
PLATFORM ?= linux
define MAKE_TARGET
define MAKE_TARGETS
+$(MAKE) -C external/chipmunk/proj.$(PLATFORM) $@
+$(MAKE) -C external/Box2D/proj.$(PLATFORM) $@
+$(MAKE) -C CocosDenshion/proj.$(PLATFORM) $@
@ -10,14 +10,22 @@ define MAKE_TARGET
+$(MAKE) -C samples/Cpp/HelloCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/SimpleGame/proj.$(PLATFORM) $@
endef
# Haven't yet got the lua projects working with emscripten
ifneq ($(PLATFORM),emscripten)
define MAKE_LUA
+$(MAKE) -C samples/Lua/HelloLua/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Lua/TestLua/proj.$(PLATFORM) $@
endef
endif
all:
$(call MAKE_TARGET,all)
$(call MAKE_TARGETS,all)
$(call MAKE_LUA,all)
clean:
$(call MAKE_TARGET,clean)
$(call MAKE_TARGETS,clean)
$(call MAKE_LUA,clean)
.PHONY: all clean

View File

@ -1,26 +0,0 @@
PLATFORM = emscripten
define MAKE_TARGET
+$(MAKE) -C external/chipmunk/proj.$(PLATFORM) $@
+$(MAKE) -C external/Box2D/proj.$(PLATFORM) $@
+$(MAKE) -C CocosDenshion/proj.$(PLATFORM) $@
+$(MAKE) -C extensions/proj.$(PLATFORM) $@
+$(MAKE) -C cocos2dx/proj.$(PLATFORM) $@
+$(MAKE) -C scripting/lua/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/HelloCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/TestCpp/proj.$(PLATFORM) $@
+$(MAKE) -C samples/Cpp/SimpleGame/proj.$(PLATFORM) $@
endef
# Haven't yet got the lua projects working.
# +$(MAKE) -C samples/Lua/HelloLua/proj.$(PLATFORM) $@
# +$(MAKE) -C samples/Lua/TestLua/proj.$(PLATFORM) $@
all:
$(call MAKE_TARGET,all)
clean:
$(call MAKE_TARGET,clean)
.PHONY: all clean

23
build-emscripten.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Build script to build all components for emscripten.
#
# By default this script will build the 'all' target in
# both debug and release configurations. Pass "clean" to
# clean all configuration.
#
# This script expects llvm-3.2 to be installed in
# $HOME/bin/clang+llvm-3.2.
SCRIPT_DIR=$(dirname ${BASH_SOURCE})
set -e
set -x
cd $SCRIPT_DIR
export PYTHON=/usr/bin/python
export LLVM=$HOME/bin/clang+llvm-3.2/bin
export LLVM_ROOT=$LLVM
make PLATFORM=emscripten DEBUG=1 -j10 $*
make PLATFORM=emscripten DEBUG=0 -j10 $*

View File

@ -31,7 +31,7 @@ JSLIBS := --js-library $(COCOS_SRC)/platform/emscripten/CCTextureCacheEmscripten
CCFLAGS += -MMD -Wall -fPIC -Qunused-arguments -Wno-overloaded-virtual -Qunused-variable -s TOTAL_MEMORY=268435456 -s VERBOSE=1 -U__native_client__ $(EXPORTED_FLAGS) $(JSLIBS)
CXXFLAGS += -MMD -Wall -fPIC -Qunused-arguments -Wno-overloaded-virtual -Qunused-variable -s TOTAL_MEMORY=268435456 -s VERBOSE=1 -U__native_client__ $(EXPORTED_FLAGS) $(JSLIBS)
LIB_DIR = $(COCOS_SRC)/lib/emscripten
LIB_DIR = $(COCOS_ROOT)/lib/emscripten
BIN_DIR = bin
INCLUDES += \

View File

@ -24,6 +24,13 @@ $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)
ifeq ($(shell uname -s),Darwin)
ARIEL_TTF := /Library/Fonts/Arial.ttf
else
ARIEL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf
endif
$(TARGET).data:
@mkdir -p $(@D)
$(eval RESTMP := $(shell mktemp -d /tmp/cocos-emscripten.XXXXXX))
@ -32,7 +39,7 @@ $(TARGET).data:
(cd $(RESOURCE_PATH) && cp -a $(RESOURCES) $(RESTMP))
(cd $(FONT_PATH) && cp -a * $(RESTMP)/fonts)
# NOTE: we copy the system arial.ttf so that there is always a fallback.
cp /Library/Fonts/Arial.ttf $(RESTMP)/fonts/arial.ttf
cp $(ARIEL_TTF) $(RESTMP)/fonts/arial.ttf
(cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst %,--preload %,$(RESOURCES)) --preload fonts --pre-run > $(EXECUTABLE).data.js)
mv $(RESTMP)/$(EXECUTABLE).data $@
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js

View File

@ -37,6 +37,12 @@ $(TARGET).js: $(OBJECTS) $(STATICLIBS) $(COCOS_LIBS) $(CORE_MAKEFILE_LIST)
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(SHAREDLIBS) $(STATICLIBS)
ifeq ($(shell uname -s),Darwin)
ARIEL_TTF := /Library/Fonts/Arial.ttf
else
ARIEL_TTF := $(COCOS_ROOT)/samples/Cpp/TestCpp/Resources/fonts/arial.ttf
endif
$(TARGET).data:
@mkdir -p $(@D)
$(eval RESTMP := $(shell mktemp -d /tmp/cocos-emscripten.XXXXXX))
@ -45,7 +51,7 @@ $(TARGET).data:
(cd $(RESOURCE_PATH) && tar cf - $(RESOURCES)) | (cd $(RESTMP) && tar xvf -)
(cd $(SD_RESOURCE_PATH) && tar cf - $(SD_RESOURCES)) | (cd $(RESTMP) && tar xvf -)
# NOTE: we copy the system arial.ttf so that there is always a fallback.
cp /Library/Fonts/Arial.ttf $(RESTMP)/fonts/arial.ttf
cp $(ARIEL_TTF) $(RESTMP)/fonts/arial.ttf
(cd $(RESTMP); python $(PACKAGER) $(EXECUTABLE).data $(patsubst %,--preload %,$(ALL_ASSETS)) --preload fonts --pre-run > $(EXECUTABLE).data.js)
mv $(RESTMP)/$(EXECUTABLE).data $@
mv $(RESTMP)/$(EXECUTABLE).data.js $@.js

View File

@ -63,9 +63,7 @@ elif [ "$PLATFORM"x = "emscripten"x ]; then
export PYTHON=/usr/bin/python
export LLVM=$HOME/bin/clang+llvm-3.2/bin
export LLVM_ROOT=$LLVM
sudo mkdir -p /Library/Fonts
sudo cp samples/Cpp/TestCpp/Resources/fonts/arial.ttf /Library/Fonts/Arial.ttf
EMCC_DEBUG=1 make -f Makefile.emscripten -j 8
EMCC_DEBUG=1 make PLATFORM=emscripten -j 8
elif [ "$PLATFORM"x = "ios"x ]; then
cd $COCOS2DX_ROOT/tools/travis-scripts
./generate-jsbindings.sh