Browse Source

Remove Rust from the tree.

Part 4 for #58
pull/1/head
wolfbeast 4 years ago committed by Roy Tam
parent
commit
963560a1d2
  1. 166
      build/moz.configure/rust.configure
  2. 1
      build/moz.configure/toolchain.configure
  3. 10
      build/mozconfig.rust
  4. 8
      build/templates.mozbuild
  5. 38
      config/rules.mk
  6. 4
      dom/media/gtest/moz.build
  7. 9
      media/libstagefright/gtest/moz.build
  8. 5
      media/libstagefright/moz.build
  9. 1
      old-configure.in
  10. 47
      python/mozbuild/mozbuild/backend/recursivemake.py
  11. 45
      python/mozbuild/mozbuild/frontend/data.py
  12. 69
      python/mozbuild/mozbuild/frontend/emitter.py
  13. 18
      python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/Cargo.toml
  14. 18
      python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/moz.build
  15. 6
      python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/shallow/Cargo.toml
  16. 9
      python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/the/depths/Cargo.toml
  17. 27
      python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/moz.build
  18. 15
      python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust1/Cargo.toml
  19. 4
      python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust1/moz.build
  20. 15
      python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust2/Cargo.toml
  21. 4
      python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust2/moz.build
  22. 15
      python/mozbuild/mozbuild/test/frontend/data/rust-library-dash-folding/Cargo.toml
  23. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-dash-folding/moz.build
  24. 15
      python/mozbuild/mozbuild/test/frontend/data/rust-library-invalid-crate-type/Cargo.toml
  25. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-invalid-crate-type/moz.build
  26. 12
      python/mozbuild/mozbuild/test/frontend/data/rust-library-name-mismatch/Cargo.toml
  27. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-name-mismatch/moz.build
  28. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-no-cargo-toml/moz.build
  29. 12
      python/mozbuild/mozbuild/test/frontend/data/rust-library-no-lib-section/Cargo.toml
  30. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-no-lib-section/moz.build
  31. 12
      python/mozbuild/mozbuild/test/frontend/data/rust-library-no-profile-section/Cargo.toml
  32. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-no-profile-section/moz.build
  33. 14
      python/mozbuild/mozbuild/test/frontend/data/rust-library-non-abort-panic/Cargo.toml
  34. 18
      python/mozbuild/mozbuild/test/frontend/data/rust-library-non-abort-panic/moz.build
  35. 73
      python/mozbuild/mozbuild/test/frontend/test_emitter.py
  36. 1
      third_party/rust/byteorder/.cargo-checksum.json
  37. 0
      third_party/rust/byteorder/.cargo-ok
  38. 6
      third_party/rust/byteorder/.gitignore
  39. 15
      third_party/rust/byteorder/.travis.yml
  40. 3
      third_party/rust/byteorder/COPYING
  41. 25
      third_party/rust/byteorder/Cargo.toml
  42. 21
      third_party/rust/byteorder/LICENSE-MIT
  43. 14
      third_party/rust/byteorder/Makefile
  44. 59
      third_party/rust/byteorder/README.md
  45. 24
      third_party/rust/byteorder/UNLICENSE
  46. 148
      third_party/rust/byteorder/benches/bench.rs
  47. 1
      third_party/rust/byteorder/session.vim
  48. 802
      third_party/rust/byteorder/src/lib.rs
  49. 269
      third_party/rust/byteorder/src/new.rs
  50. 1
      third_party/rust/gcc/.cargo-checksum.json
  51. 0
      third_party/rust/gcc/.cargo-ok
  52. 2
      third_party/rust/gcc/.gitignore
  53. 40
      third_party/rust/gcc/.travis.yml
  54. 23
      third_party/rust/gcc/Cargo.toml
  55. 201
      third_party/rust/gcc/LICENSE-APACHE
  56. 25
      third_party/rust/gcc/LICENSE-MIT
  57. 161
      third_party/rust/gcc/README.md
  58. 35
      third_party/rust/gcc/appveyor.yml
  59. 23
      third_party/rust/gcc/src/bin/gcc-shim.rs
  60. 898
      third_party/rust/gcc/src/lib.rs
  61. 169
      third_party/rust/gcc/src/registry.rs
  62. 423
      third_party/rust/gcc/src/windows_registry.rs
  63. 49
      third_party/rust/gcc/tests/cc_env.rs
  64. 111
      third_party/rust/gcc/tests/support/mod.rs
  65. 193
      third_party/rust/gcc/tests/test.rs
  66. 1
      third_party/rust/idna/.cargo-checksum.json
  67. 0
      third_party/rust/idna/.cargo-ok
  68. 24
      third_party/rust/idna/Cargo.toml
  69. 8190
      third_party/rust/idna/src/IdnaMappingTable.txt
  70. 73
      third_party/rust/idna/src/lib.rs
  71. 56
      third_party/rust/idna/src/make_uts46_mapping_table.py
  72. 213
      third_party/rust/idna/src/punycode.rs
  73. 322
      third_party/rust/idna/src/uts46.rs
  74. 8191
      third_party/rust/idna/src/uts46_mapping_table.rs
  75. 5097
      third_party/rust/idna/tests/IdnaTest.txt
  76. 65
      third_party/rust/idna/tests/punycode.rs
  77. 120
      third_party/rust/idna/tests/punycode_tests.json
  78. 25
      third_party/rust/idna/tests/tests.rs
  79. 117
      third_party/rust/idna/tests/uts46.rs
  80. 1
      third_party/rust/libc/.cargo-checksum.json
  81. 0
      third_party/rust/libc/.cargo-ok
  82. 3
      third_party/rust/libc/.gitignore
  83. 119
      third_party/rust/libc/.travis.yml
  84. 18
      third_party/rust/libc/Cargo.toml
  85. 201
      third_party/rust/libc/LICENSE-APACHE
  86. 25
      third_party/rust/libc/LICENSE-MIT
  87. 135
      third_party/rust/libc/README.md
  88. 21
      third_party/rust/libc/appveyor.yml
  89. 203
      third_party/rust/libc/ci/README.md
  90. 7
      third_party/rust/libc/ci/docker/aarch64-unknown-linux-gnu/Dockerfile
  91. 4
      third_party/rust/libc/ci/docker/arm-linux-androideabi/Dockerfile
  92. 7
      third_party/rust/libc/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile
  93. 5
      third_party/rust/libc/ci/docker/i686-unknown-linux-gnu/Dockerfile
  94. 13
      third_party/rust/libc/ci/docker/i686-unknown-linux-musl/Dockerfile
  95. 10
      third_party/rust/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile
  96. 14
      third_party/rust/libc/ci/docker/mipsel-unknown-linux-musl/Dockerfile
  97. 10
      third_party/rust/libc/ci/docker/powerpc-unknown-linux-gnu/Dockerfile
  98. 11
      third_party/rust/libc/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile
  99. 6
      third_party/rust/libc/ci/docker/x86_64-rumprun-netbsd/Dockerfile
  100. 13
      third_party/rust/libc/ci/docker/x86_64-unknown-freebsd/Dockerfile
  101. Some files were not shown because too many files have changed in this diff Show More

