build(rust): vendor googletest crate
This commit was merged in pull request #76.
This commit is contained in:
1
third_party/crates/autocfg-1.5.1/.cargo-checksum.json
vendored
Normal file
1
third_party/crates/autocfg-1.5.1/.cargo-checksum.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"$comment":"This file only protects against accidental modifications. It is not a security mechanism and does not protect against malicious changes.","files":{".cargo_vcs_info.json":"5713fb5e9d7124071a4fb0d0f8f80535560c7cef1995c42fe168af1c2627a050","Cargo.lock":"dc8d767ba9ab277c030476ca736afce4ecb4999a01bd3db8c8210a12ef79e81c","Cargo.toml":"ed7c832b4250c3be736e040d68688c2b83a5b164a93ef533e61532cbe0d44e99","Cargo.toml.orig":"57d2aec0d4157bd9446f97705aa2acff86cc3d1883f470526fed089e7cf9754e","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"27995d58ad5c1145c1a8cd86244ce844886958a35eb2b78c6b772748669999ac","README.md":"1c6c43f1d22ab1c6411b82862c356c550947f3cecbb4c7eede5edefc8890ff32","examples/integers.rs":"589ff4271566dfa322becddf3e2c7b592e6e0bc97b02892ce75619b7e452e930","examples/nightly.rs":"ac8b5a9aa1e04465e44f5053b3c899b635e07af058c73aa8b45176bf4b5912f9","examples/paths.rs":"1b30e466b824ce8df7ad0a55334424131d9d2573d6cf9f7d5d50c09c8901d526","examples/traits.rs":"cbee6a3e1f7db60b02ae25b714926517144a77cb492021f492774cf0e1865a9e","examples/versions.rs":"38535e6d9f5bfae0de474a3db79a40e8f5da8ba9334c5ff4c363de9bc99d4d12","src/error.rs":"fd8ff67c64f7cd1b9f81325a81de4baa34c39d6ae298bdb33f9829cc91acac39","src/lib.rs":"772630d0e09d06f343fd72284c8330eacde87d2a4ee22f70af62a0e2119fbf05","src/rustc.rs":"a8a213ddb64a05c1a1af933bcb331a98879e942b167c33d8f94f9f60ebb14e29","src/tests.rs":"b39f4d880ad343e65307a9e0c381954ea27adce4732f825516ce7952e2e5a91d","src/version.rs":"4f7d23b36f01c7be1871be86c038d6cb4689e145d67c82d3793690e9aa05b133","tests/no_std.rs":"18859dc4992fe1769887bde05f03d28f1ce524eafd17646d3fbcb4379422761a","tests/rustflags.rs":"e8ded4d57ba25379a38ab48456d67df14f82abbbb5f6bb66221c6decbcb517a3","tests/support/mod.rs":"32087d365b438ac3f62df9bb066d8d648b80cb130a5c777afcb2f21fbb68d88e","tests/tests.rs":"39149fe69a45f577eeb531587a5e600d8bc9f8d937480172dac9402939d856f0","tests/wrappers.rs":"96aee2217fbfc7a3aff16e70609c885620a4704dfd708de8b2d0bad4a8c6247d"},"package":"f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"}
|
||||
6
third_party/crates/autocfg-1.5.1/.cargo_vcs_info.json
vendored
Normal file
6
third_party/crates/autocfg-1.5.1/.cargo_vcs_info.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "2799b09c24e6632f8e653c5cd8fc303e85a906ba"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
110
third_party/crates/autocfg-1.5.1/BUILD.bazel
vendored
Normal file
110
third_party/crates/autocfg-1.5.1/BUILD.bazel
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
###############################################################################
|
||||
# @generated
|
||||
# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To
|
||||
# regenerate this file, run the following:
|
||||
#
|
||||
# bazel run @@//third_party:vendor_crates
|
||||
###############################################################################
|
||||
|
||||
load("@rules_rust//cargo:defs.bzl", "cargo_toml_env_vars")
|
||||
load("@rules_rust//rust:defs.bzl", "rust_library")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cargo_toml_env_vars(
|
||||
name = "cargo_toml_env_vars",
|
||||
src = "Cargo.toml",
|
||||
)
|
||||
|
||||
rust_library(
|
||||
name = "autocfg",
|
||||
srcs = glob(
|
||||
include = ["**/*.rs"],
|
||||
allow_empty = False,
|
||||
),
|
||||
compile_data = glob(
|
||||
include = ["**"],
|
||||
allow_empty = True,
|
||||
exclude = [
|
||||
"**/* *",
|
||||
".tmp_git_root/**/*",
|
||||
"BUILD",
|
||||
"BUILD.bazel",
|
||||
"WORKSPACE",
|
||||
"WORKSPACE.bazel",
|
||||
],
|
||||
),
|
||||
crate_root = "src/lib.rs",
|
||||
edition = "2015",
|
||||
rustc_env_files = [
|
||||
":cargo_toml_env_vars",
|
||||
],
|
||||
rustc_flags = [
|
||||
"--cap-lints=allow",
|
||||
],
|
||||
tags = [
|
||||
"cargo-bazel",
|
||||
"crate-name=autocfg",
|
||||
"manual",
|
||||
"noclippy",
|
||||
"norustfmt",
|
||||
],
|
||||
target_compatible_with = select({
|
||||
"@rules_rust//rust/platform:aarch64-apple-darwin": [],
|
||||
"@rules_rust//rust/platform:aarch64-apple-ios": [],
|
||||
"@rules_rust//rust/platform:aarch64-apple-ios-macabi": [],
|
||||
"@rules_rust//rust/platform:aarch64-apple-ios-sim": [],
|
||||
"@rules_rust//rust/platform:aarch64-linux-android": [],
|
||||
"@rules_rust//rust/platform:aarch64-pc-windows-msvc": [],
|
||||
"@rules_rust//rust/platform:aarch64-unknown-fuchsia": [],
|
||||
"@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:aarch64-unknown-nixos-gnu": [],
|
||||
"@rules_rust//rust/platform:aarch64-unknown-none": [],
|
||||
"@rules_rust//rust/platform:aarch64-unknown-nto-qnx710": [],
|
||||
"@rules_rust//rust/platform:aarch64-unknown-uefi": [],
|
||||
"@rules_rust//rust/platform:arm-unknown-linux-gnueabi": [],
|
||||
"@rules_rust//rust/platform:arm-unknown-linux-musleabi": [],
|
||||
"@rules_rust//rust/platform:armv7-linux-androideabi": [],
|
||||
"@rules_rust//rust/platform:armv7-unknown-linux-gnueabi": [],
|
||||
"@rules_rust//rust/platform:i686-apple-darwin": [],
|
||||
"@rules_rust//rust/platform:i686-linux-android": [],
|
||||
"@rules_rust//rust/platform:i686-pc-windows-msvc": [],
|
||||
"@rules_rust//rust/platform:i686-unknown-freebsd": [],
|
||||
"@rules_rust//rust/platform:i686-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:loongarch64-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:mips-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:powerpc-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:riscv32imac-unknown-none-elf": [],
|
||||
"@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [],
|
||||
"@rules_rust//rust/platform:riscv64gc-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:riscv64gc-unknown-none-elf": [],
|
||||
"@rules_rust//rust/platform:s390x-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:sparc64-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:sparc64-unknown-netbsd": [],
|
||||
"@rules_rust//rust/platform:sparc64-unknown-openbsd": [],
|
||||
"@rules_rust//rust/platform:thumbv6m-none-eabi": [],
|
||||
"@rules_rust//rust/platform:thumbv7em-none-eabi": [],
|
||||
"@rules_rust//rust/platform:thumbv7em-none-eabihf": [],
|
||||
"@rules_rust//rust/platform:thumbv7m-none-eabi": [],
|
||||
"@rules_rust//rust/platform:thumbv8m.main-none-eabi": [],
|
||||
"@rules_rust//rust/platform:thumbv8m.main-none-eabihf": [],
|
||||
"@rules_rust//rust/platform:wasm32-unknown-emscripten": [],
|
||||
"@rules_rust//rust/platform:wasm32-unknown-unknown": [],
|
||||
"@rules_rust//rust/platform:wasm32-wasip1": [],
|
||||
"@rules_rust//rust/platform:wasm32-wasip1-threads": [],
|
||||
"@rules_rust//rust/platform:wasm32-wasip2": [],
|
||||
"@rules_rust//rust/platform:x86_64-apple-darwin": [],
|
||||
"@rules_rust//rust/platform:x86_64-apple-ios": [],
|
||||
"@rules_rust//rust/platform:x86_64-apple-ios-macabi": [],
|
||||
"@rules_rust//rust/platform:x86_64-linux-android": [],
|
||||
"@rules_rust//rust/platform:x86_64-pc-windows-msvc": [],
|
||||
"@rules_rust//rust/platform:x86_64-unknown-freebsd": [],
|
||||
"@rules_rust//rust/platform:x86_64-unknown-fuchsia": [],
|
||||
"@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [],
|
||||
"@rules_rust//rust/platform:x86_64-unknown-nixos-gnu": [],
|
||||
"@rules_rust//rust/platform:x86_64-unknown-none": [],
|
||||
"@rules_rust//rust/platform:x86_64-unknown-uefi": [],
|
||||
"//conditions:default": ["@platforms//:incompatible"],
|
||||
}),
|
||||
version = "1.5.1",
|
||||
)
|
||||
6
third_party/crates/autocfg-1.5.1/Cargo.lock
generated
vendored
Normal file
6
third_party/crates/autocfg-1.5.1/Cargo.lock
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
|
||||
75
third_party/crates/autocfg-1.5.1/Cargo.toml
vendored
Normal file
75
third_party/crates/autocfg-1.5.1/Cargo.toml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
rust-version = "1.0"
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
authors = ["Josh Stone <cuviper@gmail.com>"]
|
||||
build = false
|
||||
exclude = ["/.github/**"]
|
||||
autolib = false
|
||||
autobins = false
|
||||
autoexamples = false
|
||||
autotests = false
|
||||
autobenches = false
|
||||
description = "Automatic cfg for Rust compiler features"
|
||||
documentation = "https://docs.rs/autocfg/"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"rustc",
|
||||
"build",
|
||||
"autoconf",
|
||||
]
|
||||
categories = ["development-tools::build-utils"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
repository = "https://github.com/cuviper/autocfg"
|
||||
|
||||
[lib]
|
||||
name = "autocfg"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[example]]
|
||||
name = "integers"
|
||||
path = "examples/integers.rs"
|
||||
|
||||
[[example]]
|
||||
name = "nightly"
|
||||
path = "examples/nightly.rs"
|
||||
|
||||
[[example]]
|
||||
name = "paths"
|
||||
path = "examples/paths.rs"
|
||||
|
||||
[[example]]
|
||||
name = "traits"
|
||||
path = "examples/traits.rs"
|
||||
|
||||
[[example]]
|
||||
name = "versions"
|
||||
path = "examples/versions.rs"
|
||||
|
||||
[[test]]
|
||||
name = "no_std"
|
||||
path = "tests/no_std.rs"
|
||||
|
||||
[[test]]
|
||||
name = "rustflags"
|
||||
path = "tests/rustflags.rs"
|
||||
|
||||
[[test]]
|
||||
name = "tests"
|
||||
path = "tests/tests.rs"
|
||||
|
||||
[[test]]
|
||||
name = "wrappers"
|
||||
path = "tests/wrappers.rs"
|
||||
harness = false
|
||||
26
third_party/crates/autocfg-1.5.1/Cargo.toml.orig
generated
vendored
Normal file
26
third_party/crates/autocfg-1.5.1/Cargo.toml.orig
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
[package]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
authors = ["Josh Stone <cuviper@gmail.com>"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
repository = "https://github.com/cuviper/autocfg"
|
||||
documentation = "https://docs.rs/autocfg/"
|
||||
description = "Automatic cfg for Rust compiler features"
|
||||
readme = "README.md"
|
||||
keywords = ["rustc", "build", "autoconf"]
|
||||
categories = ["development-tools::build-utils"]
|
||||
exclude = ["/.github/**"]
|
||||
rust-version = "1.0"
|
||||
|
||||
[[test]]
|
||||
name = "no_std"
|
||||
|
||||
[[test]]
|
||||
name = "rustflags"
|
||||
|
||||
[[test]]
|
||||
name = "tests"
|
||||
|
||||
[[test]]
|
||||
name = "wrappers"
|
||||
harness = false
|
||||
201
third_party/crates/autocfg-1.5.1/LICENSE-APACHE
vendored
Normal file
201
third_party/crates/autocfg-1.5.1/LICENSE-APACHE
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
25
third_party/crates/autocfg-1.5.1/LICENSE-MIT
vendored
Normal file
25
third_party/crates/autocfg-1.5.1/LICENSE-MIT
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
Copyright (c) 2018 Josh Stone
|
||||
|
||||
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.
|
||||
121
third_party/crates/autocfg-1.5.1/README.md
vendored
Normal file
121
third_party/crates/autocfg-1.5.1/README.md
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
autocfg
|
||||
=======
|
||||
|
||||
[](https://crates.io/crates/autocfg)
|
||||
[](https://docs.rs/autocfg)
|
||||

|
||||

|
||||
|
||||
A Rust library for build scripts to automatically configure code based on
|
||||
compiler support. Code snippets are dynamically tested to see if the `rustc`
|
||||
will accept them, rather than hard-coding specific version support.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `Cargo.toml`:
|
||||
|
||||
```toml
|
||||
[build-dependencies]
|
||||
autocfg = "1"
|
||||
```
|
||||
|
||||
Then use it in your `build.rs` script to detect compiler features. For
|
||||
example, to test for 128-bit integer support, it might look like:
|
||||
|
||||
```rust
|
||||
extern crate autocfg;
|
||||
|
||||
fn main() {
|
||||
let ac = autocfg::new();
|
||||
ac.emit_has_type("i128");
|
||||
|
||||
// (optional) We don't need to rerun for anything external.
|
||||
autocfg::rerun_path("build.rs");
|
||||
}
|
||||
```
|
||||
|
||||
If the type test succeeds, this will write a `cargo:rustc-cfg=has_i128` line
|
||||
for Cargo, which translates to Rust arguments `--cfg has_i128`. Then in the
|
||||
rest of your Rust code, you can add `#[cfg(has_i128)]` conditions on code that
|
||||
should only be used when the compiler supports it.
|
||||
|
||||
|
||||
## Release Notes
|
||||
|
||||
- 1.5.1 (2026-05-22)
|
||||
|
||||
- Refactor the `test_wrappers` test without any shell script.
|
||||
|
||||
- 1.5.0 (2025-06-17)
|
||||
|
||||
- Add `edition` and `set_edition` to control the Rust edition used in probes.
|
||||
- Remove probe result files so they don't pollute the output directory.
|
||||
|
||||
- 1.4.0 (2024-09-26)
|
||||
|
||||
- Add `emit_possibility` for Rust 1.80's [checked cfgs], and call that
|
||||
automatically for methods that conditionally `emit`, by @Techcable.
|
||||
|
||||
[checked cfgs]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
|
||||
|
||||
- 1.3.0 (2024-05-03)
|
||||
|
||||
- Add `probe_raw` for direct control of the code that will be test-compiled.
|
||||
- Use wrappers when querying the `rustc` version information too.
|
||||
|
||||
- 1.2.0 (2024-03-25)
|
||||
|
||||
- Add `no_std` and `set_no_std` to control the use of `#![no_std]` in probes.
|
||||
- Use `RUSTC_WRAPPER` and `RUSTC_WORKSPACE_WRAPPER` when they are set.
|
||||
|
||||
- 1.1.0 (2022-02-07)
|
||||
- Use `CARGO_ENCODED_RUSTFLAGS` when it is set.
|
||||
|
||||
- 1.0.1 (2020-08-20)
|
||||
- Apply `RUSTFLAGS` for more `--target` scenarios, by @adamreichold.
|
||||
|
||||
- 1.0.0 (2020-01-08)
|
||||
- 🎉 Release 1.0! 🎉 (no breaking changes)
|
||||
- Add `probe_expression` and `emit_expression_cfg` to test arbitrary expressions.
|
||||
- Add `probe_constant` and `emit_constant_cfg` to test arbitrary constant expressions.
|
||||
|
||||
- 0.1.7 (2019-10-20)
|
||||
- Apply `RUSTFLAGS` when probing `$TARGET != $HOST`, mainly for sysroot, by @roblabla.
|
||||
|
||||
- 0.1.6 (2019-08-19)
|
||||
- Add `probe`/`emit_sysroot_crate`, by @leo60228.
|
||||
|
||||
- 0.1.5 (2019-07-16)
|
||||
- Mask some warnings from newer rustc.
|
||||
|
||||
- 0.1.4 (2019-05-22)
|
||||
- Relax `std`/`no_std` probing to a warning instead of an error.
|
||||
- Improve `rustc` bootstrap compatibility.
|
||||
|
||||
- 0.1.3 (2019-05-21)
|
||||
- Auto-detects if `#![no_std]` is needed for the `$TARGET`.
|
||||
|
||||
- 0.1.2 (2019-01-16)
|
||||
- Add `rerun_env(ENV)` to print `cargo:rerun-if-env-changed=ENV`.
|
||||
- Add `rerun_path(PATH)` to print `cargo:rerun-if-changed=PATH`.
|
||||
|
||||
|
||||
## Minimum Rust version policy
|
||||
|
||||
This crate's minimum supported `rustc` version is `1.0.0`. Compatibility is
|
||||
its entire reason for existence, so this crate will be extremely conservative
|
||||
about raising this requirement. If this is ever deemed necessary, it will be
|
||||
treated as a major breaking change for semver purposes.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under either of
|
||||
|
||||
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||
https://www.apache.org/licenses/LICENSE-2.0)
|
||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
||||
https://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
9
third_party/crates/autocfg-1.5.1/examples/integers.rs
vendored
Normal file
9
third_party/crates/autocfg-1.5.1/examples/integers.rs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
extern crate autocfg;
|
||||
|
||||
fn main() {
|
||||
// Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
let ac = autocfg::AutoCfg::with_dir("target").unwrap();
|
||||
for i in 3..8 {
|
||||
ac.emit_has_type(&format!("i{}", 1 << i));
|
||||
}
|
||||
}
|
||||
18
third_party/crates/autocfg-1.5.1/examples/nightly.rs
vendored
Normal file
18
third_party/crates/autocfg-1.5.1/examples/nightly.rs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
extern crate autocfg;
|
||||
|
||||
fn main() {
|
||||
// Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
let ac = autocfg::AutoCfg::with_dir("target").unwrap();
|
||||
|
||||
// When this feature was stabilized, it also renamed the method to
|
||||
// `chunk_by`, so it's important to *use* the feature in your probe.
|
||||
let code = r#"
|
||||
#![feature(slice_group_by)]
|
||||
pub fn probe(slice: &[i32]) -> impl Iterator<Item = &[i32]> {
|
||||
slice.group_by(|a, b| a == b)
|
||||
}
|
||||
"#;
|
||||
if ac.probe_raw(code).is_ok() {
|
||||
autocfg::emit("has_slice_group_by");
|
||||
}
|
||||
}
|
||||
22
third_party/crates/autocfg-1.5.1/examples/paths.rs
vendored
Normal file
22
third_party/crates/autocfg-1.5.1/examples/paths.rs
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
extern crate autocfg;
|
||||
|
||||
fn main() {
|
||||
// Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
let ac = autocfg::AutoCfg::with_dir("target").unwrap();
|
||||
|
||||
// since ancient times...
|
||||
ac.emit_has_path("std::vec::Vec");
|
||||
ac.emit_path_cfg("std::vec::Vec", "has_vec");
|
||||
|
||||
// rustc 1.10.0
|
||||
ac.emit_has_path("std::panic::PanicInfo");
|
||||
ac.emit_path_cfg("std::panic::PanicInfo", "has_panic_info");
|
||||
|
||||
// rustc 1.20.0
|
||||
ac.emit_has_path("std::mem::ManuallyDrop");
|
||||
ac.emit_path_cfg("std::mem::ManuallyDrop", "has_manually_drop");
|
||||
|
||||
// rustc 1.25.0
|
||||
ac.emit_has_path("std::ptr::NonNull");
|
||||
ac.emit_path_cfg("std::ptr::NonNull", "has_non_null");
|
||||
}
|
||||
26
third_party/crates/autocfg-1.5.1/examples/traits.rs
vendored
Normal file
26
third_party/crates/autocfg-1.5.1/examples/traits.rs
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
extern crate autocfg;
|
||||
|
||||
fn main() {
|
||||
// Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
let ac = autocfg::AutoCfg::with_dir("target").unwrap();
|
||||
|
||||
// since ancient times...
|
||||
ac.emit_has_trait("std::ops::Add");
|
||||
ac.emit_trait_cfg("std::ops::Add", "has_ops");
|
||||
|
||||
// trait parameters have to be provided
|
||||
ac.emit_has_trait("std::borrow::Borrow<str>");
|
||||
ac.emit_trait_cfg("std::borrow::Borrow<str>", "has_borrow");
|
||||
|
||||
// rustc 1.8.0
|
||||
ac.emit_has_trait("std::ops::AddAssign");
|
||||
ac.emit_trait_cfg("std::ops::AddAssign", "has_assign_ops");
|
||||
|
||||
// rustc 1.12.0
|
||||
ac.emit_has_trait("std::iter::Sum");
|
||||
ac.emit_trait_cfg("std::iter::Sum", "has_sum");
|
||||
|
||||
// rustc 1.28.0
|
||||
ac.emit_has_trait("std::alloc::GlobalAlloc");
|
||||
ac.emit_trait_cfg("std::alloc::GlobalAlloc", "has_global_alloc");
|
||||
}
|
||||
9
third_party/crates/autocfg-1.5.1/examples/versions.rs
vendored
Normal file
9
third_party/crates/autocfg-1.5.1/examples/versions.rs
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
extern crate autocfg;
|
||||
|
||||
fn main() {
|
||||
// Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
let ac = autocfg::AutoCfg::with_dir("target").unwrap();
|
||||
for i in 0..100 {
|
||||
ac.emit_rustc_version(1, i);
|
||||
}
|
||||
}
|
||||
81
third_party/crates/autocfg-1.5.1/src/error.rs
vendored
Normal file
81
third_party/crates/autocfg-1.5.1/src/error.rs
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::io;
|
||||
use std::num;
|
||||
use std::process;
|
||||
use std::str;
|
||||
|
||||
/// A common error type for the `autocfg` crate.
|
||||
#[derive(Debug)]
|
||||
pub struct Error {
|
||||
kind: ErrorKind,
|
||||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn description(&self) -> &str {
|
||||
"AutoCfg error"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&error::Error> {
|
||||
match self.kind {
|
||||
ErrorKind::Io(ref e) => Some(e),
|
||||
ErrorKind::Num(ref e) => Some(e),
|
||||
ErrorKind::Utf8(ref e) => Some(e),
|
||||
ErrorKind::Process(_) | ErrorKind::Other(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
match self.kind {
|
||||
ErrorKind::Io(ref e) => e.fmt(f),
|
||||
ErrorKind::Num(ref e) => e.fmt(f),
|
||||
ErrorKind::Utf8(ref e) => e.fmt(f),
|
||||
ErrorKind::Process(ref status) => {
|
||||
// Same message as the newer `ExitStatusError`
|
||||
write!(f, "process exited unsuccessfully: {}", status)
|
||||
}
|
||||
ErrorKind::Other(s) => s.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ErrorKind {
|
||||
Io(io::Error),
|
||||
Num(num::ParseIntError),
|
||||
Process(process::ExitStatus),
|
||||
Utf8(str::Utf8Error),
|
||||
Other(&'static str),
|
||||
}
|
||||
|
||||
pub fn from_exit(status: process::ExitStatus) -> Error {
|
||||
Error {
|
||||
kind: ErrorKind::Process(status),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_io(e: io::Error) -> Error {
|
||||
Error {
|
||||
kind: ErrorKind::Io(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_num(e: num::ParseIntError) -> Error {
|
||||
Error {
|
||||
kind: ErrorKind::Num(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_utf8(e: str::Utf8Error) -> Error {
|
||||
Error {
|
||||
kind: ErrorKind::Utf8(e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(s: &'static str) -> Error {
|
||||
Error {
|
||||
kind: ErrorKind::Other(s),
|
||||
}
|
||||
}
|
||||
636
third_party/crates/autocfg-1.5.1/src/lib.rs
vendored
Normal file
636
third_party/crates/autocfg-1.5.1/src/lib.rs
vendored
Normal file
@@ -0,0 +1,636 @@
|
||||
//! A Rust library for build scripts to automatically configure code based on
|
||||
//! compiler support. Code snippets are dynamically tested to see if the `rustc`
|
||||
//! will accept them, rather than hard-coding specific version support.
|
||||
//!
|
||||
//!
|
||||
//! ## Usage
|
||||
//!
|
||||
//! Add this to your `Cargo.toml`:
|
||||
//!
|
||||
//! ```toml
|
||||
//! [build-dependencies]
|
||||
//! autocfg = "1"
|
||||
//! ```
|
||||
//!
|
||||
//! Then use it in your `build.rs` script to detect compiler features. For
|
||||
//! example, to test for 128-bit integer support, it might look like:
|
||||
//!
|
||||
//! ```rust
|
||||
//! extern crate autocfg;
|
||||
//!
|
||||
//! fn main() {
|
||||
//! # // Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
//! # let exe = std::env::current_exe().unwrap();
|
||||
//! # std::env::set_var("OUT_DIR", exe.parent().unwrap());
|
||||
//! let ac = autocfg::new();
|
||||
//! ac.emit_has_type("i128");
|
||||
//!
|
||||
//! // (optional) We don't need to rerun for anything external.
|
||||
//! autocfg::rerun_path("build.rs");
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! If the type test succeeds, this will write a `cargo:rustc-cfg=has_i128` line
|
||||
//! for Cargo, which translates to Rust arguments `--cfg has_i128`. Then in the
|
||||
//! rest of your Rust code, you can add `#[cfg(has_i128)]` conditions on code that
|
||||
//! should only be used when the compiler supports it.
|
||||
//!
|
||||
//! ## Caution
|
||||
//!
|
||||
//! Many of the probing methods of `AutoCfg` document the particular template they
|
||||
//! use, **subject to change**. The inputs are not validated to make sure they are
|
||||
//! semantically correct for their expected use, so it's _possible_ to escape and
|
||||
//! inject something unintended. However, such abuse is unsupported and will not
|
||||
//! be considered when making changes to the templates.
|
||||
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![deny(missing_docs)]
|
||||
// allow future warnings that can't be fixed while keeping 1.0 compatibility
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(bare_trait_objects)]
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
|
||||
/// Local macro to avoid `std::try!`, deprecated in Rust 1.39.
|
||||
macro_rules! try {
|
||||
($result:expr) => {
|
||||
match $result {
|
||||
Ok(value) => value,
|
||||
Err(error) => return Err(error),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fmt::Arguments;
|
||||
use std::fs;
|
||||
use std::io::{stderr, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Stdio;
|
||||
#[allow(deprecated)]
|
||||
use std::sync::atomic::ATOMIC_USIZE_INIT;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
mod error;
|
||||
pub use error::Error;
|
||||
|
||||
mod rustc;
|
||||
use rustc::Rustc;
|
||||
|
||||
mod version;
|
||||
use version::Version;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// Helper to detect compiler features for `cfg` output in build scripts.
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct AutoCfg {
|
||||
out_dir: PathBuf,
|
||||
rustc: Rustc,
|
||||
rustc_version: Version,
|
||||
target: Option<OsString>,
|
||||
no_std: bool,
|
||||
edition: Option<String>,
|
||||
rustflags: Vec<String>,
|
||||
uuid: u64,
|
||||
}
|
||||
|
||||
/// Writes a config flag for rustc on standard out.
|
||||
///
|
||||
/// This looks like: `cargo:rustc-cfg=CFG`
|
||||
///
|
||||
/// Cargo will use this in arguments to rustc, like `--cfg CFG`.
|
||||
///
|
||||
/// This does not automatically call [`emit_possibility`]
|
||||
/// so the compiler my generate an [`unexpected_cfgs` warning][check-cfg-flags].
|
||||
/// However, all the builtin emit methods on [`AutoCfg`] call [`emit_possibility`] automatically.
|
||||
///
|
||||
/// [check-cfg-flags]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
|
||||
pub fn emit(cfg: &str) {
|
||||
println!("cargo:rustc-cfg={}", cfg);
|
||||
}
|
||||
|
||||
/// Writes a line telling Cargo to rerun the build script if `path` changes.
|
||||
///
|
||||
/// This looks like: `cargo:rerun-if-changed=PATH`
|
||||
///
|
||||
/// This requires at least cargo 0.7.0, corresponding to rustc 1.6.0. Earlier
|
||||
/// versions of cargo will simply ignore the directive.
|
||||
pub fn rerun_path(path: &str) {
|
||||
println!("cargo:rerun-if-changed={}", path);
|
||||
}
|
||||
|
||||
/// Writes a line telling Cargo to rerun the build script if the environment
|
||||
/// variable `var` changes.
|
||||
///
|
||||
/// This looks like: `cargo:rerun-if-env-changed=VAR`
|
||||
///
|
||||
/// This requires at least cargo 0.21.0, corresponding to rustc 1.20.0. Earlier
|
||||
/// versions of cargo will simply ignore the directive.
|
||||
pub fn rerun_env(var: &str) {
|
||||
println!("cargo:rerun-if-env-changed={}", var);
|
||||
}
|
||||
|
||||
/// Indicates to rustc that a config flag should not generate an [`unexpected_cfgs` warning][check-cfg-flags]
|
||||
///
|
||||
/// This looks like `cargo:rustc-check-cfg=cfg(VAR)`
|
||||
///
|
||||
/// As of rust 1.80, the compiler does [automatic checking of cfgs at compile time][check-cfg-flags].
|
||||
/// All custom configuration flags must be known to rustc, or they will generate a warning.
|
||||
/// This is done automatically when calling the builtin emit methods on [`AutoCfg`],
|
||||
/// but not when calling [`autocfg::emit`](crate::emit) directly.
|
||||
///
|
||||
/// Versions before rust 1.80 will simply ignore this directive.
|
||||
///
|
||||
/// This function indicates to the compiler that the config flag never has a value.
|
||||
/// If this is not desired, see [the blog post][check-cfg].
|
||||
///
|
||||
/// [check-cfg-flags]: https://blog.rust-lang.org/2024/05/06/check-cfg.html
|
||||
pub fn emit_possibility(cfg: &str) {
|
||||
println!("cargo:rustc-check-cfg=cfg({})", cfg);
|
||||
}
|
||||
|
||||
/// Creates a new `AutoCfg` instance.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `AutoCfg::new()` returns an error.
|
||||
pub fn new() -> AutoCfg {
|
||||
AutoCfg::new().unwrap()
|
||||
}
|
||||
|
||||
impl AutoCfg {
|
||||
/// Creates a new `AutoCfg` instance.
|
||||
///
|
||||
/// # Common errors
|
||||
///
|
||||
/// - `rustc` can't be executed, from `RUSTC` or in the `PATH`.
|
||||
/// - The version output from `rustc` can't be parsed.
|
||||
/// - `OUT_DIR` is not set in the environment, or is not a writable directory.
|
||||
///
|
||||
pub fn new() -> Result<Self, Error> {
|
||||
match env::var_os("OUT_DIR") {
|
||||
Some(d) => Self::with_dir(d),
|
||||
None => Err(error::from_str("no OUT_DIR specified!")),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new `AutoCfg` instance with the specified output directory.
|
||||
///
|
||||
/// # Common errors
|
||||
///
|
||||
/// - `rustc` can't be executed, from `RUSTC` or in the `PATH`.
|
||||
/// - The version output from `rustc` can't be parsed.
|
||||
/// - `dir` is not a writable directory.
|
||||
///
|
||||
pub fn with_dir<T: Into<PathBuf>>(dir: T) -> Result<Self, Error> {
|
||||
let rustc = Rustc::new();
|
||||
let rustc_version = try!(rustc.version());
|
||||
|
||||
let target = env::var_os("TARGET");
|
||||
|
||||
// Sanity check the output directory
|
||||
let dir = dir.into();
|
||||
let meta = try!(fs::metadata(&dir).map_err(error::from_io));
|
||||
if !meta.is_dir() || meta.permissions().readonly() {
|
||||
return Err(error::from_str("output path is not a writable directory"));
|
||||
}
|
||||
|
||||
let mut ac = AutoCfg {
|
||||
rustflags: rustflags(&target, &dir),
|
||||
out_dir: dir,
|
||||
rustc: rustc,
|
||||
rustc_version: rustc_version,
|
||||
target: target,
|
||||
no_std: false,
|
||||
edition: None,
|
||||
uuid: new_uuid(),
|
||||
};
|
||||
|
||||
// Sanity check with and without `std`.
|
||||
if ac.probe_raw("").is_err() {
|
||||
if ac.probe_raw("#![no_std]").is_ok() {
|
||||
ac.no_std = true;
|
||||
} else {
|
||||
// Neither worked, so assume nothing...
|
||||
let warning = b"warning: autocfg could not probe for `std`\n";
|
||||
stderr().write_all(warning).ok();
|
||||
}
|
||||
}
|
||||
Ok(ac)
|
||||
}
|
||||
|
||||
/// Returns whether `AutoCfg` is using `#![no_std]` in its probes.
|
||||
///
|
||||
/// This is automatically detected during construction -- if an empty probe
|
||||
/// fails while one with `#![no_std]` succeeds, then the attribute will be
|
||||
/// used for all further probes. This is usually only necessary when the
|
||||
/// `TARGET` lacks `std` altogether. If neither succeeds, `no_std` is not
|
||||
/// set, but that `AutoCfg` will probably only work for version checks.
|
||||
///
|
||||
/// This attribute changes the implicit [prelude] from `std` to `core`,
|
||||
/// which may affect the paths you need to use in other probes. It also
|
||||
/// restricts some types that otherwise get additional methods in `std`,
|
||||
/// like floating-point trigonometry and slice sorting.
|
||||
///
|
||||
/// See also [`set_no_std`](#method.set_no_std).
|
||||
///
|
||||
/// [prelude]: https://doc.rust-lang.org/reference/names/preludes.html#the-no_std-attribute
|
||||
pub fn no_std(&self) -> bool {
|
||||
self.no_std
|
||||
}
|
||||
|
||||
/// Sets whether `AutoCfg` should use `#![no_std]` in its probes.
|
||||
///
|
||||
/// See also [`no_std`](#method.no_std).
|
||||
pub fn set_no_std(&mut self, no_std: bool) {
|
||||
self.no_std = no_std;
|
||||
}
|
||||
|
||||
/// Returns the `--edition` string that is currently being passed to `rustc`, if any,
|
||||
/// as configured by the [`set_edition`][Self::set_edition] method.
|
||||
pub fn edition(&self) -> Option<&str> {
|
||||
match self.edition {
|
||||
Some(ref edition) => Some(&**edition),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the `--edition` string that will be passed to `rustc`,
|
||||
/// or `None` to leave the compiler at its default edition.
|
||||
///
|
||||
/// See also [The Rust Edition Guide](https://doc.rust-lang.org/edition-guide/).
|
||||
///
|
||||
/// **Warning:** Setting an unsupported edition will likely cause **all** subsequent probes to
|
||||
/// fail! As of this writing, the known editions and their minimum Rust versions are:
|
||||
///
|
||||
/// | Edition | Version |
|
||||
/// | ------- | ---------- |
|
||||
/// | 2015 | 1.27.0[^1] |
|
||||
/// | 2018 | 1.31.0 |
|
||||
/// | 2021 | 1.56.0 |
|
||||
/// | 2024 | 1.85.0 |
|
||||
///
|
||||
/// [^1]: Prior to 1.27.0, Rust was effectively 2015 Edition by default, but the concept hadn't
|
||||
/// been established yet, so the explicit `--edition` flag wasn't supported either.
|
||||
pub fn set_edition(&mut self, edition: Option<String>) {
|
||||
self.edition = edition;
|
||||
}
|
||||
|
||||
/// Tests whether the current `rustc` reports a version greater than
|
||||
/// or equal to "`major`.`minor`".
|
||||
pub fn probe_rustc_version(&self, major: usize, minor: usize) -> bool {
|
||||
self.rustc_version >= Version::new(major, minor, 0)
|
||||
}
|
||||
|
||||
/// Sets a `cfg` value of the form `rustc_major_minor`, like `rustc_1_29`,
|
||||
/// if the current `rustc` is at least that version.
|
||||
pub fn emit_rustc_version(&self, major: usize, minor: usize) {
|
||||
let cfg_flag = format!("rustc_{}_{}", major, minor);
|
||||
emit_possibility(&cfg_flag);
|
||||
if self.probe_rustc_version(major, minor) {
|
||||
emit(&cfg_flag);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a new (hopefully unique) crate name for probes.
|
||||
fn new_crate_name(&self) -> String {
|
||||
#[allow(deprecated)]
|
||||
static ID: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
let id = ID.fetch_add(1, Ordering::Relaxed);
|
||||
format!("autocfg_{:016x}_{}", self.uuid, id)
|
||||
}
|
||||
|
||||
fn probe_fmt<'a>(&self, source: Arguments<'a>) -> Result<(), Error> {
|
||||
let crate_name = self.new_crate_name();
|
||||
let mut command = self.rustc.command();
|
||||
command
|
||||
.arg("--crate-name")
|
||||
.arg(&crate_name)
|
||||
.arg("--crate-type=lib")
|
||||
.arg("--out-dir")
|
||||
.arg(&self.out_dir)
|
||||
.arg("--emit=llvm-ir");
|
||||
|
||||
if let Some(edition) = self.edition.as_ref() {
|
||||
command.arg("--edition").arg(edition);
|
||||
}
|
||||
|
||||
if let Some(target) = self.target.as_ref() {
|
||||
command.arg("--target").arg(target);
|
||||
}
|
||||
|
||||
command.args(&self.rustflags);
|
||||
|
||||
command.arg("-").stdin(Stdio::piped());
|
||||
let mut child = try!(command.spawn().map_err(error::from_io));
|
||||
let mut stdin = child.stdin.take().expect("rustc stdin");
|
||||
|
||||
try!(stdin.write_fmt(source).map_err(error::from_io));
|
||||
drop(stdin);
|
||||
|
||||
match child.wait() {
|
||||
Ok(status) if status.success() => {
|
||||
// Try to remove the output file so it doesn't look like a build product for
|
||||
// systems like bazel -- but this is best-effort, so we can ignore failure.
|
||||
// The probe itself is already considered successful at this point.
|
||||
let mut file = self.out_dir.join(crate_name);
|
||||
file.set_extension("ll");
|
||||
let _ = fs::remove_file(file);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Ok(status) => Err(error::from_exit(status)),
|
||||
Err(error) => Err(error::from_io(error)),
|
||||
}
|
||||
}
|
||||
|
||||
fn probe<'a>(&self, code: Arguments<'a>) -> bool {
|
||||
let result = if self.no_std {
|
||||
self.probe_fmt(format_args!("#![no_std]\n{}", code))
|
||||
} else {
|
||||
self.probe_fmt(code)
|
||||
};
|
||||
result.is_ok()
|
||||
}
|
||||
|
||||
/// Tests whether the given code can be compiled as a Rust library.
|
||||
///
|
||||
/// This will only return `Ok` if the compiler ran and exited successfully,
|
||||
/// per `ExitStatus::success()`.
|
||||
/// The code is passed to the compiler exactly as-is, notably not even
|
||||
/// adding the [`#![no_std]`][Self::no_std] attribute like other probes.
|
||||
///
|
||||
/// Raw probes are useful for testing functionality that's not yet covered
|
||||
/// by the rest of the `AutoCfg` API. For example, the following attribute
|
||||
/// **must** be used at the crate level, so it wouldn't work within the code
|
||||
/// templates used by other `probe_*` methods.
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate autocfg;
|
||||
/// # // Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
/// # let exe = std::env::current_exe().unwrap();
|
||||
/// # std::env::set_var("OUT_DIR", exe.parent().unwrap());
|
||||
/// let ac = autocfg::new();
|
||||
/// assert!(ac.probe_raw("#![no_builtins]").is_ok());
|
||||
/// ```
|
||||
///
|
||||
/// Rust nightly features could be tested as well -- ideally including a
|
||||
/// code sample to ensure the unstable feature still works as expected.
|
||||
/// For example, `slice::group_by` was renamed to `chunk_by` when it was
|
||||
/// stabilized, even though the feature name was unchanged, so testing the
|
||||
/// `#![feature(..)]` alone wouldn't reveal that. For larger snippets,
|
||||
/// [`include_str!`] may be useful to load them from separate files.
|
||||
///
|
||||
/// ```
|
||||
/// # extern crate autocfg;
|
||||
/// # // Normally, cargo will set `OUT_DIR` for build scripts.
|
||||
/// # let exe = std::env::current_exe().unwrap();
|
||||
/// # std::env::set_var("OUT_DIR", exe.parent().unwrap());
|
||||
/// let ac = autocfg::new();
|
||||
/// let code = r#"
|
||||
/// #![feature(slice_group_by)]
|
||||
/// pub fn probe(slice: &[i32]) -> impl Iterator<Item = &[i32]> {
|
||||
/// slice.group_by(|a, b| a == b)
|
||||
/// }
|
||||
/// "#;
|
||||
/// if ac.probe_raw(code).is_ok() {
|
||||
/// autocfg::emit("has_slice_group_by");
|
||||
/// }
|
||||
/// ```
|
||||
pub fn probe_raw(&self, code: &str) -> Result<(), Error> {
|
||||
self.probe_fmt(format_args!("{}", code))
|
||||
}
|
||||
|
||||
/// Tests whether the given sysroot crate can be used.
|
||||
///
|
||||
/// The test code is subject to change, but currently looks like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// extern crate CRATE as probe;
|
||||
/// ```
|
||||
pub fn probe_sysroot_crate(&self, name: &str) -> bool {
|
||||
// Note: `as _` wasn't stabilized until Rust 1.33
|
||||
self.probe(format_args!("extern crate {} as probe;", name))
|
||||
}
|
||||
|
||||
/// Emits a config value `has_CRATE` if `probe_sysroot_crate` returns true.
|
||||
pub fn emit_sysroot_crate(&self, name: &str) {
|
||||
let cfg_flag = format!("has_{}", mangle(name));
|
||||
emit_possibility(&cfg_flag);
|
||||
if self.probe_sysroot_crate(name) {
|
||||
emit(&cfg_flag);
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests whether the given path can be used.
|
||||
///
|
||||
/// The test code is subject to change, but currently looks like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// pub use PATH;
|
||||
/// ```
|
||||
pub fn probe_path(&self, path: &str) -> bool {
|
||||
self.probe(format_args!("pub use {};", path))
|
||||
}
|
||||
|
||||
/// Emits a config value `has_PATH` if `probe_path` returns true.
|
||||
///
|
||||
/// Any non-identifier characters in the `path` will be replaced with
|
||||
/// `_` in the generated config value.
|
||||
pub fn emit_has_path(&self, path: &str) {
|
||||
self.emit_path_cfg(path, &format!("has_{}", mangle(path)));
|
||||
}
|
||||
|
||||
/// Emits the given `cfg` value if `probe_path` returns true.
|
||||
pub fn emit_path_cfg(&self, path: &str, cfg: &str) {
|
||||
emit_possibility(cfg);
|
||||
if self.probe_path(path) {
|
||||
emit(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests whether the given trait can be used.
|
||||
///
|
||||
/// The test code is subject to change, but currently looks like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// pub trait Probe: TRAIT + Sized {}
|
||||
/// ```
|
||||
pub fn probe_trait(&self, name: &str) -> bool {
|
||||
self.probe(format_args!("pub trait Probe: {} + Sized {{}}", name))
|
||||
}
|
||||
|
||||
/// Emits a config value `has_TRAIT` if `probe_trait` returns true.
|
||||
///
|
||||
/// Any non-identifier characters in the trait `name` will be replaced with
|
||||
/// `_` in the generated config value.
|
||||
pub fn emit_has_trait(&self, name: &str) {
|
||||
self.emit_trait_cfg(name, &format!("has_{}", mangle(name)));
|
||||
}
|
||||
|
||||
/// Emits the given `cfg` value if `probe_trait` returns true.
|
||||
pub fn emit_trait_cfg(&self, name: &str, cfg: &str) {
|
||||
emit_possibility(cfg);
|
||||
if self.probe_trait(name) {
|
||||
emit(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests whether the given type can be used.
|
||||
///
|
||||
/// The test code is subject to change, but currently looks like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// pub type Probe = TYPE;
|
||||
/// ```
|
||||
pub fn probe_type(&self, name: &str) -> bool {
|
||||
self.probe(format_args!("pub type Probe = {};", name))
|
||||
}
|
||||
|
||||
/// Emits a config value `has_TYPE` if `probe_type` returns true.
|
||||
///
|
||||
/// Any non-identifier characters in the type `name` will be replaced with
|
||||
/// `_` in the generated config value.
|
||||
pub fn emit_has_type(&self, name: &str) {
|
||||
self.emit_type_cfg(name, &format!("has_{}", mangle(name)));
|
||||
}
|
||||
|
||||
/// Emits the given `cfg` value if `probe_type` returns true.
|
||||
pub fn emit_type_cfg(&self, name: &str, cfg: &str) {
|
||||
emit_possibility(cfg);
|
||||
if self.probe_type(name) {
|
||||
emit(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests whether the given expression can be used.
|
||||
///
|
||||
/// The test code is subject to change, but currently looks like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// pub fn probe() { let _ = EXPR; }
|
||||
/// ```
|
||||
pub fn probe_expression(&self, expr: &str) -> bool {
|
||||
self.probe(format_args!("pub fn probe() {{ let _ = {}; }}", expr))
|
||||
}
|
||||
|
||||
/// Emits the given `cfg` value if `probe_expression` returns true.
|
||||
pub fn emit_expression_cfg(&self, expr: &str, cfg: &str) {
|
||||
emit_possibility(cfg);
|
||||
if self.probe_expression(expr) {
|
||||
emit(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests whether the given constant expression can be used.
|
||||
///
|
||||
/// The test code is subject to change, but currently looks like:
|
||||
///
|
||||
/// ```ignore
|
||||
/// pub const PROBE: () = ((), EXPR).0;
|
||||
/// ```
|
||||
pub fn probe_constant(&self, expr: &str) -> bool {
|
||||
self.probe(format_args!("pub const PROBE: () = ((), {}).0;", expr))
|
||||
}
|
||||
|
||||
/// Emits the given `cfg` value if `probe_constant` returns true.
|
||||
pub fn emit_constant_cfg(&self, expr: &str, cfg: &str) {
|
||||
emit_possibility(cfg);
|
||||
if self.probe_constant(expr) {
|
||||
emit(cfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn mangle(s: &str) -> String {
|
||||
s.chars()
|
||||
.map(|c| match c {
|
||||
'A'...'Z' | 'a'...'z' | '0'...'9' => c,
|
||||
_ => '_',
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn dir_contains_target(
|
||||
target: &Option<OsString>,
|
||||
dir: &Path,
|
||||
cargo_target_dir: Option<OsString>,
|
||||
) -> bool {
|
||||
target
|
||||
.as_ref()
|
||||
.and_then(|target| {
|
||||
dir.to_str().and_then(|dir| {
|
||||
let mut cargo_target_dir = cargo_target_dir
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from("target"));
|
||||
cargo_target_dir.push(target);
|
||||
|
||||
cargo_target_dir
|
||||
.to_str()
|
||||
.map(|cargo_target_dir| dir.contains(cargo_target_dir))
|
||||
})
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn rustflags(target: &Option<OsString>, dir: &Path) -> Vec<String> {
|
||||
// Starting with rust-lang/cargo#9601, shipped in Rust 1.55, Cargo always sets
|
||||
// CARGO_ENCODED_RUSTFLAGS for any host/target build script invocation. This
|
||||
// includes any source of flags, whether from the environment, toml config, or
|
||||
// whatever may come in the future. The value is either an empty string, or a
|
||||
// list of arguments separated by the ASCII unit separator (US), 0x1f.
|
||||
if let Ok(a) = env::var("CARGO_ENCODED_RUSTFLAGS") {
|
||||
return if a.is_empty() {
|
||||
Vec::new()
|
||||
} else {
|
||||
a.split('\x1f').map(str::to_string).collect()
|
||||
};
|
||||
}
|
||||
|
||||
// Otherwise, we have to take a more heuristic approach, and we don't
|
||||
// support values from toml config at all.
|
||||
//
|
||||
// Cargo only applies RUSTFLAGS for building TARGET artifact in
|
||||
// cross-compilation environment. Sadly, we don't have a way to detect
|
||||
// when we're building HOST artifact in a cross-compilation environment,
|
||||
// so for now we only apply RUSTFLAGS when cross-compiling an artifact.
|
||||
//
|
||||
// See https://github.com/cuviper/autocfg/pull/10#issuecomment-527575030.
|
||||
if *target != env::var_os("HOST")
|
||||
|| dir_contains_target(target, dir, env::var_os("CARGO_TARGET_DIR"))
|
||||
{
|
||||
if let Ok(rustflags) = env::var("RUSTFLAGS") {
|
||||
// This is meant to match how cargo handles the RUSTFLAGS environment variable.
|
||||
// See https://github.com/rust-lang/cargo/blob/69aea5b6f69add7c51cca939a79644080c0b0ba0/src/cargo/core/compiler/build_context/target_info.rs#L434-L441
|
||||
return rustflags
|
||||
.split(' ')
|
||||
.map(str::trim)
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(str::to_string)
|
||||
.collect();
|
||||
}
|
||||
}
|
||||
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// Generates a numeric ID to use in probe crate names.
|
||||
///
|
||||
/// This attempts to be random, within the constraints of Rust 1.0 and no dependencies.
|
||||
fn new_uuid() -> u64 {
|
||||
const FNV_OFFSET_BASIS: u64 = 0xcbf2_9ce4_8422_2325;
|
||||
const FNV_PRIME: u64 = 0x100_0000_01b3;
|
||||
|
||||
// This set should have an actual random hasher.
|
||||
let set: std::collections::HashSet<u64> = (0..256).collect();
|
||||
|
||||
// Feed the `HashSet`-shuffled order into FNV-1a.
|
||||
let mut hash: u64 = FNV_OFFSET_BASIS;
|
||||
for x in set {
|
||||
hash = (hash ^ x).wrapping_mul(FNV_PRIME);
|
||||
}
|
||||
hash
|
||||
}
|
||||
89
third_party/crates/autocfg-1.5.1/src/rustc.rs
vendored
Normal file
89
third_party/crates/autocfg-1.5.1/src/rustc.rs
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
use super::error::Error;
|
||||
use super::version::Version;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Rustc {
|
||||
rustc: PathBuf,
|
||||
rustc_wrapper: Option<PathBuf>,
|
||||
rustc_workspace_wrapper: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl Rustc {
|
||||
pub fn new() -> Self {
|
||||
Rustc {
|
||||
rustc: env::var_os("RUSTC")
|
||||
.unwrap_or_else(|| "rustc".into())
|
||||
.into(),
|
||||
rustc_wrapper: get_rustc_wrapper(false),
|
||||
rustc_workspace_wrapper: get_rustc_wrapper(true),
|
||||
}
|
||||
}
|
||||
|
||||
/// Build the command with possible wrappers.
|
||||
pub fn command(&self) -> Command {
|
||||
let mut rustc = self
|
||||
.rustc_wrapper
|
||||
.iter()
|
||||
.chain(self.rustc_workspace_wrapper.iter())
|
||||
.chain(Some(&self.rustc));
|
||||
let mut command = Command::new(rustc.next().unwrap());
|
||||
for arg in rustc {
|
||||
command.arg(arg);
|
||||
}
|
||||
command
|
||||
}
|
||||
|
||||
/// Try to get the `rustc` version.
|
||||
pub fn version(&self) -> Result<Version, Error> {
|
||||
// Some wrappers like clippy-driver don't pass through version commands,
|
||||
// so we try to fall back to combinations without each wrapper.
|
||||
macro_rules! try_version {
|
||||
($command:expr) => {
|
||||
if let Ok(value) = Version::from_command($command) {
|
||||
return Ok(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let rustc = &self.rustc;
|
||||
if let Some(ref rw) = self.rustc_wrapper {
|
||||
if let Some(ref rww) = self.rustc_workspace_wrapper {
|
||||
try_version!(Command::new(rw).args(&[rww, rustc]));
|
||||
}
|
||||
try_version!(Command::new(rw).arg(rustc));
|
||||
}
|
||||
if let Some(ref rww) = self.rustc_workspace_wrapper {
|
||||
try_version!(Command::new(rww).arg(rustc));
|
||||
}
|
||||
Version::from_command(&mut Command::new(rustc))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_rustc_wrapper(workspace: bool) -> Option<PathBuf> {
|
||||
// We didn't really know whether the workspace wrapper is applicable until Cargo started
|
||||
// deliberately setting or unsetting it in rust-lang/cargo#9601. We'll use the encoded
|
||||
// rustflags as a proxy for that change for now, but we could instead check version 1.55.
|
||||
if workspace && env::var_os("CARGO_ENCODED_RUSTFLAGS").is_none() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let name = if workspace {
|
||||
"RUSTC_WORKSPACE_WRAPPER"
|
||||
} else {
|
||||
"RUSTC_WRAPPER"
|
||||
};
|
||||
|
||||
if let Some(wrapper) = env::var_os(name) {
|
||||
// NB: `OsStr` didn't get `len` or `is_empty` until 1.9.
|
||||
if wrapper != OsString::new() {
|
||||
return Some(wrapper.into());
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
54
third_party/crates/autocfg-1.5.1/src/tests.rs
vendored
Normal file
54
third_party/crates/autocfg-1.5.1/src/tests.rs
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn version_cmp() {
|
||||
use super::version::Version;
|
||||
let v123 = Version::new(1, 2, 3);
|
||||
|
||||
assert!(Version::new(1, 0, 0) < v123);
|
||||
assert!(Version::new(1, 2, 2) < v123);
|
||||
assert!(Version::new(1, 2, 3) == v123);
|
||||
assert!(Version::new(1, 2, 4) > v123);
|
||||
assert!(Version::new(1, 10, 0) > v123);
|
||||
assert!(Version::new(2, 0, 0) > v123);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dir_does_not_contain_target() {
|
||||
assert!(!super::dir_contains_target(
|
||||
&Some("x86_64-unknown-linux-gnu".into()),
|
||||
Path::new("/project/target/debug/build/project-ea75983148559682/out"),
|
||||
None,
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dir_does_contain_target() {
|
||||
assert!(super::dir_contains_target(
|
||||
&Some("x86_64-unknown-linux-gnu".into()),
|
||||
Path::new(
|
||||
"/project/target/x86_64-unknown-linux-gnu/debug/build/project-0147aca016480b9d/out"
|
||||
),
|
||||
None,
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dir_does_not_contain_target_with_custom_target_dir() {
|
||||
assert!(!super::dir_contains_target(
|
||||
&Some("x86_64-unknown-linux-gnu".into()),
|
||||
Path::new("/project/custom/debug/build/project-ea75983148559682/out"),
|
||||
Some("custom".into()),
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dir_does_contain_target_with_custom_target_dir() {
|
||||
assert!(super::dir_contains_target(
|
||||
&Some("x86_64-unknown-linux-gnu".into()),
|
||||
Path::new(
|
||||
"/project/custom/x86_64-unknown-linux-gnu/debug/build/project-0147aca016480b9d/out"
|
||||
),
|
||||
Some("custom".into()),
|
||||
));
|
||||
}
|
||||
65
third_party/crates/autocfg-1.5.1/src/version.rs
vendored
Normal file
65
third_party/crates/autocfg-1.5.1/src/version.rs
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
use std::process::Command;
|
||||
use std::str;
|
||||
|
||||
use super::{error, Error};
|
||||
|
||||
/// A version structure for making relative comparisons.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct Version {
|
||||
major: usize,
|
||||
minor: usize,
|
||||
patch: usize,
|
||||
}
|
||||
|
||||
impl Version {
|
||||
/// Creates a `Version` instance for a specific `major.minor.patch` version.
|
||||
pub fn new(major: usize, minor: usize, patch: usize) -> Self {
|
||||
Version {
|
||||
major: major,
|
||||
minor: minor,
|
||||
patch: patch,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_command(command: &mut Command) -> Result<Self, Error> {
|
||||
// Get rustc's verbose version
|
||||
let output = try!(command
|
||||
.args(&["--version", "--verbose"])
|
||||
.output()
|
||||
.map_err(error::from_io));
|
||||
if !output.status.success() {
|
||||
return Err(error::from_str("could not execute rustc"));
|
||||
}
|
||||
let output = try!(str::from_utf8(&output.stdout).map_err(error::from_utf8));
|
||||
|
||||
// Find the release line in the verbose version output.
|
||||
let release = match output.lines().find(|line| line.starts_with("release: ")) {
|
||||
Some(line) => &line["release: ".len()..],
|
||||
None => return Err(error::from_str("could not find rustc release")),
|
||||
};
|
||||
|
||||
// Strip off any extra channel info, e.g. "-beta.N", "-nightly"
|
||||
let version = match release.find('-') {
|
||||
Some(i) => &release[..i],
|
||||
None => release,
|
||||
};
|
||||
|
||||
// Split the version into semver components.
|
||||
let mut iter = version.splitn(3, '.');
|
||||
let major = try!(iter
|
||||
.next()
|
||||
.ok_or_else(|| error::from_str("missing major version")));
|
||||
let minor = try!(iter
|
||||
.next()
|
||||
.ok_or_else(|| error::from_str("missing minor version")));
|
||||
let patch = try!(iter
|
||||
.next()
|
||||
.ok_or_else(|| error::from_str("missing patch version")));
|
||||
|
||||
Ok(Version::new(
|
||||
try!(major.parse().map_err(error::from_num)),
|
||||
try!(minor.parse().map_err(error::from_num)),
|
||||
try!(patch.parse().map_err(error::from_num)),
|
||||
))
|
||||
}
|
||||
}
|
||||
28
third_party/crates/autocfg-1.5.1/tests/no_std.rs
vendored
Normal file
28
third_party/crates/autocfg-1.5.1/tests/no_std.rs
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
extern crate autocfg;
|
||||
|
||||
use std::env;
|
||||
|
||||
mod support;
|
||||
|
||||
/// Tests that we can control the use of `#![no_std]`.
|
||||
#[test]
|
||||
fn no_std() {
|
||||
// Clear the CI `TARGET`, if any, so we're just dealing with the
|
||||
// host target which always has `std` available.
|
||||
env::remove_var("TARGET");
|
||||
|
||||
// Use the same path as this test binary.
|
||||
let out = support::out_dir();
|
||||
|
||||
let mut ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
assert!(!ac.no_std());
|
||||
assert!(ac.probe_path("std::mem"));
|
||||
|
||||
// `#![no_std]` was stabilized in Rust 1.6
|
||||
if ac.probe_rustc_version(1, 6) {
|
||||
ac.set_no_std(true);
|
||||
assert!(ac.no_std());
|
||||
assert!(!ac.probe_path("std::mem"));
|
||||
assert!(ac.probe_path("core::mem"));
|
||||
}
|
||||
}
|
||||
34
third_party/crates/autocfg-1.5.1/tests/rustflags.rs
vendored
Normal file
34
third_party/crates/autocfg-1.5.1/tests/rustflags.rs
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
extern crate autocfg;
|
||||
|
||||
use std::env;
|
||||
|
||||
mod support;
|
||||
|
||||
/// Tests that autocfg uses the RUSTFLAGS or CARGO_ENCODED_RUSTFLAGS
|
||||
/// environment variables when running rustc.
|
||||
#[test]
|
||||
fn test_with_sysroot() {
|
||||
let dir = support::exe_dir();
|
||||
let out = support::out_dir();
|
||||
|
||||
// If we have encoded rustflags, they take precedence, even if empty.
|
||||
env::set_var("CARGO_ENCODED_RUSTFLAGS", "");
|
||||
env::set_var("RUSTFLAGS", &format!("-L {}", dir.display()));
|
||||
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
assert!(ac.probe_sysroot_crate("std"));
|
||||
assert!(!ac.probe_sysroot_crate("autocfg"));
|
||||
|
||||
// Now try again with useful encoded args.
|
||||
env::set_var(
|
||||
"CARGO_ENCODED_RUSTFLAGS",
|
||||
&format!("-L\x1f{}", dir.display()),
|
||||
);
|
||||
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
assert!(ac.probe_sysroot_crate("autocfg"));
|
||||
|
||||
// Try the old-style RUSTFLAGS, ensuring HOST != TARGET.
|
||||
env::remove_var("CARGO_ENCODED_RUSTFLAGS");
|
||||
env::set_var("HOST", "lol");
|
||||
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
assert!(ac.probe_sysroot_crate("autocfg"));
|
||||
}
|
||||
21
third_party/crates/autocfg-1.5.1/tests/support/mod.rs
vendored
Normal file
21
third_party/crates/autocfg-1.5.1/tests/support/mod.rs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
use std::borrow::Cow;
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// The directory containing this test binary.
|
||||
pub fn exe_dir() -> PathBuf {
|
||||
let exe = env::current_exe().unwrap();
|
||||
exe.parent().unwrap().to_path_buf()
|
||||
}
|
||||
|
||||
/// The directory to use for test probes.
|
||||
pub fn out_dir() -> Cow<'static, Path> {
|
||||
if let Some(tmpdir) = option_env!("CARGO_TARGET_TMPDIR") {
|
||||
Cow::Borrowed(tmpdir.as_ref())
|
||||
} else if let Some(tmpdir) = env::var_os("TESTS_TARGET_DIR") {
|
||||
Cow::Owned(tmpdir.into())
|
||||
} else {
|
||||
// Use the same path as this test binary.
|
||||
Cow::Owned(exe_dir())
|
||||
}
|
||||
}
|
||||
189
third_party/crates/autocfg-1.5.1/tests/tests.rs
vendored
Normal file
189
third_party/crates/autocfg-1.5.1/tests/tests.rs
vendored
Normal file
@@ -0,0 +1,189 @@
|
||||
extern crate autocfg;
|
||||
|
||||
use autocfg::AutoCfg;
|
||||
|
||||
mod support;
|
||||
|
||||
fn core_std(ac: &AutoCfg, path: &str) -> String {
|
||||
let krate = if ac.no_std() { "core" } else { "std" };
|
||||
format!("{}::{}", krate, path)
|
||||
}
|
||||
|
||||
fn assert_std(ac: &AutoCfg, probe_result: bool) {
|
||||
assert_eq!(!ac.no_std(), probe_result);
|
||||
}
|
||||
|
||||
fn assert_min(ac: &AutoCfg, major: usize, minor: usize, probe_result: bool) {
|
||||
assert_eq!(ac.probe_rustc_version(major, minor), probe_result);
|
||||
}
|
||||
|
||||
fn autocfg_for_test() -> AutoCfg {
|
||||
AutoCfg::with_dir(support::out_dir().as_ref()).unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn autocfg_version() {
|
||||
let ac = autocfg_for_test();
|
||||
assert!(ac.probe_rustc_version(1, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_add() {
|
||||
let ac = autocfg_for_test();
|
||||
let add = core_std(&ac, "ops::Add");
|
||||
let add_rhs = add.clone() + "<i32>";
|
||||
let add_rhs_output = add.clone() + "<i32, Output = i32>";
|
||||
let dyn_add_rhs_output = "dyn ".to_string() + &*add_rhs_output;
|
||||
assert!(ac.probe_path(&add));
|
||||
assert!(ac.probe_trait(&add));
|
||||
assert!(ac.probe_trait(&add_rhs));
|
||||
assert!(ac.probe_trait(&add_rhs_output));
|
||||
assert_min(&ac, 1, 27, ac.probe_type(&dyn_add_rhs_output));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_as_ref() {
|
||||
let ac = autocfg_for_test();
|
||||
let as_ref = core_std(&ac, "convert::AsRef");
|
||||
let as_ref_str = as_ref.clone() + "<str>";
|
||||
let dyn_as_ref_str = "dyn ".to_string() + &*as_ref_str;
|
||||
assert!(ac.probe_path(&as_ref));
|
||||
assert!(ac.probe_trait(&as_ref_str));
|
||||
assert!(ac.probe_type(&as_ref_str));
|
||||
assert_min(&ac, 1, 27, ac.probe_type(&dyn_as_ref_str));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_i128() {
|
||||
let ac = autocfg_for_test();
|
||||
let i128_path = core_std(&ac, "i128");
|
||||
assert_min(&ac, 1, 26, ac.probe_path(&i128_path));
|
||||
assert_min(&ac, 1, 26, ac.probe_type("i128"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_sum() {
|
||||
let ac = autocfg_for_test();
|
||||
let sum = core_std(&ac, "iter::Sum");
|
||||
let sum_i32 = sum.clone() + "<i32>";
|
||||
let dyn_sum_i32 = "dyn ".to_string() + &*sum_i32;
|
||||
assert_min(&ac, 1, 12, ac.probe_path(&sum));
|
||||
assert_min(&ac, 1, 12, ac.probe_trait(&sum));
|
||||
assert_min(&ac, 1, 12, ac.probe_trait(&sum_i32));
|
||||
assert_min(&ac, 1, 12, ac.probe_type(&sum_i32));
|
||||
assert_min(&ac, 1, 27, ac.probe_type(&dyn_sum_i32));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_std() {
|
||||
let ac = autocfg_for_test();
|
||||
assert_std(&ac, ac.probe_sysroot_crate("std"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_alloc() {
|
||||
let ac = autocfg_for_test();
|
||||
assert_min(&ac, 1, 36, ac.probe_sysroot_crate("alloc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_bad_sysroot_crate() {
|
||||
let ac = autocfg_for_test();
|
||||
assert!(!ac.probe_sysroot_crate("doesnt_exist"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_no_std() {
|
||||
let ac = autocfg_for_test();
|
||||
assert!(ac.probe_type("i32"));
|
||||
assert!(ac.probe_type("[i32]"));
|
||||
assert_std(&ac, ac.probe_type("Vec<i32>"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_expression() {
|
||||
let ac = autocfg_for_test();
|
||||
assert!(ac.probe_expression(r#""test".trim_left()"#));
|
||||
assert_min(&ac, 1, 30, ac.probe_expression(r#""test".trim_start()"#));
|
||||
assert_std(&ac, ac.probe_expression("[1, 2, 3].to_vec()"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_constant() {
|
||||
let ac = autocfg_for_test();
|
||||
assert!(ac.probe_constant("1 + 2 + 3"));
|
||||
assert_min(
|
||||
&ac,
|
||||
1,
|
||||
33,
|
||||
ac.probe_constant("{ let x = 1 + 2 + 3; x * x }"),
|
||||
);
|
||||
assert_min(&ac, 1, 39, ac.probe_constant(r#""test".len()"#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_raw() {
|
||||
let ac = autocfg_for_test();
|
||||
let prefix = if ac.no_std() { "#![no_std]\n" } else { "" };
|
||||
let f = |s| format!("{}{}", prefix, s);
|
||||
|
||||
// This attribute **must** be used at the crate level.
|
||||
assert!(ac.probe_raw(&f("#![no_builtins]")).is_ok());
|
||||
|
||||
assert!(ac.probe_raw(&f("#![deny(dead_code)] fn x() {}")).is_err());
|
||||
assert!(ac.probe_raw(&f("#![allow(dead_code)] fn x() {}")).is_ok());
|
||||
assert!(ac
|
||||
.probe_raw(&f("#![deny(dead_code)] pub fn x() {}"))
|
||||
.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn probe_cleanup() {
|
||||
let dir = support::out_dir().join("autocfg_test_probe_cleanup");
|
||||
std::fs::create_dir(&dir).unwrap();
|
||||
|
||||
let ac = AutoCfg::with_dir(&dir).unwrap();
|
||||
assert!(ac.probe_type("i32"));
|
||||
|
||||
// NB: this is not `remove_dir_all`, so it will only work if the directory
|
||||
// is empty -- i.e. the probe should have removed any output files.
|
||||
std::fs::remove_dir(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn editions() {
|
||||
let mut ac = autocfg_for_test();
|
||||
assert!(ac.edition().is_none());
|
||||
assert!(ac.probe_raw("").is_ok());
|
||||
|
||||
for (edition, minor) in vec![(2015, 27), (2018, 31), (2021, 56), (2024, 85)] {
|
||||
let edition = edition.to_string();
|
||||
ac.set_edition(Some(edition.clone()));
|
||||
assert_eq!(ac.edition(), Some(&*edition));
|
||||
assert_min(&ac, 1, minor, ac.probe_raw("").is_ok());
|
||||
}
|
||||
|
||||
ac.set_edition(Some("invalid".into()));
|
||||
assert_eq!(ac.edition(), Some("invalid"));
|
||||
assert!(ac.probe_raw("").is_err());
|
||||
|
||||
ac.set_edition(None);
|
||||
assert!(ac.edition().is_none());
|
||||
assert!(ac.probe_raw("").is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn edition_keyword_try() {
|
||||
let mut ac = autocfg_for_test();
|
||||
|
||||
if ac.probe_rustc_version(1, 27) {
|
||||
ac.set_edition(Some(2015.to_string()));
|
||||
}
|
||||
assert!(ac.probe_expression("{ let try = 0; try }"));
|
||||
|
||||
if ac.probe_rustc_version(1, 31) {
|
||||
ac.set_edition(Some(2018.to_string()));
|
||||
assert!(!ac.probe_expression("{ let try = 0; try }"));
|
||||
assert!(ac.probe_expression("{ let r#try = 0; r#try }"));
|
||||
}
|
||||
}
|
||||
83
third_party/crates/autocfg-1.5.1/tests/wrappers.rs
vendored
Normal file
83
third_party/crates/autocfg-1.5.1/tests/wrappers.rs
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
extern crate autocfg;
|
||||
|
||||
use std::env;
|
||||
use std::io;
|
||||
|
||||
mod support;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = env::args().skip(1).collect();
|
||||
if args.is_empty() {
|
||||
// With no arguments, this must be a (harness-free) test run.
|
||||
// (we're using system binaries as wrappers, so ignore other platforms)
|
||||
if cfg!(unix) {
|
||||
test_wrappers();
|
||||
}
|
||||
} else {
|
||||
// Otherwise we're acting like a no-op rustc wrapper, ignoring almost everything.
|
||||
for arg in args {
|
||||
match &*arg {
|
||||
// Add our own version so we can check that the wrapper is used for that.
|
||||
"--version" => println!("release: 12345.6789.0"),
|
||||
|
||||
// Read all input so the writer doesn't get EPIPE when we exit.
|
||||
"-" => {
|
||||
let stdin = io::stdin();
|
||||
let _ = io::copy(&mut stdin.lock(), &mut io::sink());
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests that autocfg uses the RUSTC_WRAPPER and/or RUSTC_WORKSPACE_WRAPPER
|
||||
/// environment variables when running rustc.
|
||||
fn test_wrappers() {
|
||||
fn set(name: &str, value: Option<bool>) {
|
||||
match value {
|
||||
Some(true) => env::set_var(name, "/usr/bin/env"),
|
||||
Some(false) => env::set_var(name, "/bin/false"),
|
||||
None => env::remove_var(name),
|
||||
}
|
||||
}
|
||||
|
||||
let out = support::out_dir();
|
||||
|
||||
// This is used as a heuristic to detect rust-lang/cargo#9601.
|
||||
env::set_var("CARGO_ENCODED_RUSTFLAGS", "");
|
||||
|
||||
// No wrapper, a good pass-through wrapper, and a bad wrapper.
|
||||
let variants = [None, Some(true), Some(false)];
|
||||
|
||||
for &workspace in &variants {
|
||||
for &rustc in &variants {
|
||||
set("RUSTC_WRAPPER", rustc);
|
||||
set("RUSTC_WORKSPACE_WRAPPER", workspace);
|
||||
|
||||
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
if rustc == Some(false) || workspace == Some(false) {
|
||||
// Everything should fail with bad wrappers.
|
||||
assert!(!ac.probe_type("usize"));
|
||||
} else {
|
||||
// Try known good and bad types for the wrapped rustc.
|
||||
assert!(ac.probe_type("usize"));
|
||||
assert!(!ac.probe_type("mesize"));
|
||||
}
|
||||
// Either way, we should have found the inner rustc version.
|
||||
assert!(ac.probe_rustc_version(1, 0));
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, make sure that `RUSTC_WRAPPER` is applied outermost
|
||||
// by using something (ourself) that doesn't pass through at all.
|
||||
let wrap_ignored = env::current_exe().unwrap();
|
||||
env::set_var("RUSTC_WRAPPER", &wrap_ignored);
|
||||
env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false");
|
||||
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
assert!(ac.probe_type("mesize")); // anything goes!
|
||||
|
||||
// Make sure we also got the version from that wrapper.
|
||||
assert!(ac.probe_rustc_version(12345, 6789));
|
||||
}
|
||||
Reference in New Issue
Block a user