summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornoelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 01:50:47 +0000
committernoelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 01:50:47 +0000
commit4cc5f4f84602b693c7b61484f57166aac7b13be2 (patch)
tree583c4d3fc931575d1101b7ca38058afbd4b3481f
parent58bbd265659f44fa5e362fd5fe6e38ea1671fdce (diff)
downloadchromium_src-4cc5f4f84602b693c7b61484f57166aac7b13be2.zip
chromium_src-4cc5f4f84602b693c7b61484f57166aac7b13be2.tar.gz
chromium_src-4cc5f4f84602b693c7b61484f57166aac7b13be2.tar.bz2
Clean up examples
Simplify hello world examples. Remove DEBUG/RELEASE builds from make. Remove 'helper_functions' from simple hello_world. Move C++ hello_world -> hello_world_interactive. Move Hello_world_c -> hello_world_newlib Copy Hello_world_c -> hello_world_glibc (with glibc TC) This change grately simplifies the hello world cases making it easier to point out exactly what is different between the various builds. It also allows us to stage simple make file changes instead of starting with a more complex one. This change only affect the NaCl SDK builders. BUG= 109207 Review URL: https://chromiumcodereview.appspot.com/9370041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121374 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--native_client_sdk/src/examples/hello_world/Makefile183
-rw-r--r--native_client_sdk/src/examples/hello_world_c/Makefile183
-rw-r--r--native_client_sdk/src/examples/hello_world_glibc/Makefile199
-rw-r--r--native_client_sdk/src/examples/hello_world_glibc/hello_world.c182
-rw-r--r--native_client_sdk/src/examples/hello_world_glibc/hello_world.cc135
-rw-r--r--native_client_sdk/src/examples/hello_world_glibc/hello_world.html61
-rw-r--r--native_client_sdk/src/examples/hello_world_glibc/helper_functions.cc22
-rw-r--r--native_client_sdk/src/examples/hello_world_glibc/helper_functions.h34
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/Makefile70
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/hello_world.cc (renamed from native_client_sdk/src/examples/hello_world/hello_world.cc)0
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/hello_world.html (renamed from native_client_sdk/src/examples/hello_world/hello_world.html)2
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/hello_world.nmf (renamed from native_client_sdk/src/examples/hello_world/hello_world.nmf)0
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/helper_functions.cc (renamed from native_client_sdk/src/examples/hello_world/helper_functions.cc)0
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/helper_functions.h (renamed from native_client_sdk/src/examples/hello_world/helper_functions.h)0
-rw-r--r--native_client_sdk/src/examples/hello_world_interactive/test_helper_functions.cc (renamed from native_client_sdk/src/examples/hello_world/test_helper_functions.cc)0
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/Makefile61
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/hello_world.c182
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/hello_world.html87
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/hello_world.nmf6
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/hello_world_c.c (renamed from native_client_sdk/src/examples/hello_world_c/hello_world_c.c)0
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/hello_world_c.html (renamed from native_client_sdk/src/examples/hello_world_c/hello_world_c.html)0
-rw-r--r--native_client_sdk/src/examples/hello_world_newlib/hello_world_c.nmf (renamed from native_client_sdk/src/examples/hello_world_c/hello_world_c.nmf)0
-rw-r--r--native_client_sdk/src/examples/index_staging.html138
23 files changed, 734 insertions, 811 deletions
diff --git a/native_client_sdk/src/examples/hello_world/Makefile b/native_client_sdk/src/examples/hello_world/Makefile
deleted file mode 100644
index f5d6e46..0000000
--- a/native_client_sdk/src/examples/hello_world/Makefile
+++ /dev/null
@@ -1,183 +0,0 @@
-# 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_c/Makefile b/native_client_sdk/src/examples/hello_world_c/Makefile
deleted file mode 100644
index d66ef26..0000000
--- a/native_client_sdk/src/examples/hello_world_c/Makefile
+++ /dev/null
@@ -1,183 +0,0 @@
-# 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_glibc/Makefile b/native_client_sdk/src/examples/hello_world_glibc/Makefile
index cf14374..a52123d 100644
--- a/native_client_sdk/src/examples/hello_world_glibc/Makefile
+++ b/native_client_sdk/src/examples/hello_world_glibc/Makefile
@@ -7,194 +7,71 @@
#   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
-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,
+# If NACL_SDK_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:= -shared -pthread -std=gnu++98 $(WARNINGS) $(DEFINES) $(INCLUDES)
+NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
-#
-# Compute tool paths
-#
-#
-OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py)
-TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_glibc)
-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
#
-# NMF Manifiest generation
+# Project Build flags
#
-NMF:=python $(PEPPER_ROOT)/tools/create_nmf.py
-NMF+=-D $(TC_PATH)/x86_64-nacl/bin/objdump
-NMF_PATHS:=-L $(TC_PATH)/x86_64-nacl/lib32 -L $(TC_PATH)/x86_64-nacl/lib
+# Turns on warnings (-Wxxx), builds with zero optimization (-O0) and adds debug
+# information (-g) for correctness and ease of debugging.
+WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic
+CFLAGS:=-pthread -O0 -g $(WARNINGS)
-#
-# 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.
+# Compute path to compiler
#
-# $(1) = Source file
-# $(2) = Destination directory
-define FILE_COPY
-$(2)/$(notdir $(1)) : $(1) | $(2)
- $(COPY) $(1) $(2)
-$(2)_COPIES+=$(2)/$(notdir $(1))
-endef
+OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
+TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_glibc)
-# Declare the ALL target first, to make the 'all' target the default build
-all: DEBUG RELEASE
+# Alias for C++ compiler
+CC:=$(TC_PATH)/bin/i686-nacl-gcc
#
-# Debug Build rules.
+# Disable DOS PATH warning when using Cygwin based tools Windows
#
-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) -MMD -MF $@.d
-
-# 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)
+CYGWIN ?= nodosfilewarning
+export CYGWIN
-# Define rule for building NMF file and copying dependencies
-DBG/$(PROJECT).nmf : DBG/$(PROJECT)_x86_64.nexe DBG/$(PROJECT)_x86_32.nexe
- $(NMF) -o $@ -s DBG $(NMF_PATHS) $^
-# Define a DEBUG alias to build the debug version
-DBG_NEXES:= DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe
-.PHONY : DEBUG RUN_DEBUG
-DEBUG : $(DBG_NEXES) DBG/$(PROJECT).nmf $(DBG_COPIES)
+# Default target is everything
+all : hello_world_x86_32.nexe hello_world_x86_64.nexe hello_world.nmf
-# Define a RUN_DEBUG alias to build and server the DEBUG version
-RUN_DEBUG: DEBUG
- cd DBG && python ../../httpd.py
+# Define compile and link rule for 32 bit (-m32) nexe
+hello_world_x86_32.nexe : hello_world.c $(THIS_MAKE)
+ $(CC) -o $@ $< -m32 -O0 -g $(CFLAGS) -lppapi
+# Define compile and link rule for 64 bit (-m64) nexe
+hello_world_x86_64.nexe : hello_world.c $(THIS_MAKE)
+ $(CC) -o $@ $< -m64 -O0 -g $(CFLAGS) -lppapi
#
-# Release build rules.
+# NMF Manifiest generation
#
-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) -MMD -MF $@.d
-
-# 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 rule for building NMF file and copying dependencies
-REL/$(PROJECT).nmf : REL/$(PROJECT)_x86_64.nexe REL/$(PROJECT)_x86_32.nexe
- $(NMF) -o $@ -s REL $(NMF_PATHS) $^
+# Use the python script create_nmf to scan the binaries for dependencies using
+# objdump. Pass in the (-L) paths to the default library toolchains so that we
+# can find those libraries and have it automatically copy the files (-s) to
+# the target directory for us.
+NMF:=python $(NACL_SDK_ROOT)/tools/create_nmf.py
+NMF_ARGS:=-D $(TC_PATH)/x86_64-nacl/bin/objdump
+NMF_PATHS:=-L $(TC_PATH)/x86_64-nacl/lib32 -L $(TC_PATH)/x86_64-nacl/lib
-# Define a RELEASE alias to build the debug version
-.PHONY : RELEASE RUN_RELEASE
-REL_NEXES:=REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe
-RELEASE : $(REL_NEXES) REL/$(PROJECT).nmf $(REL_COPIES)
+hello_world.nmf : hello_world_x86_64.nexe hello_world_x86_32.nexe
+ echo $(NMF) $(NMF_ARGS) -s . -o $@ $(NMF_PATHS) $^
+ $(NMF) $(NMF_ARGS) -s . -o $@ $(NMF_PATHS) $^
-# Define a RUN_RELEASE alias to build and server the RELEASE version
-RUN_RELEASE: RELEASE
- cd REL && python ../../httpd.py
+# Define a phony rule so it always runs, to build nexe and start up server.
+.PHONY: RUN
+RUN: all
+ python ../httpd.py
diff --git a/native_client_sdk/src/examples/hello_world_glibc/hello_world.c b/native_client_sdk/src/examples/hello_world_glibc/hello_world.c
new file mode 100644
index 0000000..ab13e83
--- /dev/null
+++ b/native_client_sdk/src/examples/hello_world_glibc/hello_world.c
@@ -0,0 +1,182 @@
+/* Copyright (c) 2012 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.
+ */
+
+/** @file hello_world.c
+ * This example demonstrates loading, running and scripting a very simple
+ * NaCl module.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppb_messaging.h"
+#include "ppapi/c/ppb_var.h"
+#include "ppapi/c/ppp.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/ppp_messaging.h"
+
+static PPB_Messaging* ppb_messaging_interface = NULL;
+static PPB_Var* ppb_var_interface = NULL;
+
+
+/**
+ * Creates new string PP_Var from C string. The resulting object will be a
+ * refcounted string object. It will be AddRef()ed for the caller. When the
+ * caller is done with it, it should be Release()d.
+ * @param[in] str C string to be converted to PP_Var
+ * @return PP_Var containing string.
+ */
+static struct PP_Var CStrToVar(const char* str) {
+ if (ppb_var_interface != NULL) {
+ return ppb_var_interface->VarFromUtf8(str, strlen(str));
+ }
+ return PP_MakeUndefined();
+}
+
+
+/**
+ * Called when the NaCl module is instantiated on the web page. The identifier
+ * of the new instance will be passed in as the first argument (this value is
+ * generated by the browser and is an opaque handle). This is called for each
+ * instantiation of the NaCl module, which is each time the <embed> tag for
+ * this module is encountered.
+ *
+ * If this function reports a failure (by returning @a PP_FALSE), the NaCl
+ * module will be deleted and DidDestroy will be called.
+ * @param[in] instance The identifier of the new instance representing this
+ * NaCl module.
+ * @param[in] argc The number of arguments contained in @a argn and @a argv.
+ * @param[in] argn An array of argument names. These argument names are
+ * supplied in the <embed> tag, for example:
+ * <embed id="nacl_module" dimensions="2">
+ * will produce two arguments, one named "id" and one named "dimensions".
+ * @param[in] argv An array of argument values. These are the values of the
+ * arguments listed in the <embed> tag. In the above example, there will
+ * be two elements in this array, "nacl_module" and "2". The indices of
+ * these values match the indices of the corresponding names in @a argn.
+ * @return @a PP_TRUE on success.
+ */
+static PP_Bool Instance_DidCreate(PP_Instance instance,
+ uint32_t argc,
+ const char* argn[],
+ const char* argv[]) {
+ ppb_messaging_interface->PostMessage(instance,
+ CStrToVar("Hello a World (GLIBC)"));
+ return PP_TRUE;
+}
+
+
+/**
+ * Called when the NaCl module is destroyed. This will always be called,
+ * even if DidCreate returned failure. This routine should deallocate any data
+ * associated with the instance.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ */
+static void Instance_DidDestroy(PP_Instance instance) {
+}
+
+/**
+ * Called when the position, the size, or the clip rect of the element in the
+ * browser that corresponds to this NaCl module has changed.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ * @param[in] position The location on the page of this NaCl module. This is
+ * relative to the top left corner of the viewport, which changes as the
+ * page is scrolled.
+ * @param[in] clip The visible region of the NaCl module. This is relative to
+ * the top left of the plugin's coordinate system (not the page). If the
+ * plugin is invisible, @a clip will be (0, 0, 0, 0).
+ */
+static void Instance_DidChangeView(PP_Instance instance,
+ PP_Resource view_resource) {
+}
+
+/**
+ * Notification that the given NaCl module has gained or lost focus.
+ * Having focus means that keyboard events will be sent to the NaCl module
+ * represented by @a instance. A NaCl module's default condition is that it
+ * will not have focus.
+ *
+ * Note: clicks on NaCl modules will give focus only if you handle the
+ * click event. You signal if you handled it by returning @a true from
+ * HandleInputEvent. Otherwise the browser will bubble the event and give
+ * focus to the element on the page that actually did end up consuming it.
+ * If you're not getting focus, check to make sure you're returning true from
+ * the mouse click in HandleInputEvent.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ * @param[in] has_focus Indicates whether this NaCl module gained or lost
+ * event focus.
+ */
+static void Instance_DidChangeFocus(PP_Instance instance,
+ PP_Bool has_focus) {
+}
+
+/**
+ * Handler that gets called after a full-frame module is instantiated based on
+ * registered MIME types. This function is not called on NaCl modules. This
+ * function is essentially a place-holder for the required function pointer in
+ * the PPP_Instance structure.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ * @param[in] url_loader A PP_Resource an open PPB_URLLoader instance.
+ * @return PP_FALSE.
+ */
+static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,
+ PP_Resource url_loader) {
+ /* NaCl modules do not need to handle the document load function. */
+ return PP_FALSE;
+}
+
+
+
+/**
+ * Entry points for the module.
+ * Initialize needed interfaces: PPB_Core, PPB_Messaging and PPB_Var.
+ * @param[in] a_module_id module ID
+ * @param[in] get_browser pointer to PPB_GetInterface
+ * @return PP_OK on success, any other value on failure.
+ */
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module a_module_id,
+ PPB_GetInterface get_browser) {
+ ppb_messaging_interface =
+ (PPB_Messaging*)(get_browser(PPB_MESSAGING_INTERFACE));
+ ppb_var_interface = (PPB_Var*)(get_browser(PPB_VAR_INTERFACE));
+ return PP_OK;
+}
+
+
+/**
+ * Returns an interface pointer for the interface of the given name, or NULL
+ * if the interface is not supported.
+ * @param[in] interface_name name of the interface
+ * @return pointer to the interface
+ */
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) {
+ static PPP_Instance instance_interface = {
+ &Instance_DidCreate,
+ &Instance_DidDestroy,
+ &Instance_DidChangeView,
+ &Instance_DidChangeFocus,
+ &Instance_HandleDocumentLoad,
+ };
+ return &instance_interface;
+ }
+ return NULL;
+}
+
+
+/**
+ * Called before the plugin module is unloaded.
+ */
+PP_EXPORT void PPP_ShutdownModule() {
+}
diff --git a/native_client_sdk/src/examples/hello_world_glibc/hello_world.cc b/native_client_sdk/src/examples/hello_world_glibc/hello_world.cc
deleted file mode 100644
index 438b7bf..0000000
--- a/native_client_sdk/src/examples/hello_world_glibc/hello_world.cc
+++ /dev/null
@@ -1,135 +0,0 @@
-// Copyright (c) 2012 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.
-
-/// @file
-/// This example demonstrates loading, running and scripting a very simple NaCl
-/// module. To load the NaCl module, the browser first looks for the
-/// CreateModule() factory method (at the end of this file). It calls
-/// CreateModule() once to load the module code from your .nexe. After the
-/// .nexe code is loaded, CreateModule() is not called again.
-///
-/// Once the .nexe code is loaded, the browser then calls the
-/// HelloWorldModule::CreateInstance()
-/// method on the object returned by CreateModule(). It calls CreateInstance()
-/// each time it encounters an <embed> tag that references your NaCl module.
-
-#include <cstdio>
-#include <cstring>
-#include <string>
-#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";
-
-/// Method name for FortyTwo, as seen by Javascript code. @see FortyTwo()
-const char* const kFortyTwoMethodId = "fortyTwo";
-
-/// Separator character for the reverseText method.
-static const char kMessageArgumentSeparator = ':';
-
-/// This is the module's function that invokes FortyTwo and converts the return
-/// value from an int32_t to a pp::Var for return.
-pp::Var MarshallFortyTwo() {
- return pp::Var(FortyTwo());
-}
-
-/// This function is passed the arg list from the JavaScript call to
-/// @a reverseText.
-/// It makes sure that there is one argument and that it is a string, returning
-/// an error message if it is not.
-/// On good input, it calls ReverseText and returns the result. The result is
-/// then sent back via a call to PostMessage.
-pp::Var MarshallReverseText(const std::string& text) {
- return pp::Var(ReverseText(text));
-}
-
-/// The Instance class. One of these exists for each instance of your NaCl
-/// module on the web page. The browser will ask the Module object to create
-/// a new Instance for each occurrence of the <embed> tag that has these
-/// attributes:
-/// <pre>
-/// type="application/x-nacl"
-/// nacl="hello_world.nmf"
-/// </pre>
-class HelloWorldInstance : public pp::Instance {
- public:
- explicit HelloWorldInstance(PP_Instance instance) : pp::Instance(instance) {
- printf("HelloWorldInstance.\n");
- }
- virtual ~HelloWorldInstance() {}
-
- /// Called by the browser to handle the postMessage() call in Javascript.
- /// Detects which method is being called from the message contents, and
- /// calls the appropriate function. Posts the result back to the browser
- /// asynchronously.
- /// @param[in] var_message The message posted by the browser. The possible
- /// messages are 'fortyTwo' and 'reverseText:Hello World'. Note that
- /// the 'reverseText' form contains the string to reverse following a ':'
- /// separator.
- virtual void HandleMessage(const pp::Var& var_message);
-};
-
-void HelloWorldInstance::HandleMessage(const pp::Var& var_message) {
- if (!var_message.is_string()) {
- return;
- }
- std::string message = var_message.AsString();
- pp::Var return_var;
- if (message == kFortyTwoMethodId) {
- // Note that no arguments are passed in to FortyTwo.
- return_var = MarshallFortyTwo();
- } else if (message.find(kReverseTextMethodId) == 0) {
- // The argument to reverseText is everything after the first ':'.
- size_t sep_pos = message.find_first_of(kMessageArgumentSeparator);
- if (sep_pos != std::string::npos) {
- std::string string_arg = message.substr(sep_pos + 1);
- return_var = MarshallReverseText(string_arg);
- }
- }
- // Post the return result back to the browser. Note that HandleMessage() is
- // always called on the main thread, so it's OK to post the return message
- // directly from here. The return post is asynhronous: PostMessage returns
- // immediately.
- PostMessage(return_var);
-}
-
-/// 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
-/// <code>type="application/x-nacl"</code>.
-class HelloWorldModule : public pp::Module {
- public:
- HelloWorldModule() : pp::Module() {
- printf("Got here.\n");
- }
- virtual ~HelloWorldModule() {}
-
- /// Create and return a HelloWorldInstance object.
- /// @param[in] instance a handle to a plug-in instance.
- /// @return a newly created HelloWorldInstance.
- /// @note The browser is responsible for calling @a delete when done.
- virtual pp::Instance* CreateInstance(PP_Instance instance) {
- return new HelloWorldInstance(instance);
- }
-};
-} // namespace hello_world
-
-
-namespace pp {
-/// Factory function called by the browser when the module is first loaded.
-/// The browser keeps a singleton of this module. It calls the
-/// CreateInstance() method on the object you return to make instances. There
-/// is one instance per <embed> tag on the page. This is the main binding
-/// point for your NaCl module with the browser.
-/// @return new HelloWorldModule.
-/// @note The browser is responsible for deleting returned @a Module.
-Module* CreateModule() {
- return new hello_world::HelloWorldModule();
-}
-} // namespace pp
diff --git a/native_client_sdk/src/examples/hello_world_glibc/hello_world.html b/native_client_sdk/src/examples/hello_world_glibc/hello_world.html
index ec1b4e7..60f3722 100644
--- a/native_client_sdk/src/examples/hello_world_glibc/hello_world.html
+++ b/native_client_sdk/src/examples/hello_world_glibc/hello_world.html
@@ -1,13 +1,12 @@
<!DOCTYPE html>
<html>
<!--
- Copyright (c) 2011 The Chromium Authors. All rights reserved.
+ Copyright (c) 2012 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';
@@ -27,10 +26,6 @@
// 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 {
@@ -42,19 +37,6 @@
}
}
- 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
@@ -73,29 +55,20 @@
<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'
+<h2>Status: <code id="statusField">NO-STATUS</code></h2>
+ <!-- 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.
+ your NaCl module.
+
+ The src points to a manifest file, which provides the Native Client plug-in
+ a mapping between architecture and NaCl Executable (NEXE).
+
+ We use a non-zero sized embed to give Chrome space to place the bad plug-in
+ graphic, if there is a problem.
-->
<div id="listener">
<script type="text/javascript">
@@ -106,21 +79,9 @@
<embed name="nacl_module"
id="hello_world"
- width=0 height=0
+ width=200 height=200
src="hello_world.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/hello_world_glibc/helper_functions.cc b/native_client_sdk/src/examples/hello_world_glibc/helper_functions.cc
deleted file mode 100644
index 2b43c605..0000000
--- a/native_client_sdk/src/examples/hello_world_glibc/helper_functions.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2012 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.
-
-#include <algorithm>
-
-#include "helper_functions.h"
-
-namespace hello_world {
-
-int32_t FortyTwo() {
- return 42;
-}
-
-std::string ReverseText(const std::string& text) {
- std::string reversed_string(text);
- // Use reverse to reverse |reversed_string| in place.
- std::reverse(reversed_string.begin(), reversed_string.end());
- return reversed_string;
-}
-} // namespace hello_world
-
diff --git a/native_client_sdk/src/examples/hello_world_glibc/helper_functions.h b/native_client_sdk/src/examples/hello_world_glibc/helper_functions.h
deleted file mode 100644
index 5076300..0000000
--- a/native_client_sdk/src/examples/hello_world_glibc/helper_functions.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef EXAMPLES_HELLO_WORLD_HELPER_FUNCTIONS_H_
-#define EXAMPLES_HELLO_WORLD_HELPER_FUNCTIONS_H_
-
-/// @file
-/// These functions are stand-ins for your complicated computations which you
-/// want to run in native code. We do two very simple things: return 42, and
-/// reverse a string. But you can imagine putting more complicated things here
-/// which might be difficult or slow to achieve in JavaScript, such as
-/// cryptography, artificial intelligence, signal processing, physics modeling,
-/// etc. See hello_world.cc for the code which is required for loading a NaCl
-/// application and exposing methods to JavaScript.
-
-#include <ppapi/c/pp_stdint.h>
-#include <string>
-
-namespace hello_world {
-
-/// This is the module's function that does the work to compute the value 42.
-int32_t FortyTwo();
-
-/// This function is passed a string and returns a copy of the string with the
-/// characters in reverse order.
-/// @param[in] text The string to reverse.
-/// @return A copy of @a text with the characters in reverse order.
-std::string ReverseText(const std::string& text);
-
-} // namespace hello_world
-
-#endif // EXAMPLES_HELLO_WORLD_HELPER_FUNCTIONS_H_
-
diff --git a/native_client_sdk/src/examples/hello_world_interactive/Makefile b/native_client_sdk/src/examples/hello_world_interactive/Makefile
new file mode 100644
index 0000000..62e9f95
--- /dev/null
+++ b/native_client_sdk/src/examples/hello_world_interactive/Makefile
@@ -0,0 +1,70 @@
+# 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
+#
+
+
+#
+# Get pepper directory for toolchain and includes.
+#
+# If NACL_SDK_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)))
+NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
+
+
+#
+# Project Build flags
+#
+# Turns on warnings (-Wxxx), builds with zero optimization (-O0) and adds debug
+# information (-g) for correctness and ease of debugging.
+WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic
+CXXFLAGS:=-pthread -O0 $(WARNINGS)
+
+
+#
+# Compute path to compiler
+#
+OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
+TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib)
+
+
+# Alias for C compiler
+CXX:=$(TC_PATH)/bin/i686-nacl-g++
+
+
+#
+# Disable DOS PATH warning when using Cygwin based tools Windows
+#
+CYGWIN ?= nodosfilewarning
+export CYGWIN
+
+# Default target is everything
+all : hello_world_x86_32.nexe hello_world_x86_64.nexe
+
+# Define 32 bit compile rule for C++ sources
+hello_world_32.o helper_functions_32.o : %_32.o : %.cc
+ $(CXX) -o $@ -c $< -m32 -O0 -g $(CXXFLAGS)
+
+# Define 64 bit compile rule for C++ sources
+hello_world_64.o helper_functions_64.o : %_64.o : %.cc
+ $(CXX) -o $@ -c $< -m64 -O0 -g $(CXXFLAGS)
+
+# Define link rule for 32 bit (-m32) nexe
+hello_world_x86_32.nexe : hello_world_32.o helper_functions_32.o
+ $(CXX) -o $@ $^ -m32 -O0 -g -lppapi_cpp -lppapi
+
+# Define link rule for 64 bit (-m64) nexe
+hello_world_x86_64.nexe : hello_world_64.o helper_functions_64.o
+ $(CXX) -o $@ $^ -m64 -O0 -g -lppapi_cpp -lppapi
+
+# Define a phony rule so it always runs, to build nexe and start up server.
+.PHONY: RUN
+RUN: all
+ python ../httpd.py
+
diff --git a/native_client_sdk/src/examples/hello_world/hello_world.cc b/native_client_sdk/src/examples/hello_world_interactive/hello_world.cc
index 438b7bf..438b7bf 100644
--- a/native_client_sdk/src/examples/hello_world/hello_world.cc
+++ b/native_client_sdk/src/examples/hello_world_interactive/hello_world.cc
diff --git a/native_client_sdk/src/examples/hello_world/hello_world.html b/native_client_sdk/src/examples/hello_world_interactive/hello_world.html
index ec1b4e7..516a995 100644
--- a/native_client_sdk/src/examples/hello_world/hello_world.html
+++ b/native_client_sdk/src/examples/hello_world_interactive/hello_world.html
@@ -106,7 +106,7 @@
<embed name="nacl_module"
id="hello_world"
- width=0 height=0
+ width=200 height=200
src="hello_world.nmf"
type="application/x-nacl" />
</div>
diff --git a/native_client_sdk/src/examples/hello_world/hello_world.nmf b/native_client_sdk/src/examples/hello_world_interactive/hello_world.nmf
index 78df8e1..78df8e1 100644
--- a/native_client_sdk/src/examples/hello_world/hello_world.nmf
+++ b/native_client_sdk/src/examples/hello_world_interactive/hello_world.nmf
diff --git a/native_client_sdk/src/examples/hello_world/helper_functions.cc b/native_client_sdk/src/examples/hello_world_interactive/helper_functions.cc
index 2b43c605..2b43c605 100644
--- a/native_client_sdk/src/examples/hello_world/helper_functions.cc
+++ b/native_client_sdk/src/examples/hello_world_interactive/helper_functions.cc
diff --git a/native_client_sdk/src/examples/hello_world/helper_functions.h b/native_client_sdk/src/examples/hello_world_interactive/helper_functions.h
index 5076300..5076300 100644
--- a/native_client_sdk/src/examples/hello_world/helper_functions.h
+++ b/native_client_sdk/src/examples/hello_world_interactive/helper_functions.h
diff --git a/native_client_sdk/src/examples/hello_world/test_helper_functions.cc b/native_client_sdk/src/examples/hello_world_interactive/test_helper_functions.cc
index 30d3f27..30d3f27 100644
--- a/native_client_sdk/src/examples/hello_world/test_helper_functions.cc
+++ b/native_client_sdk/src/examples/hello_world_interactive/test_helper_functions.cc
diff --git a/native_client_sdk/src/examples/hello_world_newlib/Makefile b/native_client_sdk/src/examples/hello_world_newlib/Makefile
new file mode 100644
index 0000000..71f29cb
--- /dev/null
+++ b/native_client_sdk/src/examples/hello_world_newlib/Makefile
@@ -0,0 +1,61 @@
+# Copyright (c) 2012 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
+#
+
+
+#
+# Get pepper directory for toolchain and includes.
+#
+# If NACL_SDK_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)))
+NACL_SDK_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..)
+
+
+#
+# Project Build flags
+#
+# Turns on warnings (-Wxxx), builds with zero optimization (-O0) and adds debug
+# information (-g) for correctness and ease of debugging.
+WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -Werror -pedantic
+CFLAGS:=-pthread -O0 -g $(WARNINGS)
+
+
+#
+# Compute path to compiler
+#
+OSNAME:=$(shell python $(NACL_SDK_ROOT)/tools/getos.py)
+TC_PATH:=$(abspath $(NACL_SDK_ROOT)/toolchain/$(OSNAME)_x86_newlib)
+
+
+# Alias for C compiler
+CC:=$(TC_PATH)/bin/i686-nacl-gcc
+
+
+#
+# Disable DOS PATH warning when using Cygwin based tools Windows
+#
+CYGWIN ?= nodosfilewarning
+export CYGWIN
+
+# Default target is everything
+all : hello_world_x86_32.nexe hello_world_x86_64.nexe
+
+# Define compile and link rule for 32 bit (-m32) nexe
+hello_world_x86_32.nexe : hello_world.c $(THIS_MAKE)
+ $(CC) -o $@ $< -m32 -O0 -g $(CFLAGS) -lppapi
+
+# Define compile and link rule for 64 bit (-m64) nexe
+hello_world_x86_64.nexe : hello_world.c $(THIS_MAKE)
+ $(CC) -o $@ $< -m64 -O0 -g $(CFLAGS) -lppapi
+
+# Define a phony rule so it always runs, to build nexe and start up server.
+.PHONY: RUN
+RUN: all
+ python ../httpd.py
diff --git a/native_client_sdk/src/examples/hello_world_newlib/hello_world.c b/native_client_sdk/src/examples/hello_world_newlib/hello_world.c
new file mode 100644
index 0000000..72c7a4a
--- /dev/null
+++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world.c
@@ -0,0 +1,182 @@
+/* Copyright (c) 2012 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.
+ */
+
+/** @file hello_world.c
+ * This example demonstrates loading, running and scripting a very simple
+ * NaCl module.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/pp_module.h"
+#include "ppapi/c/pp_var.h"
+#include "ppapi/c/ppb.h"
+#include "ppapi/c/ppb_instance.h"
+#include "ppapi/c/ppb_messaging.h"
+#include "ppapi/c/ppb_var.h"
+#include "ppapi/c/ppp.h"
+#include "ppapi/c/ppp_instance.h"
+#include "ppapi/c/ppp_messaging.h"
+
+static PPB_Messaging* ppb_messaging_interface = NULL;
+static PPB_Var* ppb_var_interface = NULL;
+
+
+/**
+ * Creates new string PP_Var from C string. The resulting object will be a
+ * refcounted string object. It will be AddRef()ed for the caller. When the
+ * caller is done with it, it should be Release()d.
+ * @param[in] str C string to be converted to PP_Var
+ * @return PP_Var containing string.
+ */
+static struct PP_Var CStrToVar(const char* str) {
+ if (ppb_var_interface != NULL) {
+ return ppb_var_interface->VarFromUtf8(str, strlen(str));
+ }
+ return PP_MakeUndefined();
+}
+
+
+/**
+ * Called when the NaCl module is instantiated on the web page. The identifier
+ * of the new instance will be passed in as the first argument (this value is
+ * generated by the browser and is an opaque handle). This is called for each
+ * instantiation of the NaCl module, which is each time the <embed> tag for
+ * this module is encountered.
+ *
+ * If this function reports a failure (by returning @a PP_FALSE), the NaCl
+ * module will be deleted and DidDestroy will be called.
+ * @param[in] instance The identifier of the new instance representing this
+ * NaCl module.
+ * @param[in] argc The number of arguments contained in @a argn and @a argv.
+ * @param[in] argn An array of argument names. These argument names are
+ * supplied in the <embed> tag, for example:
+ * <embed id="nacl_module" dimensions="2">
+ * will produce two arguments, one named "id" and one named "dimensions".
+ * @param[in] argv An array of argument values. These are the values of the
+ * arguments listed in the <embed> tag. In the above example, there will
+ * be two elements in this array, "nacl_module" and "2". The indices of
+ * these values match the indices of the corresponding names in @a argn.
+ * @return @a PP_TRUE on success.
+ */
+static PP_Bool Instance_DidCreate(PP_Instance instance,
+ uint32_t argc,
+ const char* argn[],
+ const char* argv[]) {
+ ppb_messaging_interface->PostMessage(instance,
+ CStrToVar("Hello a World (NEWLIB)"));
+ return PP_TRUE;
+}
+
+
+/**
+ * Called when the NaCl module is destroyed. This will always be called,
+ * even if DidCreate returned failure. This routine should deallocate any data
+ * associated with the instance.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ */
+static void Instance_DidDestroy(PP_Instance instance) {
+}
+
+/**
+ * Called when the position, the size, or the clip rect of the element in the
+ * browser that corresponds to this NaCl module has changed.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ * @param[in] position The location on the page of this NaCl module. This is
+ * relative to the top left corner of the viewport, which changes as the
+ * page is scrolled.
+ * @param[in] clip The visible region of the NaCl module. This is relative to
+ * the top left of the plugin's coordinate system (not the page). If the
+ * plugin is invisible, @a clip will be (0, 0, 0, 0).
+ */
+static void Instance_DidChangeView(PP_Instance instance,
+ PP_Resource view_resource) {
+}
+
+/**
+ * Notification that the given NaCl module has gained or lost focus.
+ * Having focus means that keyboard events will be sent to the NaCl module
+ * represented by @a instance. A NaCl module's default condition is that it
+ * will not have focus.
+ *
+ * Note: clicks on NaCl modules will give focus only if you handle the
+ * click event. You signal if you handled it by returning @a true from
+ * HandleInputEvent. Otherwise the browser will bubble the event and give
+ * focus to the element on the page that actually did end up consuming it.
+ * If you're not getting focus, check to make sure you're returning true from
+ * the mouse click in HandleInputEvent.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ * @param[in] has_focus Indicates whether this NaCl module gained or lost
+ * event focus.
+ */
+static void Instance_DidChangeFocus(PP_Instance instance,
+ PP_Bool has_focus) {
+}
+
+/**
+ * Handler that gets called after a full-frame module is instantiated based on
+ * registered MIME types. This function is not called on NaCl modules. This
+ * function is essentially a place-holder for the required function pointer in
+ * the PPP_Instance structure.
+ * @param[in] instance The identifier of the instance representing this NaCl
+ * module.
+ * @param[in] url_loader A PP_Resource an open PPB_URLLoader instance.
+ * @return PP_FALSE.
+ */
+static PP_Bool Instance_HandleDocumentLoad(PP_Instance instance,
+ PP_Resource url_loader) {
+ /* NaCl modules do not need to handle the document load function. */
+ return PP_FALSE;
+}
+
+
+
+/**
+ * Entry points for the module.
+ * Initialize needed interfaces: PPB_Core, PPB_Messaging and PPB_Var.
+ * @param[in] a_module_id module ID
+ * @param[in] get_browser pointer to PPB_GetInterface
+ * @return PP_OK on success, any other value on failure.
+ */
+PP_EXPORT int32_t PPP_InitializeModule(PP_Module a_module_id,
+ PPB_GetInterface get_browser) {
+ ppb_messaging_interface =
+ (PPB_Messaging*)(get_browser(PPB_MESSAGING_INTERFACE));
+ ppb_var_interface = (PPB_Var*)(get_browser(PPB_VAR_INTERFACE));
+ return PP_OK;
+}
+
+
+/**
+ * Returns an interface pointer for the interface of the given name, or NULL
+ * if the interface is not supported.
+ * @param[in] interface_name name of the interface
+ * @return pointer to the interface
+ */
+PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
+ if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) {
+ static PPP_Instance instance_interface = {
+ &Instance_DidCreate,
+ &Instance_DidDestroy,
+ &Instance_DidChangeView,
+ &Instance_DidChangeFocus,
+ &Instance_HandleDocumentLoad,
+ };
+ return &instance_interface;
+ }
+ return NULL;
+}
+
+
+/**
+ * Called before the plugin module is unloaded.
+ */
+PP_EXPORT void PPP_ShutdownModule() {
+}
diff --git a/native_client_sdk/src/examples/hello_world_newlib/hello_world.html b/native_client_sdk/src/examples/hello_world_newlib/hello_world.html
new file mode 100644
index 0000000..60f3722
--- /dev/null
+++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+ <!--
+ Copyright (c) 2012 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() {
+ 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();
+ }
+ }
+
+ // 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>
+<h2>Status: <code id="statusField">NO-STATUS</code></h2>
+ <!-- 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.
+
+ The src points to a manifest file, which provides the Native Client plug-in
+ a mapping between architecture and NaCl Executable (NEXE).
+
+ We use a non-zero sized embed to give Chrome space to place the bad plug-in
+ graphic, if there is a problem.
+ -->
+ <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=200 height=200
+ src="hello_world.nmf"
+ type="application/x-nacl" />
+ </div>
+</body>
+</html>
diff --git a/native_client_sdk/src/examples/hello_world_newlib/hello_world.nmf b/native_client_sdk/src/examples/hello_world_newlib/hello_world.nmf
new file mode 100644
index 0000000..78df8e1
--- /dev/null
+++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world.nmf
@@ -0,0 +1,6 @@
+{
+ "program": {
+ "x86-64": {"url": "hello_world_x86_64.nexe"},
+ "x86-32": {"url": "hello_world_x86_32.nexe"}
+ }
+}
diff --git a/native_client_sdk/src/examples/hello_world_c/hello_world_c.c b/native_client_sdk/src/examples/hello_world_newlib/hello_world_c.c
index 5169514..5169514 100644
--- a/native_client_sdk/src/examples/hello_world_c/hello_world_c.c
+++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world_c.c
diff --git a/native_client_sdk/src/examples/hello_world_c/hello_world_c.html b/native_client_sdk/src/examples/hello_world_newlib/hello_world_c.html
index ff43841..ff43841 100644
--- a/native_client_sdk/src/examples/hello_world_c/hello_world_c.html
+++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world_c.html
diff --git a/native_client_sdk/src/examples/hello_world_c/hello_world_c.nmf b/native_client_sdk/src/examples/hello_world_newlib/hello_world_c.nmf
index 377d01e..377d01e 100644
--- a/native_client_sdk/src/examples/hello_world_c/hello_world_c.nmf
+++ b/native_client_sdk/src/examples/hello_world_newlib/hello_world_c.nmf
diff --git a/native_client_sdk/src/examples/index_staging.html b/native_client_sdk/src/examples/index_staging.html
index e7b95c7..a3d2a88 100644
--- a/native_client_sdk/src/examples/index_staging.html
+++ b/native_client_sdk/src/examples/index_staging.html
@@ -16,7 +16,7 @@ dt {
}
dd {
margin-bottom: 12pt;
- width: 600px;
+ width: 800px;
}
</style>
<link href="http://code.google.com/css/codesite.css" rel="stylesheet"
@@ -24,25 +24,71 @@ dd {
<title>Native Client Examples</title>
</head>
<body>
-<h2>Native Client Examples</h2>
-<p>This page lists all of the examples available in the most recent Native Client SDK bundle. Each example is designed to teach a few specific Native Client programming concepts.</p>
+<h1>Native Client Examples</h1>
+<dd><p>This page lists all of the examples available in the most recent Native
+ Client SDK bundle. Each example is designed to teach a few specific Native
+ Client programming concepts. You will need to setup the build environment
+ including a path to 'make' which can be found in the 'tools' directory for
+ Windows, and the variable NACL_SDK_ROOT which points to one of the pepper
+ bundles found under the SDK install location. Calling make from the examples
+ directory will build all the projects, while calling make from and individual
+ example directory will build only that example.
+ </p>
+</dd>
+<h3>Using the Tools</h3>
+<dd><p>The following "hello_world" examples, show the basic outline of a Native
+Client application. The make files in each of the examples bellow show a
+simple way to build a NaCl application using
+<a href="http://www.gnu.org/software/make/manual/make.html">GNU Make</a>.
+See the link for further information.
+</p></dd>
<dl>
- <dt><a href="hello_world_c/hello_world_c.html">Hello World in C</a></dt>
- <dd>The Hello World In C example demonstrates the basic structure of all Native Client applications. This example loads a Native Client module and responds to button click events by showing alert panels.
-
- <p>Teaching focus: Basic HTML, JavaScript, and module architecture; Messaging API.</p>
+ <dt><a href="hello_world_newlib/hello_world.html">
+ Hello World (NEWLIB)</a></dt>
+ <dd>The Hello World In C example demonstrates the basic structure of all
+ Native Client applications. This example loads a Native Client module. The
+ page tracks the status of the module as it load. On a successful load, the
+ module will post a message containing the string "Hello World" back to
+ JavaScript which will display it as an alert.
+ <p>Teaching focus: Basic HTML, JavaScript, and module architecture.</p>
+ </dd>
+ <dt><a href="hello_world_glibc/hello_world.html">
+ Hello World (GLIBC)</a></dt>
+ <dd>The Hello World (GLIBC) example is identical to the one above, with the
+ exception that it used the GLIBC toolchain which uses Shared Objects. The use
+ of Shared Objects means a more complicated manifest file (NMF) which is needed
+ to allow the application to find the libraries. The NMF is automatically
+ generated as part of the build process, by scanning the application for
+ dependencies.
+ <p>Teaching focus: Basic HTML, JavaScript, Shared Objects, and module
+ architecture.</p>
+ </dd>
+ <dt><a href="hello_world_interactive/hello_world.html">
+ Interactive Hello World in C++</a></dt>
+ <dd>The Interactive Hello World C++ example demonstrates the basic structure
+ of all Native Client applications. This example loads a Native Client module
+ which uses two way interaction with JavaScript whenever a button is clicked.
+ The NaCl module will respond with the number 42 or the reversed version of the
+ string in the text box when the appropriate button is clicked.
+ <p>Teaching focus: Basic HTML, JavaScript, C++ PPAPI, and module
+ architecture; Messaging API.</p>
</dd>
- <dt><a href="hello_world/hello_world.html">Hello World in C++</a></dt>
- <dd>The Hello World C++ example demonstrates the basic structure of all Native Client applications. This example loads a Native Client module and responds to button click events by showing alert panels.
- <p>Teaching focus: Basic HTML, JavaScript, and module architecture; Messaging API.</p>
+<h3>Common APIs</h3>
+<dd><p>The following set of examples illustrate various Pepper APIs including
+audio, 2D, 3D, input and urls.</p></dd>
+<dt><a href="sine_synth/sine_synth.html">Sine Wave Synthesizer</a></dt>
+ <dd> The Sine Wave Synthesizer example demonstrates playing sound (a sine
+ wave). Enter the desired frequency and hit play to start, stop to end. The
+ frequency box will display "Loading, please wait." while the module loads.
+ <p>Teaching focus: Audio.</p>
</dd>
-<dt><a href="load_progress/load_progress.html">Load Progress</a></dt>
- <dd> The Load Progress example demonstrates how to listen for and handle events that occur while a
- NaCl module loads. This example listens for different load event types and dispatches different events to their respective handler. This example also checks for valid browser
- version and shows how to calculate and display loading progress.
+<dt><a href="input_events/input_events.html">Input Events</a></dt>
+ <dd> The Input Events example demonstrates how to handle events triggered by the user. This example allows a user
+ to interact with a square representing a module instance. Events are displayed on the screen as the user clicks, scrolls, types, inside or outside
+ of the square.
- <p>Teaching focus: Progress event handling.</p>
+ <p>Teaching focus: Keyboard and mouse input, view change, and focus events.</p>
</dd>
<dt><a href="pi_generator/pi_generator.html">Pi Generator</a></dt>
<dd> The Pi Generator example demonstrates creating a helper thread that estimate pi using the Monte Carlo
@@ -51,17 +97,39 @@ dd {
<p>Teaching focus: Thread creation, 2D graphics, view change events.</p>
</dd>
-<dt><a href="input_events/input_events.html">Input Events</a></dt>
- <dd> The Input Events example demonstrates how to handle events triggered by the user. This example allows a user
- to interact with a square representing a module instance. Events are displayed on the screen as the user clicks, scrolls, types, inside or outside
- of the square.
+ <dt><a href="tumbler/tumbler.html">Tumbler</a></dt>
+ <dd> The Tumbler example demonstrates how to create a 3D cube that you can rotate with your mouse while pressing the
+ left mouse button. This example creates a 3D context and draws to it using
+ OpenGL ES. The JavaScript implements a virtual trackball interface to
+ map mouse movements into 3D rotations using simple 3D vector math and
+ quaternions.
- <p>Teaching focus: Keyboard and mouse input, view change, and focus events.</p>
+ <p>Teaching focus: 3D graphics</p>
</dd>
-<dt><a href="sine_synth/sine_synth.html">Sine Wave Synthesizer</a></dt>
- <dd> The Sine Wave Synthesizer example demonstrates playing sound (a sine wave).
+ <dt><a href="geturl/geturl.html">Get URL</a></dt>
+ <dd> The Get URL example demonstrates fetching an URL and then displaying its contents.
+
+ <p>Teaching focus: URL loading.</p>
+ </dd>
+
+<h3>Common Concepts</h3>
+<dd><p>The following set of examples illustrate various common concepts such as
+showing load progress, using Shared Objects (dynamic libraries),
+mulithreading...</p></dd>
+<dt><a href="dlopen/dlopen.html">Shared Object Loading (GLIBC)</a></dt>
+ <dd> The Load Progress example demonstrates how to listen for and handle
+ events that occur while a NaCl module loads. This example listens for
+ different load event types and dispatches different events to their
+ respective handler. This example also checks for valid browser version and
+ shows how to calculate and display loading progress.
+ <p>Teaching focus: Using shared objects.</p>
+ </dd>
+<dt><a href="load_progress/load_progress.html">Load Progress</a></dt>
+ <dd> The Load Progress example demonstrates how to listen for and handle events that occur while a
+ NaCl module loads. This example listens for different load event types and dispatches different events to their respective handler. This example also checks for valid browser
+ version and shows how to calculate and display loading progress.
- <p>Teaching focus: Audio.</p>
+ <p>Teaching focus: Progress event handling.</p>
</dd>
<dt><a href="pong/pong.html">Pong</a></dt>
<dd> The Pong example demonstrates how to create a basic 2D video game and how to store application
@@ -70,11 +138,6 @@ dd {
<p>Teaching focus: File I/O, 2D graphics, input events.</p>
</dd>
- <dt><a href="geturl/geturl.html">Get URL</a></dt>
- <dd> The Get URL example demonstrates fetching an URL and then displaying its contents.
-
- <p>Teaching focus: URL loading.</p>
- </dd>
<dt><a href="multithreaded_input_events/mt_input_events.html">Multi-threaded Input Events</a></dt>
<dd>The Multithreaded Input Events example combines HTML, Javascript,
and C++ (the C++ is compiled to create a .nexe file).
@@ -83,22 +146,13 @@ dd {
a queue. The worker thread pulls them off of the queue, converts them to a
string, and then uses CallOnMainThread so that PostMessage can be send the
result of the worker thread to the browser.
- </dd>
- <dt><a href="tumbler/tumbler.html">Tumbler</a></dt>
- <dd> The Tumbler example demonstrates how to create a 3D cube that you can rotate with your mouse while pressing the
- left mouse button. This example creates a 3D context and draws to it using
- OpenGL ES. The JavaScript implements a virtual trackball interface to
- map mouse movements into 3D rotations using simple 3D vector math and
- quaternions.
-
- <p>Teaching focus: 3D graphics</p>
+ <p>Teaching focus: Multithreaded event handling.</p>
</dd>
<dt><a href="fullscreen_tumbler/fullscreen_tumbler.html">Full-screen Tumbler</a></dt>
- <dd> This is a modified version of the Tumbler example above that supports
- full-screen display. It is in every way identical to Tumbler in
- functionality, except that it adds the ability to switch to/from
- full-screen display by pressing the Enter key.
-
+ <dd>This is a modified version of the Tumbler example above that supports
+ full-screen display. It is in every way identical to Tumbler in
+ functionality, except that it adds the ability to switch to/from
+ full-screen display by pressing the Enter key.
<p>Teaching focus: Full-screen</p>
</dd>
<dt><a href="mouselock/mouselock.html">Mouse Locker</a></dt>