summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-18 20:32:26 +0000
committerbinji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-18 20:32:26 +0000
commit7c1c307c7a4b599c114127ec971dc356639d415c (patch)
tree1f5287d31ae268d5457b5c822890ac04b7ee96eb
parente3736ccc35d566a899cffd5b6480f768742e61fc (diff)
downloadchromium_src-7c1c307c7a4b599c114127ec971dc356639d415c.zip
chromium_src-7c1c307c7a4b599c114127ec971dc356639d415c.tar.gz
chromium_src-7c1c307c7a4b599c114127ec971dc356639d415c.tar.bz2
[NaCl SDK] Add multi-platform zip support, and example.
BUG=none R=sbc@chromium.org Review URL: https://codereview.chromium.org/241803002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264844 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--native_client_sdk/src/build_tools/generate_make.py2
-rwxr-xr-xnative_client_sdk/src/build_tools/parse_dsc.py3
-rw-r--r--native_client_sdk/src/build_tools/sdk_files.list2
-rw-r--r--native_client_sdk/src/examples/tutorial/multi_platform/README22
-rw-r--r--native_client_sdk/src/examples/tutorial/multi_platform/example.dsc20
-rw-r--r--native_client_sdk/src/examples/tutorial/multi_platform/example.js16
-rw-r--r--native_client_sdk/src/examples/tutorial/multi_platform/index.html21
-rw-r--r--native_client_sdk/src/examples/tutorial/multi_platform/multi_platform.cc36
-rw-r--r--native_client_sdk/src/resources/Makefile.example.template6
-rw-r--r--native_client_sdk/src/resources/manifest.json.template16
-rwxr-xr-xnative_client_sdk/src/tools/fix_manifest.py132
-rw-r--r--native_client_sdk/src/tools/nacl_gcc.mk150
12 files changed, 374 insertions, 52 deletions
diff --git a/native_client_sdk/src/build_tools/generate_make.py b/native_client_sdk/src/build_tools/generate_make.py
index d44d2a5..4188e7a 100644
--- a/native_client_sdk/src/build_tools/generate_make.py
+++ b/native_client_sdk/src/build_tools/generate_make.py
@@ -159,6 +159,7 @@ def GenerateManifest(srcroot, dstroot, desc):
'key': True,
'channel': None,
'permissions': pretty_permissions,
+ 'multi_platform': desc.get('MULTI_PLATFORM', False),
'version': build_version.ChromeVersionNoTrunk()
}
RunTemplateFileIfChanged(srcpath, dstpath, replace)
@@ -262,6 +263,7 @@ def ProcessProject(pepperdir, srcroot, dstroot, desc, toolchains, configs=None,
'tools': tools,
'sel_ldr': desc.get('SEL_LDR'),
'targets': desc['TARGETS'],
+ 'multi_platform': desc.get('MULTI_PLATFORM', False),
}
RunTemplateFileIfChanged(template, make_path, template_dict)
diff --git a/native_client_sdk/src/build_tools/parse_dsc.py b/native_client_sdk/src/build_tools/parse_dsc.py
index 1088fef..63e55d1 100755
--- a/native_client_sdk/src/build_tools/parse_dsc.py
+++ b/native_client_sdk/src/build_tools/parse_dsc.py
@@ -65,7 +65,8 @@ DSC_FORMAT = {
'GROUP': (str, '', False),
'EXPERIMENTAL': (bool, [True, False], False),
'PERMISSIONS': (list, '', False),
- 'SOCKET_PERMISSIONS': (list, '', False)
+ 'SOCKET_PERMISSIONS': (list, '', False),
+ 'MULTI_PLATFORM': (bool, [True, False], False),
}
diff --git a/native_client_sdk/src/build_tools/sdk_files.list b/native_client_sdk/src/build_tools/sdk_files.list
index 0427225..605cfce 100644
--- a/native_client_sdk/src/build_tools/sdk_files.list
+++ b/native_client_sdk/src/build_tools/sdk_files.list
@@ -40,6 +40,7 @@ examples/Makefile
examples/tutorial/debugging/*
examples/tutorial/dlopen/*
examples/tutorial/load_progress/*
+examples/tutorial/multi_platform/*
[win]examples/tutorial/make.bat
examples/tutorial/Makefile
examples/tutorial/testing/*
@@ -415,6 +416,7 @@ tools/create_nmf.py
tools/decode_dump.py
[linux,mac]tools/dump_syms
tools/fix_deps.py
+tools/fix_manifest.py
tools/genhttpfs.py
tools/getos.py
tools/host_gcc.mk
diff --git a/native_client_sdk/src/examples/tutorial/multi_platform/README b/native_client_sdk/src/examples/tutorial/multi_platform/README
new file mode 100644
index 0000000..08218fd
--- /dev/null
+++ b/native_client_sdk/src/examples/tutorial/multi_platform/README
@@ -0,0 +1,22 @@
+==================
+Multi-platform App
+==================
+
+Please see the online documentation here:
+
+ https://developer.chrome.com/native-client/devguide/distributing#packaged-application
+
+
+This example shows how to use the SDK build system to generate a Chrome App
+with support for multi-platform zip files.
+
+Starting with Chrome 28, the Chrome Web Store includes a feature called
+**multi-platform zip files.** This feature lets you structure your application
+directory and zip file in a way that reduces the size of the user download
+package. Here's how this feature works:
+
+* You still include all the .nexe files in the zip file that you upload to
+ the CWS, but you designate specific .nexe files (and other files if
+ appropriate) for specific architectures.
+* The Chrome Web Store re-packages your app, so that users only download
+ the files that they need for their specific architecture.
diff --git a/native_client_sdk/src/examples/tutorial/multi_platform/example.dsc b/native_client_sdk/src/examples/tutorial/multi_platform/example.dsc
new file mode 100644
index 0000000..ad5cc23
--- /dev/null
+++ b/native_client_sdk/src/examples/tutorial/multi_platform/example.dsc
@@ -0,0 +1,20 @@
+{
+ 'TOOLS': ['newlib', 'glibc'],
+ 'TARGETS': [
+ {
+ 'NAME': 'multi_platform',
+ 'TYPE': 'main',
+ 'SOURCES': ['multi_platform.cc'],
+ 'LIBS': ['ppapi_cpp', 'ppapi', 'pthread'],
+ }
+ ],
+ 'DATA': [
+ 'example.js',
+ 'README',
+ ],
+ 'DEST': 'examples/tutorial',
+ 'NAME': 'multi_platform',
+ 'TITLE': 'Multi-platform App',
+ 'GROUP': 'Tutorial',
+ 'MULTI_PLATFORM': True,
+}
diff --git a/native_client_sdk/src/examples/tutorial/multi_platform/example.js b/native_client_sdk/src/examples/tutorial/multi_platform/example.js
new file mode 100644
index 0000000..a2f86d0
--- /dev/null
+++ b/native_client_sdk/src/examples/tutorial/multi_platform/example.js
@@ -0,0 +1,16 @@
+// Copyright (c) 2014 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 moduleDidLoad() {
+ // The module is not hidden by default so we can easily see if the plugin
+ // failed to load.
+ common.hideModule();
+}
+
+// This function is called by common.js when a message is received from the
+// NaCl module.
+function handleMessage(message) {
+ var logEl = document.getElementById('log');
+ logEl.textContent += message.data;
+}
diff --git a/native_client_sdk/src/examples/tutorial/multi_platform/index.html b/native_client_sdk/src/examples/tutorial/multi_platform/index.html
new file mode 100644
index 0000000..14d7cee
--- /dev/null
+++ b/native_client_sdk/src/examples/tutorial/multi_platform/index.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <!--
+ Copyright (c) 2014 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>
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Expires" content="-1">
+ <title>{{title}}</title>
+ <script type="text/javascript" src="common.js"></script>
+ <script type="text/javascript" src="example.js"></script>
+</head>
+<body {{attrs}}>
+ <h1>{{title}}</h1>
+ <h2>Status: <code id="statusField">NO-STATUS</code></h2>
+ <div id="listener"></div>
+ <div id="log"></div>
+</body>
+</html>
diff --git a/native_client_sdk/src/examples/tutorial/multi_platform/multi_platform.cc b/native_client_sdk/src/examples/tutorial/multi_platform/multi_platform.cc
new file mode 100644
index 0000000..946808c
--- /dev/null
+++ b/native_client_sdk/src/examples/tutorial/multi_platform/multi_platform.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2014 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 "ppapi/cpp/instance.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/var.h"
+
+class Instance : public pp::Instance {
+ public:
+ explicit Instance(PP_Instance instance) : pp::Instance(instance) {}
+ virtual ~Instance() {}
+
+ virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) {
+ PostMessage("Hello, multi-platform!");
+ return true;
+ }
+};
+
+class Module : public pp::Module {
+ public:
+ Module() : pp::Module() {}
+ virtual ~Module() {}
+
+ virtual pp::Instance* CreateInstance(PP_Instance instance) {
+ return new Instance(instance);
+ }
+};
+
+namespace pp {
+
+Module* CreateModule() {
+ return new ::Module();
+}
+
+} // namespace pp
diff --git a/native_client_sdk/src/resources/Makefile.example.template b/native_client_sdk/src/resources/Makefile.example.template
index 7398d3c..73f3996 100644
--- a/native_client_sdk/src/resources/Makefile.example.template
+++ b/native_client_sdk/src/resources/Makefile.example.template
@@ -34,6 +34,12 @@ NACL_SDK_ROOT ?= $(abspath $(CURDIR)/{{rel_sdk}})
EXTRA_INC_PATHS={{' '.join(targets[0]['INCLUDES'])}}
[[]]
+[[if multi_platform:]]
+# Build with platform-specific subdirectories, to reduce the download size of
+# the app.
+MULTI_PLATFORM = 1
+[[]]
+
include $(NACL_SDK_ROOT)/tools/common.mk
[[if desc.get('SOCKET_PERMISSIONS'):]]
diff --git a/native_client_sdk/src/resources/manifest.json.template b/native_client_sdk/src/resources/manifest.json.template
index 31882ce..f240fd2 100644
--- a/native_client_sdk/src/resources/manifest.json.template
+++ b/native_client_sdk/src/resources/manifest.json.template
@@ -26,5 +26,21 @@
[[]]
"scopes": ["https://www.googleapis.com/auth/drive"]
},
+[[if multi_platform:]]
+ "platforms": [
+ {
+ "nacl_arch": "x86-64",
+ "sub_package_path": "_platform_specific/x86-64"
+ },
+ {
+ "nacl_arch": "x86-32",
+ "sub_package_path": "_platform_specific/x86-32"
+ },
+ {
+ "nacl_arch": "arm",
+ "sub_package_path": "_platform_specific/arm"
+ }
+ ],
+[[]]
"permissions": {{permissions}}
}
diff --git a/native_client_sdk/src/tools/fix_manifest.py b/native_client_sdk/src/tools/fix_manifest.py
new file mode 100755
index 0000000..c9b892f
--- /dev/null
+++ b/native_client_sdk/src/tools/fix_manifest.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python
+# Copyright (c) 2014 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.
+
+# Disable the lint error for too-long lines for the URL below.
+# pylint: disable=C0301
+
+"""Fix Chrome App manifest.json files for use with multi-platform zip files.
+
+See info about multi-platform zip files here:
+https://developer.chrome.com/native-client/devguide/distributing#packaged-application
+
+The manifest.json file needs to point to the correct platform-specific paths,
+but we build all toolchains and configurations in the same tree. As a result,
+we can't have one manifest.json for all combinations.
+
+Instead, we update the top-level manifest.json file during the build:
+
+ "platforms": [
+ {
+ "nacl_arch": "x86-64",
+ "sub_package_path": "_platform_specific/x86-64/"
+ },
+ ...
+
+Becomes
+
+ "platforms": [
+ {
+ "nacl_arch": "x86-64",
+ "sub_package_path": "<toolchain>/<config>/_platform_specific/x86-64/"
+ },
+ ...
+"""
+
+import collections
+import json
+import optparse
+import os
+import sys
+
+if sys.version_info < (2, 6, 0):
+ sys.stderr.write("python 2.6 or later is required run this script\n")
+ sys.exit(1)
+
+
+class Error(Exception):
+ """Local Error class for this file."""
+ pass
+
+
+def Trace(msg):
+ if Trace.verbose:
+ sys.stderr.write(str(msg) + '\n')
+
+Trace.verbose = False
+
+
+def main(argv):
+ parser = optparse.OptionParser(
+ usage='Usage: %prog [options] manifest.json', description=__doc__)
+ parser.add_option('-p', '--prefix',
+ help='Prefix to set for all sub_package_paths in the '
+ 'manifest. If none is specified, the prefix will be '
+ 'removed; i.e. the start of the path will be '
+ '"_platform_specific/..."')
+ parser.add_option('-v', '--verbose',
+ help='Verbose output', action='store_true')
+
+ options, args = parser.parse_args(argv)
+ if options.verbose:
+ Trace.verbose = True
+
+ if not args:
+ parser.error('Expected manifest file.')
+
+ manifest = args[0]
+
+ Trace('Reading %s' % manifest)
+ with open(manifest) as f:
+ # Keep the dictionary order. This is only supported on Python 2.7+
+ if sys.version_info >= (2, 7, 0):
+ data = json.load(f, object_pairs_hook=collections.OrderedDict)
+ else:
+ data = json.load(f)
+
+ if 'platforms' not in data:
+ raise Error('%s does not have "platforms" key.' % manifest)
+
+ platforms = data['platforms']
+ if type(platforms) is not list:
+ raise Error('Expected "platforms" key to be array.')
+
+ if options.prefix:
+ prefix = options.prefix + '/'
+ else:
+ prefix = ''
+
+ for platform in platforms:
+ nacl_arch = platform.get('nacl_arch')
+
+ if 'sub_package_path' not in platform:
+ raise Error('Expected each platform to have "sub_package_path" key.')
+
+ sub_package_path = platform['sub_package_path']
+ index = sub_package_path.find('_platform_specific')
+ if index == -1:
+ raise Error('Could not find "_platform_specific" in the '
+ '"sub_package_path" key.')
+
+ new_path = prefix + sub_package_path[index:]
+ platform['sub_package_path'] = new_path
+
+ Trace(' %s: "%s" -> "%s"' % (nacl_arch, sub_package_path, new_path))
+
+ with open(manifest, 'w') as f:
+ json.dump(data, f, indent=2)
+
+ return 0
+
+
+if __name__ == '__main__':
+ try:
+ rtn = main(sys.argv[1:])
+ except Error, e:
+ sys.stderr.write('%s: %s\n' % (os.path.basename(__file__), e))
+ rtn = 1
+ except KeyboardInterrupt:
+ sys.stderr.write('%s: interrupted\n' % os.path.basename(__file__))
+ rtn = 1
+ sys.exit(rtn)
diff --git a/native_client_sdk/src/tools/nacl_gcc.mk b/native_client_sdk/src/tools/nacl_gcc.mk
index 3dae078..832efeb 100644
--- a/native_client_sdk/src/tools/nacl_gcc.mk
+++ b/native_client_sdk/src/tools/nacl_gcc.mk
@@ -10,9 +10,6 @@
#
# Macros for TOOLS
#
-# We always link with the C++ compiler but include -Wl,-as-needed flag
-# in LDFLAGS so the linker should drop libc++ unless it's actually needed.
-#
ifneq ($(TOOLCHAIN),bionic)
X86_32_CC := $(NACL_COMPILER_PREFIX) $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_32 --tool=cc)
X86_32_CXX := $(NACL_COMPILER_PREFIX) $(shell $(NACL_CONFIG) -t $(TOOLCHAIN) -a x86_32 --tool=c++)
@@ -40,6 +37,17 @@ endif
NCVAL ?= python $(NACL_SDK_ROOT)/tools/ncval.py
+# Architecture-specific variables
+ifeq (,$(MULTI_PLATFORM))
+X86_32_OUTDIR ?= $(OUTDIR)
+X86_64_OUTDIR ?= $(OUTDIR)
+ARM_OUTDIR ?= $(OUTDIR)
+else
+X86_32_OUTDIR ?= $(OUTDIR)/_platform_specific/x86-32
+X86_64_OUTDIR ?= $(OUTDIR)/_platform_specific/x86-64
+ARM_OUTDIR ?= $(OUTDIR)/_platform_specific/arm
+endif
+
# Architecture-specific flags
X86_32_CFLAGS ?=
X86_64_CFLAGS ?=
@@ -55,9 +63,15 @@ ARM_CFLAGS ?=
ARM_CXXFLAGS ?=
endif
+ifeq (,$(MULTI_PLATFORM))
X86_32_LDFLAGS ?= -Wl,-Map,$(OUTDIR)/$(TARGET)_x86_32.map
X86_64_LDFLAGS ?= -Wl,-Map,$(OUTDIR)/$(TARGET)_x86_64.map
ARM_LDFLAGS ?= -Wl,-Map,$(OUTDIR)/$(TARGET)_arm.map
+else
+X86_32_LDFLAGS ?= -Wl,-Map,$(X86_32_OUTDIR)/$(TARGET)_x86_32.map
+X86_64_LDFLAGS ?= -Wl,-Map,$(X86_64_OUTDIR)/$(TARGET)_x86_64.map
+ARM_LDFLAGS ?= -Wl,-Map,$(ARM_OUTDIR)/$(TARGET)_arm.map
+endif
LDFLAGS_SHARED = -shared
@@ -185,52 +199,55 @@ GLIBC_REMAP :=
#
define SO_LINKER_RULE
ifneq (,$(findstring x86_32,$(ARCHES)))
-all: $(OUTDIR)/lib$(1)_x86_32.so
-$(OUTDIR)/lib$(1)_x86_32.so: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32_pic)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+all: $(X86_32_OUTDIR)/lib$(1)_x86_32.so
+$(X86_32_OUTDIR)/lib$(1)_x86_32.so: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32_pic)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(X86_32_LINK) -o $$@ $$(filter %.o,$$^) $(LDFLAGS_SHARED) -m32 $(NACL_LDFLAGS) $(X86_32_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(TOOLCHAIN)_x86_32/$(CONFIG)) $(foreach lib,$(3),-l$(lib)))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so
install: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so
-$(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so: $(OUTDIR)/lib$(1)_x86_32.so
+$(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).so: $(X86_32_OUTDIR)/lib$(1)_x86_32.so
$(MKDIR) -p $$(dir $$@)
$(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
ifneq ($(6),1)
-GLIBC_SO_LIST += $(OUTDIR)/lib$(1)_x86_32.so
+GLIBC_SO_LIST += $(X86_32_OUTDIR)/lib$(1)_x86_32.so
GLIBC_REMAP += -n lib$(1)_x86_32.so,lib$(1).so
endif
endif
ifneq (,$(findstring x86_64,$(ARCHES)))
-all: $(OUTDIR)/lib$(1)_x86_64.so
-$(OUTDIR)/lib$(1)_x86_64.so: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64_pic)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+all: $(X86_64_OUTDIR)/lib$(1)_x86_64.so
+$(X86_64_OUTDIR)/lib$(1)_x86_64.so: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64_pic)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(X86_32_LINK) -o $$@ $$(filter %.o,$$^) $(LDFLAGS_SHARED) -m64 $(NACL_LDFLAGS) $(X86_64_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(TOOLCHAIN)_x86_64/$(CONFIG)) $(foreach lib,$(3),-l$(lib)))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so
install: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so
-$(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so: $(OUTDIR)/lib$(1)_x86_64.so
+$(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).so: $(X86_64_OUTDIR)/lib$(1)_x86_64.so
$(MKDIR) -p $$(dir $$@)
$(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
ifneq ($(6),1)
-GLIBC_SO_LIST += $(OUTDIR)/lib$(1)_x86_64.so
+GLIBC_SO_LIST += $(X86_64_OUTDIR)/lib$(1)_x86_64.so
GLIBC_REMAP += -n lib$(1)_x86_64.so,lib$(1).so
endif
endif
ifneq (,$(findstring arm,$(ARCHES)))
-all: $(OUTDIR)/lib$(1)_arm.so
-$(OUTDIR)/lib$(1)_arm.so: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm_pic)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+all: $(ARM_OUTDIR)/lib$(1)_arm.so
+$(ARM_OUTDIR)/lib$(1)_arm.so: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm_pic)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(ARM_LINK) -o $$@ $$(filter %.o,$$^) $(LDFLAGS_SHARED) -marm $(NACL_LDFLAGS) $(ARM_LDFLAGS) $(LDFLAGS) $(foreach path,$(5),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so
install: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so
-$(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so: $(OUTDIR)/lib$(1)_arm.so
+$(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).so: $(ARM_OUTDIR)/lib$(1)_arm.so
$(MKDIR) -p $$(dir $$@)
$(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
ifneq ($(6),1)
-GLIBC_SO_LIST += $(OUTDIR)/lib$(1)_arm.so
+GLIBC_SO_LIST += $(ARM_OUTDIR)/lib$(1)_arm.so
GLIBC_REMAP += -n lib$(1)_arm.so,lib$(1).so
endif
endif
@@ -261,45 +278,45 @@ $(STAMPDIR)/$(1).stamp:
@echo "TOUCHED $$@" > $(STAMPDIR)/$(1).stamp
ifneq (,$(findstring x86_32,$(ARCHES)))
-all: $(OUTDIR)/lib$(1)_x86_32.a
-$(OUTDIR)/lib$(1)_x86_32.a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32))
+all: $(X86_32_OUTDIR)/lib$(1)_x86_32.a
+$(X86_32_OUTDIR)/lib$(1)_x86_32.a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32))
$(MKDIR) -p $$(dir $$@)
$(RM) -f $$@
$(call LOG,LIB ,$$@,$(X86_32_LIB) -cr $$@ $$^)
$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a
install: $(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a
-$(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a: $(OUTDIR)/lib$(1)_x86_32.a
+$(LIBDIR)/$(TOOLCHAIN)_x86_32/$(CONFIG)/lib$(1).a: $(X86_32_OUTDIR)/lib$(1)_x86_32.a
$(MKDIR) -p $$(dir $$@)
$(RM) -f $$@
$(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
endif
ifneq (,$(findstring x86_64,$(ARCHES)))
-all: $(OUTDIR)/lib$(1)_x86_64.a
-$(OUTDIR)/lib$(1)_x86_64.a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64))
+all: $(X86_64_OUTDIR)/lib$(1)_x86_64.a
+$(X86_64_OUTDIR)/lib$(1)_x86_64.a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64))
$(MKDIR) -p $$(dir $$@)
$(RM) -f $$@
$(call LOG,LIB ,$$@,$(X86_64_LIB) -cr $$@ $$^)
$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a
install: $(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a
-$(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a: $(OUTDIR)/lib$(1)_x86_64.a
+$(LIBDIR)/$(TOOLCHAIN)_x86_64/$(CONFIG)/lib$(1).a: $(X86_64_OUTDIR)/lib$(1)_x86_64.a
$(MKDIR) -p $$(dir $$@)
$(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
endif
ifneq (,$(findstring arm,$(ARCHES)))
ifneq ($(TOOLCHAIN),glibc)
-all: $(OUTDIR)/lib$(1)_arm.a
-$(OUTDIR)/lib$(1)_arm.a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm))
+all: $(ARM_OUTDIR)/lib$(1)_arm.a
+$(ARM_OUTDIR)/lib$(1)_arm.a: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm))
$(MKDIR) -p $$(dir $$@)
$(RM) -f $$@
$(call LOG,LIB ,$$@,$(ARM_LIB) -cr $$@ $$^)
$(STAMPDIR)/$(1).stamp: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a
install: $(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a
-$(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a: $(OUTDIR)/lib$(1)_arm.a
+$(LIBDIR)/$(TOOLCHAIN)_arm/$(CONFIG)/lib$(1).a: $(ARM_OUTDIR)/lib$(1)_arm.a
$(MKDIR) -p $$(dir $$@)
$(call LOG,CP ,$$@,$(OSHELPERS) cp $$^ $$@)
endif
@@ -319,22 +336,25 @@ endef
#
define LINKER_RULE
ifneq (,$(findstring x86_32,$(ARCHES)))
-all: $(OUTDIR)/$(1)_x86_32.nexe
-$(OUTDIR)/$(1)_x86_32.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+all: $(X86_32_OUTDIR)/$(1)_x86_32.nexe
+$(X86_32_OUTDIR)/$(1)_x86_32.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_32)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(X86_32_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(X86_32_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_x86_32/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
endif
ifneq (,$(findstring x86_64,$(ARCHES)))
-all: $(OUTDIR)/$(1)_x86_64.nexe
-$(OUTDIR)/$(1)_x86_64.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+all: $(X86_64_OUTDIR)/$(1)_x86_64.nexe
+$(X86_64_OUTDIR)/$(1)_x86_64.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_x86_64)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(X86_64_LINK) -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(X86_64_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_x86_64/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
endif
ifneq (,$(findstring arm,$(ARCHES)))
-all: $(OUTDIR)/$(1)_arm.nexe
-$(OUTDIR)/$(1)_arm.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+all: $(ARM_OUTDIR)/$(1)_arm.nexe
+$(ARM_OUTDIR)/$(1)_arm.nexe: $(foreach src,$(2),$(call SRC_TO_OBJ,$(src),_arm)) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
+ $(MKDIR) -p $$(dir $$@)
$(call LOG,LINK,$$@,$(ARM_LINK) -static -o $$@ $$(filter %.o,$$^) $(NACL_LDFLAGS) $(ARM_LDFLAGS) $(foreach path,$(6),-L$(path)/$(TOOLCHAIN)_arm/$(CONFIG)) $(foreach lib,$(3),-l$(lib)) $(5))
$(call LOG,VALIDATE,$$@,$(NCVAL) $$@)
endif
@@ -364,17 +384,17 @@ endef
#
define STRIP_ALL_RULE
ifneq (,$(findstring x86_32,$(ARCHES)))
-$(OUTDIR)/$(1)_x86_32.nexe: $(OUTDIR)/$(2)_x86_32.nexe
+$(X86_32_OUTDIR)/$(1)_x86_32.nexe: $(X86_32_OUTDIR)/$(2)_x86_32.nexe
$(call LOG,STRIP,$$@,$(X86_32_STRIP) -o $$@ $$^)
endif
ifneq (,$(findstring x86_64,$(ARCHES)))
-$(OUTDIR)/$(1)_x86_64.nexe: $(OUTDIR)/$(2)_x86_64.nexe
+$(X86_64_OUTDIR)/$(1)_x86_64.nexe: $(X86_64_OUTDIR)/$(2)_x86_64.nexe
$(call LOG,STRIP,$$@,$(X86_64_STRIP) -o $$@ $$^)
endif
ifneq (,$(findstring arm,$(ARCHES)))
-$(OUTDIR)/$(1)_arm.nexe: $(OUTDIR)/$(2)_arm.nexe
+$(ARM_OUTDIR)/$(1)_arm.nexe: $(ARM_OUTDIR)/$(2)_arm.nexe
$(call LOG,STRIP,$$@,$(ARM_STRIP) -o $$@ $$^)
endif
endef
@@ -399,20 +419,20 @@ endef
#
define MAP_ALL_RULE
ifneq (,$(findstring x86_32,$(ARCHES)))
-all: $(OUTDIR)/$(1)_x86_32.map
-$(OUTDIR)/$(1)_x86_32.map: $(OUTDIR)/$(2)_x86_32.nexe
+all: $(X86_32_OUTDIR)/$(1)_x86_32.map
+$(X86_32_OUTDIR)/$(1)_x86_32.map: $(X86_32_OUTDIR)/$(2)_x86_32.nexe
$(call LOG,MAP,$$@,$(X86_32_NM) -l $$^ > $$@)
endif
ifneq (,$(findstring x86_64,$(ARCHES)))
-all: $(OUTDIR)/$(1)_x86_64.map
-$(OUTDIR)/$(1)_x86_64.map: $(OUTDIR)/$(2)_x86_64.nexe
+all: $(X86_64_OUTDIR)/$(1)_x86_64.map
+$(X86_64_OUTDIR)/$(1)_x86_64.map: $(X86_64_OUTDIR)/$(2)_x86_64.nexe
$(call LOG,MAP,$$@,$(X86_64_NM) -l $$^ > $$@)
endif
ifneq (,$(findstring arm,$(ARCHES)))
-all: $(OUTDIR)/$(1)_arm.map
-$(OUTDIR)/$(1)_arm.map: $(OUTDIR)/$(2)_arm.nexe
+all: $(ARM_OUTDIR)/$(1)_arm.map
+$(ARM_OUTDIR)/$(1)_arm.map: $(ARM_OUTDIR)/$(2)_arm.nexe
$(call LOG,MAP,$$@,$(ARM_NM) -l $$^ > $$@ )
endif
endef
@@ -430,21 +450,14 @@ endef
#
-# Generate ARCH_SUFFIXES, a list of suffixes for executables corresponding to all
-# the architectures in the current build.
-#
-ARCH_SUFFIXES := $(foreach arch,$(ARCHES),_$(arch).nexe)
-
-
-#
-# NMF Manifest generation
+# NMF Manifiest generation
#
# 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.
#
-# $1 = Target Name (the basename of the nmf)
+# $1 = Target Name (the basename of the nmf
# $2 = Additional create_nmf.py arguments
#
NMF := python $(NACL_SDK_ROOT)/tools/create_nmf.py
@@ -453,12 +466,47 @@ NMF_FLAGS += --debug-libs
HTML_FLAGS += --debug-libs
endif
-EXECUTABLES=$(foreach arch,$(ARCH_SUFFIXES),$(OUTDIR)/$(1)$(arch)) $(GLIBC_SO_LIST)
+EXECUTABLES = $(GLIBC_SO_LIST)
+ifneq (,$(findstring x86_32,$(ARCHES)))
+EXECUTABLES += $(X86_32_OUTDIR)/$(1)_x86_32.nexe
+endif
+ifneq (,$(findstring x86_64,$(ARCHES)))
+EXECUTABLES += $(X86_64_OUTDIR)/$(1)_x86_64.nexe
+endif
+ifneq (,$(findstring arm,$(ARCHES)))
+EXECUTABLES += $(ARM_OUTDIR)/$(1)_arm.nexe
+endif
+
+ifneq (,$(MULTI_PLATFORM))
+# When building a multi-platform package, stage all dependent shared libraries
+# in the same directory as the .nexe (which will be an architecture-specific
+# directory under _platform_specific).
+NMF_FLAGS += -s $(OUTDIR) --no-arch-prefix
+else
+# Otherwise stage dependent libraries the normal way, under lib32 for x86_32
+# libraries, and lib64 for x86_64 libraries.
+NMF_FLAGS += -s $(OUTDIR)
+endif
+
+ifneq (,$(MULTI_PLATFORM))
+# This script fixes the manifest.json file for this App to point to:
+#
+# <toolchain>/<config>/_platform_specific/<arch>/
+#
+# instead of
+#
+# _platform_specific/<arch>
+FIX_MANIFEST := python $(NACL_SDK_ROOT)/tools/fix_manifest.py
+MANIFEST_JSON ?= manifest.json
+endif
define NMF_RULE
all: $(OUTDIR)/$(1).nmf
-$(OUTDIR)/$(1).nmf: $(EXECUTABLES)
- $(call LOG,CREATE_NMF,$$@,$(NMF) $(NMF_FLAGS) -o $$@ $$^ $(GLIBC_PATHS) -s $(OUTDIR) $(2) $(GLIBC_REMAP))
+$(OUTDIR)/$(1).nmf $(MANIFEST_JSON): $(EXECUTABLES)
+ $(call LOG,CREATE_NMF,$$@,$(NMF) $(NMF_FLAGS) -o $$@ $$^ $(GLIBC_PATHS) $(2) $(GLIBC_REMAP))
+ifneq (,$(MULTI_PLATFORM))
+ $(call LOG,FIX_MANIFEST,$(MANIFEST_JSON),$(FIX_MANIFEST) $(MANIFEST_JSON)) -p "$(TOOLCHAIN)/$(CONFIG)"
+endif
endef
#