166
build/moz.configure/rust.configure vendored

@ -1,166 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
option('--enable-rust', help='Include Rust language sources')
@depends('--enable-rust')
def rust_compiler_names(value):
if value:
return ['rustc']
@depends('--enable-rust')
def cargo_binary_names(value):
if value:
return ['cargo']
rustc = check_prog('RUSTC', rust_compiler_names, allow_missing=True)
cargo = check_prog('CARGO', cargo_binary_names, allow_missing=True)
@depends_if(rustc)
@checking('rustc version', lambda info: info.version)
def rustc_info(rustc):
out = check_cmd_output(rustc, '--version', '--verbose').splitlines()
info = dict((s.strip() for s in line.split(':', 1)) for line in out[1:])
return namespace(
version=Version(info.get('release', '0')),
commit=info.get('commit-hash', 'unknown'),
)
@depends_if(cargo)
@checking('cargo support for --frozen')
@imports('subprocess')
@imports('os')
def cargo_supports_frozen(cargo):
try:
lines = subprocess.check_output(
[cargo, 'help', 'build']
).splitlines()
supported = any(' --frozen' in l for l in lines)
if 'MOZ_AUTOMATION' in os.environ and not supported:
die('cargo in automation must support --frozen')
return supported
except subprocess.CalledProcessError as e:
die('Failed to call cargo: %s', e.message)
set_config('MOZ_CARGO_SUPPORTS_FROZEN', cargo_supports_frozen)
@depends('--enable-rust', rustc, rustc_info)
@imports(_from='textwrap', _import='dedent')
def rust_compiler(value, rustc, rustc_info):
if value:
if not rustc:
die(dedent('''\
Rust compiler not found.
To compile rust language sources, you must have 'rustc' in your path.
See https//www.rust-lang.org/ for more information.
'''))
version = rustc_info.version
min_version = Version('1.10')
if version < min_version:
die(dedent('''\
Rust compiler {} is too old.
To compile Rust language sources please install at least
version {} of the 'rustc' toolchain and make sure it is
first in your path.
You can verify this by typing 'rustc --version'.
'''.format(version, min_version)))
return True
set_config('MOZ_RUST', rust_compiler)
@depends(rust_compiler, rustc, target, cross_compiling)
@imports('os')
@imports('subprocess')
@imports(_from='mozbuild.configure.util', _import='LineIO')
@imports(_from='mozbuild.shellutil', _import='quote')
@imports(_from='tempfile', _import='mkstemp')
def rust_target(rust_compiler, rustc, target, cross_compiling):
if rust_compiler:
# Rust's --target options are similar to, but not exactly the same
# as, the autoconf-derived targets we use. An example would be that
# Rust uses distinct target triples for targetting the GNU C++ ABI
# and the MSVC C++ ABI on Win32, whereas autoconf has a single
# triple and relies on the user to ensure that everything is
# compiled for the appropriate ABI. We need to perform appropriate
# munging to get the correct option to rustc.
#
# The canonical list of targets supported can be derived from:
#
# https://github.com/rust-lang/rust/tree/master/mk/cfg
# Avoid having to write out os+kernel for all the platforms where
# they don't differ.
os_or_kernel = target.kernel if target.kernel == 'Linux' and target.os != 'Android' else target.os
rustc_target = {
# DragonFly
('x86_64', 'DragonFly'): 'x86_64-unknown-dragonfly',
# FreeBSD
('x86', 'FreeBSD'): 'i686-unknown-freebsd',
('x86_64', 'FreeBSD'): 'x86_64-unknown-freebsd',
# NetBSD
('x86_64', 'NetBSD'): 'x86_64-unknown-netbsd',
# OpenBSD
('x86_64', 'OpenBSD'): 'x86_64-unknown-openbsd',
# Linux
('x86', 'Linux'): 'i586-unknown-linux-gnu',
# Linux
('x86_64', 'Linux'): 'x86_64-unknown-linux-gnu',
# OS X and iOS
('x86', 'OSX'): 'i686-apple-darwin',
('x86', 'iOS'): 'i386-apple-ios',
('x86_64', 'OSX'): 'x86_64-apple-darwin',
# Android
('x86', 'Android'): 'i686-linux-android',
('arm', 'Android'): 'armv7-linux-androideabi',
# Windows
# XXX better detection of CXX needed here, to figure out whether
# we need i686-pc-windows-gnu instead, since mingw32 builds work.
('x86', 'WINNT'): 'i686-pc-windows-msvc',
('x86_64', 'WINNT'): 'x86_64-pc-windows-msvc',
}.get((target.cpu, os_or_kernel), None)
if rustc_target is None:
die("Don't know how to translate {} for rustc".format(target.alias))
# Check to see whether our rustc has a reasonably functional stdlib
# for our chosen target.
target_arg = '--target=' + rustc_target
in_fd, in_path = mkstemp(prefix='conftest', suffix='.rs')
out_fd, out_path = mkstemp(prefix='conftest', suffix='.rlib')
os.close(out_fd)
try:
source = 'pub extern fn hello() { println!("Hello world"); }'
log.debug('Creating `%s` with content:', in_path)
with LineIO(lambda l: log.debug('| %s', l)) as out:
out.write(source)
os.write(in_fd, source)
os.close(in_fd)
cmd = [
rustc,
'--crate-type', 'staticlib',
target_arg,
'-o', out_path,
in_path,
]
def failed():
die('Cannot compile for {} with {}'.format(target.alias, rustc))
check_cmd_output(*cmd, onerror=failed)
if not os.path.exists(out_path) or os.path.getsize(out_path) == 0:
failed()
finally:
os.remove(in_path)
os.remove(out_path)
# This target is usable.
return rustc_target
set_config('RUST_TARGET', rust_target)
# Until we remove all the other Rust checks in old-configure.
add_old_configure_assignment('MOZ_RUST', rust_compiler)
add_old_configure_assignment('RUSTC', rustc)
add_old_configure_assignment('RUST_TARGET', rust_target)

