diff options
author | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 19:51:13 +0000 |
---|---|---|
committer | noelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-13 19:51:13 +0000 |
commit | ebf9f3932c75fc02864e446f10aa4d99ffbe1512 (patch) | |
tree | 93f9f41bcbe7beb0e69025045e8a40c4ead88120 /native_client_sdk | |
parent | 2ad285cc76f93848cfec89f4028193793e8746e1 (diff) | |
download | chromium_src-ebf9f3932c75fc02864e446f10aa4d99ffbe1512.zip chromium_src-ebf9f3932c75fc02864e446f10aa4d99ffbe1512.tar.gz chromium_src-ebf9f3932c75fc02864e446f10aa4d99ffbe1512.tar.bz2 |
Convert examples from scons to Make
Remove all scons files.
Remove all scons test files.
Add Makefile.
Fix various build issues due to PPAPI changes.
NOTE: This only affect SDK builders and not Chrome itself.
BUG= http://code.google.com/p/chromium/issues/detail?id=109917
Review URL: http://codereview.chromium.org/9139029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
70 files changed, 2335 insertions, 967 deletions
diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/Makefile b/native_client_sdk/src/examples/fullscreen_tumbler/Makefile new file mode 100644 index 0000000..79bc0b9 --- /dev/null +++ b/native_client_sdk/src/examples/fullscreen_tumbler/Makefile @@ -0,0 +1,188 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=fullscreen_tumbler +C_SOURCES:= +CXX_SOURCES:=transforms.cc shader_util.cc opengl_context.cc tumbler_module.cc +CXX_SOURCES+=scripting_bridge.cc tumbler.cc cube.cc +COPY_FILES:=bind.js trackball.js dragger.js vector3.js tumbler.js +COPY_FILES+=fullscreen_tumbler.html fullscreen_tumbler.nmf +COPY_FILES+=../common/check_browser.js + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) +LDFLAGS:=-lppapi_gles2 -lppapi_cpp -lppapi + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py + diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/build.scons b/native_client_sdk/src/examples/fullscreen_tumbler/build.scons deleted file mode 100644 index b68cd27..0000000 --- a/native_client_sdk/src/examples/fullscreen_tumbler/build.scons +++ /dev/null @@ -1,66 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import nacl_utils -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='fullscreen_tumbler', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - LIBS=['ppapi_gles2'], - ) - -sources = [ - 'cube.cc', - 'opengl_context.cc', - 'scripting_bridge.cc', - 'shader_util.cc', - 'transforms.cc', - 'tumbler.cc', - 'tumbler_module.cc', - ] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'fullscreen_tumbler') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('fullscreen_tumbler') - -common_files = [ - 'check_browser.js', - ] -common_files = [ - os.path.join(os.path.dirname(os.getcwd()), 'common', common_file) - for common_file in common_files] - -app_files = [ - 'fullscreen_tumbler.html', - 'fullscreen_tumbler.nmf', - 'bind.js', - 'dragger.js', - 'trackball.js', - 'tumbler.js', - 'vector3.js', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -common_dir = os.path.join(os.path.dirname(nacl_env['NACL_INSTALL_ROOT']), - 'common') -install_common = nacl_env.Install(dir=common_dir, source=common_files) -nacl_env.Alias('install', - source=[install_app, install_common, install_nexes]) diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/cube.cc b/native_client_sdk/src/examples/fullscreen_tumbler/cube.cc index 5ce78c7..b9daf01 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/cube.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/cube.cc @@ -2,12 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/cube.h" #include <algorithm> +#include <GLES2/gl2.h> + +#include "ppapi/gles2/gl2ext_ppapi.h" + +#include "cube.h" +#include "shader_util.h" +#include "transforms.h" -#include "examples/fullscreen_tumbler/shader_util.h" -#include "examples/fullscreen_tumbler/transforms.h" namespace tumbler { diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/cube.h b/native_client_sdk/src/examples/fullscreen_tumbler/cube.h index 452182f..a90e0364 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/cube.h +++ b/native_client_sdk/src/examples/fullscreen_tumbler/cube.h @@ -7,8 +7,9 @@ #include <GLES2/gl2.h> #include <vector> -#include "examples/fullscreen_tumbler/opengl_context.h" -#include "examples/fullscreen_tumbler/opengl_context_ptrs.h" + +#include "opengl_context.h" +#include "opengl_context_ptrs.h" namespace tumbler { diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/fullscreen_tumbler.html b/native_client_sdk/src/examples/fullscreen_tumbler/fullscreen_tumbler.html index 84daad7..880acc4 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/fullscreen_tumbler.html +++ b/native_client_sdk/src/examples/fullscreen_tumbler/fullscreen_tumbler.html @@ -14,7 +14,7 @@ // Fullscreen support is in Chrome version 16. tumbler.CHROME_MINIMUM_VERSION = 16; </script> - <script type="text/javascript" src="../common/check_browser.js"></script> + <script type="text/javascript" src="check_browser.js"></script> <script type="text/javascript" src="bind.js"></script> <script type="text/javascript" src="dragger.js"></script> <script type="text/javascript" src="tumbler.js"></script> diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.cc b/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.cc index 8f0844d..d1675fc 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/opengl_context.h" #include <pthread.h> + +#include "ppapi/c/pp_graphics_3d.h" #include "ppapi/cpp/completion_callback.h" #include "ppapi/gles2/gl2ext_ppapi.h" +#include "opengl_context.h" namespace { // This is called by the brower when the 3D context has been flushed to the diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.h b/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.h index 24d7d90..48a8462 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.h +++ b/native_client_sdk/src/examples/fullscreen_tumbler/opengl_context.h @@ -17,13 +17,14 @@ #include <algorithm> #include <string> -#include "examples/fullscreen_tumbler/opengl_context_ptrs.h" #include "ppapi/c/ppb_opengles2.h" #include "ppapi/cpp/graphics_3d.h" #include "ppapi/cpp/graphics_3d_client.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/size.h" +#include "opengl_context_ptrs.h" + namespace tumbler { /// OpenGLContext manages an OpenGL rendering context in the browser. diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.cc b/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.cc index ba87765..b44bb8e 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/scripting_bridge.h" +#include "scripting_bridge.h" namespace { const char* const kWhiteSpaceCharacters = " \t"; diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.h b/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.h index 6c32c10..e89d157 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.h +++ b/native_client_sdk/src/examples/fullscreen_tumbler/scripting_bridge.h @@ -10,9 +10,10 @@ #include <tr1/memory> #include <vector> -#include "examples/fullscreen_tumbler/callback.h" #include "ppapi/cpp/var.h" +#include "callback.h" + namespace tumbler { class MethodCallbackExecutor; diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/shader_util.cc b/native_client_sdk/src/examples/fullscreen_tumbler/shader_util.cc index 544d9a4..e6a4ae7 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/shader_util.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/shader_util.cc @@ -2,10 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/shader_util.h" - #include <stdio.h> #include <stdlib.h> +#include <GLES2/gl2.h> + +#include "ppapi/gles2/gl2ext_ppapi.h" +#include "shader_util.h" namespace shader_util { diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/transforms.cc b/native_client_sdk/src/examples/fullscreen_tumbler/transforms.cc index 4e1a892..75a7c2c 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/transforms.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/transforms.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/transforms.h" - #include <GLES2/gl2.h> #include <math.h> #include <string.h> +#include "transforms.h" + namespace transform_4x4 { static const GLfloat kPI = 3.1415926535897932384626433832795f; diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.cc b/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.cc index 2437141..a4fe68e 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/tumbler.h" #include <stdio.h> @@ -11,14 +10,16 @@ #include <string> #include <vector> -#include "examples/fullscreen_tumbler/cube.h" -#include "examples/fullscreen_tumbler/opengl_context.h" -#include "examples/fullscreen_tumbler/scripting_bridge.h" #include "ppapi/cpp/input_event.h" #include "ppapi/cpp/rect.h" #include "ppapi/cpp/size.h" #include "ppapi/cpp/var.h" +#include "cube.h" +#include "opengl_context.h" +#include "scripting_bridge.h" +#include "tumbler.h" + namespace { const uint32_t kKeyEnter = 0x0D; const size_t kQuaternionElementCount = 4; diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.h b/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.h index 6fe0e20..35699d8 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.h +++ b/native_client_sdk/src/examples/fullscreen_tumbler/tumbler.h @@ -9,13 +9,14 @@ #include <map> #include <vector> -#include "examples/fullscreen_tumbler/cube.h" -#include "examples/fullscreen_tumbler/opengl_context.h" -#include "examples/fullscreen_tumbler/opengl_context_ptrs.h" -#include "examples/fullscreen_tumbler/scripting_bridge.h" #include "ppapi/cpp/fullscreen.h" #include "ppapi/cpp/instance.h" +#include "cube.h" +#include "opengl_context.h" +#include "opengl_context_ptrs.h" +#include "scripting_bridge.h" + namespace pp { class KeyboardInputEvent; } // namespace pp diff --git a/native_client_sdk/src/examples/fullscreen_tumbler/tumbler_module.cc b/native_client_sdk/src/examples/fullscreen_tumbler/tumbler_module.cc index bf4bee0..d1d103f 100644 --- a/native_client_sdk/src/examples/fullscreen_tumbler/tumbler_module.cc +++ b/native_client_sdk/src/examples/fullscreen_tumbler/tumbler_module.cc @@ -2,11 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/fullscreen_tumbler/tumbler.h" +#include <GLES2/gl2.h> + #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/gles2/gl2ext_ppapi.h" +#include "tumbler.h" + /// The Module class. The browser calls the CreateInstance() method to create /// an instance of your NaCl module on the web page. The browser creates a new /// instance for each <embed> tag with type="application/x-nacl". diff --git a/native_client_sdk/src/examples/geturl/Makefile b/native_client_sdk/src/examples/geturl/Makefile new file mode 100644 index 0000000..42c3c7c --- /dev/null +++ b/native_client_sdk/src/examples/geturl/Makefile @@ -0,0 +1,182 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=geturl +CXX_SOURCES:=geturl.cc geturl_handler.cc +COPY_FILES:=geturl.html geturl.nmf geturl_success.html +LDFLAGS:=-lppapi_cpp -lppapi + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/geturl/build.scons b/native_client_sdk/src/examples/geturl/build.scons deleted file mode 100644 index 791b2f3..0000000 --- a/native_client_sdk/src/examples/geturl/build.scons +++ /dev/null @@ -1,41 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='geturl', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['geturl.cc', 'geturl_handler.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'geturl') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('geturl') - -app_files = [ - 'geturl.html', - 'geturl_success.html', - 'geturl.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/geturl/geturl.cc b/native_client_sdk/src/examples/geturl/geturl.cc index 3785d55..fa3838d 100644 --- a/native_client_sdk/src/examples/geturl/geturl.cc +++ b/native_client_sdk/src/examples/geturl/geturl.cc @@ -6,12 +6,13 @@ #include <cstdio> #include <string> -#include "examples/geturl/geturl_handler.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/url_loader.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" +#include "geturl_handler.h" + // These are the method names as JavaScript sees them. namespace { const char* const kLoadUrlMethodId = "getUrl"; diff --git a/native_client_sdk/src/examples/geturl/geturl_handler.cc b/native_client_sdk/src/examples/geturl/geturl_handler.cc index 7b96957..2c944bb 100644 --- a/native_client_sdk/src/examples/geturl/geturl_handler.cc +++ b/native_client_sdk/src/examples/geturl/geturl_handler.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/geturl/geturl_handler.h" - #include <stdio.h> #include <stdlib.h> #include "ppapi/c/pp_errors.h" @@ -11,6 +9,8 @@ #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" +#include "geturl_handler.h" + namespace { bool IsError(int32_t result) { return ((PP_OK != result) && (PP_OK_COMPLETIONPENDING != result)); diff --git a/native_client_sdk/src/examples/geturl/geturl_handler.h b/native_client_sdk/src/examples/geturl/geturl_handler.h index bc71d8e..4caffa1 100644 --- a/native_client_sdk/src/examples/geturl/geturl_handler.h +++ b/native_client_sdk/src/examples/geturl/geturl_handler.h @@ -10,7 +10,7 @@ #include "ppapi/cpp/url_loader.h" #include "ppapi/cpp/url_request_info.h" #include "ppapi/cpp/instance.h" - +#include "ppapi/utility/completion_callback_factory.h" #define READ_BUFFER_SIZE 32768 // GetURLHandler is used to download data from |url|. When download is diff --git a/native_client_sdk/src/examples/hello_world/Makefile b/native_client_sdk/src/examples/hello_world/Makefile new file mode 100644 index 0000000..f5d6e46 --- /dev/null +++ b/native_client_sdk/src/examples/hello_world/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=hello_world +CXX_SOURCES:=hello_world.cc helper_functions.cc +COPY_FILES:=hello_world.html hello_world.nmf +LDFLAGS:=-lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/hello_world/build.scons b/native_client_sdk/src/examples/hello_world/build.scons deleted file mode 100644 index e21cf78..0000000 --- a/native_client_sdk/src/examples/hello_world/build.scons +++ /dev/null @@ -1,59 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import nacl_utils -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='hello_world', lib_prefix='..') -nacl_test_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, - nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - use_ppapi=False) -for env in [nacl_env, nacl_test_env]: - env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - CCFLAGS=['-pedantic', '-Werror'], - ) - -sources = ['hello_world.cc', 'helper_functions.cc'] -test_sources = ['helper_functions.cc', 'test_helper_functions.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'hello_world') - -nacl_test_32 = nacl_test_env.Clone() -nacl_test_32.NaClTestProgram(test_sources, - nacl_utils.ARCH_SPECS['x86-32'], - module_name='hello_world_test', - target_name='test32') - -nacl_test_64 = nacl_test_env.Clone() -nacl_test_64.NaClTestProgram(test_sources, - nacl_utils.ARCH_SPECS['x86-64'], - module_name='hello_world_test', - target_name='test64') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('hello_world') - -app_files = [ - 'hello_world.html', - 'hello_world.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/hello_world/hello_world.cc b/native_client_sdk/src/examples/hello_world/hello_world.cc index 8d45599..438b7bf 100644 --- a/native_client_sdk/src/examples/hello_world/hello_world.cc +++ b/native_client_sdk/src/examples/hello_world/hello_world.cc @@ -17,11 +17,12 @@ #include <cstdio> #include <cstring> #include <string> -#include "examples/hello_world/helper_functions.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/var.h" +#include "helper_functions.h" + namespace hello_world { /// Method name for ReverseText, as seen by JavaScript code. const char* const kReverseTextMethodId = "reverseText"; @@ -58,7 +59,9 @@ pp::Var MarshallReverseText(const std::string& text) { /// </pre> class HelloWorldInstance : public pp::Instance { public: - explicit HelloWorldInstance(PP_Instance instance) : pp::Instance(instance) {} + explicit HelloWorldInstance(PP_Instance instance) : pp::Instance(instance) { + printf("HelloWorldInstance.\n"); + } virtual ~HelloWorldInstance() {} /// Called by the browser to handle the postMessage() call in Javascript. @@ -102,7 +105,9 @@ void HelloWorldInstance::HandleMessage(const pp::Var& var_message) { /// <code>type="application/x-nacl"</code>. class HelloWorldModule : public pp::Module { public: - HelloWorldModule() : pp::Module() {} + HelloWorldModule() : pp::Module() { + printf("Got here.\n"); + } virtual ~HelloWorldModule() {} /// Create and return a HelloWorldInstance object. diff --git a/native_client_sdk/src/examples/hello_world/helper_functions.cc b/native_client_sdk/src/examples/hello_world/helper_functions.cc index 21191b9..2b43c605 100644 --- a/native_client_sdk/src/examples/hello_world/helper_functions.cc +++ b/native_client_sdk/src/examples/hello_world/helper_functions.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/hello_world/helper_functions.h" - #include <algorithm> +#include "helper_functions.h" + namespace hello_world { int32_t FortyTwo() { diff --git a/native_client_sdk/src/examples/hello_world/test_helper_functions.cc b/native_client_sdk/src/examples/hello_world/test_helper_functions.cc index 10903c6..30d3f27 100644 --- a/native_client_sdk/src/examples/hello_world/test_helper_functions.cc +++ b/native_client_sdk/src/examples/hello_world/test_helper_functions.cc @@ -47,5 +47,6 @@ int main() { std::string alphabet("abcdefghijklmnopqrstuvwxyz"); std::string alphabet_backwards("zyxwvutsrqponmlkjihgfedcba"); EXPECT_EQUAL(ReverseText(alphabet), alphabet_backwards); + return 0; } diff --git a/native_client_sdk/src/examples/hello_world_c/Makefile b/native_client_sdk/src/examples/hello_world_c/Makefile new file mode 100644 index 0000000..d66ef26 --- /dev/null +++ b/native_client_sdk/src/examples/hello_world_c/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=hello_world_c +C_SOURCES:=hello_world_c.c +COPY_FILES:=hello_world_c.html hello_world_c.nmf +LDFLAGS:=-lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CFLAGS:=-pthread $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.c,DBG/x86_32/%.o,$(C_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.c,DBG/x86_64/%.o,$(C_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.c $(THIS_MAKE) | DBG/x86_32 + $(CC) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.c $(THIS_MAKE) | DBG/x86_64 + $(CC) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CC) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CC) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.c,REL/x86_32/%.o,$(C_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.c,REL/x86_64/%.o,$(C_SOURCES)) + +REL: + $(MKDIR) -pv $@ + +REL/x86_32: + $(MKDIR) -pv $@ + +REL/x86_64: + $(MKDIR) -pv $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.c $(THIS_MAKE) | REL/x86_32 + $(CC) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.c $(THIS_MAKE) | REL/x86_64 + $(CC) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CC) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CC) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/hello_world_c/build.scons b/native_client_sdk/src/examples/hello_world_c/build.scons deleted file mode 100644 index 3259e39..0000000 --- a/native_client_sdk/src/examples/hello_world_c/build.scons +++ /dev/null @@ -1,40 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='hello_world_c', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['hello_world_c.c'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'hello_world_c') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('hello_world_c') - -app_files = [ - 'hello_world_c.html', - 'hello_world_c.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/hello_world_c/hello_world_c.c b/native_client_sdk/src/examples/hello_world_c/hello_world_c.c index d27a9118..5169514 100644 --- a/native_client_sdk/src/examples/hello_world_c/hello_world_c.c +++ b/native_client_sdk/src/examples/hello_world_c/hello_world_c.c @@ -149,8 +149,7 @@ static void Instance_DidDestroy(PP_Instance instance) { * plugin is invisible, @a clip will be (0, 0, 0, 0). */ static void Instance_DidChangeView(PP_Instance instance, - const struct PP_Rect* position, - const struct PP_Rect* clip) { + PP_Resource view_resource) { } /** @@ -201,14 +200,17 @@ static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance, * browser via postMessage. */ void Messaging_HandleMessage(PP_Instance instance, struct PP_Var var_message) { + struct PP_Var var_result = PP_MakeUndefined(); + char* message; + if (var_message.type != PP_VARTYPE_STRING) { /* Only handle string messages */ return; } - char* message = VarToCStr(var_message); + message = VarToCStr(var_message); if (message == NULL) return; - struct PP_Var var_result = PP_MakeUndefined(); + if (strncmp(message, kFortyTwoMethodId, strlen(kFortyTwoMethodId)) == 0) { var_result = FortyTwo(); } else if (strncmp(message, diff --git a/native_client_sdk/src/examples/hello_world_c/hello_world_c_dbg.html b/native_client_sdk/src/examples/hello_world_c/hello_world_c_dbg.html deleted file mode 100644 index ea4fd04..0000000 --- a/native_client_sdk/src/examples/hello_world_c/hello_world_c_dbg.html +++ /dev/null @@ -1,126 +0,0 @@ -<!DOCTYPE html> -<html> - <!-- - Copyright (c) 2011 The Chromium Authors. All rights reserved. - Use of this source code is governed by a BSD-style license that can be - found in the LICENSE file. - --> -<head> - <title>Hello, World!</title> - - <script type="text/javascript"> - helloWorldModule = null; // Global application object. - statusText = 'NO-STATUS'; - - // Indicate success when the NaCl module has loaded. - function moduleDidLoad() { - helloWorldModule = document.getElementById('hello_world'); - updateStatus('SUCCESS'); - } - - // Handle a message coming from the NaCl module. - function handleMessage(message_event) { - alert(message_event.data); - } - - // If the page loads before the Native Client module loads, then set the - // status message indicating that the module is still loading. Otherwise, - // do not change the status message. - function pageDidLoad() { - // Set the focus on the text input box. Doing this means you can press - // return as soon as the page loads, and it will fire the reversetText() - // function. - document.forms.helloForm.inputBox.focus(); - if (helloWorldModule == null) { - updateStatus('LOADING...'); - } else { - // It's possible that the Native Client module onload event fired - // before the page's onload event. In this case, the status message - // will reflect 'SUCCESS', but won't be displayed. This call will - // display the current message. - updateStatus(); - } - } - - function fortyTwo() { - helloWorldModule.postMessage('fortyTwo'); - } - - function reverseText() { - // Grab the text from the text box, pass it into reverseText() - var inputBox = document.forms.helloForm.inputBox; - helloWorldModule.postMessage('reverseText:' + inputBox.value); - // Note: a |false| return tells the <form> tag to cancel the GET action - // when submitting the form. - return false; - } - - // Set the global status message. If the element with id 'statusField' - // exists, then set its HTML to the status message as well. - // opt_message The message test. If this is null or undefined, then - // attempt to set the element with id 'statusField' to the value of - // |statusText|. - function updateStatus(opt_message) { - if (opt_message) - statusText = opt_message; - var statusField = document.getElementById('statusField'); - if (statusField) { - statusField.innerHTML = statusText; - } - } - </script> -</head> -<body onload="pageDidLoad()"> - -<h1>Native Client Simple Module</h1> -<p> - <form name="helloForm" - action="" - method="get" - onsubmit="return reverseText()"> - <input type="text" id="inputBox" name="inputBox" value="Hello world" /><p> - <input type="button" value="Call fortyTwo()" onclick="fortyTwo()" /> - <input type="submit" value="Call reverseText()" /> - </form> - <!-- Load the published .nexe. This includes the 'src' attribute which - shows how to load multi-architecture modules. Each entry in the "nexes" - object in the .nmf manifest file is a key-value pair: the key is the runtime - ('x86-32', 'x86-64', etc.); the value is a URL for the desired NaCl module. - To load the debug versions of your .nexes, set the 'src' attribute to the - _dbg.nmf version of the manifest file. - - Note: The <EMBED> element is wrapped inside a <DIV>, which has both a 'load' - and a 'message' event listener attached. This wrapping method is used - instead of attaching the event listeners directly to the <EMBED> element to - ensure that the listeners are active before the NaCl module 'load' event - fires. This also allows you to use PPB_Messaging.PostMessage() (in C) or - pp::Instance.PostMessage() (in C++) from within the initialization code in - your NaCl module. - --> - <div id="listener"> - <script type="text/javascript"> - var listener = document.getElementById('listener') - listener.addEventListener('load', moduleDidLoad, true); - listener.addEventListener('message', handleMessage, true); - </script> - - <embed name="nacl_module" - id="hello_world" - width=0 height=0 - src="hello_world_c_dbg.nmf" - type="application/x-nacl" /> - </div> - -</p> - -<p>If the module is working correctly, a click on the "Call fortyTwo()" button - should open a popup dialog containing <b>42</b> as its value.</p> - -<p> Clicking on the "Call reverseText()" button - should open a popup dialog containing the textbox contents and its reverse - as its value.</p> - -<h2>Status</h2> -<div id="statusField">NO-STATUS</div> -</body> -</html> diff --git a/native_client_sdk/src/examples/httpd.py b/native_client_sdk/src/examples/httpd.py index 76a4977..9865129 100755 --- a/native_client_sdk/src/examples/httpd.py +++ b/native_client_sdk/src/examples/httpd.py @@ -25,21 +25,21 @@ logging.getLogger().setLevel(logging.INFO) SERVER_PORT = 5103 SERVER_HOST = '' -# We only run from the examples or staging directory so -# that not too much is exposed via this HTTP server. Everything in the -# directory is served, so there should never be anything potentially sensitive -# in the serving directory, especially if the machine might be a -# multi-user machine and not all users are trusted. We only serve via -# the loopback interface. - -SAFE_DIR_COMPONENTS = ['staging', 'examples'] - +# We only run from the examples directory so that not too much is exposed +# via this HTTP server. Everything in the directory is served, so there should +# never be anything potentially sensitive in the serving directory, especially +# if the machine might be a multi-user machine and not all users are trusted. +# We only serve via the loopback interface. def SanityCheckDirectory(): - if os.path.basename(os.getcwd()) in SAFE_DIR_COMPONENTS: + httpd_path = os.path.abspath(os.path.dirname(__file__)) + serve_path = os.path.abspath(os.getcwd()) + + # Verify we are serving from the directory this script came from, or bellow + if serve_path[:len(httpd_path)] == httpd_path: return - logging.error('For security, httpd.py should only be run from one of the') - logging.error('following directories: %s' % SAFE_DIR_COMPONENTS) - logging.error('We are currently in %s', os.getcwd()) + logging.error('For security, httpd.py should only be run from within the') + logging.error('example directory tree.') + logging.error('We are currently in %s.' % serve_path) sys.exit(1) diff --git a/native_client_sdk/src/examples/input_events/Makefile b/native_client_sdk/src/examples/input_events/Makefile new file mode 100644 index 0000000..53a5c76 --- /dev/null +++ b/native_client_sdk/src/examples/input_events/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=input_events +CXX_SOURCES:=input_events.cc +COPY_FILES:=input_events.html input_events.nmf +LDFLAGS:=-lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/input_events/build.scons b/native_client_sdk/src/examples/input_events/build.scons deleted file mode 100644 index cfb999b4..0000000 --- a/native_client_sdk/src/examples/input_events/build.scons +++ /dev/null @@ -1,41 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import nacl_utils -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='input_events', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['input_events.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'input_events') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('input_events') - -app_files = [ - 'input_events.html', - 'input_events.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/load_progress/Makefile b/native_client_sdk/src/examples/load_progress/Makefile new file mode 100644 index 0000000..bf83856 --- /dev/null +++ b/native_client_sdk/src/examples/load_progress/Makefile @@ -0,0 +1,184 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=load_progress +C_SOURCES:= +CXX_SOURCES:=load_progress.cc +COPY_FILES:=load_progress.html load_progress.nmf +LDFLAGS:=-lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/load_progress/build.scons b/native_client_sdk/src/examples/load_progress/build.scons deleted file mode 100644 index c12ee41..0000000 --- a/native_client_sdk/src/examples/load_progress/build.scons +++ /dev/null @@ -1,51 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='load_progress', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - CCFLAGS=['-pedantic', '-Werror'], - ) - -sources = ['load_progress.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'load_progress') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('load_progress') - -common_files = [ - 'check_browser.js', - ] -common_files = [ - os.path.join(os.path.dirname(os.getcwd()), 'common', common_file) - for common_file in common_files] - -app_files = [ - 'load_progress.html', - 'load_progress.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -common_dir = os.path.join(os.path.dirname(nacl_env['NACL_INSTALL_ROOT']), - 'common') -install_common = nacl_env.Install(dir=common_dir, source=common_files) -nacl_env.Alias('install', - source=[install_app, install_common, install_nexes]) diff --git a/native_client_sdk/src/examples/mouselock/Makefile b/native_client_sdk/src/examples/mouselock/Makefile new file mode 100644 index 0000000..02ff22c --- /dev/null +++ b/native_client_sdk/src/examples/mouselock/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=mouselock +CXX_SOURCES:=mouselock.cc +COPY_FILES:=mouselock.html mouselock.nmf ../common/check_browser.js +LDFLAGS:=-lppapi_gles2 -lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/mouselock/build.scons b/native_client_sdk/src/examples/mouselock/build.scons deleted file mode 100644 index cf7a976..0000000 --- a/native_client_sdk/src/examples/mouselock/build.scons +++ /dev/null @@ -1,51 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='mouselock', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - CCFLAGS=['-pedantic', '-Werror'], - ) - -sources = ['mouselock.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'mouselock') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('mouselock') - -common_files = [ - 'check_browser.js', - ] -common_files = [ - os.path.join(os.path.dirname(os.getcwd()), 'common', common_file) - for common_file in common_files] - -app_files = [ - 'mouselock.html', - 'mouselock.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -common_dir = os.path.join(os.path.dirname(nacl_env['NACL_INSTALL_ROOT']), - 'common') -install_common = nacl_env.Install(dir=common_dir, source=common_files) -nacl_env.Alias('install', - source=[install_app, install_common, install_nexes]) diff --git a/native_client_sdk/src/examples/mouselock/mouselock.cc b/native_client_sdk/src/examples/mouselock/mouselock.cc index bf45679..f020da9 100644 --- a/native_client_sdk/src/examples/mouselock/mouselock.cc +++ b/native_client_sdk/src/examples/mouselock/mouselock.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/mouselock/mouselock.h" - #include <cmath> #include <cstdlib> #include <stdarg.h> @@ -12,6 +10,8 @@ #include <algorithm> +#include "mouselock.h" + // Indicate the direction of the mouse location relative to the center of the // view. These values are used to determine which 2D quadrant the needle lies // in. diff --git a/native_client_sdk/src/examples/mouselock/mouselock.h b/native_client_sdk/src/examples/mouselock/mouselock.h index 13c615c..b31aaef 100644 --- a/native_client_sdk/src/examples/mouselock/mouselock.h +++ b/native_client_sdk/src/examples/mouselock/mouselock.h @@ -16,6 +16,7 @@ #include "ppapi/cpp/module.h" #include "ppapi/cpp/rect.h" #include "ppapi/cpp/var.h" +#include "ppapi/utility/completion_callback_factory.h" namespace mouselock { diff --git a/native_client_sdk/src/examples/mouselock/mouselock.html b/native_client_sdk/src/examples/mouselock/mouselock.html index 4908c0e..7a4ba3f 100644 --- a/native_client_sdk/src/examples/mouselock/mouselock.html +++ b/native_client_sdk/src/examples/mouselock/mouselock.html @@ -9,7 +9,7 @@ found in the LICENSE file. <head> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="-1" /> - <script type="text/javascript" src="../common/check_browser.js"></script> + <script type="text/javascript" src="check_browser.js"></script> <script> // Check for Native Client support in the browser before the DOM loads. var isValidBrowser = false; diff --git a/native_client_sdk/src/examples/multithreaded_input_events/Makefile b/native_client_sdk/src/examples/multithreaded_input_events/Makefile new file mode 100644 index 0000000..1a54e0d --- /dev/null +++ b/native_client_sdk/src/examples/multithreaded_input_events/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=multithreaded_input_events +CXX_SOURCES:=custom_events.cc mt_input_events.cc +LDFLAGS:=-lppapi_cpp -lppapi +COPY_FILES:=mt_input_events.html mt_input_events.nmf + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/multithreaded_input_events/build.scons b/native_client_sdk/src/examples/multithreaded_input_events/build.scons deleted file mode 100644 index 4e7bc84..0000000 --- a/native_client_sdk/src/examples/multithreaded_input_events/build.scons +++ /dev/null @@ -1,41 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import nacl_utils -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='multithreaded_input_events', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['mt_input_events.cc', 'custom_events.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'mt_input_events') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('mt_input_events') - -app_files = [ - 'mt_input_events.html', - 'mt_input_events.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/multithreaded_input_events/custom_events.cc b/native_client_sdk/src/examples/multithreaded_input_events/custom_events.cc index b005ccd..9f5be7d 100644 --- a/native_client_sdk/src/examples/multithreaded_input_events/custom_events.cc +++ b/native_client_sdk/src/examples/multithreaded_input_events/custom_events.cc @@ -4,7 +4,7 @@ #include <sstream> -#include "examples/multithreaded_input_events/custom_events.h" +#include "custom_events.h" namespace event_queue { diff --git a/native_client_sdk/src/examples/multithreaded_input_events/mt_input_events.cc b/native_client_sdk/src/examples/multithreaded_input_events/mt_input_events.cc index c207f22..bf20880 100644 --- a/native_client_sdk/src/examples/multithreaded_input_events/mt_input_events.cc +++ b/native_client_sdk/src/examples/multithreaded_input_events/mt_input_events.cc @@ -10,17 +10,18 @@ #include <sstream> #include <string> -#include "examples/multithreaded_input_events/custom_events.h" -#include "examples/multithreaded_input_events/shared_queue.h" -#include "examples/multithreaded_input_events/thread_safe_ref_count.h" - -// NaCl +// PPAPI headers #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/input_event.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/cpp/point.h" #include "ppapi/cpp/var.h" +#include "ppapi/utility/completion_callback_factory.h" + +#include "custom_events.h" +#include "shared_queue.h" +#include "thread_safe_ref_count.h" namespace event_queue { const char* const kDidChangeView = "DidChangeView"; diff --git a/native_client_sdk/src/examples/multithreaded_input_events/shared_queue.h b/native_client_sdk/src/examples/multithreaded_input_events/shared_queue.h index a87e7e6..2578100 100644 --- a/native_client_sdk/src/examples/multithreaded_input_events/shared_queue.h +++ b/native_client_sdk/src/examples/multithreaded_input_events/shared_queue.h @@ -9,7 +9,7 @@ #include <cassert> #include <deque> -#include "examples/multithreaded_input_events/thread_safe_ref_count.h" +#include "thread_safe_ref_count.h" namespace event_queue { diff --git a/native_client_sdk/src/examples/pi_generator/Makefile b/native_client_sdk/src/examples/pi_generator/Makefile new file mode 100644 index 0000000..9e999f6 --- /dev/null +++ b/native_client_sdk/src/examples/pi_generator/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=pi_generator +CXX_SOURCES:=pi_generator.cc pi_generator_module.cc +COPY_FILES:=pi_generator.html pi_generator.nmf +LDFLAGS:=-lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/pi_generator/build.scons b/native_client_sdk/src/examples/pi_generator/build.scons deleted file mode 100644 index c842b09..0000000 --- a/native_client_sdk/src/examples/pi_generator/build.scons +++ /dev/null @@ -1,40 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='pi_generator', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['pi_generator.cc', 'pi_generator_module.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'pi_generator') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('pi_generator') - -app_files = [ - 'pi_generator.html', - 'pi_generator.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/pi_generator/pi_generator.cc b/native_client_sdk/src/examples/pi_generator/pi_generator.cc index d38d027..3180d81 100644 --- a/native_client_sdk/src/examples/pi_generator/pi_generator.cc +++ b/native_client_sdk/src/examples/pi_generator/pi_generator.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/pi_generator/pi_generator.h" - #include <stdio.h> #include <stdlib.h> #include <cassert> @@ -13,6 +11,8 @@ #include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/var.h" +#include "pi_generator.h" + namespace { const int kPthreadMutexSuccess = 0; const char* const kPaintMethodId = "paint"; diff --git a/native_client_sdk/src/examples/pi_generator/pi_generator_dbg.html b/native_client_sdk/src/examples/pi_generator/pi_generator_dbg.html deleted file mode 100644 index 455a724..0000000 --- a/native_client_sdk/src/examples/pi_generator/pi_generator_dbg.html +++ /dev/null @@ -1,83 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
- <!--
- Copyright (c) 2011 The Chromium Authors. All rights reserved.
- Use of this source code is governed by a BSD-style license that can be
- found in the LICENSE file.
- -->
- <head>
- <title>Monte Carlo Estimate for Pi</title>
- <script type="text/javascript">
- var piGenerator = null;
- var paintInterval = null;
-
- // Start up the paint timer when the NaCl module has loaded.
- function moduleDidLoad() {
- piGenerator = document.getElementById('piGenerator');
- paintInterval = setInterval('piGenerator.postMessage("paint")', 5);
- }
-
- // Handle a message coming from the NaCl module. The message payload is
- // assumed to contain the current estimated value of Pi. Update the Pi
- // text display with this value.
- function handleMessage(message_event) {
- document.form.pi.value = message_event.data;
- }
-
- function pageDidUnload() {
- clearInterval(paintInterval);
- }
- </script>
- </head>
- <body id="bodyId" onunload="pageDidUnload()">
- <h1>Monte Carlo Estimate for Pi</h1>
- <p>
- The Native Client module executed in this page creates a thread
- that estimates pi (π) using the Monte Carlo method.
- The thread randomly puts 1,000,000,000 points
- inside a square that shares two sides with a quarter circle (a quadrant).
- Because the area of
- the quadrant is r²π/4
- and the area of
- the square is r²,
- dividing the number of points inside the quadrant
- by the number of points inside the square gives us
- an estimate of π/4.
- The textbox under the square
- shows the current estimate of π.
- </p>
- <!-- Load the published .nexe. This includes the 'src' attribute which
- shows how to load multi-architecture modules. Each entry in the "nexes"
- object in the .nmf manifest file is a key-value pair: the key is the
- runtime ('x86-32', 'x86-64', etc.); the value is a URL for the desired NaCl
- module. To load the debug versions of your .nexes, set the 'src'
- attribute to the _dbg.nmf version of the manifest file.
-
- Note: The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
- and a 'message' event listener attached. This wrapping method is used
- instead of attaching the event listeners directly to the <EMBED> element to
- ensure that the listeners are active before the NaCl module 'load' event
- fires. This also allows you to use PPB_Messaging.PostMessage() (in C) or
- pp::Instance.PostMessage() (in C++) from within the initialization code in
- your NaCl module.
- -->
- <div id="listener">
- <script type="text/javascript">
- var listener = document.getElementById('listener')
- listener.addEventListener('load', moduleDidLoad, true);
- listener.addEventListener('message', handleMessage, true);
- </script>
-
- <embed name="nacl_module"
- id="piGenerator"
- width=200 height=200
- src="pi_generator_dbg.nmf"
- type="application/x-nacl" />
- </div>
- <br />
- <form name="form">
- <input type="text" size="15" name="pi" />
- </form>
- </body>
-</html>
diff --git a/native_client_sdk/src/examples/pi_generator/pi_generator_module.cc b/native_client_sdk/src/examples/pi_generator/pi_generator_module.cc index 34f35a1..2434a09 100644 --- a/native_client_sdk/src/examples/pi_generator/pi_generator_module.cc +++ b/native_client_sdk/src/examples/pi_generator/pi_generator_module.cc @@ -4,7 +4,7 @@ #include <ppapi/cpp/module.h> -#include "examples/pi_generator/pi_generator.h" +#include "pi_generator.h" namespace pi_generator { // The Module class. The browser calls the CreateInstance() method to create diff --git a/native_client_sdk/src/examples/pong/Makefile b/native_client_sdk/src/examples/pong/Makefile new file mode 100644 index 0000000..7b02598 --- /dev/null +++ b/native_client_sdk/src/examples/pong/Makefile @@ -0,0 +1,184 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=pong +CXX_SOURCES:=pong_module.cc pong.cc view.cc +COPY_FILES:=pong.nmf pong.html +LDFLAGS:=-lppapi_cpp -lppapi + + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/pong/build.scons b/native_client_sdk/src/examples/pong/build.scons deleted file mode 100644 index bc0438d..0000000 --- a/native_client_sdk/src/examples/pong/build.scons +++ /dev/null @@ -1,40 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='pong', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['pong.cc', 'pong_module.cc', 'view.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'pong') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('pong') - -app_files = [ - 'pong.html', - 'pong.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/pong/pong.cc b/native_client_sdk/src/examples/pong/pong.cc index 9661ba9..14b5321 100644 --- a/native_client_sdk/src/examples/pong/pong.cc +++ b/native_client_sdk/src/examples/pong/pong.cc @@ -2,12 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/pong/pong.h" - #include <stdio.h> #include <cmath> #include <string> -#include "examples/pong/view.h" #include "ppapi/c/pp_file_info.h" #include "ppapi/c/ppb_file_io.h" #include "ppapi/cpp/completion_callback.h" @@ -18,6 +15,9 @@ #include "ppapi/cpp/rect.h" #include "ppapi/cpp/var.h" +#include "pong.h" +#include "view.h" + namespace { const uint32_t kSpaceBar = 0x20; @@ -91,10 +91,14 @@ void QueryCallback(void* data, int32_t result) { pong->bytes_to_read_ = pong->file_info_.size; pong->offset_ = 0; pong->bytes_buffer_.resize(pong->bytes_to_read_); - pong->file_io_->Read(pong->offset_, - &pong->bytes_buffer_[0], - pong->bytes_to_read_, - pp::CompletionCallback(ReadCallback, pong)); + + // Check if there is anything to read. + if (pong->bytes_to_read_ == 0) { + pong->file_io_->Read(pong->offset_, + &pong->bytes_buffer_[0], + pong->bytes_to_read_, + pp::CompletionCallback(ReadCallback, pong)); + } } // Callback that is called as a result of pp::FileIO::Open diff --git a/native_client_sdk/src/examples/pong/pong_module.cc b/native_client_sdk/src/examples/pong/pong_module.cc index 19aa164..6d330aa 100644 --- a/native_client_sdk/src/examples/pong/pong_module.cc +++ b/native_client_sdk/src/examples/pong/pong_module.cc @@ -4,7 +4,7 @@ #include <ppapi/cpp/module.h> -#include "examples/pong/pong.h" +#include "pong.h" namespace pong { // The Module class. The browser calls the CreateInstance() method to create diff --git a/native_client_sdk/src/examples/pong/view.cc b/native_client_sdk/src/examples/pong/view.cc index 2bac4f3..2938275 100644 --- a/native_client_sdk/src/examples/pong/view.cc +++ b/native_client_sdk/src/examples/pong/view.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/pong/view.h" - #include <math.h> #include <stdio.h> #include <string.h> @@ -16,6 +14,8 @@ #include "ppapi/cpp/point.h" #include "ppapi/cpp/var.h" +#include "view.h" + // Input event key codes. PPAPI uses Windows Virtual key codes. const uint32_t kSpaceBar = 0x20; const uint32_t kUpArrow = 0x26; diff --git a/native_client_sdk/src/examples/scons b/native_client_sdk/src/examples/scons deleted file mode 100755 index 17e9350..0000000 --- a/native_client_sdk/src/examples/scons +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -readonly SCRIPT_DIR="$(dirname "$0")" -readonly SCRIPT_DIR_ABS="$(cd "${SCRIPT_DIR}" ; pwd -P)" -readonly SRC_DIR="$(dirname $(dirname $(dirname ${SCRIPT_DIR_ABS})))" - -# NACL_SDK_ROOT must be set. -if [ x"${NACL_SDK_ROOT}"x == "xx" ] ; then - echo "Error: NACL_SDK_ROOT is not set." - exit 1; -fi - -# NACL_TARGET_PLATFORM is really the name of a folder with the base dir - -# usually NACL_SDK_ROOT - within which the toolchain for the target platform -# are found. -# Replace the platform with the name of your target platform. For example, to -# build applications that target the pepper_17 API, set -# NACL_TARGET_PLATFORM="pepper_17" -if [ x"${NACL_TARGET_PLATFORM}"x == "xx" ] ; then - export NACL_TARGET_PLATFORM="pepper_17" -fi - -readonly NACL_PLATFORM_DIR="${NACL_SDK_ROOT}/${NACL_TARGET_PLATFORM}" - -SCONS_DIR="${NACL_PLATFORM_DIR}/third_party/scons-2.0.1" - -if [ ! -f ${SCONS_DIR}/script/scons ]; then - SCONS_DIR="${SRC_DIR}/third_party/scons-2.0.1" -fi - -BASE_SCRIPT="${SCONS_DIR}/script/scons" - -export SCONS_LIB_DIR="${SCONS_DIR}/engine" -export PYTHONPATH="${SCONS_LIB_DIR}" -export PYTHONPATH="${PYTHONPATH}:${NACL_PLATFORM_DIR}/build_tools" - -# We have to do this because scons overrides PYTHONPATH and does not preserve -# what is provided by the OS. The custom variable name won't be overwritten. -export PYMOX="${NACL_PLATFORM_DIR}/third_party/pymox/src" - -"${BASE_SCRIPT}" --file=build.scons \ - --site-dir="${SCRIPT_DIR_ABS}/../build_tools/nacl_sdk_scons" \ - $* diff --git a/native_client_sdk/src/examples/scons.bat b/native_client_sdk/src/examples/scons.bat deleted file mode 100755 index d56f245..0000000 --- a/native_client_sdk/src/examples/scons.bat +++ /dev/null @@ -1,50 +0,0 @@ -@echo off - -:: Copyright (c) 2011 The Chromium Authors. All rights reserved. -:: Use of this source code is governed by a BSD-style license that can be -:: found in the LICENSE file. - -setlocal - -:: NACL_SDK_ROOT must be set. -if not defined NACL_SDK_ROOT ( - echo Error: NACL_SDK_ROOT is not set. - echo Please set NACL_SDK_ROOT to the full path of the Native Client SDK. - echo For example: - echo set NACL_SDK_ROOT=D:\nacl_sdk - goto end -) - -:: NACL_TARGET_PLATFORM is really the name of a folder with the base dir - -:: usually NACL_SDK_ROOT - within which the toolchain for the target platform -:: are found. -:: Replace the platform with the name of your target platform. For example, to -:: build applications that target the pepper_17 API, set -:: NACL_TARGET_PLATFORM=pepper_17 -if not defined NACL_TARGET_PLATFORM ( - set NACL_TARGET_PLATFORM=pepper_17 -) - -set NACL_PLATFORM_DIR=%NACL_SDK_ROOT%\%NACL_TARGET_PLATFORM% - -set SCONS_DIR=%NACL_PLATFORM_DIR%\third_party\scons-2.0.1 -if exist %SCONS_DIR% goto gotscons -set SCONS_DIR=%~dp0..\..\..\third_party\scons-2.0.1 -:gotscons - -set SCONS_LIB_DIR=%SCONS_DIR%\engine -set PYTHONPATH=%SCONS_LIB_DIR%;%NACL_PLATFORM_DIR%\build_tools - -:: We have to do this because scons overrides PYTHONPATH and does not preserve -:: what is provided by the OS. The custom variable name won't be overwritten. -set PYMOX=%NACL_PLATFORM_DIR%\third_party\pymox\src - -set BASE_SCRIPT=%SCONS_DIR%\script\scons - -:: Run the included copy of scons. -python -O -OO %BASE_SCRIPT% ^ ---warn no-visual-c-missing ^ ---file=build.scons ^ ---site-dir="%~dp0..\build_tools\nacl_sdk_scons" %* - -:end diff --git a/native_client_sdk/src/examples/sine_synth/Makefile b/native_client_sdk/src/examples/sine_synth/Makefile new file mode 100644 index 0000000..ca9a070 --- /dev/null +++ b/native_client_sdk/src/examples/sine_synth/Makefile @@ -0,0 +1,183 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=sine_synth +CXX_SOURCES:=sine_synth.cc +COPY_FILES:=sine_synth.nmf sine_synth.html +LDFLAGS:=-lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/sine_synth/build.scons b/native_client_sdk/src/examples/sine_synth/build.scons deleted file mode 100644 index 35f2279..0000000 --- a/native_client_sdk/src/examples/sine_synth/build.scons +++ /dev/null @@ -1,40 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='sine_synth', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - ) - -sources = ['sine_synth.cc'] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'sine_synth') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('sine_synth') - -app_files = [ - 'sine_synth.html', - 'sine_synth.nmf', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/tumbler/Makefile b/native_client_sdk/src/examples/tumbler/Makefile new file mode 100644 index 0000000..fb8f32c --- /dev/null +++ b/native_client_sdk/src/examples/tumbler/Makefile @@ -0,0 +1,185 @@ +# Copyright (c) 2011 The Native Client Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# GNU Make based build file. For details on GNU Make see: +# http://www.gnu.org/software/make/manual/make.html +# + +# +# Project information +# +# These variables store project specific settings for the project name +# build flags, files to copy or install. In the examples it is typically +# only the list of sources and project name that will actually change and +# the rest of the makefile is boilerplate for defining build rules. +# +PROJECT:=tumbler +CXX_SOURCES:=transforms.cc shader_util.cc opengl_context.cc tumbler_module.cc +CXX_SOURCES+=scripting_bridge.cc tumbler.cc cube.cc +COPY_FILES:=tumbler.nmf tumbler.html bind.js dragger.js vector3.js tumbler.js +COPY_FILES+=trackball.js +LDFLAGS:=-lppapi_gles2 -lppapi_cpp -lppapi + + +# +# Get pepper directory for toolchain and includes. +# +# If PEPPER_ROOT is not set, then assume it can be found a two directories up, +# from the default example directory location. +# +THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) +PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) + +# Project Build flags +DEFINES:= +INCLUDES:= +WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror +CXXFLAGS:=-pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES) + +# +# Compute tool paths +# +# +OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) +TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) +CC:=$(TC_PATH)/bin/i686-nacl-gcc +CXX:=$(TC_PATH)/bin/i686-nacl-g++ +STRIP:=$(TC_PATH)/bin/i686-nacl-strip + +# +# Create shell aliases +# +# Create Python based aliases for common shell commands like copy or move. +# +COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp +MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir +RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm +MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv + +# +# Disable DOS PATH warning when using Cygwin based tools Windows +# +CYGWIN ?= nodosfilewarning +export CYGWIN + +# +# Define a macro for copying files to the configuration directory +# +# Copys a source file to the destination directory, removing the base path +# from the source. Adds a dependency to the destination directory in case it +# needs to be created. +# +# $(1) = Source file +# $(2) = Destination directory +define FILE_COPY +$(2)/$(notdir $(1)) : $(1) | $(2) + $(COPY) $(1) $(2) +$(2)_COPIES+=$(2)/$(notdir $(1)) +endef + + +# Declare the ALL target first, to make the 'all' target the default build +all: DEBUG RELEASE + + +# +# Debug Build rules. +# +DEBUG_x86_32_FLAGS:=-m32 -O0 -g +DEBUG_x86_64_FLAGS:=-m64 -O0 -g +DEBUG_x86_32_OBJS:=$(patsubst %.cc,DBG/x86_32/%.o,$(CXX_SOURCES)) +DEBUG_x86_64_OBJS:=$(patsubst %.cc,DBG/x86_64/%.o,$(CXX_SOURCES)) + +# Create DBG configuration directories +DBG: + $(MKDIR) -p $@ + +DBG/x86_32: + $(MKDIR) -p $@ + +DBG/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) + +# Include generated dependencies +-include DBG/x86_32/*.d +-include DBG/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +DBG/x86_32/%.o : %.cc $(THIS_MAKE) | DBG/x86_32 + $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +DBG/x86_64/%.o : %.cc $(THIS_MAKE) | DBG/x86_64 + $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit debug NEXE +DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) + +# Define Link rule for 64 bit debug NEXE +DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) + $(CXX) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) + +# Define a DEBUG alias to build the debug version +.PHONY : DEBUG RUN_DEBUG +DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) + +# Define a RUN_DEBUG alias to build and server the DEBUG version +RUN_DEBUG: DEBUG + cd DBG && python ../../httpd.py + + +# +# Release build rules. +# +RELEASE_x86_32_FLAGS:=-m32 -O2 -g +RELEASE_x86_64_FLAGS:=-m64 -O2 -g +RELEASE_x86_32_OBJS:=$(patsubst %.cc,REL/x86_32/%.o,$(CXX_SOURCES)) +RELEASE_x86_64_OBJS:=$(patsubst %.cc,REL/x86_64/%.o,$(CXX_SOURCES)) + +REL: + $(MKDIR) -p $@ + +REL/x86_32: + $(MKDIR) -p $@ + +REL/x86_64: + $(MKDIR) -p $@ + +# Copy all files to that config +$(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) + +# Include generated dependencies +-include REL/x86_32/*.d +-include REL/x86_64/*.d + +# Define compile rule for all 32 bit debug objects +REL/x86_32/%.o : %.cc $(THIS_MAKE) | REL/x86_32 + $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -MMD -MF $@.d + +# Define compile rule for all 64 bit debug objects +REL/x86_64/%.o : %.cc $(THIS_MAKE) | REL/x86_64 + $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) + +# Define Link rule for 32 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) + $(STRIP) $< -o $@ + +# Define Link rule for 64 bit optimized and stripped NEXE +REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) + $(CXX) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) + $(STRIP) $@.unstripped -o $@ + +# Define a RELEASE alias to build the debug version +.PHONY : RELEASE RUN_RELEASE +RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) + +# Define a RUN_RELEASE alias to build and server the RELEASE version +RUN_RELEASE: RELEASE + cd REL && python ../../httpd.py diff --git a/native_client_sdk/src/examples/tumbler/build.scons b/native_client_sdk/src/examples/tumbler/build.scons deleted file mode 100644 index ccf7e3d..0000000 --- a/native_client_sdk/src/examples/tumbler/build.scons +++ /dev/null @@ -1,55 +0,0 @@ -#! -*- python -*- -# -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import make_nacl_env -import nacl_utils -import os - -nacl_env = make_nacl_env.NaClEnvironment( - use_c_plus_plus_libs=True, nacl_platform=os.getenv('NACL_TARGET_PLATFORM'), - install_subdir='tumbler', lib_prefix='..') -nacl_env.Append( - # Add a CPPPATH that enables the full-path #include directives, such as - # #include "examples/sine_synth/sine_synth.h" - CPPPATH=[os.path.dirname(os.path.dirname(os.getcwd()))], - # Strict ANSI compliance. - EXTRA_CCFLAGS=['-pedantic'], - LIBS=['ppapi_gles2'], - ) - -sources = [ - 'cube.cc', - 'opengl_context.cc', - 'scripting_bridge.cc', - 'shader_util.cc', - 'transforms.cc', - 'tumbler.cc', - 'tumbler_module.cc', - ] - -opt_nexes, dbg_nexes = nacl_env.AllNaClModules(sources, 'tumbler') - -# This target is used by the SDK build system to provide a prebuilt version -# of the example in the SDK installer. -nacl_env.InstallPrebuilt('tumbler') - -app_files = [ - 'tumbler.html', - 'tumbler.nmf', - 'bind.js', - 'dragger.js', - 'trackball.js', - 'tumbler.js', - 'vector3.js', - ] - -# Split the install of the .nexes from the other app sources so that the strip -# action is applied to the .nexes only. -install_nexes = nacl_env.NaClStrippedInstall(dir=nacl_env['NACL_INSTALL_ROOT'], - source=opt_nexes) -install_app = nacl_env.Install(dir=nacl_env['NACL_INSTALL_ROOT'], - source=app_files) -nacl_env.Alias('install', source=install_app + install_nexes) diff --git a/native_client_sdk/src/examples/tumbler/cube.cc b/native_client_sdk/src/examples/tumbler/cube.cc index e36ac72..9f0f3ea 100644 --- a/native_client_sdk/src/examples/tumbler/cube.cc +++ b/native_client_sdk/src/examples/tumbler/cube.cc @@ -2,12 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/cube.h" - #include <algorithm> -#include "examples/tumbler/shader_util.h" -#include "examples/tumbler/transforms.h" +#include "cube.h" +#include "shader_util.h" +#include "transforms.h" namespace tumbler { diff --git a/native_client_sdk/src/examples/tumbler/cube.h b/native_client_sdk/src/examples/tumbler/cube.h index 1fc5283..fc607f5 100644 --- a/native_client_sdk/src/examples/tumbler/cube.h +++ b/native_client_sdk/src/examples/tumbler/cube.h @@ -7,8 +7,9 @@ #include <GLES2/gl2.h> #include <vector> -#include "examples/tumbler/opengl_context.h" -#include "examples/tumbler/opengl_context_ptrs.h" + +#include "opengl_context.h" +#include "opengl_context_ptrs.h" namespace tumbler { diff --git a/native_client_sdk/src/examples/tumbler/opengl_context.cc b/native_client_sdk/src/examples/tumbler/opengl_context.cc index 5c104d8..82aa5da 100644 --- a/native_client_sdk/src/examples/tumbler/opengl_context.cc +++ b/native_client_sdk/src/examples/tumbler/opengl_context.cc @@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/opengl_context.h" #include <pthread.h> #include "ppapi/cpp/completion_callback.h" #include "ppapi/gles2/gl2ext_ppapi.h" +#include "opengl_context.h" + namespace { // This is called by the brower when the 3D context has been flushed to the // browser window. diff --git a/native_client_sdk/src/examples/tumbler/opengl_context.h b/native_client_sdk/src/examples/tumbler/opengl_context.h index 6b05634..6850647 100644 --- a/native_client_sdk/src/examples/tumbler/opengl_context.h +++ b/native_client_sdk/src/examples/tumbler/opengl_context.h @@ -17,13 +17,14 @@ #include <algorithm> #include <string> -#include "examples/tumbler/opengl_context_ptrs.h" #include "ppapi/c/ppb_opengles2.h" #include "ppapi/cpp/graphics_3d_client.h" #include "ppapi/cpp/graphics_3d.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/size.h" +#include "opengl_context_ptrs.h" + namespace tumbler { /// OpenGLContext manages an OpenGL rendering context in the browser. diff --git a/native_client_sdk/src/examples/tumbler/scripting_bridge.cc b/native_client_sdk/src/examples/tumbler/scripting_bridge.cc index 94294fc..09e0c26 100644 --- a/native_client_sdk/src/examples/tumbler/scripting_bridge.cc +++ b/native_client_sdk/src/examples/tumbler/scripting_bridge.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/scripting_bridge.h" +#include "scripting_bridge.h" namespace { const char* const kWhiteSpaceCharacters = " \t"; diff --git a/native_client_sdk/src/examples/tumbler/scripting_bridge.h b/native_client_sdk/src/examples/tumbler/scripting_bridge.h index 7bda30a..b0a415b 100644 --- a/native_client_sdk/src/examples/tumbler/scripting_bridge.h +++ b/native_client_sdk/src/examples/tumbler/scripting_bridge.h @@ -10,9 +10,10 @@ #include <tr1/memory> #include <vector> -#include "examples/tumbler/callback.h" #include "ppapi/cpp/var.h" +#include "callback.h" + namespace tumbler { class MethodCallbackExecutor; diff --git a/native_client_sdk/src/examples/tumbler/shader_util.cc b/native_client_sdk/src/examples/tumbler/shader_util.cc index 2029a02..6f5fd00 100644 --- a/native_client_sdk/src/examples/tumbler/shader_util.cc +++ b/native_client_sdk/src/examples/tumbler/shader_util.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/shader_util.h" - #include <stdlib.h> #include <stdio.h> +#include "shader_util.h" + namespace shader_util { GLuint CreateShaderOfType(GLenum type, const char *shader_src) { diff --git a/native_client_sdk/src/examples/tumbler/transforms.cc b/native_client_sdk/src/examples/tumbler/transforms.cc index 4dfbbde..6cd4ced 100644 --- a/native_client_sdk/src/examples/tumbler/transforms.cc +++ b/native_client_sdk/src/examples/tumbler/transforms.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/transforms.h" - #include <math.h> #include <string.h> #include <GLES2/gl2.h> +#include "transforms.h" + namespace transform_4x4 { static const GLfloat kPI = 3.1415926535897932384626433832795f; diff --git a/native_client_sdk/src/examples/tumbler/tumbler.cc b/native_client_sdk/src/examples/tumbler/tumbler.cc index 23c4362..d711d20 100644 --- a/native_client_sdk/src/examples/tumbler/tumbler.cc +++ b/native_client_sdk/src/examples/tumbler/tumbler.cc @@ -2,20 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/tumbler.h" - #include <cstdlib> #include <cstring> #include <string> #include <vector> -#include "examples/tumbler/cube.h" -#include "examples/tumbler/opengl_context.h" -#include "examples/tumbler/scripting_bridge.h" #include "ppapi/cpp/rect.h" #include "ppapi/cpp/size.h" #include "ppapi/cpp/var.h" +#include "cube.h" +#include "opengl_context.h" +#include "scripting_bridge.h" +#include "tumbler.h" + namespace { const size_t kQuaternionElementCount = 4; const char* const kArrayStartCharacter = "["; diff --git a/native_client_sdk/src/examples/tumbler/tumbler.h b/native_client_sdk/src/examples/tumbler/tumbler.h index 41d055e..42317e6 100644 --- a/native_client_sdk/src/examples/tumbler/tumbler.h +++ b/native_client_sdk/src/examples/tumbler/tumbler.h @@ -9,12 +9,13 @@ #include <map> #include <vector> -#include "examples/tumbler/cube.h" -#include "examples/tumbler/opengl_context.h" -#include "examples/tumbler/opengl_context_ptrs.h" -#include "examples/tumbler/scripting_bridge.h" #include "ppapi/cpp/instance.h" +#include "cube.h" +#include "opengl_context.h" +#include "opengl_context_ptrs.h" +#include "scripting_bridge.h" + namespace tumbler { class Tumbler : public pp::Instance { diff --git a/native_client_sdk/src/examples/tumbler/tumbler_module.cc b/native_client_sdk/src/examples/tumbler/tumbler_module.cc index d96b94e..98ec385 100644 --- a/native_client_sdk/src/examples/tumbler/tumbler_module.cc +++ b/native_client_sdk/src/examples/tumbler/tumbler_module.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "examples/tumbler/tumbler.h" #include "ppapi/cpp/instance.h" #include "ppapi/cpp/module.h" #include "ppapi/gles2/gl2ext_ppapi.h" +#include "tumbler.h" /// The Module class. The browser calls the CreateInstance() method to create /// an instance of your NaCl module on the web page. The browser creates a new /// instance for each <embed> tag with type="application/x-nacl". |