target-2.1.0/.cargo_vcs_info.json0000644000000001120000000000100123140ustar { "git": { "sha1": "0e4fea19dcbd612af484db2a02eb4209bf699bb3" } } target-2.1.0/.github/workflows/build.yaml000064400000000000000000000020260072674642500165220ustar 00000000000000name: Build on: push: branches: - master tags: - "*" pull_request: branches: - master defaults: run: shell: bash env: CACHE_KEY: 1 jobs: all: name: All runs-on: ubuntu-latest env: RUSTFLAGS: "--deny warnings" steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: cargo-${{ env.CACHE_KEY }}-${{ hashFiles('**/Cargo.lock') }} - name: Install clippy and rustfmt run: rustup component add clippy rustfmt - name: Info run: | rustup --version cargo --version cargo clippy --version cargo fmt --version - name: Check run: cargo check - name: Test run: cargo test - name: Format run: cargo fmt -- --check - name: Lint run: cargo clippy target-2.1.0/.gitignore000064400000000000000000000000370072674642500131320ustar 00000000000000/target/ **/*.rs.bk Cargo.lock target-2.1.0/Cargo.lock0000644000000061130000000000100102760ustar # This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "ansi_term" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] [[package]] name = "ctor" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", "syn", ] [[package]] name = "diff" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "executable-path" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ebc5a6d89e3c90b84e8f33c8737933dda8f1c106b5415900b38b9d433841478" [[package]] name = "output_vt100" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" dependencies = [ "winapi", ] [[package]] name = "pretty_assertions" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cab0e7c02cf376875e9335e0ba1da535775beb5450d21e1dffca068818ed98b" dependencies = [ "ansi_term", "ctor", "diff", "output_vt100", ] [[package]] name = "proc-macro2" version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "syn" version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "target" version = "2.1.0" dependencies = [ "executable-path", "pretty_assertions", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" target-2.1.0/Cargo.toml0000644000000015170000000000100103240ustar # 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 believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "target" version = "2.1.0" authors = ["Casey Rodarmor "] description = "Get information on compilation target" homepage = "https://github.com/casey/target" license = "CC0-1.0" [dev-dependencies.executable-path] version = "1.0.0" [dev-dependencies.pretty_assertions] version = "0.7.2" target-2.1.0/Cargo.toml.orig000064400000000000000000000004650072674642500140360ustar 00000000000000[package] name = "target" version = "2.1.0" description = "Get information on compilation target" authors = ["Casey Rodarmor "] license = "CC0-1.0" homepage = "https://github.com/casey/target" [dev-dependencies] executable-path = "1.0.0" pretty_assertions = "0.7.2" target-2.1.0/LICENSE000064400000000000000000000156100072674642500121520ustar 00000000000000Creative Commons Legal Code CC0 1.0 Universal CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER. Statement of Purpose The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. 1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; ii. moral rights retained by the original author(s) and/or performer(s); iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; v. rights protecting the extraction, dissemination, use and reuse of data in a Work; vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. 2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. 3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. 4. Limitations and Disclaimers. a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. target-2.1.0/README.md000064400000000000000000000002270072674642500124220ustar 00000000000000target ====== Provides information about the current compilation target's architecture, OS, OS family, environment, pointer width, and pointer width. target-2.1.0/justfile000064400000000000000000000000260072674642500127100ustar 00000000000000default: cargo build target-2.1.0/rust-toolchain000064400000000000000000000000070072674642500140350ustar 000000000000001.54.0 target-2.1.0/rustfmt.toml000064400000000000000000000000510072674642500135370ustar 00000000000000newline_style = "Unix" tab_spaces = 2 target-2.1.0/src/lib.rs000064400000000000000000000055060072674642500130530ustar 00000000000000macro_rules! value { ($name:ident, $($value:literal,)+) => { $( #[cfg($name = $value)] { $value } )+ }; } macro_rules! features { ($($feature:literal,)+) => { &[ $( #[cfg(target_feature = $feature)] $feature, )+ ] } } pub fn arch() -> &'static str { value! { target_arch, "aarch64", "arm", "asmjs", "avr", "hexagon", "le32", "loongarch64", "mips", "mips64", "msp430", "nvptx", "nvptx64", "powerpc", "powerpc64", "riscv32", "riscv64", "s390x", "sparc", "sparc64", "spriv", "thumb", "wasm32", "x86", "x86_64", "xcore", } } pub fn endian() -> &'static str { value! { target_endian, "big", "little", } } pub fn env() -> &'static str { value! { target_env, "", "gnu", "libnx", "msvc", "musl", "newlib", "sgx", "uclibc", } } pub fn family() -> &'static str { value! { target_family, "unix", "wasm", "windows", } } pub fn features() -> &'static [&'static str] { features!( "adx", "aes", "altivec", "atomics", "avx", "avx2", "avx512bf16", "avx512bitalg", "avx512bw", "avx512cd", "avx512f", "avx512gfni", "avx512ifma", "avx512vaes", "avx512vbmi", "avx512vl", "avx512vnni", "avx512vpopcntdq", "bmi1", "bmi2", "cmpxchg16b", "crc", "f16c", "fma", "fxsr", "lzcnt", "msa", "neon", "pclmulqdq", "popcnt", "rdrand", "rdseed", "rtm", "sha", "simd128", "sse", "sse2", "sse3", "sse4.1", "sse4.2", "sse4a", "ssse3", "tbm", "tme", "v7", "v8", "vsx", "xsave", "xsavec", "xsaveopt", "xsaves", ) } pub fn os() -> &'static str { value! { target_os, "aix", "android", "bitrig", "cloudabi", "cuda", "dragonfly", "emscripten", "freebsd", "fuchsia", "haiku", "hermit", "hurd", "illumos", "ios", "l4re", "linux", "macos", "netbsd", "none", "openbsd", "psp", "redox", "sgx", "solaris", "tvos", "vxworks", "wasi", "watchos", "windows", } } pub fn pointer_width() -> &'static str { value! { target_pointer_width, "8", "16", "32", "64", } } pub fn test() -> bool { cfg!(test) } pub fn vendor() -> &'static str { if cfg!(target_vendor = "apple") { "apple" } else if cfg!(target_vendor = "fortanix") { "fortanix" } else if cfg!(target_vendor = "pc") { "pc" } else if cfg!(target_vendor = "sun") { "sun" } else if cfg!(target_vendor = "uwp") { "uwp" } else if cfg!(target_vendor = "ibm") { "ibm" } else { "unknown" } } target-2.1.0/src/main.rs000064400000000000000000000005570072674642500132320ustar 00000000000000fn main() { println!("arch: {}", target::arch()); println!("os: {}", target::os()); println!("family: {}", target::family()); println!("env: {}", target::env()); println!("endian: {}", target::endian()); println!("pointer_width: {}", target::pointer_width()); println!("vendor: {}", target::vendor()); println!("feature: {:?}", target::features()); } target-2.1.0/tests/binary.rs000064400000000000000000000023510072674642500141370ustar 00000000000000extern crate executable_path; use {executable_path::executable_path, std::process::Command}; #[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))] static EXPECTED: &str = r#"arch: x86_64 os: linux family: unix env: gnu endian: little pointer_width: 64 vendor: unknown feature: ["fxsr", "sse", "sse2"] "#; #[cfg(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc"))] static EXPECTED: &str = r#"arch: x86_64 os: windows family: windows env: msvc endian: little pointer_width: 64 vendor: pc feature: ["fxsr", "sse", "sse2"] "#; #[cfg(all(target_arch = "x86_64", target_os = "macos", target_env = ""))] static EXPECTED: &str = r#"arch: x86_64 os: macos family: unix env: endian: little pointer_width: 64 vendor: apple feature: ["fxsr", "sse", "sse2", "sse3", "ssse3"] "#; #[cfg(all(target_arch = "aarch64", target_os = "macos", target_env = ""))] static EXPECTED: &str = r#"arch: aarch64 os: macos family: unix env: endian: little pointer_width: 64 vendor: apple feature: [] "#; #[test] fn binary_output() { let output = Command::new(executable_path("target")) .output() .unwrap() .stdout; let output = std::str::from_utf8(&output).unwrap(); pretty_assertions::assert_eq!(output, EXPECTED); }