1
build/moz.configure/toolchain.configure vendored

@ -907,4 +907,3 @@ set_config('WRAP_SYSTEM_INCLUDES', wrap_system_includes)
set_config('VISIBILITY_FLAGS', visibility_flags)
include('windows.configure')
include('rust.configure')

10
build/mozconfig.rust

@ -1,10 +0,0 @@
# Options to enable rust in automation builds.
# Tell configure to use the tooltool rustc.
# Assume this is compiled with --enable-rpath so we don't
# have to set LD_LIBRARY_PATH.
RUSTC="$topsrcdir/rustc/bin/rustc"
CARGO="$topsrcdir/cargo/bin/cargo"
# Enable rust in the build.
ac_add_options --enable-rust

8
build/templates.mozbuild

@ -60,14 +60,6 @@ def Library(name):
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
@template
def SharedLibrary(name):
'''Template for shared libraries.'''

38
config/rules.mk

@ -905,44 +905,6 @@ $(ASOBJS):
$(AS) $(ASOUTOPTION)$@ $(ASFLAGS) $($(notdir $<)_FLAGS) $(AS_DASH_C_FLAG) $(_VPATH_SRCS)
endif
ifdef MOZ_RUST
ifdef RUST_LIBRARY_FILE
# Permit users to pass flags to cargo from their mozconfigs (e.g. --color=always).
cargo_build_flags = $(CARGOFLAGS)
ifndef MOZ_DEBUG
cargo_build_flags = --release
endif
ifdef MOZ_CARGO_SUPPORTS_FROZEN
cargo_build_flags += --frozen
endif
cargo_build_flags += --manifest-path $(CARGO_FILE)
cargo_build_flags += --target=$(RUST_TARGET)
cargo_build_flags += --verbose
# Enable color output if original stdout was a TTY and color settings
# aren't already present. This essentially restores the default behavior
# of cargo when running via `mach`.
ifdef MACH_STDOUT_ISATTY
ifeq (,$(findstring --color,$(cargo_build_flags)))
cargo_build_flags += --color=always
endif
endif
# Assume any system libraries rustc links against are already in the target's LIBS.
#
# We need to run cargo unconditionally, because cargo is the only thing that
# has full visibility into how changes in Rust sources might affect the final
# build.
force-cargo-build:
$(REPORT_BUILD)
env CARGO_TARGET_DIR=. RUSTC=$(RUSTC) $(CARGO) build $(cargo_build_flags) --
$(RUST_LIBRARY_FILE): force-cargo-build
endif # CARGO_FILE
endif # MOZ_RUST
$(SOBJS):
$(REPORT_BUILD)
$(AS) -o $@ $(DEFINES) $(ASFLAGS) $($(notdir $<)_FLAGS) $(LOCAL_INCLUDES) -c $<

4
dom/media/gtest/moz.build

