diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-03-13 13:38:57 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-03-13 13:38:57 +0100 |
commit | 38d185280e2cad4ed6673bb38f707f54dad4ded7 (patch) | |
tree | bbbb7df9a9f18c5fd3caf406d7f5bc9e13168d1f /third_party/rust/pkg-config | |
parent | 7c68c5a22cfe8f83322836a1a6a76a8ae0415ec1 (diff) | |
download | UXP-38d185280e2cad4ed6673bb38f707f54dad4ded7.tar UXP-38d185280e2cad4ed6673bb38f707f54dad4ded7.tar.gz UXP-38d185280e2cad4ed6673bb38f707f54dad4ded7.tar.lz UXP-38d185280e2cad4ed6673bb38f707f54dad4ded7.tar.xz UXP-38d185280e2cad4ed6673bb38f707f54dad4ded7.zip |
Remove Rust from the tree.
Part 4 for #58
Diffstat (limited to 'third_party/rust/pkg-config')
-rw-r--r-- | third_party/rust/pkg-config/.cargo-checksum.json | 1 | ||||
-rw-r--r-- | third_party/rust/pkg-config/.cargo-ok | 0 | ||||
-rw-r--r-- | third_party/rust/pkg-config/.gitignore | 2 | ||||
-rw-r--r-- | third_party/rust/pkg-config/.travis.yml | 25 | ||||
-rw-r--r-- | third_party/rust/pkg-config/Cargo.toml | 13 | ||||
-rw-r--r-- | third_party/rust/pkg-config/LICENSE-APACHE | 201 | ||||
-rw-r--r-- | third_party/rust/pkg-config/LICENSE-MIT | 25 | ||||
-rw-r--r-- | third_party/rust/pkg-config/README.md | 25 | ||||
-rw-r--r-- | third_party/rust/pkg-config/src/lib.rs | 471 | ||||
-rw-r--r-- | third_party/rust/pkg-config/tests/foo.pc | 16 | ||||
-rw-r--r-- | third_party/rust/pkg-config/tests/framework.pc | 16 | ||||
-rw-r--r-- | third_party/rust/pkg-config/tests/test.rs | 97 |
12 files changed, 0 insertions, 892 deletions
diff --git a/third_party/rust/pkg-config/.cargo-checksum.json b/third_party/rust/pkg-config/.cargo-checksum.json deleted file mode 100644 index fce933c2b..000000000 --- a/third_party/rust/pkg-config/.cargo-checksum.json +++ /dev/null @@ -1 +0,0 @@ -{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".gitignore":"c1e953ee360e77de57f7b02f1b7880bd6a3dc22d1a69e953c2ac2c52cc52d247",".travis.yml":"8d7877933bd1dbc8e7d45491cfeffb596e99f007b87d1704fbcbb1e2907aa55d","Cargo.toml":"6b8bd4b975acf4a3b8fca56990bafcb7e30fea391a754e0ed79a2eab61891c32","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"24788a22c94dd50f248fb7baa1520acf5a02f000600a9b5a8bb9ab5bde5c35a8","src/lib.rs":"1b110ac5e75501837db190de3a39b3d2f202dd71289a1087483d61f1f7d31359","tests/foo.pc":"f77712847e77ea81ac6362de5861dc0eddf14b9c07dce1853b3e3e587ffcac5e","tests/framework.pc":"4d02091799252777afb0547321cc04e7df1e017226a6b05630fed5eaf37e0125","tests/test.rs":"1a842822fc56bac88efa9d604061b5d88e03faa8efb23cdfbdd86f6a6c2ca2c9"},"package":"8cee804ecc7eaf201a4a207241472cc870e825206f6c031e3ee2a72fa425f2fa"}
\ No newline at end of file diff --git a/third_party/rust/pkg-config/.cargo-ok b/third_party/rust/pkg-config/.cargo-ok deleted file mode 100644 index e69de29bb..000000000 --- a/third_party/rust/pkg-config/.cargo-ok +++ /dev/null diff --git a/third_party/rust/pkg-config/.gitignore b/third_party/rust/pkg-config/.gitignore deleted file mode 100644 index 4fffb2f89..000000000 --- a/third_party/rust/pkg-config/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/third_party/rust/pkg-config/.travis.yml b/third_party/rust/pkg-config/.travis.yml deleted file mode 100644 index f02def70b..000000000 --- a/third_party/rust/pkg-config/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: rust -rust: - - stable - - beta - - nightly -sudo: false -script: - - cargo build --verbose - - | - [ $TRAVIS_RUST_VERSION != nightly ] || cargo test --verbose - - cargo doc -after_success: | - [ $TRAVIS_BRANCH = master ] && - [ $TRAVIS_PULL_REQUEST = false ] && - [ $TRAVIS_RUST_VERSION = nightly ] && - echo '<meta http-equiv=refresh content=0;url=pkg_config/index.html>' > target/doc/index.html && - pip install ghp-import --user $USER && - $HOME/.local/bin/ghp-import -n target/doc && - git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages -env: - global: - secure: XlfwiQ+fPgRWqFwHbyPTma2FAVtgN+IXFpkiIdh1sKxWEeHMqABrTtOKf/NugDYCGsOJfr2vb5qFL6teBV2lTXOffUIWj+1hMd0N/FbVKWzABBV02XdxQi8w2ptPez5LPRTEfXJRRHmJpc8ww2aCTIrdT3AQE2oqZM/jHJTi/1U= -notifications: - email: - on_success: never diff --git a/third_party/rust/pkg-config/Cargo.toml b/third_party/rust/pkg-config/Cargo.toml deleted file mode 100644 index 895bdd1b1..000000000 --- a/third_party/rust/pkg-config/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] - -name = "pkg-config" -version = "0.3.8" -authors = ["Alex Crichton <alex@alexcrichton.com>"] -license = "MIT/Apache-2.0" -repository = "https://github.com/alexcrichton/pkg-config-rs" -documentation = "http://alexcrichton.com/pkg-config-rs" -description = """ -A library to run the pkg-config system tool at build time in order to be used in -Cargo build scripts. -""" -keywords = ["build-dependencies"] diff --git a/third_party/rust/pkg-config/LICENSE-APACHE b/third_party/rust/pkg-config/LICENSE-APACHE deleted file mode 100644 index 16fe87b06..000000000 --- a/third_party/rust/pkg-config/LICENSE-APACHE +++ /dev/null @@ -1,201 +0,0 @@ - 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. diff --git a/third_party/rust/pkg-config/LICENSE-MIT b/third_party/rust/pkg-config/LICENSE-MIT deleted file mode 100644 index 39e0ed660..000000000 --- a/third_party/rust/pkg-config/LICENSE-MIT +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2014 Alex Crichton - -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. diff --git a/third_party/rust/pkg-config/README.md b/third_party/rust/pkg-config/README.md deleted file mode 100644 index 4db41e2bb..000000000 --- a/third_party/rust/pkg-config/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# pkg-config-rs - -[![Build Status](https://travis-ci.org/alexcrichton/pkg-config-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/pkg-config-rs) - -[Documentation](http://alexcrichton.com/pkg-config-rs) - -A simple library meant to be used as a build dependency with Cargo packages in -order to use the system `pkg-config` tool (if available) to determine where a -library is located. - -```rust -extern crate pkg_config; - -fn main() { - pkg_config::find_library("foo").unwrap(); -} -``` - -# License - -`pkg-config-rs` is primarily distributed under the terms of both the MIT -license and the Apache License (Version 2.0), with portions covered by various -BSD-like licenses. - -See LICENSE-APACHE, and LICENSE-MIT for details. diff --git a/third_party/rust/pkg-config/src/lib.rs b/third_party/rust/pkg-config/src/lib.rs deleted file mode 100644 index 26f64adb7..000000000 --- a/third_party/rust/pkg-config/src/lib.rs +++ /dev/null @@ -1,471 +0,0 @@ -//! A build dependency for Cargo libraries to find system artifacts through the -//! `pkg-config` utility. -//! -//! This library will shell out to `pkg-config` as part of build scripts and -//! probe the system to determine how to link to a specified library. The -//! `Config` structure serves as a method of configuring how `pkg-config` is -//! invoked in a builder style. -//! -//! A number of environment variables are available to globally configure how -//! this crate will invoke `pkg-config`: -//! -//! * `PKG_CONFIG_ALLOW_CROSS` - if this variable is not set, then `pkg-config` -//! will automatically be disabled for all cross compiles. -//! * `FOO_NO_PKG_CONFIG` - if set, this will disable running `pkg-config` when -//! probing for the library named `foo`. -//! -//! There are also a number of environment variables which can configure how a -//! library is linked to (dynamically vs statically). These variables control -//! whether the `--static` flag is passed. Note that this behavior can be -//! overridden by configuring explicitly on `Config`. The variables are checked -//! in the following order: -//! -//! * `FOO_STATIC` - pass `--static` for the library `foo` -//! * `FOO_DYNAMIC` - do not pass `--static` for the library `foo` -//! * `PKG_CONFIG_ALL_STATIC` - pass `--static` for all libraries -//! * `PKG_CONFIG_ALL_DYNAMIC` - do not pass `--static` for all libraries -//! -//! After running `pkg-config` all appropriate Cargo metadata will be printed on -//! stdout if the search was successful. -//! -//! # Example -//! -//! Find the system library named `foo`. -//! -//! ```no_run -//! extern crate pkg_config; -//! -//! fn main() { -//! pkg_config::probe_library("foo").unwrap(); -//! } -//! ``` -//! -//! Configure how library `foo` is linked to. -//! -//! ```no_run -//! extern crate pkg_config; -//! -//! fn main() { -//! pkg_config::Config::new().statik(true).probe("foo").unwrap(); -//! } -//! ``` - -#![doc(html_root_url = "http://alexcrichton.com/pkg-config-rs")] -#![cfg_attr(test, deny(warnings))] - -use std::ascii::AsciiExt; -use std::env; -use std::error; -use std::ffi::{OsStr, OsString}; -use std::fmt; -use std::fs; -use std::io; -use std::path::{PathBuf, Path}; -use std::process::{Command, Output}; -use std::str; - -pub fn target_supported() -> bool { - let target = env::var("TARGET").unwrap_or(String::new()); - let host = env::var("HOST").unwrap_or(String::new()); - - // Only use pkg-config in host == target situations by default (allowing an - // override) and then also don't use pkg-config on MSVC as it's really not - // meant to work there but when building MSVC code in a MSYS shell we may be - // able to run pkg-config anyway. - (host == target || env::var_os("PKG_CONFIG_ALLOW_CROSS").is_some()) && - !target.contains("msvc") -} - -#[derive(Clone)] -pub struct Config { - statik: Option<bool>, - atleast_version: Option<String>, - extra_args: Vec<OsString>, - cargo_metadata: bool, -} - -#[derive(Debug)] -pub struct Library { - pub libs: Vec<String>, - pub link_paths: Vec<PathBuf>, - pub frameworks: Vec<String>, - pub framework_paths: Vec<PathBuf>, - pub include_paths: Vec<PathBuf>, - pub version: String, - _priv: (), -} - -/// Represents all reasons `pkg-config` might not succeed or be run at all. -pub enum Error { - /// Aborted because of `*_NO_PKG_CONFIG` environment variable. - /// - /// Contains the name of the responsible environment variable. - EnvNoPkgConfig(String), - - /// Cross compilation detected. - /// - /// Override with `PKG_CONFIG_ALLOW_CROSS=1`. - CrossCompilation, - - /// Failed to run `pkg-config`. - /// - /// Contains the command and the cause. - Command { command: String, cause: io::Error }, - - /// `pkg-config` did not exit sucessfully. - /// - /// Contains the command and output. - Failure { command: String, output: Output }, - - #[doc(hidden)] - // please don't match on this, we're likely to add more variants over time - __Nonexhaustive, -} - -impl error::Error for Error { - fn description(&self) -> &str { - match *self { - Error::EnvNoPkgConfig(_) => "pkg-config requested to be aborted", - Error::CrossCompilation => { - "pkg-config doesn't handle cross compilation. \ - Use PKG_CONFIG_ALLOW_CROSS=1 to override" - } - Error::Command { .. } => "failed to run pkg-config", - Error::Failure { .. } => "pkg-config did not exit sucessfully", - Error::__Nonexhaustive => panic!(), - } - } - - fn cause(&self) -> Option<&error::Error> { - match *self { - Error::Command { ref cause, .. } => Some(cause), - _ => None, - } - } -} - -// Workaround for temporary lack of impl Debug for Output in stable std -struct OutputDebugger<'a>(&'a Output); - -// Lifted from 1.7 std -impl<'a> fmt::Debug for OutputDebugger<'a> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let stdout_utf8 = str::from_utf8(&self.0.stdout); - let stdout_debug: &fmt::Debug = match stdout_utf8 { - Ok(ref str) => str, - Err(_) => &self.0.stdout - }; - - let stderr_utf8 = str::from_utf8(&self.0.stderr); - let stderr_debug: &fmt::Debug = match stderr_utf8 { - Ok(ref str) => str, - Err(_) => &self.0.stderr - }; - - fmt.debug_struct("Output") - .field("status", &self.0.status) - .field("stdout", stdout_debug) - .field("stderr", stderr_debug) - .finish() - } -} - -// Workaround for temporary lack of impl Debug for Output in stable std, continued -impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - Error::EnvNoPkgConfig(ref name) => { - f.debug_tuple("EnvNoPkgConfig") - .field(name) - .finish() - } - Error::CrossCompilation => write!(f, "CrossCompilation"), - Error::Command { ref command, ref cause } => { - f.debug_struct("Command") - .field("command", command) - .field("cause", cause) - .finish() - } - Error::Failure { ref command, ref output } => { - f.debug_struct("Failure") - .field("command", command) - .field("output", &OutputDebugger(output)) - .finish() - } - Error::__Nonexhaustive => panic!(), - } - } -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - match *self { - Error::EnvNoPkgConfig(ref name) => { - write!(f, "Aborted because {} is set", name) - } - Error::CrossCompilation => { - write!(f, "Cross compilation detected. \ - Use PKG_CONFIG_ALLOW_CROSS=1 to override") - } - Error::Command { ref command, ref cause } => { - write!(f, "Failed to run `{}`: {}", command, cause) - } - Error::Failure { ref command, ref output } => { - let stdout = str::from_utf8(&output.stdout).unwrap(); - let stderr = str::from_utf8(&output.stderr).unwrap(); - try!(write!(f, "`{}` did not exit successfully: {}", command, output.status)); - if !stdout.is_empty() { - try!(write!(f, "\n--- stdout\n{}", stdout)); - } - if !stderr.is_empty() { - try!(write!(f, "\n--- stdout\n{}", stderr)); - } - Ok(()) - } - Error::__Nonexhaustive => panic!(), - } - } -} - -/// Deprecated in favor of the probe_library function -#[doc(hidden)] -pub fn find_library(name: &str) -> Result<Library, String> { - probe_library(name).map_err(|e| e.to_string()) -} - -/// Simple shortcut for using all default options for finding a library. -pub fn probe_library(name: &str) -> Result<Library, Error> { - Config::new().probe(name) -} - -/// Run `pkg-config` to get the value of a variable from a package using -/// --variable. -pub fn get_variable(package: &str, variable: &str) -> Result<String, Error> { - let arg = format!("--variable={}", variable); - let cfg = Config::new(); - Ok(try!(run(cfg.command(package, &[&arg]))).trim_right().to_owned()) -} - -impl Config { - /// Creates a new set of configuration options which are all initially set - /// to "blank". - pub fn new() -> Config { - Config { - statik: None, - atleast_version: None, - extra_args: vec![], - cargo_metadata: true, - } - } - - /// Indicate whether the `--static` flag should be passed. - /// - /// This will override the inference from environment variables described in - /// the crate documentation. - pub fn statik(&mut self, statik: bool) -> &mut Config { - self.statik = Some(statik); - self - } - - /// Indicate that the library must be at least version `vers`. - pub fn atleast_version(&mut self, vers: &str) -> &mut Config { - self.atleast_version = Some(vers.to_string()); - self - } - - /// Add an argument to pass to pkg-config. - /// - /// It's placed after all of the arguments generated by this library. - pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Config { - self.extra_args.push(arg.as_ref().to_os_string()); - self - } - - /// Define whether metadata should be emitted for cargo allowing it to - /// automatically link the binary. Defaults to `true`. - pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Config { - self.cargo_metadata = cargo_metadata; - self - } - - /// Deprecated in favor fo the `probe` function - #[doc(hidden)] - pub fn find(&self, name: &str) -> Result<Library, String> { - self.probe(name).map_err(|e| e.to_string()) - } - - /// Run `pkg-config` to find the library `name`. - /// - /// This will use all configuration previously set to specify how - /// `pkg-config` is run. - pub fn probe(&self, name: &str) -> Result<Library, Error> { - let abort_var_name = format!("{}_NO_PKG_CONFIG", envify(name)); - if env::var_os(&abort_var_name).is_some() { - return Err(Error::EnvNoPkgConfig(abort_var_name)) - } else if !target_supported() { - return Err(Error::CrossCompilation); - } - - let mut library = Library::new(); - - let output = try!(run(self.command(name, &["--libs", "--cflags"]))); - library.parse_libs_cflags(name, &output, self); - - let output = try!(run(self.command(name, &["--modversion"]))); - library.parse_modversion(&output); - - Ok(library) - } - - /// Deprecated in favor of the top level `get_variable` function - #[doc(hidden)] - pub fn get_variable(package: &str, variable: &str) -> Result<String, String> { - get_variable(package, variable).map_err(|e| e.to_string()) - } - - fn is_static(&self, name: &str) -> bool { - self.statik.unwrap_or_else(|| infer_static(name)) - } - - fn command(&self, name: &str, args: &[&str]) -> Command { - let exe = env::var("PKG_CONFIG").unwrap_or(String::from("pkg-config")); - let mut cmd = Command::new(exe); - if self.is_static(name) { - cmd.arg("--static"); - } - cmd.args(args) - .args(&self.extra_args) - .env("PKG_CONFIG_ALLOW_SYSTEM_LIBS", "1"); - if let Some(ref version) = self.atleast_version { - cmd.arg(&format!("{} >= {}", name, version)); - } else { - cmd.arg(name); - } - cmd - } - - fn print_metadata(&self, s: &str) { - if self.cargo_metadata { - println!("cargo:{}", s); - } - } -} - -impl Library { - fn new() -> Library { - Library { - libs: Vec::new(), - link_paths: Vec::new(), - include_paths: Vec::new(), - frameworks: Vec::new(), - framework_paths: Vec::new(), - version: String::new(), - _priv: (), - } - } - - fn parse_libs_cflags(&mut self, name: &str, output: &str, config: &Config) { - let parts = output.trim_right() - .split(' ') - .filter(|l| l.len() > 2) - .map(|arg| (&arg[0..2], &arg[2..])) - .collect::<Vec<_>>(); - - let mut dirs = Vec::new(); - let statik = config.is_static(name); - for &(flag, val) in parts.iter() { - match flag { - "-L" => { - let meta = format!("rustc-link-search=native={}", val); - config.print_metadata(&meta); - dirs.push(PathBuf::from(val)); - self.link_paths.push(PathBuf::from(val)); - } - "-F" => { - let meta = format!("rustc-link-search=framework={}", val); - config.print_metadata(&meta); - self.framework_paths.push(PathBuf::from(val)); - } - "-I" => { - self.include_paths.push(PathBuf::from(val)); - } - "-l" => { - self.libs.push(val.to_string()); - if statik && !is_system(val, &dirs) { - let meta = format!("rustc-link-lib=static={}", val); - config.print_metadata(&meta); - } else { - let meta = format!("rustc-link-lib={}", val); - config.print_metadata(&meta); - } - } - _ => {} - } - } - - let mut iter = output.trim_right().split(' '); - while let Some(part) = iter.next() { - if part != "-framework" { - continue - } - if let Some(lib) = iter.next() { - let meta = format!("rustc-link-lib=framework={}", lib); - config.print_metadata(&meta); - self.frameworks.push(lib.to_string()); - } - } - } - - fn parse_modversion(&mut self, output: &str) { - self.version.push_str(output.trim()); - } -} - -fn infer_static(name: &str) -> bool { - let name = envify(name); - if env::var_os(&format!("{}_STATIC", name)).is_some() { - true - } else if env::var_os(&format!("{}_DYNAMIC", name)).is_some() { - false - } else if env::var_os("PKG_CONFIG_ALL_STATIC").is_some() { - true - } else if env::var_os("PKG_CONFIG_ALL_DYNAMIC").is_some() { - false - } else { - false - } -} - -fn envify(name: &str) -> String { - name.chars().map(|c| c.to_ascii_uppercase()).map(|c| { - if c == '-' {'_'} else {c} - }).collect() -} - -fn is_system(name: &str, dirs: &[PathBuf]) -> bool { - let libname = format!("lib{}.a", name); - let root = Path::new("/usr"); - !dirs.iter().any(|d| { - !d.starts_with(root) && fs::metadata(&d.join(&libname)).is_ok() - }) -} - -fn run(mut cmd: Command) -> Result<String, Error> { - match cmd.output() { - Ok(output) => { - if output.status.success() { - let stdout = String::from_utf8(output.stdout).unwrap(); - Ok(stdout) - } else { - Err(Error::Failure { - command: format!("{:?}", cmd), - output: output, - }) - } - } - Err(cause) => Err(Error::Command { - command: format!("{:?}", cmd), - cause: cause, - }), - } -} diff --git a/third_party/rust/pkg-config/tests/foo.pc b/third_party/rust/pkg-config/tests/foo.pc deleted file mode 100644 index b1ae3d8ce..000000000 --- a/third_party/rust/pkg-config/tests/foo.pc +++ /dev/null @@ -1,16 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include/valgrind -arch=amd64 -os=linux -platform=amd64-linux -valt_load_address=0x38000000 - -Name: Valgrind -Description: A dynamic binary instrumentation framework -Version: 3.10.0.SVN -Requires: -Libs: -L${libdir}/valgrind -lcoregrind-amd64-linux -lvex-amd64-linux -lgcc -Cflags: -I${includedir} - diff --git a/third_party/rust/pkg-config/tests/framework.pc b/third_party/rust/pkg-config/tests/framework.pc deleted file mode 100644 index 57c0447f1..000000000 --- a/third_party/rust/pkg-config/tests/framework.pc +++ /dev/null @@ -1,16 +0,0 @@ -prefix=/usr -exec_prefix=${prefix} -libdir=${exec_prefix}/lib -includedir=${prefix}/include/valgrind -arch=amd64 -os=linux -platform=amd64-linux -valt_load_address=0x38000000 - -Name: Valgrind -Description: A dynamic binary instrumentation framework -Version: 3.10.0.SVN -Requires: -Libs: -F${libdir} -framework foo -Cflags: -I${includedir} - diff --git a/third_party/rust/pkg-config/tests/test.rs b/third_party/rust/pkg-config/tests/test.rs deleted file mode 100644 index 842516690..000000000 --- a/third_party/rust/pkg-config/tests/test.rs +++ /dev/null @@ -1,97 +0,0 @@ -#![feature(static_mutex)] - -extern crate pkg_config; - -use pkg_config::Error; -use std::env; -use std::sync::{StaticMutex, MUTEX_INIT}; -use std::path::PathBuf; - -static LOCK: StaticMutex = MUTEX_INIT; - -fn reset() { - for (k, _) in env::vars() { - if k.contains("DYNAMIC") || - k.contains("STATIC") || - k.contains("PKG_CONFIG_ALLOW_CROSS") || - k.contains("FOO_NO_PKG_CONFIG") { - env::remove_var(&k); - } - } - env::remove_var("TARGET"); - env::remove_var("HOST"); - env::set_var("PKG_CONFIG_PATH", &env::current_dir().unwrap().join("tests")); -} - -fn find(name: &str) -> Result<pkg_config::Library, Error> { - pkg_config::probe_library(name) -} - -#[test] -fn cross_disabled() { - let _g = LOCK.lock(); - reset(); - env::set_var("TARGET", "foo"); - env::set_var("HOST", "bar"); - match find("foo") { - Err(Error::CrossCompilation) => {}, - x => panic!("Error::CrossCompilation expected, found `{:?}`", x), - } -} - -#[test] -fn cross_enabled() { - let _g = LOCK.lock(); - reset(); - env::set_var("TARGET", "foo"); - env::set_var("HOST", "bar"); - env::set_var("PKG_CONFIG_ALLOW_CROSS", "1"); - find("foo").unwrap(); -} - -#[test] -fn package_disabled() { - let _g = LOCK.lock(); - reset(); - env::set_var("FOO_NO_PKG_CONFIG", "1"); - match find("foo") { - Err(Error::EnvNoPkgConfig(name)) => { - assert_eq!(name, "FOO_NO_PKG_CONFIG") - } - x => panic!("Error::EnvNoPkgConfig expected, found `{:?}`", x), - } -} - -#[test] -fn output_ok() { - let _g = LOCK.lock(); - reset(); - let lib = find("foo").unwrap(); - assert!(lib.libs.contains(&"gcc".to_string())); - assert!(lib.libs.contains(&"coregrind-amd64-linux".to_string())); - assert!(lib.link_paths.contains(&PathBuf::from("/usr/lib/valgrind"))); -} - -#[test] -fn framework() { - let _g = LOCK.lock(); - reset(); - let lib = find("framework").unwrap(); - assert!(lib.frameworks.contains(&"foo".to_string())); - assert!(lib.framework_paths.contains(&PathBuf::from("/usr/lib"))); -} - -#[test] -fn get_variable() { - let _g = LOCK.lock(); - reset(); - let prefix = pkg_config::get_variable("foo", "prefix").unwrap(); - assert_eq!(prefix, "/usr"); -} - -#[test] -fn version() { - let _g = LOCK.lock(); - reset(); - assert_eq!(&find("foo").unwrap().version[..], "3.10.0.SVN"); -} |