From 07ec0acf438dd4b53dbb27fbc4a55db25d8459c2 Mon Sep 17 00:00:00 2001 From: "binji@chromium.org" Date: Fri, 6 Sep 2013 18:36:28 +0000 Subject: [NaCl SDK] Create a resources/ directory and move files to it. * Move files out of the roout of examples/ to resources/ * Move files from examples/resources to resources/ * Move Makefile templates to resources/ and rename them. BUG=none R=sbc@chromium.org Review URL: https://codereview.chromium.org/23919004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221741 0039d316-1c4b-4281-b951-d872f2087c98 --- native_client_sdk/src/build_tools/build_app.py | 6 +- native_client_sdk/src/build_tools/build_paths.py | 1 + .../src/build_tools/build_projects.py | 18 +- native_client_sdk/src/build_tools/generate_make.py | 13 +- native_client_sdk/src/build_tools/library.mk | 65 --- native_client_sdk/src/build_tools/template.mk | 89 ----- native_client_sdk/src/examples/Makefile | 68 ---- native_client_sdk/src/examples/Makefile_gyp | 52 --- native_client_sdk/src/examples/common.js | 439 --------------------- native_client_sdk/src/examples/favicon.ico | Bin 1150 -> 0 bytes native_client_sdk/src/examples/httpd.cmd | 8 - .../src/examples/resources/background.js | 13 - .../src/examples/resources/button_close.png | Bin 326 -> 0 bytes .../src/examples/resources/button_close_hover.png | Bin 405 -> 0 bytes .../src/examples/resources/icon128.png | Bin 10729 -> 0 bytes native_client_sdk/src/examples/resources/index.css | 88 ----- .../src/examples/resources/index.html.template | 45 --- native_client_sdk/src/examples/resources/index.js | 72 ---- .../src/examples/resources/manifest.json.template | 23 -- .../src/examples/resources/promo440.png | Bin 86991 -> 0 bytes .../examples/resources/screenshot_gles_1280.png | Bin 60899 -> 0 bytes .../src/examples/resources/screenshot_pi_1280.png | Bin 100971 -> 0 bytes .../src/examples/tutorial/debugging/example.dsc | 4 - native_client_sdk/src/libraries/gmock/library.dsc | 1 - .../src/libraries/ppapi_cpp/library.dsc | 1 - .../src/libraries/sdk_util/library.dsc | 3 - native_client_sdk/src/libraries/xray/library.dsc | 3 - .../src/resources/Makefile.example.template | 89 +++++ .../src/resources/Makefile.index.template | 68 ++++ .../src/resources/Makefile.library.template | 65 +++ native_client_sdk/src/resources/Makefile_gyp | 52 +++ native_client_sdk/src/resources/background.js | 13 + native_client_sdk/src/resources/button_close.png | Bin 0 -> 326 bytes .../src/resources/button_close_hover.png | Bin 0 -> 405 bytes native_client_sdk/src/resources/common.js | 439 +++++++++++++++++++++ native_client_sdk/src/resources/favicon.ico | Bin 0 -> 1150 bytes native_client_sdk/src/resources/httpd.cmd | 8 + native_client_sdk/src/resources/icon128.png | Bin 0 -> 10729 bytes native_client_sdk/src/resources/index.css | 88 +++++ .../src/resources/index.html.template | 45 +++ native_client_sdk/src/resources/index.js | 72 ++++ .../src/resources/manifest.json.template | 23 ++ native_client_sdk/src/resources/promo440.png | Bin 0 -> 86991 bytes .../src/resources/screenshot_gles_1280.png | Bin 0 -> 60899 bytes .../src/resources/screenshot_pi_1280.png | Bin 0 -> 100971 bytes .../src/tests/nacl_io_socket_test/example.dsc | 3 - .../src/tests/nacl_io_test/example.dsc | 2 - .../src/tests/sdk_util_test/example.dsc | 2 - 48 files changed, 978 insertions(+), 1003 deletions(-) delete mode 100644 native_client_sdk/src/build_tools/library.mk delete mode 100644 native_client_sdk/src/build_tools/template.mk delete mode 100644 native_client_sdk/src/examples/Makefile delete mode 100644 native_client_sdk/src/examples/Makefile_gyp delete mode 100644 native_client_sdk/src/examples/common.js delete mode 100644 native_client_sdk/src/examples/favicon.ico delete mode 100644 native_client_sdk/src/examples/httpd.cmd delete mode 100644 native_client_sdk/src/examples/resources/background.js delete mode 100644 native_client_sdk/src/examples/resources/button_close.png delete mode 100644 native_client_sdk/src/examples/resources/button_close_hover.png delete mode 100644 native_client_sdk/src/examples/resources/icon128.png delete mode 100644 native_client_sdk/src/examples/resources/index.css delete mode 100644 native_client_sdk/src/examples/resources/index.html.template delete mode 100644 native_client_sdk/src/examples/resources/index.js delete mode 100644 native_client_sdk/src/examples/resources/manifest.json.template delete mode 100644 native_client_sdk/src/examples/resources/promo440.png delete mode 100644 native_client_sdk/src/examples/resources/screenshot_gles_1280.png delete mode 100644 native_client_sdk/src/examples/resources/screenshot_pi_1280.png create mode 100644 native_client_sdk/src/resources/Makefile.example.template create mode 100644 native_client_sdk/src/resources/Makefile.index.template create mode 100644 native_client_sdk/src/resources/Makefile.library.template create mode 100644 native_client_sdk/src/resources/Makefile_gyp create mode 100644 native_client_sdk/src/resources/background.js create mode 100644 native_client_sdk/src/resources/button_close.png create mode 100644 native_client_sdk/src/resources/button_close_hover.png create mode 100644 native_client_sdk/src/resources/common.js create mode 100644 native_client_sdk/src/resources/favicon.ico create mode 100644 native_client_sdk/src/resources/httpd.cmd create mode 100644 native_client_sdk/src/resources/icon128.png create mode 100644 native_client_sdk/src/resources/index.css create mode 100644 native_client_sdk/src/resources/index.html.template create mode 100644 native_client_sdk/src/resources/index.js create mode 100644 native_client_sdk/src/resources/manifest.json.template create mode 100644 native_client_sdk/src/resources/promo440.png create mode 100644 native_client_sdk/src/resources/screenshot_gles_1280.png create mode 100644 native_client_sdk/src/resources/screenshot_pi_1280.png diff --git a/native_client_sdk/src/build_tools/build_app.py b/native_client_sdk/src/build_tools/build_app.py index 5ed0fb6..cf16f881 100755 --- a/native_client_sdk/src/build_tools/build_app.py +++ b/native_client_sdk/src/build_tools/build_app.py @@ -19,7 +19,7 @@ import build_version import easy_template import parse_dsc -from build_paths import SDK_SRC_DIR, OUT_DIR, SDK_EXAMPLE_DIR +from build_paths import SDK_SRC_DIR, OUT_DIR, SDK_RESOURCE_DIR sys.path.append(os.path.join(SDK_SRC_DIR, 'tools')) import getos @@ -81,7 +81,7 @@ def main(args): pepperdir = os.path.join(OUT_DIR, 'pepper_' + pepper_ver) app_dir = os.path.join(OUT_DIR, 'naclsdk_app') app_examples_dir = os.path.join(app_dir, 'examples') - sdk_resources_dir = os.path.join(SDK_EXAMPLE_DIR, 'resources') + sdk_resources_dir = SDK_RESOURCE_DIR platform = getos.GetPlatform() buildbot_common.RemoveDir(app_dir) @@ -138,7 +138,7 @@ def main(args): os.environ['NACL_SDK_ROOT'] = pepperdir - build_projects.BuildProjects(app_dir, tree, deps=True, clean=False, + build_projects.BuildProjects(app_dir, tree, deps=False, clean=False, config=config) RemoveBuildCruft(app_dir) diff --git a/native_client_sdk/src/build_tools/build_paths.py b/native_client_sdk/src/build_tools/build_paths.py index a01671b..941f91b 100644 --- a/native_client_sdk/src/build_tools/build_paths.py +++ b/native_client_sdk/src/build_tools/build_paths.py @@ -9,6 +9,7 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) SDK_SRC_DIR = os.path.dirname(SCRIPT_DIR) SDK_EXAMPLE_DIR = os.path.join(SDK_SRC_DIR, 'examples') SDK_LIBRARY_DIR = os.path.join(SDK_SRC_DIR, 'libraries') +SDK_RESOURCE_DIR = os.path.join(SDK_SRC_DIR, 'resources') SDK_DIR = os.path.dirname(SDK_SRC_DIR) SRC_DIR = os.path.dirname(SDK_DIR) NACL_DIR = os.path.join(SRC_DIR, 'native_client') diff --git a/native_client_sdk/src/build_tools/build_projects.py b/native_client_sdk/src/build_tools/build_projects.py index 953b56f..4758460 100755 --- a/native_client_sdk/src/build_tools/build_projects.py +++ b/native_client_sdk/src/build_tools/build_projects.py @@ -13,7 +13,7 @@ import build_version import generate_make import parse_dsc -from build_paths import NACL_DIR, SDK_SRC_DIR, OUT_DIR, SDK_EXAMPLE_DIR +from build_paths import NACL_DIR, SDK_SRC_DIR, OUT_DIR, SDK_RESOURCE_DIR from build_paths import GSTORE from generate_index import LandingPage @@ -54,14 +54,10 @@ def UpdateHelpers(pepperdir, clobber=False): buildbot_common.RemoveDir(exampledir) buildbot_common.MakeDir(exampledir) - # Copy files for individual bild and landing page - files = ['favicon.ico', 'httpd.cmd'] - CopyFilesFromTo(files, SDK_EXAMPLE_DIR, exampledir) - - resourcesdir = os.path.join(SDK_EXAMPLE_DIR, 'resources') - files = ['index.css', 'index.js', 'button_close.png', - 'button_close_hover.png'] - CopyFilesFromTo(files, resourcesdir, exampledir) + # Copy files for individual build and landing page + files = ['favicon.ico', 'httpd.cmd', 'index.css', 'index.js', + 'button_close.png', 'button_close_hover.png'] + CopyFilesFromTo(files, SDK_RESOURCE_DIR, exampledir) # Copy tools scripts and make includes buildbot_common.CopyDir(os.path.join(SDK_SRC_DIR, 'tools', '*.py'), @@ -133,9 +129,7 @@ def UpdateProjects(pepperdir, project_tree, toolchains, if landing_page: # Generate the landing page text file. index_html = os.path.join(pepperdir, 'examples', 'index.html') - example_resources_dir = os.path.join(SDK_EXAMPLE_DIR, 'resources') - index_template = os.path.join(example_resources_dir, - 'index.html.template') + index_template = os.path.join(SDK_RESOURCE_DIR, 'index.html.template') with open(index_html, 'w') as fh: out = landing_page.GeneratePage(index_template) fh.write(out) diff --git a/native_client_sdk/src/build_tools/generate_make.py b/native_client_sdk/src/build_tools/generate_make.py index db12444..17fbcc9 100644 --- a/native_client_sdk/src/build_tools/generate_make.py +++ b/native_client_sdk/src/build_tools/generate_make.py @@ -11,7 +11,7 @@ import build_version import getos from buildbot_common import ErrorExit from easy_template import RunTemplateFileIfChanged -from build_paths import SCRIPT_DIR, SDK_EXAMPLE_DIR +from build_paths import SDK_RESOURCE_DIR def Trace(msg): if Trace.verbose: @@ -137,7 +137,7 @@ def ProcessHTML(srcroot, dstroot, desc, toolchains, configs, first_toolchain): def GenerateManifest(srcroot, dstroot, desc): outdir = os.path.join(dstroot, desc['DEST'], desc['NAME']) - srcpath = os.path.join(SDK_EXAMPLE_DIR, 'resources', 'manifest.json.template') + srcpath = os.path.join(SDK_RESOURCE_DIR, 'manifest.json.template') dstpath = os.path.join(outdir, 'manifest.json') permissions = desc.get('PERMISSIONS', []) socket_permissions = desc.get('SOCKET_PERMISSIONS', []) @@ -182,8 +182,7 @@ def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None, name = desc['NAME'] out_dir = os.path.join(dstroot, desc['DEST'], name) buildbot_common.MakeDir(out_dir) - srcdirs = desc.get('SEARCH', ['.', '..', '../..']) - srcdirs.append(os.path.join(SDK_EXAMPLE_DIR, 'resources')) + srcdirs = desc.get('SEARCH', ['.', SDK_RESOURCE_DIR]) # Copy sources to example directory sources = GenerateSourceCopyList(desc) @@ -198,9 +197,9 @@ def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None, make_path = os.path.join(out_dir, 'Makefile') if IsNexe(desc): - template = os.path.join(SCRIPT_DIR, 'template.mk') + template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.example.template') else: - template = os.path.join(SCRIPT_DIR, 'library.mk') + template = os.path.join(SDK_RESOURCE_DIR, 'Makefile.library.template') # Ensure the order of |tools| is the same as toolchains; that way if # first_toolchain is set, it will choose based on the order of |toolchains|. @@ -240,7 +239,7 @@ def GenerateMasterMakefile(pepperdir, out_path, targets): out_path: Root for output such that out_path+NAME = full path targets: List of targets names """ - in_path = os.path.join(SDK_EXAMPLE_DIR, 'Makefile') + in_path = os.path.join(SDK_RESOURCE_DIR, 'Makefile.index.template') out_path = os.path.join(out_path, 'Makefile') rel_path = os.path.relpath(pepperdir, os.path.dirname(out_path)) template_dict = { diff --git a/native_client_sdk/src/build_tools/library.mk b/native_client_sdk/src/build_tools/library.mk deleted file mode 100644 index ff991aa..0000000 --- a/native_client_sdk/src/build_tools/library.mk +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (c) 2013 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. -[[def ExpandDict(key, value_in, pre_list=[], post_list=[]):]] -[[ value = value_in or [] ]] -[[ pre = pre_list or [] ]] -[[ post = post_list or [] ]] -[[ if type(value) is not dict:]] -[[ out = pre]] -[[ out.extend(value)]] -[[ out.extend(post)]] -[[ if out:]] -{{key}} = {{' '.join(out)}} -[[ ]] -[[ return]] -[[ ]] -[[ for subkey in value:]] -[[ out = pre]] -[[ out.extend(value[subkey])]] -[[ out.extend(post)]] -{{key}}_{{subkey}} = {{' '.join(out)}} -[[ ]] -{{key}} = $({{key}}_$(TOOLCHAIN)) -[[]] - -[[target = targets[0] ]] -# GNU Makefile based on shared rules provided by the Native Client SDK. -# See README.Makefiles for more details. - -VALID_TOOLCHAINS := {{' '.join(tools)}} -NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) -[[if 'INCLUDES' in target:]] -EXTRA_INC_PATHS={{' '.join(target['INCLUDES'])}} -[[]] - -include $(NACL_SDK_ROOT)/tools/common.mk - -TARGET = {{target['NAME']}} -[[flags = target.get('CFLAGS', [])]] -[[flags.extend(target.get('CXXFLAGS', []))]] -[[ExpandDict('CFLAGS', flags)]] -[[if 'CFLAGS_GCC' in target:]] -ifneq ($(TOOLCHAIN),pnacl) -CFLAGS += {{' '.join(target['CFLAGS_GCC'])}} -endif -[[]] - -SOURCES = \ -[[for source in sorted(target['SOURCES']):]] - {{source}} \ -[[]] - -all: install - -# Build rules generated by macros from common.mk: -# -$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) -$(eval $(call LIB_RULE,$(TARGET),$(SOURCES))) - -[[if target['TYPE'] != 'static-lib':]] -ifeq ($(TOOLCHAIN),glibc) -$(eval $(call SO_RULE,$(TARGET),$(SOURCES))) -endif -[[]] -{{post}} diff --git a/native_client_sdk/src/build_tools/template.mk b/native_client_sdk/src/build_tools/template.mk deleted file mode 100644 index 8c63756..0000000 --- a/native_client_sdk/src/build_tools/template.mk +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright (c) 2013 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. - -# GNU Makefile based on shared rules provided by the Native Client SDK. -# See README.Makefiles for more details. -[[]] -[[def ExpandDict(key, value_in, pre_list=[], post_list=[]):]] -[[ value = value_in or [] ]] -[[ pre = pre_list or [] ]] -[[ post = post_list or [] ]] -[[ if type(value) is not dict:]] -[[ out = pre]] -[[ out.extend(value)]] -[[ out.extend(post)]] -[[ if out:]] -{{key}} = {{' '.join(out)}} -[[ ]] -[[ return]] -[[ ]] -[[ for subkey in value:]] -[[ out = pre]] -[[ out.extend(value[subkey])]] -[[ out.extend(post)]] -{{key}}_{{subkey}} = {{' '.join(out)}} -[[ ]] -{{key}} = $({{key}}_$(TOOLCHAIN)) -[[]] - -VALID_TOOLCHAINS := {{' '.join(tools)}} -{{pre}} -NACL_SDK_ROOT ?= $(abspath $(CURDIR)/{{rel_sdk}}) -include $(NACL_SDK_ROOT)/tools/common.mk - -TARGET = {{targets[0]['NAME']}} -[[ExpandDict('DEPS', targets[0].get('DEPS', []))]] -[[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]] - -[[for target in targets:]] -[[ source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))]] -[[ source_list = ' \\\n '.join(source_list)]] -[[ sources = target['NAME'] + '_SOURCES']] -[[ cflags = target['NAME'] + '_CFLAGS']] -[[ flags = target.get('CFLAGS', [])]] -[[ flags.extend(target.get('CXXFLAGS', []))]] -[[ if len(targets) == 1:]] -[[ sources = 'SOURCES']] -[[ cflags = 'CFLAGS']] -[[ ]] -[[ ExpandDict(cflags, flags)]] -[[ if 'CFLAGS_GCC' in target:]] -ifneq ($(TOOLCHAIN),pnacl) -{{cflags}} += {{' '.join(target['CFLAGS_GCC'])}} -endif -[[ ]] -{{sources}} = {{source_list}} - -# Build rules generated by macros from common.mk: - -[[if targets[0].get('DEPS'):]] -$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) -[[if len(targets) > 1:]] -[[ for target in targets:]] -[[ name = target['NAME'] ]] -$(foreach src,$({{name}}_SOURCES),$(eval $(call COMPILE_RULE,$(src),$({{name}}_CFLAGS)))) -[[else:]] -$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) -[[]] - -[[for target in targets:]] -[[ sources = target['NAME'] + '_SOURCES']] -[[ name = target['NAME'] ]] -[[ if len(targets) == 1:]] -[[ sources = 'SOURCES']] -[[ name = '$(TARGET)']] -[[ if target['TYPE'] == 'so':]] -$(eval $(call SO_RULE,{{name}},$({{sources}}))) -[[ elif target['TYPE'] == 'so-standalone':]] -$(eval $(call SO_RULE,{{name}},$({{sources}}),,,1)) -[[ else:]] -ifeq ($(CONFIG),Release) -$(eval $(call LINK_RULE,{{name}}_unstripped,$({{sources}}),$(LIBS),$(DEPS))) -$(eval $(call STRIP_RULE,{{name}},{{name}}_unstripped)) -else -$(eval $(call LINK_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS))) -endif -[[]] - -$(eval $(call NMF_RULE,$(TARGET),)){{post}} diff --git a/native_client_sdk/src/examples/Makefile b/native_client_sdk/src/examples/Makefile deleted file mode 100644 index 84110b5..0000000 --- a/native_client_sdk/src/examples/Makefile +++ /dev/null @@ -1,68 +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. - -# -# GNU Make based build file.  For details on GNU Make see: -#   http://www.gnu.org/software/make/manual/make.html -# - -PROJECTS:= \ -[[for project in projects:]] - {{project}} \ -[[]] - -HTTPD:={{rel_sdk}}/tools/httpd.py - -ifeq ($(TOOLCHAIN),all) -TOOLCHAIN_ARG:=TOOLCHAIN=all -endif - -# Define the default target -all: - -# -# Target Macro -# -# Macro defines a phony target for each example, and adds it to a list of -# targets. -# -# Note: We use targets for each project (instead of an explicit recipe) so -# each project can be built in parallel. -# -define TARGET -ALL_TARGET_LIST+=$(1)_ALL_TARGET -.PHONY: $(1)_ALL_TARGET -$(1)_ALL_TARGET: - +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) all - -CLEAN_TARGET_LIST+=$(1)_CLEAN_TARGET -.PHONY: $(1)_CLEAN_TARGET -$(1)_CLEAN_TARGET: - +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) clean -endef - - -# Define the various targets via the Macro -$(foreach proj,$(PROJECTS),$(eval $(call TARGET,$(proj)))) - -.PHONY: all -all: $(ALL_TARGET_LIST) - @echo Done building targets. - -.PHONY: clean -clean: $(CLEAN_TARGET_LIST) - @echo Done cleaning targets. - -.PHONY: run -run: all - @echo Starting up python webserver. - python $(HTTPD) - -# Phony aliases for backward compatibility -RUN: run - -all_versions: - +$(MAKE) TOOLCHAIN=all - -.PHONY: RUN all_versions diff --git a/native_client_sdk/src/examples/Makefile_gyp b/native_client_sdk/src/examples/Makefile_gyp deleted file mode 100644 index 84b0cf4..0000000 --- a/native_client_sdk/src/examples/Makefile_gyp +++ /dev/null @@ -1,52 +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. - -# -# GNU Make based build file.  For details on GNU Make see: -#   http://www.gnu.org/software/make/manual/make.html -# - -__PROJECT_LIST__ - -# Define the default target -all: - -CONFIG=debug - -# -# Target Macro -# -# Macro defines a phony target for each example, and adds it to a list of -# targets. -# -define TARGET -TARGET_LIST+=$(1)_TARGET -.PHONY: $(1)_TARGET -$(1)_TARGET: - +$(MAKE) BUILDTYPE=glibc-$(CONFIG) -C $(1) - +$(MAKE) BUILDTYPE=newlib-$(CONFIG) -C $(1) - +$(MAKE) BUILDTYPE=host-$(CONFIG) -C $(1) - -CLEAN_LIST+=$(1)_CLEAN -.PHONY: $(1)_CLEAN -$(1)_CLEAN: - +$(MAKE) -C $(1) clean -endef - - -# Define the various targets via the Macro -$(foreach proj,$(PROJECTS),$(eval $(call TARGET,$(proj)))) - -__DEPENDENCIES__ - -all: $(TARGET_LIST) - echo "Done building targets." - -clean: $(CLEAN_LIST) - echo "Done cleaning targets." - -RUN: all - echo "Staring up python webserver." - python httpd.py - diff --git a/native_client_sdk/src/examples/common.js b/native_client_sdk/src/examples/common.js deleted file mode 100644 index dc5328f..0000000 --- a/native_client_sdk/src/examples/common.js +++ /dev/null @@ -1,439 +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. - -// Set to true when the Document is loaded IFF "test=true" is in the query -// string. -var isTest = false; - -// Set to true when loading a "Release" NaCl module, false when loading a -// "Debug" NaCl module. -var isRelease = false; - -// Javascript module pattern: -// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces -// In essence, we define an anonymous function which is immediately called and -// returns a new object. The new object contains only the exported definitions; -// all other definitions in the anonymous function are inaccessible to external -// code. -var common = (function() { - - function isHostToolchain(tool) { - return tool == 'win' || tool == 'linux' || tool == 'mac'; - } - - /** - * Return the mime type for NaCl plugin. - * - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @return {string} The mime-type for the kind of NaCl plugin matching - * the given toolchain. - */ - function mimeTypeForTool(tool) { - // For NaCl modules use application/x-nacl. - var mimetype = 'application/x-nacl'; - if (isHostToolchain(tool)) { - // For non-NaCl PPAPI plugins use the x-ppapi-debug/release - // mime type. - if (isRelease) - mimetype = 'application/x-ppapi-release'; - else - mimetype = 'application/x-ppapi-debug'; - } else if (tool == 'pnacl' && isRelease) { - mimetype = 'application/x-pnacl'; - } - return mimetype; - } - - /** - * Check if the browser supports NaCl plugins. - * - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @return {bool} True if the browser supports the type of NaCl plugin - * produced by the given toolchain. - */ - function browserSupportsNaCl(tool) { - // Assume host toolchains always work with the given browser. - // The below mime-type checking might not work with - // --register-pepper-plugins. - if (isHostToolchain(tool)) { - return true; - } - var mimetype = mimeTypeForTool(tool); - return navigator.mimeTypes[mimetype] !== undefined; - } - - /** - * Inject a script into the DOM, and call a callback when it is loaded. - * - * @param {string} url The url of the script to load. - * @param {Function} onload The callback to call when the script is loaded. - * @param {Function} onerror The callback to call if the script fails to load. - */ - function injectScript(url, onload, onerror) { - var scriptEl = document.createElement('script'); - scriptEl.type = 'text/javascript'; - scriptEl.src = url; - scriptEl.onload = onload; - if (onerror) { - scriptEl.addEventListener('error', onerror, false); - } - document.head.appendChild(scriptEl); - } - - /** - * Run all tests for this example. - * - * @param {Object} moduleEl The module DOM element. - */ - function runTests(moduleEl) { - console.log('runTests()'); - common.tester = new Tester(); - - // All NaCl SDK examples are OK if the example exits cleanly; (i.e. the - // NaCl module returns 0 or calls exit(0)). - // - // Without this exception, the browser_tester thinks that the module - // has crashed. - common.tester.exitCleanlyIsOK(); - - common.tester.addAsyncTest('loaded', function(test) { - test.pass(); - }); - - if (typeof window.addTests !== 'undefined') { - window.addTests(); - } - - common.tester.waitFor(moduleEl); - common.tester.run(); - } - - /** - * Create the Native Client element as a child of the DOM element - * named "listener". - * - * @param {string} name The name of the example. - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @param {string} path Directory name where .nmf file can be found. - * @param {number} width The width to create the plugin. - * @param {number} height The height to create the plugin. - * @param {Object} attrs Dictionary of attributes to set on the module. - */ - function createNaClModule(name, tool, path, width, height, attrs) { - var moduleEl = document.createElement('embed'); - moduleEl.setAttribute('name', 'nacl_module'); - moduleEl.setAttribute('id', 'nacl_module'); - moduleEl.setAttribute('width', width); - moduleEl.setAttribute('height', height); - moduleEl.setAttribute('path', path); - moduleEl.setAttribute('src', path + '/' + name + '.nmf'); - - // Add any optional arguments - if (attrs) { - for (var key in attrs) { - moduleEl.setAttribute(key, attrs[key]); - } - } - - var mimetype = mimeTypeForTool(tool); - moduleEl.setAttribute('type', mimetype); - - // The element is wrapped inside a
, 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 element - // to ensure that the listeners are active before the NaCl module 'load' - // event fires. - var listenerDiv = document.getElementById('listener'); - listenerDiv.appendChild(moduleEl); - - // Host plugins don't send a moduleDidLoad message. We'll fake it here. - var isHost = isHostToolchain(tool); - if (isHost) { - window.setTimeout(function() { - moduleEl.readyState = 1; - moduleEl.dispatchEvent(new CustomEvent('loadstart')); - moduleEl.readyState = 4; - moduleEl.dispatchEvent(new CustomEvent('load')); - moduleEl.dispatchEvent(new CustomEvent('loadend')); - }, 100); // 100 ms - } - - // This is code that is only used to test the SDK. - if (isTest) { - var loadNaClTest = function() { - injectScript('nacltest.js', function() { - runTests(moduleEl); - }); - }; - - // Try to load test.js for the example. Whether or not it exists, load - // nacltest.js. - injectScript('test.js', loadNaClTest, loadNaClTest); - } - } - - /** - * Add the default "load" and "message" event listeners to the element with - * id "listener". - * - * The "load" event is sent when the module is successfully loaded. The - * "message" event is sent when the naclModule posts a message using - * PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in - * C++). - */ - function attachDefaultListeners() { - var listenerDiv = document.getElementById('listener'); - listenerDiv.addEventListener('load', moduleDidLoad, true); - listenerDiv.addEventListener('message', handleMessage, true); - listenerDiv.addEventListener('crash', handleCrash, true); - if (typeof window.attachListeners !== 'undefined') { - window.attachListeners(); - } - } - - - /** - * Called when the Browser can not communicate with the Module - * - * This event listener is registered in attachDefaultListeners above. - */ - function handleCrash(event) { - if (common.naclModule.exitStatus == -1) { - updateStatus('CRASHED'); - } else { - updateStatus('EXITED [' + common.naclModule.exitStatus + ']'); - } - if (typeof window.handleCrash !== 'undefined') { - window.handleCrash(common.naclModule.lastError); - } - } - - /** - * Called when the NaCl module is loaded. - * - * This event listener is registered in attachDefaultListeners above. - */ - function moduleDidLoad() { - common.naclModule = document.getElementById('nacl_module'); - updateStatus('RUNNING'); - - if (typeof window.moduleDidLoad !== 'undefined') { - window.moduleDidLoad(); - } - } - - /** - * Hide the NaCl module's embed element. - * - * We don't want to hide by default; if we do, it is harder to determine that - * a plugin failed to load. Instead, call this function inside the example's - * "moduleDidLoad" function. - * - */ - function hideModule() { - // Setting common.naclModule.style.display = "None" doesn't work; the - // module will no longer be able to receive postMessages. - common.naclModule.style.height = '0'; - } - - /** - * Return true when |s| starts with the string |prefix|. - * - * @param {string} s The string to search. - * @param {string} prefix The prefix to search for in |s|. - */ - function startsWith(s, prefix) { - // indexOf would search the entire string, lastIndexOf(p, 0) only checks at - // the first index. See: http://stackoverflow.com/a/4579228 - return s.lastIndexOf(prefix, 0) === 0; - } - - /** Maximum length of logMessageArray. */ - var kMaxLogMessageLength = 20; - - /** An array of messages to display in the element with id "log". */ - var logMessageArray = []; - - /** - * Add a message to an element with id "log". - * - * This function is used by the default "log:" message handler. - * - * @param {string} message The message to log. - */ - function logMessage(message) { - logMessageArray.push(message); - if (logMessageArray.length > kMaxLogMessageLength) - logMessageArray.shift(); - - document.getElementById('log').textContent = logMessageArray.join('\n'); - console.log(message); - } - - /** - */ - var defaultMessageTypes = { - 'alert': alert, - 'log': logMessage - }; - - /** - * Called when the NaCl module sends a message to JavaScript (via - * PPB_Messaging.PostMessage()) - * - * This event listener is registered in createNaClModule above. - * - * @param {Event} message_event A message event. message_event.data contains - * the data sent from the NaCl module. - */ - function handleMessage(message_event) { - if (typeof message_event.data === 'string') { - for (var type in defaultMessageTypes) { - if (defaultMessageTypes.hasOwnProperty(type)) { - if (startsWith(message_event.data, type + ':')) { - func = defaultMessageTypes[type]; - func(message_event.data.slice(type.length + 1)); - return; - } - } - } - } - - if (typeof window.handleMessage !== 'undefined') { - window.handleMessage(message_event); - return; - } - - logMessage('Unhandled message: ' + message_event.data); - } - - /** - * Called when the DOM content has loaded; i.e. the page's document is fully - * parsed. At this point, we can safely query any elements in the document via - * document.querySelector, document.getElementById, etc. - * - * @param {string} name The name of the example. - * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. - * @param {string} path Directory name where .nmf file can be found. - * @param {number} width The width to create the plugin. - * @param {number} height The height to create the plugin. - * @param {Object} attrs Optional dictionary of additional attributes. - */ - function domContentLoaded(name, tool, path, width, height, attrs) { - // 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. - updateStatus('Page loaded.'); - if (!browserSupportsNaCl(tool)) { - updateStatus( - 'Browser does not support NaCl (' + tool + '), or NaCl is disabled'); - } else if (common.naclModule == null) { - updateStatus('Creating embed: ' + tool); - - // We use a non-zero sized embed to give Chrome space to place the bad - // plug-in graphic, if there is a problem. - width = typeof width !== 'undefined' ? width : 200; - height = typeof height !== 'undefined' ? height : 200; - attachDefaultListeners(); - createNaClModule(name, tool, path, width, height, attrs); - } 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('Waiting.'); - } - } - - /** Saved text to display in the element with id 'statusField'. */ - var statusText = 'NO-STATUSES'; - - /** - * Set the global status message. If the element with id 'statusField' - * exists, then set its HTML to the status message as well. - * - * @param {string} opt_message The message to set. If null or undefined, then - * set element 'statusField' to the message from the last call to - * updateStatus. - */ - function updateStatus(opt_message) { - if (opt_message) { - statusText = opt_message; - } - var statusField = document.getElementById('statusField'); - if (statusField) { - statusField.innerHTML = statusText; - } - } - - // The symbols to export. - return { - /** A reference to the NaCl module, once it is loaded. */ - naclModule: null, - - attachDefaultListeners: attachDefaultListeners, - domContentLoaded: domContentLoaded, - createNaClModule: createNaClModule, - hideModule: hideModule, - logMessage: logMessage, - updateStatus: updateStatus - }; - -}()); - -// Listen for the DOM content to be loaded. This event is fired when parsing of -// the page's document has finished. -document.addEventListener('DOMContentLoaded', function() { - var body = document.body; - - // The data-* attributes on the body can be referenced via body.dataset. - if (body.dataset) { - var loadFunction; - if (!body.dataset.customLoad) { - loadFunction = common.domContentLoaded; - } else if (typeof window.domContentLoaded !== 'undefined') { - loadFunction = window.domContentLoaded; - } - - // From https://developer.mozilla.org/en-US/docs/DOM/window.location - var searchVars = {}; - if (window.location.search.length > 1) { - var pairs = window.location.search.substr(1).split('&'); - for (var key_ix = 0; key_ix < pairs.length; key_ix++) { - var keyValue = pairs[key_ix].split('='); - searchVars[unescape(keyValue[0])] = - keyValue.length > 1 ? unescape(keyValue[1]) : ''; - } - } - - if (loadFunction) { - var toolchains = body.dataset.tools.split(' '); - var configs = body.dataset.configs.split(' '); - - var attrs = {}; - if (body.dataset.attrs) { - var attr_list = body.dataset.attrs.split(' '); - for (var key in attr_list) { - var attr = attr_list[key].split('='); - var key = attr[0]; - var value = attr[1]; - attrs[key] = value; - } - } - - var tc = toolchains.indexOf(searchVars.tc) !== -1 ? - searchVars.tc : toolchains[0]; - var config = configs.indexOf(searchVars.config) !== -1 ? - searchVars.config : configs[0]; - var pathFormat = body.dataset.path; - var path = pathFormat.replace('{tc}', tc).replace('{config}', config); - - isTest = searchVars.test === 'true'; - isRelease = path.toLowerCase().indexOf('release') != -1; - - loadFunction(body.dataset.name, tc, path, body.dataset.width, - body.dataset.height, attrs); - } - } -}); diff --git a/native_client_sdk/src/examples/favicon.ico b/native_client_sdk/src/examples/favicon.ico deleted file mode 100644 index ee7c943..0000000 Binary files a/native_client_sdk/src/examples/favicon.ico and /dev/null differ diff --git a/native_client_sdk/src/examples/httpd.cmd b/native_client_sdk/src/examples/httpd.cmd deleted file mode 100644 index d7aec88..0000000 --- a/native_client_sdk/src/examples/httpd.cmd +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -setlocal - -PATH=%CYGWIN%;%PATH% -REM Use the path to this file (httpd.cmd) to get the -REM path to httpd.py, so that we can run httpd.cmd from -REM any directory. Pass up to 9 arguments to httpd.py. -python %~dp0\..\tools\httpd.py %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/native_client_sdk/src/examples/resources/background.js b/native_client_sdk/src/examples/resources/background.js deleted file mode 100644 index 1fc5a19b..0000000 --- a/native_client_sdk/src/examples/resources/background.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2013 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. - -function onLaunched(launchData) { - chrome.app.window.create('index.html', { - width: 1024, - height: 800, - frame: 'none' - }); -} - -chrome.app.runtime.onLaunched.addListener(onLaunched); diff --git a/native_client_sdk/src/examples/resources/button_close.png b/native_client_sdk/src/examples/resources/button_close.png deleted file mode 100644 index 02a927e..0000000 Binary files a/native_client_sdk/src/examples/resources/button_close.png and /dev/null differ diff --git a/native_client_sdk/src/examples/resources/button_close_hover.png b/native_client_sdk/src/examples/resources/button_close_hover.png deleted file mode 100644 index 2df566d..0000000 Binary files a/native_client_sdk/src/examples/resources/button_close_hover.png and /dev/null differ diff --git a/native_client_sdk/src/examples/resources/icon128.png b/native_client_sdk/src/examples/resources/icon128.png deleted file mode 100644 index a10c52a..0000000 Binary files a/native_client_sdk/src/examples/resources/icon128.png and /dev/null differ diff --git a/native_client_sdk/src/examples/resources/index.css b/native_client_sdk/src/examples/resources/index.css deleted file mode 100644 index 93f2663..0000000 --- a/native_client_sdk/src/examples/resources/index.css +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) 2013 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. */ - -html { - color: #222; - font-family: Arial, san-serif; -} -body { - margin: 0; -} -.main-column { - background-color: #fff; - display: -webkit-flex; - height: 100%; - position: absolute; - -webkit-flex-direction: column; - width: 100%; -} -.header, .footer, .left-border, .right-border { - background-color: #444; - -webkit-flex: none; -} -.header { - color: #fff; - font-size: 150%; - font-weight: bold; - padding: 2px; - -webkit-app-region: drag; -} -.left-border, .right-border { - width: 2px; -} -.footer { - height: 2px; -} -.close-button { - background-image: url('button_close.png'); - float: right; - height: 17px; - margin: 8px 2px; - text-align: center; - -webkit-app-region: no-drag; - width: 17px; -} -.close-button:hover { - background-image: url('button_close_hover.png'); -} -.main { - display: -webkit-flex; - min-height: 0; - -webkit-flex: 1; - -webkit-flex-direction: row; -} -.nav-wrapper { - overflow-y: auto; -} -.nav { - padding: 8px; - -webkit-flex: initial; -} -.nav-group-header { - font-weight: bold; - padding: 4px 0; -} -.nav-item { - cursor: pointer; - font-size: 13px; - padding: 4px 0; -} -.nav-item:hover { - background-color: #eee; -} -.selected { - color: #dd4b39; -} -.nav-title { - padding-left: 8px; -} -.iframe-wrapper { - overflow-y: auto; - -webkit-flex: auto; -} -iframe { - border: none; - width: 100%; - height: auto; -} diff --git a/native_client_sdk/src/examples/resources/index.html.template b/native_client_sdk/src/examples/resources/index.html.template deleted file mode 100644 index 207afdb..0000000 --- a/native_client_sdk/src/examples/resources/index.html.template +++ /dev/null @@ -1,45 +0,0 @@ - - - - - Native Client SDK - - - - -
-
- Native Client SDK -
-
-
-
- -
- -
-
-
- -
- - diff --git a/native_client_sdk/src/examples/resources/index.js b/native_client_sdk/src/examples/resources/index.js deleted file mode 100644 index ab4b4ff..0000000 --- a/native_client_sdk/src/examples/resources/index.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2013 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. - -var iframeUpdateIntervalID; - -function selectExample(el) { - setIframeSrc(el.dataset.href); - deselectAllNavItems(); - selectNavItem(el); -} - -function selectNavItem(el) { - el.classList.add('selected'); -} - -function deselectAllNavItems() { - var navItemEls = document.querySelectorAll('.nav-item'); - for (var i = 0; i < navItemEls.length; ++i) { - navItemEls[i].classList.remove('selected'); - } -} - -function setIframeSrc(src) { - var iframeEl = document.querySelector('iframe'); - - window.clearInterval(iframeUpdateIntervalID); - iframeEl.style.height = ''; - iframeEl.src = src; -} - -document.addEventListener('DOMContentLoaded', function () { - var iframeEl = document.querySelector('iframe'); - var iframeWrapperEl = document.querySelector('.iframe-wrapper'); - var navItemEls = document.querySelectorAll('.nav-item'); - - for (var i = 0; i < navItemEls.length; ++i) { - navItemEls[i].addEventListener('click', function (e) { - selectExample(this); - }); - } - - iframeEl.addEventListener('load', function () { - var iframeDocument = this.contentWindow.document; - var iframeBodyEl = iframeDocument.body; - iframeEl.style.height = iframeBodyEl.scrollHeight + 'px'; - - // HACK: polling the body height to update the iframe. There's got to be a - // better way to do this... - var prevBodyHeight; - var prevWrapperHeight; - iframeUpdateIntervalID = window.setInterval(function () { - var bodyHeight = iframeBodyEl.getBoundingClientRect().height; - var wrapperHeight = iframeWrapperEl.clientHeight; - if (bodyHeight != prevBodyHeight || wrapperHeight != prevWrapperHeight) { - // HACK: magic 4... without it, the scrollbar is always visible. :( - var newHeight = Math.max(wrapperHeight - 4, bodyHeight); - iframeEl.style.height = newHeight + 'px'; - prevBodyHeight = bodyHeight; - prevWrapperHeight = wrapperHeight; - } - }, 100); // .1s - }, false); - - var closeButtonEl = document.querySelector('.close-button'); - closeButtonEl.addEventListener('click', function () { - window.close(); - }); - - // select the first example. - selectExample(document.querySelector('.nav-item')); -}); diff --git a/native_client_sdk/src/examples/resources/manifest.json.template b/native_client_sdk/src/examples/resources/manifest.json.template deleted file mode 100644 index e7e9760..0000000 --- a/native_client_sdk/src/examples/resources/manifest.json.template +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "{{name}}", - "version": "{{version}}", - "manifest_version": 2, - "description": "{{description}}", - "offline_enabled": true, - "icons": { - "128": "icon128.png" - }, - "app": { - "background": { - "scripts": ["background.js"] - } - }, -[[if key:]] - "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMN716Qyu0l2EHNFqIJVqVysFcTR6urqhaGGqW4UK7slBaURz9+Sb1b4Ot5P1uQNE5c+CTU5Vu61wpqmSqMMxqHLWdPPMh8uRlyctsb2cxWwG6XoGSvpX29NsQVUFXd4v2tkJm3G9t+V0X8TYskrvWQmnyOW8OEIDvrBhUEfFxWQIDAQAB", -[[]] - "oauth2": { - "client_id": "903965034255.apps.googleusercontent.com", - "scopes": ["https://www.googleapis.com/auth/drive"] - }, - "permissions": {{permissions}} -} diff --git a/native_client_sdk/src/examples/resources/promo440.png b/native_client_sdk/src/examples/resources/promo440.png deleted file mode 100644 index 2d9b521..0000000 Binary files a/native_client_sdk/src/examples/resources/promo440.png and /dev/null differ diff --git a/native_client_sdk/src/examples/resources/screenshot_gles_1280.png b/native_client_sdk/src/examples/resources/screenshot_gles_1280.png deleted file mode 100644 index 853a6bc..0000000 Binary files a/native_client_sdk/src/examples/resources/screenshot_gles_1280.png and /dev/null differ diff --git a/native_client_sdk/src/examples/resources/screenshot_pi_1280.png b/native_client_sdk/src/examples/resources/screenshot_pi_1280.png deleted file mode 100644 index 4dad188..0000000 Binary files a/native_client_sdk/src/examples/resources/screenshot_pi_1280.png and /dev/null differ diff --git a/native_client_sdk/src/examples/tutorial/debugging/example.dsc b/native_client_sdk/src/examples/tutorial/debugging/example.dsc index 36ef726..a9233e4 100644 --- a/native_client_sdk/src/examples/tutorial/debugging/example.dsc +++ b/native_client_sdk/src/examples/tutorial/debugging/example.dsc @@ -1,10 +1,6 @@ { 'DISABLE_PACKAGE': True, # Doesn't work in packaged apps yet. 'TOOLS': ['newlib'], - 'SEARCH': [ - '.', - '../..', - ], 'TARGETS': [ { 'NAME' : 'debugging', diff --git a/native_client_sdk/src/libraries/gmock/library.dsc b/native_client_sdk/src/libraries/gmock/library.dsc index 4cbbb85..a61ffeb 100644 --- a/native_client_sdk/src/libraries/gmock/library.dsc +++ b/native_client_sdk/src/libraries/gmock/library.dsc @@ -1,7 +1,6 @@ { 'TOOLS': ['newlib', 'glibc', 'pnacl', 'linux', 'win'], 'SEARCH': [ - '.', '../../../../testing/gmock/include/gmock', '../../../../testing/gmock/include/gmock/internal', '../../../../testing/gmock/src', diff --git a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc index cd1ae06..16db397 100644 --- a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc +++ b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc @@ -1,7 +1,6 @@ { 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win', 'linux'], 'SEARCH': [ - '.', '../../../../ppapi/cpp', '../../../../ppapi/cpp/dev', '../../../../ppapi/cpp/extensions', diff --git a/native_client_sdk/src/libraries/sdk_util/library.dsc b/native_client_sdk/src/libraries/sdk_util/library.dsc index 38cad6a..7d14db1 100644 --- a/native_client_sdk/src/libraries/sdk_util/library.dsc +++ b/native_client_sdk/src/libraries/sdk_util/library.dsc @@ -1,8 +1,5 @@ { 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win'], - 'SEARCH': [ - '.' - ], 'TARGETS': [ { 'NAME' : 'sdk_util', diff --git a/native_client_sdk/src/libraries/xray/library.dsc b/native_client_sdk/src/libraries/xray/library.dsc index f7e23ef..64daf75 100644 --- a/native_client_sdk/src/libraries/xray/library.dsc +++ b/native_client_sdk/src/libraries/xray/library.dsc @@ -1,8 +1,5 @@ { 'TOOLS': ['newlib', 'glibc', 'pnacl'], - 'SEARCH': [ - '.' - ], 'TARGETS': [ { 'NAME' : 'xray', diff --git a/native_client_sdk/src/resources/Makefile.example.template b/native_client_sdk/src/resources/Makefile.example.template new file mode 100644 index 0000000..8c63756 --- /dev/null +++ b/native_client_sdk/src/resources/Makefile.example.template @@ -0,0 +1,89 @@ +# Copyright (c) 2013 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. + +# GNU Makefile based on shared rules provided by the Native Client SDK. +# See README.Makefiles for more details. +[[]] +[[def ExpandDict(key, value_in, pre_list=[], post_list=[]):]] +[[ value = value_in or [] ]] +[[ pre = pre_list or [] ]] +[[ post = post_list or [] ]] +[[ if type(value) is not dict:]] +[[ out = pre]] +[[ out.extend(value)]] +[[ out.extend(post)]] +[[ if out:]] +{{key}} = {{' '.join(out)}} +[[ ]] +[[ return]] +[[ ]] +[[ for subkey in value:]] +[[ out = pre]] +[[ out.extend(value[subkey])]] +[[ out.extend(post)]] +{{key}}_{{subkey}} = {{' '.join(out)}} +[[ ]] +{{key}} = $({{key}}_$(TOOLCHAIN)) +[[]] + +VALID_TOOLCHAINS := {{' '.join(tools)}} +{{pre}} +NACL_SDK_ROOT ?= $(abspath $(CURDIR)/{{rel_sdk}}) +include $(NACL_SDK_ROOT)/tools/common.mk + +TARGET = {{targets[0]['NAME']}} +[[ExpandDict('DEPS', targets[0].get('DEPS', []))]] +[[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]] + +[[for target in targets:]] +[[ source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))]] +[[ source_list = ' \\\n '.join(source_list)]] +[[ sources = target['NAME'] + '_SOURCES']] +[[ cflags = target['NAME'] + '_CFLAGS']] +[[ flags = target.get('CFLAGS', [])]] +[[ flags.extend(target.get('CXXFLAGS', []))]] +[[ if len(targets) == 1:]] +[[ sources = 'SOURCES']] +[[ cflags = 'CFLAGS']] +[[ ]] +[[ ExpandDict(cflags, flags)]] +[[ if 'CFLAGS_GCC' in target:]] +ifneq ($(TOOLCHAIN),pnacl) +{{cflags}} += {{' '.join(target['CFLAGS_GCC'])}} +endif +[[ ]] +{{sources}} = {{source_list}} + +# Build rules generated by macros from common.mk: + +[[if targets[0].get('DEPS'):]] +$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) +[[if len(targets) > 1:]] +[[ for target in targets:]] +[[ name = target['NAME'] ]] +$(foreach src,$({{name}}_SOURCES),$(eval $(call COMPILE_RULE,$(src),$({{name}}_CFLAGS)))) +[[else:]] +$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) +[[]] + +[[for target in targets:]] +[[ sources = target['NAME'] + '_SOURCES']] +[[ name = target['NAME'] ]] +[[ if len(targets) == 1:]] +[[ sources = 'SOURCES']] +[[ name = '$(TARGET)']] +[[ if target['TYPE'] == 'so':]] +$(eval $(call SO_RULE,{{name}},$({{sources}}))) +[[ elif target['TYPE'] == 'so-standalone':]] +$(eval $(call SO_RULE,{{name}},$({{sources}}),,,1)) +[[ else:]] +ifeq ($(CONFIG),Release) +$(eval $(call LINK_RULE,{{name}}_unstripped,$({{sources}}),$(LIBS),$(DEPS))) +$(eval $(call STRIP_RULE,{{name}},{{name}}_unstripped)) +else +$(eval $(call LINK_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS))) +endif +[[]] + +$(eval $(call NMF_RULE,$(TARGET),)){{post}} diff --git a/native_client_sdk/src/resources/Makefile.index.template b/native_client_sdk/src/resources/Makefile.index.template new file mode 100644 index 0000000..84110b5 --- /dev/null +++ b/native_client_sdk/src/resources/Makefile.index.template @@ -0,0 +1,68 @@ +# 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. + +# +# GNU Make based build file.  For details on GNU Make see: +#   http://www.gnu.org/software/make/manual/make.html +# + +PROJECTS:= \ +[[for project in projects:]] + {{project}} \ +[[]] + +HTTPD:={{rel_sdk}}/tools/httpd.py + +ifeq ($(TOOLCHAIN),all) +TOOLCHAIN_ARG:=TOOLCHAIN=all +endif + +# Define the default target +all: + +# +# Target Macro +# +# Macro defines a phony target for each example, and adds it to a list of +# targets. +# +# Note: We use targets for each project (instead of an explicit recipe) so +# each project can be built in parallel. +# +define TARGET +ALL_TARGET_LIST+=$(1)_ALL_TARGET +.PHONY: $(1)_ALL_TARGET +$(1)_ALL_TARGET: + +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) all + +CLEAN_TARGET_LIST+=$(1)_CLEAN_TARGET +.PHONY: $(1)_CLEAN_TARGET +$(1)_CLEAN_TARGET: + +$(MAKE) -C $(1) $(TOOLCHAIN_ARG) clean +endef + + +# Define the various targets via the Macro +$(foreach proj,$(PROJECTS),$(eval $(call TARGET,$(proj)))) + +.PHONY: all +all: $(ALL_TARGET_LIST) + @echo Done building targets. + +.PHONY: clean +clean: $(CLEAN_TARGET_LIST) + @echo Done cleaning targets. + +.PHONY: run +run: all + @echo Starting up python webserver. + python $(HTTPD) + +# Phony aliases for backward compatibility +RUN: run + +all_versions: + +$(MAKE) TOOLCHAIN=all + +.PHONY: RUN all_versions diff --git a/native_client_sdk/src/resources/Makefile.library.template b/native_client_sdk/src/resources/Makefile.library.template new file mode 100644 index 0000000..ff991aa --- /dev/null +++ b/native_client_sdk/src/resources/Makefile.library.template @@ -0,0 +1,65 @@ +# Copyright (c) 2013 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. +[[def ExpandDict(key, value_in, pre_list=[], post_list=[]):]] +[[ value = value_in or [] ]] +[[ pre = pre_list or [] ]] +[[ post = post_list or [] ]] +[[ if type(value) is not dict:]] +[[ out = pre]] +[[ out.extend(value)]] +[[ out.extend(post)]] +[[ if out:]] +{{key}} = {{' '.join(out)}} +[[ ]] +[[ return]] +[[ ]] +[[ for subkey in value:]] +[[ out = pre]] +[[ out.extend(value[subkey])]] +[[ out.extend(post)]] +{{key}}_{{subkey}} = {{' '.join(out)}} +[[ ]] +{{key}} = $({{key}}_$(TOOLCHAIN)) +[[]] + +[[target = targets[0] ]] +# GNU Makefile based on shared rules provided by the Native Client SDK. +# See README.Makefiles for more details. + +VALID_TOOLCHAINS := {{' '.join(tools)}} +NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) +[[if 'INCLUDES' in target:]] +EXTRA_INC_PATHS={{' '.join(target['INCLUDES'])}} +[[]] + +include $(NACL_SDK_ROOT)/tools/common.mk + +TARGET = {{target['NAME']}} +[[flags = target.get('CFLAGS', [])]] +[[flags.extend(target.get('CXXFLAGS', []))]] +[[ExpandDict('CFLAGS', flags)]] +[[if 'CFLAGS_GCC' in target:]] +ifneq ($(TOOLCHAIN),pnacl) +CFLAGS += {{' '.join(target['CFLAGS_GCC'])}} +endif +[[]] + +SOURCES = \ +[[for source in sorted(target['SOURCES']):]] + {{source}} \ +[[]] + +all: install + +# Build rules generated by macros from common.mk: +# +$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) +$(eval $(call LIB_RULE,$(TARGET),$(SOURCES))) + +[[if target['TYPE'] != 'static-lib':]] +ifeq ($(TOOLCHAIN),glibc) +$(eval $(call SO_RULE,$(TARGET),$(SOURCES))) +endif +[[]] +{{post}} diff --git a/native_client_sdk/src/resources/Makefile_gyp b/native_client_sdk/src/resources/Makefile_gyp new file mode 100644 index 0000000..84b0cf4 --- /dev/null +++ b/native_client_sdk/src/resources/Makefile_gyp @@ -0,0 +1,52 @@ +# 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. + +# +# GNU Make based build file.  For details on GNU Make see: +#   http://www.gnu.org/software/make/manual/make.html +# + +__PROJECT_LIST__ + +# Define the default target +all: + +CONFIG=debug + +# +# Target Macro +# +# Macro defines a phony target for each example, and adds it to a list of +# targets. +# +define TARGET +TARGET_LIST+=$(1)_TARGET +.PHONY: $(1)_TARGET +$(1)_TARGET: + +$(MAKE) BUILDTYPE=glibc-$(CONFIG) -C $(1) + +$(MAKE) BUILDTYPE=newlib-$(CONFIG) -C $(1) + +$(MAKE) BUILDTYPE=host-$(CONFIG) -C $(1) + +CLEAN_LIST+=$(1)_CLEAN +.PHONY: $(1)_CLEAN +$(1)_CLEAN: + +$(MAKE) -C $(1) clean +endef + + +# Define the various targets via the Macro +$(foreach proj,$(PROJECTS),$(eval $(call TARGET,$(proj)))) + +__DEPENDENCIES__ + +all: $(TARGET_LIST) + echo "Done building targets." + +clean: $(CLEAN_LIST) + echo "Done cleaning targets." + +RUN: all + echo "Staring up python webserver." + python httpd.py + diff --git a/native_client_sdk/src/resources/background.js b/native_client_sdk/src/resources/background.js new file mode 100644 index 0000000..1fc5a19b --- /dev/null +++ b/native_client_sdk/src/resources/background.js @@ -0,0 +1,13 @@ +// Copyright (c) 2013 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. + +function onLaunched(launchData) { + chrome.app.window.create('index.html', { + width: 1024, + height: 800, + frame: 'none' + }); +} + +chrome.app.runtime.onLaunched.addListener(onLaunched); diff --git a/native_client_sdk/src/resources/button_close.png b/native_client_sdk/src/resources/button_close.png new file mode 100644 index 0000000..02a927e Binary files /dev/null and b/native_client_sdk/src/resources/button_close.png differ diff --git a/native_client_sdk/src/resources/button_close_hover.png b/native_client_sdk/src/resources/button_close_hover.png new file mode 100644 index 0000000..2df566d Binary files /dev/null and b/native_client_sdk/src/resources/button_close_hover.png differ diff --git a/native_client_sdk/src/resources/common.js b/native_client_sdk/src/resources/common.js new file mode 100644 index 0000000..dc5328f --- /dev/null +++ b/native_client_sdk/src/resources/common.js @@ -0,0 +1,439 @@ +// 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. + +// Set to true when the Document is loaded IFF "test=true" is in the query +// string. +var isTest = false; + +// Set to true when loading a "Release" NaCl module, false when loading a +// "Debug" NaCl module. +var isRelease = false; + +// Javascript module pattern: +// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces +// In essence, we define an anonymous function which is immediately called and +// returns a new object. The new object contains only the exported definitions; +// all other definitions in the anonymous function are inaccessible to external +// code. +var common = (function() { + + function isHostToolchain(tool) { + return tool == 'win' || tool == 'linux' || tool == 'mac'; + } + + /** + * Return the mime type for NaCl plugin. + * + * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. + * @return {string} The mime-type for the kind of NaCl plugin matching + * the given toolchain. + */ + function mimeTypeForTool(tool) { + // For NaCl modules use application/x-nacl. + var mimetype = 'application/x-nacl'; + if (isHostToolchain(tool)) { + // For non-NaCl PPAPI plugins use the x-ppapi-debug/release + // mime type. + if (isRelease) + mimetype = 'application/x-ppapi-release'; + else + mimetype = 'application/x-ppapi-debug'; + } else if (tool == 'pnacl' && isRelease) { + mimetype = 'application/x-pnacl'; + } + return mimetype; + } + + /** + * Check if the browser supports NaCl plugins. + * + * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. + * @return {bool} True if the browser supports the type of NaCl plugin + * produced by the given toolchain. + */ + function browserSupportsNaCl(tool) { + // Assume host toolchains always work with the given browser. + // The below mime-type checking might not work with + // --register-pepper-plugins. + if (isHostToolchain(tool)) { + return true; + } + var mimetype = mimeTypeForTool(tool); + return navigator.mimeTypes[mimetype] !== undefined; + } + + /** + * Inject a script into the DOM, and call a callback when it is loaded. + * + * @param {string} url The url of the script to load. + * @param {Function} onload The callback to call when the script is loaded. + * @param {Function} onerror The callback to call if the script fails to load. + */ + function injectScript(url, onload, onerror) { + var scriptEl = document.createElement('script'); + scriptEl.type = 'text/javascript'; + scriptEl.src = url; + scriptEl.onload = onload; + if (onerror) { + scriptEl.addEventListener('error', onerror, false); + } + document.head.appendChild(scriptEl); + } + + /** + * Run all tests for this example. + * + * @param {Object} moduleEl The module DOM element. + */ + function runTests(moduleEl) { + console.log('runTests()'); + common.tester = new Tester(); + + // All NaCl SDK examples are OK if the example exits cleanly; (i.e. the + // NaCl module returns 0 or calls exit(0)). + // + // Without this exception, the browser_tester thinks that the module + // has crashed. + common.tester.exitCleanlyIsOK(); + + common.tester.addAsyncTest('loaded', function(test) { + test.pass(); + }); + + if (typeof window.addTests !== 'undefined') { + window.addTests(); + } + + common.tester.waitFor(moduleEl); + common.tester.run(); + } + + /** + * Create the Native Client element as a child of the DOM element + * named "listener". + * + * @param {string} name The name of the example. + * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. + * @param {string} path Directory name where .nmf file can be found. + * @param {number} width The width to create the plugin. + * @param {number} height The height to create the plugin. + * @param {Object} attrs Dictionary of attributes to set on the module. + */ + function createNaClModule(name, tool, path, width, height, attrs) { + var moduleEl = document.createElement('embed'); + moduleEl.setAttribute('name', 'nacl_module'); + moduleEl.setAttribute('id', 'nacl_module'); + moduleEl.setAttribute('width', width); + moduleEl.setAttribute('height', height); + moduleEl.setAttribute('path', path); + moduleEl.setAttribute('src', path + '/' + name + '.nmf'); + + // Add any optional arguments + if (attrs) { + for (var key in attrs) { + moduleEl.setAttribute(key, attrs[key]); + } + } + + var mimetype = mimeTypeForTool(tool); + moduleEl.setAttribute('type', mimetype); + + // The element is wrapped inside a
, 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 element + // to ensure that the listeners are active before the NaCl module 'load' + // event fires. + var listenerDiv = document.getElementById('listener'); + listenerDiv.appendChild(moduleEl); + + // Host plugins don't send a moduleDidLoad message. We'll fake it here. + var isHost = isHostToolchain(tool); + if (isHost) { + window.setTimeout(function() { + moduleEl.readyState = 1; + moduleEl.dispatchEvent(new CustomEvent('loadstart')); + moduleEl.readyState = 4; + moduleEl.dispatchEvent(new CustomEvent('load')); + moduleEl.dispatchEvent(new CustomEvent('loadend')); + }, 100); // 100 ms + } + + // This is code that is only used to test the SDK. + if (isTest) { + var loadNaClTest = function() { + injectScript('nacltest.js', function() { + runTests(moduleEl); + }); + }; + + // Try to load test.js for the example. Whether or not it exists, load + // nacltest.js. + injectScript('test.js', loadNaClTest, loadNaClTest); + } + } + + /** + * Add the default "load" and "message" event listeners to the element with + * id "listener". + * + * The "load" event is sent when the module is successfully loaded. The + * "message" event is sent when the naclModule posts a message using + * PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in + * C++). + */ + function attachDefaultListeners() { + var listenerDiv = document.getElementById('listener'); + listenerDiv.addEventListener('load', moduleDidLoad, true); + listenerDiv.addEventListener('message', handleMessage, true); + listenerDiv.addEventListener('crash', handleCrash, true); + if (typeof window.attachListeners !== 'undefined') { + window.attachListeners(); + } + } + + + /** + * Called when the Browser can not communicate with the Module + * + * This event listener is registered in attachDefaultListeners above. + */ + function handleCrash(event) { + if (common.naclModule.exitStatus == -1) { + updateStatus('CRASHED'); + } else { + updateStatus('EXITED [' + common.naclModule.exitStatus + ']'); + } + if (typeof window.handleCrash !== 'undefined') { + window.handleCrash(common.naclModule.lastError); + } + } + + /** + * Called when the NaCl module is loaded. + * + * This event listener is registered in attachDefaultListeners above. + */ + function moduleDidLoad() { + common.naclModule = document.getElementById('nacl_module'); + updateStatus('RUNNING'); + + if (typeof window.moduleDidLoad !== 'undefined') { + window.moduleDidLoad(); + } + } + + /** + * Hide the NaCl module's embed element. + * + * We don't want to hide by default; if we do, it is harder to determine that + * a plugin failed to load. Instead, call this function inside the example's + * "moduleDidLoad" function. + * + */ + function hideModule() { + // Setting common.naclModule.style.display = "None" doesn't work; the + // module will no longer be able to receive postMessages. + common.naclModule.style.height = '0'; + } + + /** + * Return true when |s| starts with the string |prefix|. + * + * @param {string} s The string to search. + * @param {string} prefix The prefix to search for in |s|. + */ + function startsWith(s, prefix) { + // indexOf would search the entire string, lastIndexOf(p, 0) only checks at + // the first index. See: http://stackoverflow.com/a/4579228 + return s.lastIndexOf(prefix, 0) === 0; + } + + /** Maximum length of logMessageArray. */ + var kMaxLogMessageLength = 20; + + /** An array of messages to display in the element with id "log". */ + var logMessageArray = []; + + /** + * Add a message to an element with id "log". + * + * This function is used by the default "log:" message handler. + * + * @param {string} message The message to log. + */ + function logMessage(message) { + logMessageArray.push(message); + if (logMessageArray.length > kMaxLogMessageLength) + logMessageArray.shift(); + + document.getElementById('log').textContent = logMessageArray.join('\n'); + console.log(message); + } + + /** + */ + var defaultMessageTypes = { + 'alert': alert, + 'log': logMessage + }; + + /** + * Called when the NaCl module sends a message to JavaScript (via + * PPB_Messaging.PostMessage()) + * + * This event listener is registered in createNaClModule above. + * + * @param {Event} message_event A message event. message_event.data contains + * the data sent from the NaCl module. + */ + function handleMessage(message_event) { + if (typeof message_event.data === 'string') { + for (var type in defaultMessageTypes) { + if (defaultMessageTypes.hasOwnProperty(type)) { + if (startsWith(message_event.data, type + ':')) { + func = defaultMessageTypes[type]; + func(message_event.data.slice(type.length + 1)); + return; + } + } + } + } + + if (typeof window.handleMessage !== 'undefined') { + window.handleMessage(message_event); + return; + } + + logMessage('Unhandled message: ' + message_event.data); + } + + /** + * Called when the DOM content has loaded; i.e. the page's document is fully + * parsed. At this point, we can safely query any elements in the document via + * document.querySelector, document.getElementById, etc. + * + * @param {string} name The name of the example. + * @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc. + * @param {string} path Directory name where .nmf file can be found. + * @param {number} width The width to create the plugin. + * @param {number} height The height to create the plugin. + * @param {Object} attrs Optional dictionary of additional attributes. + */ + function domContentLoaded(name, tool, path, width, height, attrs) { + // 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. + updateStatus('Page loaded.'); + if (!browserSupportsNaCl(tool)) { + updateStatus( + 'Browser does not support NaCl (' + tool + '), or NaCl is disabled'); + } else if (common.naclModule == null) { + updateStatus('Creating embed: ' + tool); + + // We use a non-zero sized embed to give Chrome space to place the bad + // plug-in graphic, if there is a problem. + width = typeof width !== 'undefined' ? width : 200; + height = typeof height !== 'undefined' ? height : 200; + attachDefaultListeners(); + createNaClModule(name, tool, path, width, height, attrs); + } 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('Waiting.'); + } + } + + /** Saved text to display in the element with id 'statusField'. */ + var statusText = 'NO-STATUSES'; + + /** + * Set the global status message. If the element with id 'statusField' + * exists, then set its HTML to the status message as well. + * + * @param {string} opt_message The message to set. If null or undefined, then + * set element 'statusField' to the message from the last call to + * updateStatus. + */ + function updateStatus(opt_message) { + if (opt_message) { + statusText = opt_message; + } + var statusField = document.getElementById('statusField'); + if (statusField) { + statusField.innerHTML = statusText; + } + } + + // The symbols to export. + return { + /** A reference to the NaCl module, once it is loaded. */ + naclModule: null, + + attachDefaultListeners: attachDefaultListeners, + domContentLoaded: domContentLoaded, + createNaClModule: createNaClModule, + hideModule: hideModule, + logMessage: logMessage, + updateStatus: updateStatus + }; + +}()); + +// Listen for the DOM content to be loaded. This event is fired when parsing of +// the page's document has finished. +document.addEventListener('DOMContentLoaded', function() { + var body = document.body; + + // The data-* attributes on the body can be referenced via body.dataset. + if (body.dataset) { + var loadFunction; + if (!body.dataset.customLoad) { + loadFunction = common.domContentLoaded; + } else if (typeof window.domContentLoaded !== 'undefined') { + loadFunction = window.domContentLoaded; + } + + // From https://developer.mozilla.org/en-US/docs/DOM/window.location + var searchVars = {}; + if (window.location.search.length > 1) { + var pairs = window.location.search.substr(1).split('&'); + for (var key_ix = 0; key_ix < pairs.length; key_ix++) { + var keyValue = pairs[key_ix].split('='); + searchVars[unescape(keyValue[0])] = + keyValue.length > 1 ? unescape(keyValue[1]) : ''; + } + } + + if (loadFunction) { + var toolchains = body.dataset.tools.split(' '); + var configs = body.dataset.configs.split(' '); + + var attrs = {}; + if (body.dataset.attrs) { + var attr_list = body.dataset.attrs.split(' '); + for (var key in attr_list) { + var attr = attr_list[key].split('='); + var key = attr[0]; + var value = attr[1]; + attrs[key] = value; + } + } + + var tc = toolchains.indexOf(searchVars.tc) !== -1 ? + searchVars.tc : toolchains[0]; + var config = configs.indexOf(searchVars.config) !== -1 ? + searchVars.config : configs[0]; + var pathFormat = body.dataset.path; + var path = pathFormat.replace('{tc}', tc).replace('{config}', config); + + isTest = searchVars.test === 'true'; + isRelease = path.toLowerCase().indexOf('release') != -1; + + loadFunction(body.dataset.name, tc, path, body.dataset.width, + body.dataset.height, attrs); + } + } +}); diff --git a/native_client_sdk/src/resources/favicon.ico b/native_client_sdk/src/resources/favicon.ico new file mode 100644 index 0000000..ee7c943 Binary files /dev/null and b/native_client_sdk/src/resources/favicon.ico differ diff --git a/native_client_sdk/src/resources/httpd.cmd b/native_client_sdk/src/resources/httpd.cmd new file mode 100644 index 0000000..d7aec88 --- /dev/null +++ b/native_client_sdk/src/resources/httpd.cmd @@ -0,0 +1,8 @@ +@echo off +setlocal + +PATH=%CYGWIN%;%PATH% +REM Use the path to this file (httpd.cmd) to get the +REM path to httpd.py, so that we can run httpd.cmd from +REM any directory. Pass up to 9 arguments to httpd.py. +python %~dp0\..\tools\httpd.py %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/native_client_sdk/src/resources/icon128.png b/native_client_sdk/src/resources/icon128.png new file mode 100644 index 0000000..a10c52a Binary files /dev/null and b/native_client_sdk/src/resources/icon128.png differ diff --git a/native_client_sdk/src/resources/index.css b/native_client_sdk/src/resources/index.css new file mode 100644 index 0000000..93f2663 --- /dev/null +++ b/native_client_sdk/src/resources/index.css @@ -0,0 +1,88 @@ +/* Copyright (c) 2013 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. */ + +html { + color: #222; + font-family: Arial, san-serif; +} +body { + margin: 0; +} +.main-column { + background-color: #fff; + display: -webkit-flex; + height: 100%; + position: absolute; + -webkit-flex-direction: column; + width: 100%; +} +.header, .footer, .left-border, .right-border { + background-color: #444; + -webkit-flex: none; +} +.header { + color: #fff; + font-size: 150%; + font-weight: bold; + padding: 2px; + -webkit-app-region: drag; +} +.left-border, .right-border { + width: 2px; +} +.footer { + height: 2px; +} +.close-button { + background-image: url('button_close.png'); + float: right; + height: 17px; + margin: 8px 2px; + text-align: center; + -webkit-app-region: no-drag; + width: 17px; +} +.close-button:hover { + background-image: url('button_close_hover.png'); +} +.main { + display: -webkit-flex; + min-height: 0; + -webkit-flex: 1; + -webkit-flex-direction: row; +} +.nav-wrapper { + overflow-y: auto; +} +.nav { + padding: 8px; + -webkit-flex: initial; +} +.nav-group-header { + font-weight: bold; + padding: 4px 0; +} +.nav-item { + cursor: pointer; + font-size: 13px; + padding: 4px 0; +} +.nav-item:hover { + background-color: #eee; +} +.selected { + color: #dd4b39; +} +.nav-title { + padding-left: 8px; +} +.iframe-wrapper { + overflow-y: auto; + -webkit-flex: auto; +} +iframe { + border: none; + width: 100%; + height: auto; +} diff --git a/native_client_sdk/src/resources/index.html.template b/native_client_sdk/src/resources/index.html.template new file mode 100644 index 0000000..207afdb --- /dev/null +++ b/native_client_sdk/src/resources/index.html.template @@ -0,0 +1,45 @@ + + + + + Native Client SDK + + + + +
+
+ Native Client SDK +
+
+
+
+ +
+ +
+
+
+ +
+ + diff --git a/native_client_sdk/src/resources/index.js b/native_client_sdk/src/resources/index.js new file mode 100644 index 0000000..ab4b4ff --- /dev/null +++ b/native_client_sdk/src/resources/index.js @@ -0,0 +1,72 @@ +// Copyright (c) 2013 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. + +var iframeUpdateIntervalID; + +function selectExample(el) { + setIframeSrc(el.dataset.href); + deselectAllNavItems(); + selectNavItem(el); +} + +function selectNavItem(el) { + el.classList.add('selected'); +} + +function deselectAllNavItems() { + var navItemEls = document.querySelectorAll('.nav-item'); + for (var i = 0; i < navItemEls.length; ++i) { + navItemEls[i].classList.remove('selected'); + } +} + +function setIframeSrc(src) { + var iframeEl = document.querySelector('iframe'); + + window.clearInterval(iframeUpdateIntervalID); + iframeEl.style.height = ''; + iframeEl.src = src; +} + +document.addEventListener('DOMContentLoaded', function () { + var iframeEl = document.querySelector('iframe'); + var iframeWrapperEl = document.querySelector('.iframe-wrapper'); + var navItemEls = document.querySelectorAll('.nav-item'); + + for (var i = 0; i < navItemEls.length; ++i) { + navItemEls[i].addEventListener('click', function (e) { + selectExample(this); + }); + } + + iframeEl.addEventListener('load', function () { + var iframeDocument = this.contentWindow.document; + var iframeBodyEl = iframeDocument.body; + iframeEl.style.height = iframeBodyEl.scrollHeight + 'px'; + + // HACK: polling the body height to update the iframe. There's got to be a + // better way to do this... + var prevBodyHeight; + var prevWrapperHeight; + iframeUpdateIntervalID = window.setInterval(function () { + var bodyHeight = iframeBodyEl.getBoundingClientRect().height; + var wrapperHeight = iframeWrapperEl.clientHeight; + if (bodyHeight != prevBodyHeight || wrapperHeight != prevWrapperHeight) { + // HACK: magic 4... without it, the scrollbar is always visible. :( + var newHeight = Math.max(wrapperHeight - 4, bodyHeight); + iframeEl.style.height = newHeight + 'px'; + prevBodyHeight = bodyHeight; + prevWrapperHeight = wrapperHeight; + } + }, 100); // .1s + }, false); + + var closeButtonEl = document.querySelector('.close-button'); + closeButtonEl.addEventListener('click', function () { + window.close(); + }); + + // select the first example. + selectExample(document.querySelector('.nav-item')); +}); diff --git a/native_client_sdk/src/resources/manifest.json.template b/native_client_sdk/src/resources/manifest.json.template new file mode 100644 index 0000000..e7e9760 --- /dev/null +++ b/native_client_sdk/src/resources/manifest.json.template @@ -0,0 +1,23 @@ +{ + "name": "{{name}}", + "version": "{{version}}", + "manifest_version": 2, + "description": "{{description}}", + "offline_enabled": true, + "icons": { + "128": "icon128.png" + }, + "app": { + "background": { + "scripts": ["background.js"] + } + }, +[[if key:]] + "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMN716Qyu0l2EHNFqIJVqVysFcTR6urqhaGGqW4UK7slBaURz9+Sb1b4Ot5P1uQNE5c+CTU5Vu61wpqmSqMMxqHLWdPPMh8uRlyctsb2cxWwG6XoGSvpX29NsQVUFXd4v2tkJm3G9t+V0X8TYskrvWQmnyOW8OEIDvrBhUEfFxWQIDAQAB", +[[]] + "oauth2": { + "client_id": "903965034255.apps.googleusercontent.com", + "scopes": ["https://www.googleapis.com/auth/drive"] + }, + "permissions": {{permissions}} +} diff --git a/native_client_sdk/src/resources/promo440.png b/native_client_sdk/src/resources/promo440.png new file mode 100644 index 0000000..2d9b521 Binary files /dev/null and b/native_client_sdk/src/resources/promo440.png differ diff --git a/native_client_sdk/src/resources/screenshot_gles_1280.png b/native_client_sdk/src/resources/screenshot_gles_1280.png new file mode 100644 index 0000000..853a6bc Binary files /dev/null and b/native_client_sdk/src/resources/screenshot_gles_1280.png differ diff --git a/native_client_sdk/src/resources/screenshot_pi_1280.png b/native_client_sdk/src/resources/screenshot_pi_1280.png new file mode 100644 index 0000000..4dad188 Binary files /dev/null and b/native_client_sdk/src/resources/screenshot_pi_1280.png differ diff --git a/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc b/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc index 6340d66..842a84c 100644 --- a/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc +++ b/native_client_sdk/src/tests/nacl_io_socket_test/example.dsc @@ -1,8 +1,5 @@ { 'TOOLS': ['newlib', 'glibc', 'pnacl'], - - # Need to add ../../examples for common.js - 'SEARCH': ['.', '../../examples'], 'TARGETS': [ { 'NAME' : 'nacl_io_socket_test', diff --git a/native_client_sdk/src/tests/nacl_io_test/example.dsc b/native_client_sdk/src/tests/nacl_io_test/example.dsc index 1afb68a..7dbbfbc 100644 --- a/native_client_sdk/src/tests/nacl_io_test/example.dsc +++ b/native_client_sdk/src/tests/nacl_io_test/example.dsc @@ -2,8 +2,6 @@ 'TOOLS': ['newlib', 'glibc', 'pnacl'], 'SEL_LDR': True, - # Need to add ../../examples for common.js - 'SEARCH': ['.', '../../examples'], 'TARGETS': [ { 'NAME' : 'nacl_io_test', diff --git a/native_client_sdk/src/tests/sdk_util_test/example.dsc b/native_client_sdk/src/tests/sdk_util_test/example.dsc index 86f7635..2073d3f 100644 --- a/native_client_sdk/src/tests/sdk_util_test/example.dsc +++ b/native_client_sdk/src/tests/sdk_util_test/example.dsc @@ -2,8 +2,6 @@ 'TOOLS': ['newlib', 'glibc', 'pnacl'], 'SEL_LDR': True, - # Need to add ../../examples for common.js - 'SEARCH': ['.', '../../examples'], 'TARGETS': [ { 'NAME' : 'sdk_util_test', -- cgit v1.1