@ -35,10 +35,6 @@ if CONFIG['MOZ_WEBM_ENCODER']:
'TestWebMWriter.cpp',
]
if CONFIG['MOZ_RUST']:
UNIFIED_SOURCES += ['TestRust.cpp',]
TEST_HARNESS_FILES.gtest += [
'../test/gizmo-frag.mp4',
'../test/gizmo.mp4',

9
media/libstagefright/gtest/moz.build

@ -37,13 +37,4 @@ TEST_HARNESS_FILES.gtest += [
'test_case_1351094.mp4',
]
if CONFIG['MOZ_RUST']:
UNIFIED_SOURCES += ['TestMP4Rust.cpp',]
TEST_HARNESS_FILES.gtest += [
'../../../dom/media/test/street.mp4',
]
LOCAL_INCLUDES += [
'../binding/include',
]
FINAL_LIBRARY = 'xul-gtest'

5
media/libstagefright/moz.build

@ -80,11 +80,6 @@ SOURCES += [
'system/core/libutils/VectorImpl.cpp',
]
if CONFIG['MOZ_RUST']:
EXPORTS += [
'binding/include/mp4parse.h',
]
UNIFIED_SOURCES += [
'binding/Adts.cpp',
'binding/AnnexB.cpp',

1
old-configure.in

@ -6060,7 +6060,6 @@ export MOZ_ZLIB_CFLAGS
export MOZ_ZLIB_LIBS
export MOZ_APP_NAME
export MOZ_APP_REMOTINGNAME
export RUSTC
export MOZILLA_CENTRAL_PATH=$_topsrcdir
export STLPORT_CPPFLAGS
export STLPORT_LIBS

47
python/mozbuild/mozbuild/backend/recursivemake.py

@ -59,7 +59,6 @@ from ..frontend.data import (
ObjdirPreprocessedFiles,
PerSourceFlag,
Program,
RustLibrary,
SharedLibrary,
SimpleProgram,
Sources,
@ -574,12 +573,6 @@ class RecursiveMakeBackend(CommonBackend):
else:
return False
elif isinstance(obj, RustLibrary):
self.backend_input_files.add(obj.cargo_file)
self._process_rust_library(obj, backend_file)
# No need to call _process_linked_libraries, because Rust
# libraries are self-contained objects at this point.
elif isinstance(obj, SharedLibrary):
self._process_shared_library(obj, backend_file)
self._process_linked_libraries(obj, backend_file)
@ -1172,10 +1165,6 @@ class RecursiveMakeBackend(CommonBackend):
if libdef.no_expand_lib:
backend_file.write('NO_EXPAND_LIBS := 1\n')
def _process_rust_library(self, libdef, backend_file):
backend_file.write_once('RUST_LIBRARY_FILE := %s\n' % libdef.import_name)
backend_file.write('CARGO_FILE := $(srcdir)/Cargo.toml')
def _process_host_library(self, libdef, backend_file):
backend_file.write('HOST_LIBRARY_NAME = %s\n' % libdef.basename)
@ -1186,7 +1175,7 @@ class RecursiveMakeBackend(CommonBackend):
def _process_linked_libraries(self, obj, backend_file):
def write_shared_and_system_libs(lib):
for l in lib.linked_libraries:
if isinstance(l, (StaticLibrary, RustLibrary)):
if isinstance(l, StaticLibrary):
write_shared_and_system_libs(l)
else:
backend_file.write_once('SHARED_LIBS += %s/%s\n'
@ -1208,11 +1197,7 @@ class RecursiveMakeBackend(CommonBackend):
self._build_target_for_obj(lib))
relpath = pretty_relpath(lib)
if isinstance(obj, Library):
if isinstance(lib, RustLibrary):
# We don't need to do anything here; we will handle
# linkage for any RustLibrary elsewhere.
continue
elif isinstance(lib, StaticLibrary):
if isinstance(lib, StaticLibrary):
backend_file.write_once('STATIC_LIBS += %s/%s\n'
% (relpath, lib.import_name))
if isinstance(obj, SharedLibrary):
@ -1235,12 +1220,6 @@ class RecursiveMakeBackend(CommonBackend):
backend_file.write_once('HOST_LIBS += %s/%s\n'
% (relpath, lib.import_name))
# We have to link any Rust libraries after all intermediate static
# libraries have been listed to ensure that the Rust libraries are
# searched after the C/C++ objects that might reference Rust symbols.
if isinstance(obj, SharedLibrary):
self._process_rust_libraries(obj, backend_file, pretty_relpath)
for lib in obj.linked_system_libs:
if obj.KIND == 'target':
backend_file.write_once('OS_LIBS += %s\n' % lib)
@ -1250,23 +1229,6 @@ class RecursiveMakeBackend(CommonBackend):
# Process library-based defines
self._process_defines(obj.lib_defines, backend_file)
def _process_rust_libraries(self, obj, backend_file, pretty_relpath):
assert isinstance(obj, SharedLibrary)
# If this library does not depend on any Rust libraries, then we are done.
direct_linked = [l for l in obj.linked_libraries if isinstance(l, RustLibrary)]
if not direct_linked:
return
# We should have already checked this in Linkable.link_library.
assert len(direct_linked) == 1
# TODO: see bug 1310063 for checking dependencies are set up correctly.
direct_linked = direct_linked[0]
backend_file.write('RUST_STATIC_LIB_FOR_SHARED_LIB := %s/%s\n' %
(pretty_relpath(direct_linked), direct_linked.import_name))
def _process_final_target_files(self, obj, files, backend_file):
target = obj.install_target
path = mozpath.basedir(target, (
@ -1445,11 +1407,6 @@ class RecursiveMakeBackend(CommonBackend):
self._makefile_out_count += 1
def _handle_linked_rust_crates(self, obj, extern_crate_file):
backend_file = self._get_backend_file_for(obj)
backend_file.write('RS_STATICLIB_CRATE_SRC := %s\n' % extern_crate_file)
def _handle_ipdl_sources(self, ipdl_dir, sorted_ipdl_sources,
unified_ipdl_cppsrcs_mapping):
# Write out a master list of all IPDL source files.

45
python/mozbuild/mozbuild/frontend/data.py

@ -310,10 +310,6 @@ class LinkageWrongKindError(Exception):
"""Error thrown when trying to link objects of the wrong kind"""
class LinkageMultipleRustLibrariesError(Exception):
"""Error thrown when trying to link multiple Rust libraries to an object"""
class Linkable(ContextDerived):
"""Generic context derived container object for programs and libraries"""
__slots__ = (
@ -337,13 +333,6 @@ class Linkable(ContextDerived):
'Linkable.link_library() does not take components.')
if obj.KIND != self.KIND:
raise LinkageWrongKindError('%s != %s' % (obj.KIND, self.KIND))
# Linking multiple Rust libraries into an object would result in
# multiple copies of the Rust standard library, as well as linking
# errors from duplicate symbols.
if isinstance(obj, RustLibrary) and any(isinstance(l, RustLibrary)
for l in self.linked_libraries):
raise LinkageMultipleRustLibrariesError("Cannot link multiple Rust libraries into %s",
self)
self.linked_libraries.append(obj)
if obj.cxx_link:
self.cxx_link = True
@ -474,40 +463,6 @@ class StaticLibrary(Library):
self.no_expand_lib = no_expand_lib
class RustLibrary(StaticLibrary):
"""Context derived container object for a static library"""
__slots__ = (
'cargo_file',
'crate_type',
'dependencies',
'deps_path',
)
def __init__(self, context, basename, cargo_file, crate_type, dependencies, **args):
StaticLibrary.__init__(self, context, basename, **args)
self.cargo_file = cargo_file
self.crate_type = crate_type
# We need to adjust our naming here because cargo replaces '-' in
# package names defined in Cargo.toml with underscores in actual
# filenames. But we need to keep the basename consistent because
# many other things in the build system depend on that.
assert self.crate_type == 'staticlib'
self.lib_name = '%s%s%s' % (context.config.lib_prefix,
basename.replace('-', '_'),
context.config.lib_suffix)
self.dependencies = dependencies
# cargo creates several directories and places its build artifacts
# in those directories. The directory structure depends not only
# on the target, but also what sort of build we are doing.
rust_build_kind = 'release'
if context.config.substs.get('MOZ_DEBUG'):
rust_build_kind = 'debug'
build_dir = mozpath.join(context.config.substs['RUST_TARGET'],
rust_build_kind)
self.import_name = mozpath.join(build_dir, self.lib_name)
self.deps_path = mozpath.join(build_dir, 'deps')
class SharedLibrary(Library):
"""Context derived container object for a shared library"""
__slots__ = (

69
python/mozbuild/mozbuild/frontend/emitter.py

@ -61,7 +61,6 @@ from .data import (
PreprocessedTestWebIDLFile,
PreprocessedWebIDLFile,
Program,
RustLibrary,
SdkFiles,
SharedLibrary,
SimpleProgram,
@ -198,7 +197,7 @@ class TreeMetadataEmitter(LoggingMixin):
def _emit_libs_derived(self, contexts):
# First do FINAL_LIBRARY linkage.
for lib in (l for libs in self._libs.values() for l in libs):
if not isinstance(lib, (StaticLibrary, RustLibrary)) or not lib.link_into:
if not isinstance(lib, StaticLibrary) or not lib.link_into:
continue
if lib.link_into not in self._libs:
raise SandboxValidationError(
@ -408,66 +407,6 @@ class TreeMetadataEmitter(LoggingMixin):
'%s %s of crate %s refers to a non-existent path' % (description, dep_crate_name, crate_name),
context)
def _rust_library(self, context, libname, static_args):
# We need to note any Rust library for linking purposes.
cargo_file = mozpath.join(context.srcdir, 'Cargo.toml')
if not os.path.exists(cargo_file):
raise SandboxValidationError(
'No Cargo.toml file found in %s' % cargo_file, context)
config = self._parse_cargo_file(cargo_file)
crate_name = config['package']['name']
if crate_name != libname:
raise SandboxValidationError(
'library %s does not match Cargo.toml-defined package %s' % (libname, crate_name),
context)
# Check that the [lib.crate-type] field is correct
lib_section = config.get('lib', None)
if not lib_section:
raise SandboxValidationError(
'Cargo.toml for %s has no [lib] section' % libname,
context)
crate_type = lib_section.get('crate-type', None)
if not crate_type:
raise SandboxValidationError(
'Can\'t determine a crate-type for %s from Cargo.toml' % libname,
context)
crate_type = crate_type[0]
if crate_type != 'staticlib':
raise SandboxValidationError(
'crate-type %s is not permitted for %s' % (crate_type, libname),
context)
# Check that the [profile.{dev,release}.panic] field is "abort"
profile_section = config.get('profile', None)
if not profile_section:
raise SandboxValidationError(
'Cargo.toml for %s has no [profile] section' % libname,
context)
for profile_name in ['dev', 'release']:
profile = profile_section.get(profile_name, None)
if not profile:
raise SandboxValidationError(
'Cargo.toml for %s has no [profile.%s] section' % (libname, profile_name),
context)
panic = profile.get('panic', None)
if panic != 'abort':
raise SandboxValidationError(
('Cargo.toml for %s does not specify `panic = "abort"`'
' in [profile.%s] section') % (libname, profile_name),
context)
dependencies = set(config.get('dependencies', {}).iterkeys())
return RustLibrary(context, libname, cargo_file, crate_type,
dependencies, **static_args)
def _handle_linkables(self, context, passthru, generated_files):
linkables = []
host_linkables = []
@ -688,11 +627,7 @@ class TreeMetadataEmitter(LoggingMixin):
'generate_symbols_file', lib.symbols_file,
[symbols_file], defines)
if static_lib:
is_rust_library = context.get('IS_RUST_LIBRARY')
if is_rust_library:
lib = self._rust_library(context, libname, static_args)
else:
lib = StaticLibrary(context, libname, **static_args)
lib = StaticLibrary(context, libname, **static_args)
self._libs[libname].append(lib)
self._linkage.append((context, lib, 'USE_LIBS'))
linkables.append(lib)

18
python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/Cargo.toml

@ -1,18 +0,0 @@
[package]
name = "random-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["staticlib"]
[dependencies]
deep-crate = { version = "0.1.0", path = "the/depths" }
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

18
python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

6
python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/shallow/Cargo.toml

@ -1,6 +0,0 @@
[package]
name = "shallow-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]

9
python/mozbuild/mozbuild/test/frontend/data/crate-dependency-path-resolution/the/depths/Cargo.toml

@ -1,9 +0,0 @@
[package]
name = "deep-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[dependencies]
shallow-crate = { path = "../../shallow" }

27
python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/moz.build

@ -1,27 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
Library('test')
DIRS += [
'rust1',
'rust2',
]
USE_LIBS += [
'rust1',
'rust2',
]

15
python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust1/Cargo.toml

@ -1,15 +0,0 @@
[package]
name = "rust1"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["staticlib"]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

4
python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust1/moz.build

@ -1,4 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
RustLibrary('rust1')

15
python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust2/Cargo.toml

@ -1,15 +0,0 @@
[package]
name = "rust2"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["staticlib"]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

4
python/mozbuild/mozbuild/test/frontend/data/multiple-rust-libraries/rust2/moz.build

@ -1,4 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
RustLibrary('rust2')

15
python/mozbuild/mozbuild/test/frontend/data/rust-library-dash-folding/Cargo.toml

@ -1,15 +0,0 @@
[package]
name = "random-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["staticlib"]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-dash-folding/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

15
python/mozbuild/mozbuild/test/frontend/data/rust-library-invalid-crate-type/Cargo.toml

@ -1,15 +0,0 @@
[package]
name = "random-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["dylib"]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-invalid-crate-type/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

12
python/mozbuild/mozbuild/test/frontend/data/rust-library-name-mismatch/Cargo.toml

@ -1,12 +0,0 @@
[package]
name = "deterministic-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-name-mismatch/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-no-cargo-toml/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

12
python/mozbuild/mozbuild/test/frontend/data/rust-library-no-lib-section/Cargo.toml

@ -1,12 +0,0 @@
[package]
name = "random-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-no-lib-section/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

12
python/mozbuild/mozbuild/test/frontend/data/rust-library-no-profile-section/Cargo.toml

@ -1,12 +0,0 @@
[package]
name = "random-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["staticlib"]
[profile.release]
panic = "abort"

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-no-profile-section/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

14
python/mozbuild/mozbuild/test/frontend/data/rust-library-non-abort-panic/Cargo.toml

@ -1,14 +0,0 @@
[package]
name = "random-crate"
version = "0.1.0"
authors = [
"Nobody <nobody@mozilla.org>",
]
[lib]
crate-type = ["staticlib"]
[profile.dev]
panic = "unwind"
[profile.release]

18
python/mozbuild/mozbuild/test/frontend/data/rust-library-non-abort-panic/moz.build

@ -1,18 +0,0 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries.'''
LIBRARY_NAME = name
@template
def RustLibrary(name):
'''Template for Rust libraries.'''
Library(name)
IS_RUST_LIBRARY = True
RustLibrary('random-crate')

73
python/mozbuild/mozbuild/test/frontend/test_emitter.py

@ -31,7 +31,6 @@ from mozbuild.frontend.data import (
LinkageMultipleRustLibrariesError,
LocalInclude,
Program,
RustLibrary,
SdkFiles,
SharedLibrary,
SimpleProgram,
@ -1021,78 +1020,6 @@ class TestEmitterBasic(unittest.TestCase):
'Only source directory paths allowed in FINAL_TARGET_PP_FILES:'):
self.read_topsrcdir(reader)
def test_rust_library_no_cargo_toml(self):
'''Test that defining a RustLibrary without a Cargo.toml fails.'''
reader = self.reader('rust-library-no-cargo-toml')
with self.assertRaisesRegexp(SandboxValidationError,
'No Cargo.toml file found'):
self.read_topsrcdir(reader)
def test_rust_library_name_mismatch(self):
'''Test that defining a RustLibrary that doesn't match Cargo.toml fails.'''
reader = self.reader('rust-library-name-mismatch')
with self.assertRaisesRegexp(SandboxValidationError,
'library.*does not match Cargo.toml-defined package'):
self.read_topsrcdir(reader)
def test_rust_library_no_lib_section(self):
'''Test that a RustLibrary Cargo.toml with no [lib] section fails.'''
reader = self.reader('rust-library-no-lib-section')
with self.assertRaisesRegexp(SandboxValidationError,
'Cargo.toml for.* has no \\[lib\\] section'):
self.read_topsrcdir(reader)
def test_rust_library_no_profile_section(self):
'''Test that a RustLibrary Cargo.toml with no [profile] section fails.'''
reader = self.reader('rust-library-no-profile-section')
with self.assertRaisesRegexp(SandboxValidationError,
'Cargo.toml for.* has no \\[profile\\.dev\\] section'):
self.read_topsrcdir(reader)
def test_rust_library_invalid_crate_type(self):
'''Test that a RustLibrary Cargo.toml has a permitted crate-type.'''
reader = self.reader('rust-library-invalid-crate-type')
with self.assertRaisesRegexp(SandboxValidationError,
'crate-type.* is not permitted'):
self.read_topsrcdir(reader)
def test_rust_library_non_abort_panic(self):
'''Test that a RustLibrary Cargo.toml has `panic = "abort" set'''
reader = self.reader('rust-library-non-abort-panic')
with self.assertRaisesRegexp(SandboxValidationError,
'does not specify `panic = "abort"`'):
self.read_topsrcdir(reader)
def test_rust_library_dash_folding(self):
'''Test that on-disk names of RustLibrary objects convert dashes to underscores.'''
reader = self.reader('rust-library-dash-folding',
extra_substs=dict(RUST_TARGET='i686-pc-windows-msvc'))
objs = self.read_topsrcdir(reader)
self.assertEqual(len(objs), 1)
lib = objs[0]
self.assertIsInstance(lib, RustLibrary)
self.assertRegexpMatches(lib.lib_name, "random_crate")
self.assertRegexpMatches(lib.import_name, "random_crate")
self.assertRegexpMatches(lib.basename, "random-crate")
def test_multiple_rust_libraries(self):
'''Test that linking multiple Rust libraries throws an error'''
reader = self.reader('multiple-rust-libraries',
extra_substs=dict(RUST_TARGET='i686-pc-windows-msvc'))
with self.assertRaisesRegexp(LinkageMultipleRustLibrariesError,
'Cannot link multiple Rust libraries'):
self.read_topsrcdir(reader)
def test_crate_dependency_path_resolution(self):
'''Test recursive dependencies resolve with the correct paths.'''
reader = self.reader('crate-dependency-path-resolution',
extra_substs=dict(RUST_TARGET='i686-pc-windows-msvc'))
objs = self.read_topsrcdir(reader)
self.assertEqual(len(objs), 1)
self.assertIsInstance(objs[0], RustLibrary)
def test_android_res_dirs(self):
"""Test that ANDROID_RES_DIRS works properly."""
reader = self.reader('android-res-dirs')

1
third_party/rust/byteorder/.cargo-checksum.json vendored

@ -1 +0,0 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"2879af3c0512f976015d532e2d768f04ff22fdcf8745b69b955b78fda321c3fb",".travis.yml":"81545ce3c6c72111a68434464c3f9fa8df9cbe39759a081fac527628ab21ae0c","COPYING":"01c266bced4a434da0051174d6bee16a4c82cf634e2679b6155d40d75012390f","Cargo.toml":"a7282931b50dff2e463f82baaed95a9d76636bc0fef3e921acd8ca69eab32b83","LICENSE-MIT":"0f96a83840e146e43c0ec96a22ec1f392e0680e6c1226e6f3ba87e0740af850f","Makefile":"a45a128685a2ae7d4fa39d310786674417ee113055ef290a11f88002285865fc","README.md":"fbcc46b6d0a585096737f50922818b59016b69d959b05f1b29863b2af8e4da43","UNLICENSE":"7e12e5df4bae12cb21581ba157ced20e1986a0508dd10d0e8a4ab9a4cf94e85c","benches/bench.rs":"f583692d829c8dfe19b1d5b9e968ccf5c74d6733367ca183edff74041a6afedd","session.vim":"95cb1d7caf0ff7fbe76ec911988d908ddd883381c925ba64b537695bc9f021c4","src/lib.rs":"ef9e7a218fa3a4912c47f6840d32b975940d98277b6c9be85e8d7d045552eb87","src/new.rs":"161c21b7ebb5668c7cc70b46b0eb37709e06bb9c854f2fdfc6ce3d3babcbf3de"},"package":"0fc10e8cc6b2580fda3f36eb6dc5316657f812a3df879a44a66fc9f0fdbc4855"}

0
third_party/rust/byteorder/.cargo-ok vendored

6
third_party/rust/byteorder/.gitignore vendored

@ -1,6 +0,0 @@
.*.swp
doc
tags
build
target
Cargo.lock

15
third_party/rust/byteorder/.travis.yml vendored

@ -1,15 +0,0 @@
language: rust
matrix:
include:
- rust: "nightly"
env: TEST_SUITE=suite_nightly
- rust: "beta"
env: TEST_SUITE=suite_beta
- rust: "stable"
env: TEST_SUITE=suite_stable
script:
- cargo build --verbose
- cargo test --verbose
- if [ "$TEST_SUITE" = "suite_nightly" ]; then
cargo bench --verbose;
fi

3
third_party/rust/byteorder/COPYING vendored

@ -1,3 +0,0 @@
This project is dual-licensed under the Unlicense and MIT licenses.
You may use this code under the terms of either license.

25
third_party/rust/byteorder/Cargo.toml vendored

@ -1,25 +0,0 @@
[package]
name = "byteorder"
version = "0.5.3" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = "Library for reading/writing numbers in big-endian and little-endian."
documentation = "http://burntsushi.net/rustdoc/byteorder/"
homepage = "https://github.com/BurntSushi/byteorder"
repository = "https://github.com/BurntSushi/byteorder"
readme = "README.md"
keywords = ["byte", "endian", "big-endian", "little-endian", "binary"]
license = "Unlicense/MIT"
[lib]
name = "byteorder"
[dev-dependencies]
quickcheck = "0.2"
rand = "0.3"
[features]
default = ["std"]
std = []
[profile.bench]
opt-level = 3

21
third_party/rust/byteorder/LICENSE-MIT vendored

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2015 Andrew Gallant
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

14
third_party/rust/byteorder/Makefile vendored

@ -1,14 +0,0 @@
all:
echo Nothing to do...
ctags:
ctags --recurse --options=ctags.rust --languages=Rust
docs:
cargo doc
in-dir ./target/doc fix-perms
rscp ./target/doc/* gopher:~/www/burntsushi.net/rustdoc/
push:
git push origin master
git push github master

59
third_party/rust/byteorder/README.md vendored

@ -1,59 +0,0 @@
This crate provides convenience methods for encoding and decoding numbers in
either big-endian or little-endian order. This is meant to replace the old
methods defined on the standard library `Reader` and `Writer` traits.
[![Build status](https://api.travis-ci.org/BurntSushi/byteorder.png)](https://travis-ci.org/BurntSushi/byteorder)
[![](http://meritbadge.herokuapp.com/byteorder)](https://crates.io/crates/byteorder)
Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org).
### Documentation
[http://burntsushi.net/rustdoc/byteorder/](http://burntsushi.net/rustdoc/byteorder/).
The documentation includes examples.
### Installation
This crate works with Cargo and is on
[crates.io](https://crates.io/crates/byteorder). The package is regularly
updated. Add it to your `Cargo.toml` like so:
```toml
[dependencies]
byteorder = "0.5"
```
If you want to augment existing `Read` and `Write` traits, then import the
extension methods like so:
```rust
extern crate byteorder;
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian};
```
For example:
```rust
use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt};
let mut rdr = Cursor::new(vec![2, 5, 3, 0]);
// Note that we use type parameters to indicate which kind of byte order
// we want!
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());
```
### `no_std` crates
This crate has a feature, `std`, that is enabled by default. To use this crate
in a `no_std` context, add the following to your `Cargo.toml`:
```toml
[dependencies]
byteorder = { version = "0.5", default-features = false }
```

24
third_party/rust/byteorder/UNLICENSE vendored

@ -1,24 +0,0 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

148
third_party/rust/byteorder/benches/bench.rs vendored

@ -1,148 +0,0 @@
#![feature(test)]
extern crate byteorder;
extern crate test;
macro_rules! bench_num {
($name:ident, $read:ident, $bytes:expr, $data:expr) => (
mod $name {
use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian};
use super::test::Bencher;
use super::test::black_box as bb;
const NITER: usize = 100_000;
#[bench]
fn read_big_endian(b: &mut Bencher) {
let buf = $data;
b.iter(|| {
for _ in 0..NITER {
bb(BigEndian::$read(&buf, $bytes));
}
});
}
#[bench]
fn read_little_endian(b: &mut Bencher) {
let buf = $data;
b.iter(|| {
for _ in 0..NITER {
bb(LittleEndian::$read(&buf, $bytes));
}
});
}
#[bench]
fn read_native_endian(b: &mut Bencher) {
let buf = $data;
b.iter(|| {
for _ in 0..NITER {
bb(NativeEndian::$read(&buf, $bytes));
}
});
}
}
);
($ty:ident, $max:ident,
$read:ident, $write:ident, $size:expr, $data:expr) => (
mod $ty {
use std::$ty;
use byteorder::{ByteOrder, BigEndian, NativeEndian, LittleEndian};
use super::test::Bencher;
use super::test::black_box as bb;
const NITER: usize = 100_000;
#[bench]
fn read_big_endian(b: &mut Bencher) {
let buf = $data;
b.iter(|| {
for _ in 0..NITER {
bb(BigEndian::$read(&buf));
}
});
}
#[bench]
fn read_little_endian(b: &mut Bencher) {
let buf = $data;
b.iter(|| {
for _ in 0..NITER {
bb(LittleEndian::$read(&buf));
}
});
}
#[bench]
fn read_native_endian(b: &mut Bencher) {
let buf = $data;
b.iter(|| {
for _ in 0..NITER {
bb(NativeEndian::$read(&buf));
}
});
}
#[bench]
fn write_big_endian(b: &mut Bencher) {
let mut buf = $data;
let n = $ty::$max;
b.iter(|| {
for _ in 0..NITER {
bb(BigEndian::$write(&mut buf, n));
}
});
}
#[bench]
fn