diff options
author | Ben Murdoch <benm@google.com> | 2013-07-24 10:36:34 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2013-07-24 10:36:34 +0100 |
commit | a3f7b4e666c476898878fa745f637129375cd889 (patch) | |
tree | 1d78b48780e4c8603c226fd88d8f4b786f00bb81 /native_client_sdk | |
parent | d4336a7d5c149891bede0c3201c8e831520067af (diff) | |
download | chromium_org-a3f7b4e666c476898878fa745f637129375cd889.tar.gz |
Merge from Chromium at DEPS revision r213371
This commit was generated by merge_to_master.py.
Change-Id: I35a74205de4bff52a2dd6b15330f8a002a39efaf
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/build_tools/build_sdk.py | 170 | ||||
-rw-r--r-- | native_client_sdk/src/build_tools/sdk_files.list | 9 | ||||
-rw-r--r-- | native_client_sdk/src/examples/common.js | 67 | ||||
-rw-r--r-- | native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc | 4 | ||||
-rw-r--r-- | native_client_sdk/src/libraries/nacl_io/library.dsc | 2 |
5 files changed, 139 insertions, 113 deletions
diff --git a/native_client_sdk/src/build_tools/build_sdk.py b/native_client_sdk/src/build_tools/build_sdk.py index a4ab579d5f..190e5c33f7 100755 --- a/native_client_sdk/src/build_tools/build_sdk.py +++ b/native_client_sdk/src/build_tools/build_sdk.py @@ -61,30 +61,24 @@ GYPBUILD_DIR = 'gypbuild' options = None -def GetGlibcToolchain(arch): +def GetGlibcToolchain(host_arch): tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') - tcname = 'toolchain_%s_%s.tar.bz2' % (getos.GetPlatform(), arch) + tcname = 'toolchain_%s_%s.tar.bz2' % (getos.GetPlatform(), host_arch) return os.path.join(tcdir, tcname) -def GetNewlibToolchain(arch): +def GetNewlibToolchain(host_arch): tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') - tcname = 'naclsdk_%s_%s.tgz' % (getos.GetPlatform(), arch) + tcname = 'naclsdk_%s_%s.tgz' % (getos.GetPlatform(), host_arch) return os.path.join(tcdir, tcname) -def GetPNaClToolchain(arch): +def GetPNaClToolchain(host_arch): tcdir = os.path.join(NACL_DIR, 'toolchain', '.tars') - tcname = 'naclsdk_pnacl_%s_%s.tgz' % (getos.GetPlatform(), arch) + tcname = 'naclsdk_pnacl_%s_%s.tgz' % (getos.GetPlatform(), host_arch) return os.path.join(tcdir, tcname) -def GetArchName(arch, xarch=None): - if xarch: - return arch + '-' + str(xarch) - return arch - - def GetToolchainNaClInclude(tcname, tcpath, arch): if arch == 'x86': if tcname == 'pnacl': @@ -96,43 +90,55 @@ def GetToolchainNaClInclude(tcname, tcpath, arch): buildbot_common.ErrorExit('Unknown architecture: %s' % arch) -def GetToolchainNaClLib(tcname, tcpath, arch, xarch): - if arch == 'x86': - if tcname == 'pnacl': - return os.path.join(tcpath, 'newlib', 'sdk', 'lib') - if str(xarch) == '32': - return os.path.join(tcpath, 'x86_64-nacl', 'lib32') - if str(xarch) == '64': - return os.path.join(tcpath, 'x86_64-nacl', 'lib') - if str(xarch) == 'arm': - return os.path.join(tcpath, 'arm-nacl', 'lib') - buildbot_common.ErrorExit('Unknown architecture: %s' % arch) +def GetGypGenDir(xarch): + if xarch == 'arm': + build_dir = GYPBUILD_DIR + '-arm' + else: + build_dir = GYPBUILD_DIR + return os.path.join(OUT_DIR, build_dir, 'Release', 'gen') -def GetPNaClNativeLib(tcpath, arch): - if arch not in ['arm', 'x86-32', 'x86-64']: - buildbot_common.ErrorExit('Unknown architecture %s.' % arch) - return os.path.join(tcpath, 'lib-' + arch) +def GetGypBuiltLib(tcname, xarch=None): + if tcname == 'pnacl': + tcname = 'pnacl_newlib' + if not xarch: + xarch = '' + return os.path.join(GetGypGenDir(xarch), 'tc_' + tcname, 'lib' + xarch) -def GetSconsArgs(tcpath, outdir, arch, xarch=None): - """Return list of scons build arguments to generate user libraries. +def GetToolchainNaClLib(tcname, tcpath, xarch): + if tcname == 'pnacl': + return os.path.join(tcpath, 'newlib', 'sdk', 'lib') + if xarch == '32': + return os.path.join(tcpath, 'x86_64-nacl', 'lib32') + if xarch == '64': + return os.path.join(tcpath, 'x86_64-nacl', 'lib') + if xarch == 'arm': + return os.path.join(tcpath, 'arm-nacl', 'lib') - Only used for pnacl builds. - """ - if getos.GetPlatform() == 'win': - scons = 'scons.bat' - else: - scons = './scons' - mode = '--mode=opt-host,nacl' - arch_name = GetArchName(arch, xarch) - plat = 'platform=' + arch_name - binarg = 'bindir=' + os.path.join(outdir, 'tools') - lib = 'libdir=' + GetToolchainNaClLib('pnacl', tcpath, arch, xarch) - args = [scons, mode, plat, binarg, lib, '-j10', 'install_lib', 'bitcode=1'] - print "Building pnacl (%s): %s" % (arch, ' '.join(args)) - return args +def GetToolchainDirName(tcname, xarch): + if xarch != 'arm': + xarch = 'x86' + return '%s_%s_%s' % (getos.GetPlatform(), xarch, tcname) + + +def GetGypToolchainLib(tcname, xarch): + tcpath = os.path.join(GetGypGenDir(xarch), 'sdk', 'toolchain', + GetToolchainDirName(tcname, xarch)) + return GetToolchainNaClLib(tcname, tcpath, xarch) + + +def GetOutputToolchainLib(pepperdir, tcname, xarch): + tcpath = os.path.join(pepperdir, 'toolchain', + GetToolchainDirName(tcname, xarch)) + return GetToolchainNaClLib(tcname, tcpath, xarch) + + +def GetPNaClNativeLib(tcpath, arch): + if arch not in ['arm', 'x86-32', 'x86-64']: + buildbot_common.ErrorExit('Unknown architecture %s.' % arch) + return os.path.join(tcpath, 'lib-' + arch) def BuildStepDownloadToolchains(): @@ -365,6 +371,17 @@ TOOLCHAIN_LIBS = { 'libppapi.a', 'libppapi.so', 'libppapi_stub.a', + ], + 'pnacl': [ + 'libminidump_generator.a', + 'libnacl.a', + 'libnacl_dyncode.a', + 'libnacl_exception.a', + 'libnacl_list_mappings.a', + 'libnosys.a', + 'libppapi.a', + 'libppapi_stub.a', + 'libpthread.a', ] } @@ -410,31 +427,23 @@ def GypNinjaInstall(pepperdir, toolchains): InstallFiles(ninja_out_dir, os.path.join(pepperdir, 'tools'), tools_files) - for tc in set(toolchains) & set(['newlib', 'glibc']): - for archname in ('arm', '32', '64'): - if tc == 'glibc' and archname == 'arm': - continue - tc_dir = 'tc_' + tc - lib_dir = 'lib' + archname - if archname == 'arm': - build_dir = GYPBUILD_DIR + '-arm' - tcdir = '%s_arm_%s' % (platform, tc) - else: - build_dir = GYPBUILD_DIR - tcdir = '%s_x86_%s' % (platform, tc) + for tc in set(toolchains) & set(['newlib', 'glibc', 'pnacl']): + if tc == 'pnacl': + xarches = (None,) + else: + xarches = ('arm', '32', '64') - ninja_out_dir = os.path.join(OUT_DIR, build_dir, 'Release') - src_dir = os.path.join(ninja_out_dir, 'gen', tc_dir, lib_dir) - tcpath = os.path.join(pepperdir, 'toolchain', tcdir) - dst_dir = GetToolchainNaClLib(tc, tcpath, 'x86', archname) + for xarch in xarches: + if tc == 'glibc' and xarch == 'arm': + continue + src_dir = GetGypBuiltLib(tc, xarch) + dst_dir = GetOutputToolchainLib(pepperdir, tc, xarch) InstallFiles(src_dir, dst_dir, TOOLCHAIN_LIBS[tc]) - ninja_tcpath = os.path.join(ninja_out_dir, 'gen', 'sdk', 'toolchain', - tcdir) - lib_dir = GetToolchainNaClLib(tc, ninja_tcpath, 'x86', archname) - buildbot_common.CopyFile(os.path.join(lib_dir, 'crt1.o'), dst_dir) - + if tc != 'pnacl': + src_dir = GetGypToolchainLib(tc, xarch) + InstallFiles(src_dir, dst_dir, ['crt1.o']) def GypNinjaBuild_NaCl(rel_out_dir): @@ -501,16 +510,6 @@ def GypNinjaBuild_Pnacl(rel_out_dir, target_arch): targets = ['pnacl_irt_shim'] GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir, False) - gyp_py = os.path.join(NACL_DIR, 'build', 'gyp_nacl') - gyp_file = os.path.join(NACL_DIR, 'src', 'untrusted', 'minidump_generator', - 'minidump_generator.gyp') - targets = ['minidump_generator_lib'] - GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir, False) - - gyp_file = os.path.join(NACL_DIR, 'src', 'untrusted', 'nacl', 'nacl.gyp') - targets = ['nacl_exception_lib'] - GypNinjaBuild(target_arch, gyp_py, gyp_file, targets, out_dir, False) - def GypNinjaBuild(arch, gyp_py_script, gyp_file, targets, out_dir, force_arm_gcc=True): @@ -582,14 +581,6 @@ def BuildStepBuildToolchains(pepperdir, toolchains): 'arm') if 'pnacl' in toolchains: - # shell=True is needed on windows to enable searching of the PATH: - # http://bugs.python.org/issue8557 - shell = platform == 'win' - buildbot_common.Run( - GetSconsArgs(pnacldir, pepperdir, 'x86', '32'), - cwd=NACL_DIR, - shell=shell) - # NOTE: For ia32, gyp builds both x86-32 and x86-64 by default. for arch in ('ia32', 'arm'): # Fill in the latest native pnacl shim library from the chrome build. @@ -610,25 +601,10 @@ def BuildStepBuildToolchains(pepperdir, toolchains): os.path.join(release_build_dir, 'libpnacl_irt_shim.a'), GetPNaClNativeLib(pnacldir, nacl_arch)) - # TODO: should these next couple of bitcode libraries really be - # installed to the native library directory instead of bitcode - # library directory? - release_build_dir = os.path.join(OUT_DIR, build_dir, 'Release', - 'gen', 'tc_pnacl_newlib', 'lib') - buildbot_common.CopyFile( - os.path.join(release_build_dir, 'libminidump_generator.a'), - GetPNaClNativeLib(pnacldir, nacl_arch)) - - buildbot_common.CopyFile( - os.path.join(release_build_dir, 'libnacl_exception.a'), - GetPNaClNativeLib(pnacldir, nacl_arch)) - InstallNaClHeaders(GetToolchainNaClInclude('pnacl', pnacldir, 'x86'), 'newlib') - - def MakeDirectoryOrClobber(pepperdir, dirname, clobber): dirpath = os.path.join(pepperdir, dirname) if clobber: diff --git a/native_client_sdk/src/build_tools/sdk_files.list b/native_client_sdk/src/build_tools/sdk_files.list index 11133cba38..50710c5590 100644 --- a/native_client_sdk/src/build_tools/sdk_files.list +++ b/native_client_sdk/src/build_tools/sdk_files.list @@ -1181,6 +1181,15 @@ toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/include/nacl/nacl_thread.h toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/include/pnacl.h toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/include/pthread.h toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/include/semaphore.h +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libminidump_generator.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libnacl.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libnacl_dyncode.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libnacl_exception.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libnacl_list_mappings.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libnosys.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libppapi.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libppapi_stub.a +toolchain/${PLATFORM}_x86_pnacl/newlib/sdk/lib/libpthread.a tools/common.mk tools/compiler-wrapper.py tools/create_html.py diff --git a/native_client_sdk/src/examples/common.js b/native_client_sdk/src/examples/common.js index 1562924d03..0d355bffb7 100644 --- a/native_client_sdk/src/examples/common.js +++ b/native_client_sdk/src/examples/common.js @@ -14,6 +14,52 @@ var isTest = false; // 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. + * @param {bool} isRelease True if this is a release build. + * @return {string} The mime-type for the kind of NaCl plugin matching + * the given toolchain. + */ + function mimeTypeForTool(tool, isRelease) { + // 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') { + 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; + } + /** * Create the Native Client <embed> element as a child of the DOM element * named "listener". @@ -41,19 +87,7 @@ var common = (function() { } } - // For NaCL modules use application/x-nacl. - var mimetype = 'application/x-nacl'; - var isHost = tool == 'win' || tool == 'linux' || tool == 'mac'; - if (isHost) { - // For non-nacl PPAPI plugins use the x-ppapi-debug/release - // mime type. - if (path.toLowerCase().indexOf('release') != -1) - mimetype = 'application/x-ppapi-release'; - else - mimetype = 'application/x-ppapi-debug'; - } else if (tool == 'pnacl') { - mimetype = 'application/x-pnacl'; - } + var mimetype = mimeTypeForTool(tool); moduleEl.setAttribute('type', mimetype); // The <EMBED> element is wrapped inside a <DIV>, which has both a 'load' @@ -65,6 +99,7 @@ var common = (function() { 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() { var evt = document.createEvent('Event'); @@ -258,7 +293,11 @@ var common = (function() { // status message indicating that the module is still loading. Otherwise, // do not change the status message. updateStatus('Page loaded.'); - if (common.naclModule == null) { + var isRelease = path.toLowerCase().indexOf('release') != -1; + if (!browserSupportsNaCl(tool, isRelease)) { + 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 diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc index d99178595b..77b8b60bce 100644 --- a/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc +++ b/native_client_sdk/src/libraries/nacl_io/kernel_wrap_win.cc @@ -15,6 +15,8 @@ #include <sys/stat.h> #include "nacl_io/kernel_intercept.h" +#include <windows.h> + namespace { template <typename SrcStat, typename DstStat> @@ -317,7 +319,7 @@ uint64_t usec_since_epoch() { ularge.HighPart = ft.dwHighDateTime; // Truncate to usec resolution. - return usecs = ularge.QuadPart / 10; + return ularge.QuadPart / 10; } // Do nothing for Windows, we replace the library at link time. diff --git a/native_client_sdk/src/libraries/nacl_io/library.dsc b/native_client_sdk/src/libraries/nacl_io/library.dsc index 6d65846ccd..217a93da24 100644 --- a/native_client_sdk/src/libraries/nacl_io/library.dsc +++ b/native_client_sdk/src/libraries/nacl_io/library.dsc @@ -1,5 +1,5 @@ { - 'TOOLS': ['newlib', 'glibc', 'pnacl'], + 'TOOLS': ['newlib', 'glibc', 'pnacl', 'win'], 'SEARCH': [ '.', 'pepper' |