Browse Source

Merge branch 'master' into peterhj-cuda

cl-test
Peter Jin 7 years ago
parent
commit
3ccd18d012
  1. 6
      .travis.yml
  2. 8
      Cargo.toml
  3. 57
      README.md
  4. 6
      appveyor.yml
  5. 9
      cc-test/Cargo.toml
  6. 20
      cc-test/build.rs
  7. 0
      cc-test/src/NMakefile
  8. 0
      cc-test/src/bar1.c
  9. 0
      cc-test/src/bar2.c
  10. 0
      cc-test/src/baz.cpp
  11. 0
      cc-test/src/expand.c
  12. 0
      cc-test/src/foo.c
  13. 0
      cc-test/src/i686.S
  14. 0
      cc-test/src/i686.asm
  15. 0
      cc-test/src/include/foo.h
  16. 0
      cc-test/src/lib.rs
  17. 0
      cc-test/src/msvc.c
  18. 0
      cc-test/src/opt_linkage.c
  19. 0
      cc-test/src/windows.c
  20. 0
      cc-test/src/x86_64.S
  21. 0
      cc-test/src/x86_64.asm
  22. 4
      cc-test/tests/all.rs
  23. 216
      src/lib.rs
  24. 2
      tests/cc_env.rs
  25. 6
      tests/support/mod.rs
  26. 2
      tests/test.rs

6
.travis.yml

@ -21,9 +21,9 @@ script:
- cargo build --verbose
- cargo test --verbose
- cargo test --verbose --features parallel
- cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET
- cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET --features parallel
- cargo test --manifest-path gcc-test/Cargo.toml --target $TARGET --release
- cargo test --manifest-path cc-test/Cargo.toml --target $TARGET
- cargo test --manifest-path cc-test/Cargo.toml --target $TARGET --features parallel
- cargo test --manifest-path cc-test/Cargo.toml --target $TARGET --release
- cargo doc
- cargo clean && cargo build
- rustdoc --test README.md -L target/debug -L target/debug/deps

8
Cargo.toml

@ -1,11 +1,11 @@
[package]
name = "gcc"
version = "0.3.54"
name = "cc"
version = "1.0.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/gcc-rs"
documentation = "https://docs.rs/gcc"
repository = "https://github.com/alexcrichton/cc-rs"
documentation = "https://docs.rs/cc"
description = """
A build-time dependency for Cargo build scripts to assist in invoking the native
C compiler to compile native C code into a static archive to be linked into Rust

57
README.md

@ -1,30 +1,27 @@
# gcc-rs
# cc-rs
A library to compile C/C++ code into a Rust library/application.
A library to compile C/C++/assembly into a Rust library/application.
[![Build Status](https://travis-ci.org/alexcrichton/gcc-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/gcc-rs)
[![Build status](https://ci.appveyor.com/api/projects/status/onu270iw98h81nwv?svg=true)](https://ci.appveyor.com/project/alexcrichton/gcc-rs)
[![Build Status](https://travis-ci.org/alexcrichton/cc-rs.svg?branch=master)](https://travis-ci.org/alexcrichton/cc-rs)
[![Build status](https://ci.appveyor.com/api/projects/status/onu270iw98h81nwv?svg=true)](https://ci.appveyor.com/project/alexcrichton/cc-rs)
[Documentation](https://docs.rs/gcc)
[Documentation](https://docs.rs/cc)
A simple library meant to be used as a build dependency with Cargo packages in
order to build a set of C/C++ files into a static archive. Note that while this
crate is called "gcc", it actually calls out to the most relevant compile for
a platform, for example using `cl` on MSVC. That is, this crate does indeed work
on MSVC!
order to build a set of C/C++ files into a static archive. This crate calls out
to the most relevant compiler for a platform, for example using `cl` on MSVC.
## Using gcc-rs
> **Note**: this crate was recently renamed from the `gcc` crate, so if you're
> looking for the `gcc` crate you're in the right spot!
## Using cc-rs
First, you'll want to both add a build script for your crate (`build.rs`) and
also add this crate to your `Cargo.toml` via:
```toml
[package]
# ...
build = "build.rs"
[build-dependencies]
gcc = "0.3"
cc = "1.0"
```
Next up, you'll want to write a build script like so:
@ -32,10 +29,10 @@ Next up, you'll want to write a build script like so:
```rust,no_run
// build.rs
extern crate gcc;
extern crate cc;
fn main() {
gcc::Build::new()
cc::Build::new()
.file("foo.c")
.file("bar.c")
.compile("foo");
@ -70,7 +67,7 @@ fn main() {
To control the programs and flags used for building, the builder can set a
number of different environment variables.
* `CFLAGS` - a series of space separated flags passed to "gcc". Note that
* `CFLAGS` - a series of space separated flags passed to compilers. Note that
individual flags cannot currently contain spaces, so doing
something like: "-L=foo\ bar" is not possible.
* `CC` - the actual C compiler used. Note that this is used as an exact
@ -89,9 +86,9 @@ in the following prioritized order:
3. `<build-kind>_<var>` - for example, `HOST_CC` or `TARGET_CFLAGS`
4. `<var>` - a plain `CC`, `AR` as above.
If none of these variables exist, gcc-rs uses built-in defaults
If none of these variables exist, cc-rs uses built-in defaults
In addition to the the above optional environment variables, `gcc-rs` has some
In addition to the the above optional environment variables, `cc-rs` has some
functions with hard requirements on some variables supplied by [cargo's
build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`,
and `HOST` variables.
@ -100,16 +97,16 @@ and `HOST` variables.
## Optional features
Currently gcc-rs supports parallel compilation (think `make -jN`) but this
feature is turned off by default. To enable gcc-rs to compile C/C++ in parallel,
Currently cc-rs supports parallel compilation (think `make -jN`) but this
feature is turned off by default. To enable cc-rs to compile C/C++ in parallel,
you can change your dependency to:
```toml
[build-dependencies]
gcc = { version = "0.3", features = ["parallel"] }
cc = { version = "1.0", features = ["parallel"] }
```
By default gcc-rs will limit parallelism to `$NUM_JOBS`, or if not present it
By default cc-rs will limit parallelism to `$NUM_JOBS`, or if not present it
will limit it to the number of cpus on the machine. If you are using cargo,
use `-jN` option of `build`, `test` and `run` commands as `$NUM_JOBS`
is supplied by cargo.
@ -121,13 +118,13 @@ is being run. This crate does not ship a C compiler with it. The compiler
required varies per platform, but there are three broad categories:
* Unix platforms require `cc` to be the C compiler. This can be found by
installing gcc/clang on Linux distributions and Xcode on OSX, for example.
installing cc/clang on Linux distributions and Xcode on OSX, for example.
* Windows platforms targeting MSVC (e.g. your target triple ends in `-msvc`)
require `cl.exe` to be available and in `PATH`. This is typically found in
standard Visual Studio installations and the `PATH` can be set up by running
the appropriate developer tools shell.
* Windows platforms targeting MinGW (e.g. your target triple ends in `-gnu`)
require `gcc` to be available in `PATH`. We recommend the
require `cc` to be available in `PATH`. We recommend the
[MinGW-w64](http://mingw-w64.org) distribution, which is using the
[Win-builds](http://win-builds.org) installation system.
You may also acquire it via
@ -140,14 +137,14 @@ required varies per platform, but there are three broad categories:
## C++ support
`gcc-rs` supports C++ libraries compilation by using the `cpp` method on
`cc-rs` supports C++ libraries compilation by using the `cpp` method on
`Build`:
```rust,no_run
extern crate gcc;
extern crate cc;
fn main() {
gcc::Build::new()
cc::Build::new()
.cpp(true) // Switch to C++ library compilation.
.file("foo.cpp")
.compile("libfoo.a");
@ -179,7 +176,7 @@ fn main() {
## License
`gcc-rs` is primarily distributed under the terms of both the MIT license and
`cc-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.

6
appveyor.yml

@ -50,6 +50,6 @@ build: false
test_script:
- cargo test --target %TARGET%
- cargo test --features parallel --target %TARGET%
- cargo test --manifest-path gcc-test/Cargo.toml --target %TARGET%
- cargo test --manifest-path gcc-test/Cargo.toml --features parallel --target %TARGET%
- cargo test --manifest-path gcc-test/Cargo.toml --release --target %TARGET%
- cargo test --manifest-path cc-test/Cargo.toml --target %TARGET%
- cargo test --manifest-path cc-test/Cargo.toml --features parallel --target %TARGET%
- cargo test --manifest-path cc-test/Cargo.toml --release --target %TARGET%

9
gcc-test/Cargo.toml → cc-test/Cargo.toml

@ -1,16 +1,15 @@
[package]
name = "gcc-test"
name = "cc-test"
version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
build = "build.rs"
[lib]
name = "gcc_test"
name = "cc_test"
doctest = false
test = false
[build-dependencies]
gcc = { path = ".." }
cc = { path = ".." }
[features]
parallel = ["gcc/parallel"]
parallel = ["cc/parallel"]

20
gcc-test/build.rs → cc-test/build.rs

@ -1,4 +1,4 @@
extern crate gcc;
extern crate cc;
use std::env;
use std::fs;
@ -9,7 +9,7 @@ fn main() {
fs::remove_dir_all(&out).unwrap();
fs::create_dir(&out).unwrap();
gcc::Build::new()
cc::Build::new()
.file("src/foo.c")
.flag_if_supported("-Wall")
.flag_if_supported("-Wfoo-bar-this-flag-does-not-exist")
@ -17,7 +17,7 @@ fn main() {
.define("BAR", "1")
.compile("foo");
gcc::Build::new()
cc::Build::new()
.file("src/bar1.c")
.file("src/bar2.c")
.include("src/include")
@ -28,17 +28,17 @@ fn main() {
let file = format!("src/{}.{}",
file,
if target.contains("msvc") { "asm" } else { "S" });
gcc::Build::new()
cc::Build::new()
.file(file)
.compile("asm");
gcc::Build::new()
cc::Build::new()
.file("src/baz.cpp")
.cpp(true)
.compile("baz");
if target.contains("windows") {
gcc::Build::new()
cc::Build::new()
.file("src/windows.c")
.compile("windows");
}
@ -50,7 +50,7 @@ fn main() {
let out = out.join("tmp");
fs::create_dir(&out).unwrap();
println!("nmake 1");
let status = gcc::windows_registry::find(&target, "nmake.exe")
let status = cc::windows_registry::find(&target, "nmake.exe")
.unwrap()
.env_remove("MAKEFLAGS")
.arg("/fsrc/NMakefile")
@ -67,7 +67,7 @@ fn main() {
env::remove_var("INCLUDE");
env::remove_var("LIB");
println!("nmake 2");
let status = gcc::windows_registry::find(&target, "nmake.exe")
let status = cc::windows_registry::find(&target, "nmake.exe")
.unwrap()
.env_remove("MAKEFLAGS")
.arg("/fsrc/NMakefile")
@ -81,12 +81,12 @@ fn main() {
// This tests whether we can build a library but not link it to the main
// crate. The test module will do its own linking.
gcc::Build::new()
cc::Build::new()
.cargo_metadata(false)
.file("src/opt_linkage.c")
.compile("OptLinkage");
let out = gcc::Build::new()
let out = cc::Build::new()
.file("src/expand.c")
.expand();
let out = String::from_utf8(out).unwrap();

0
gcc-test/src/NMakefile → cc-test/src/NMakefile

0
gcc-test/src/bar1.c → cc-test/src/bar1.c

0
gcc-test/src/bar2.c → cc-test/src/bar2.c

0
gcc-test/src/baz.cpp → cc-test/src/baz.cpp

0
gcc-test/src/expand.c → cc-test/src/expand.c

0
gcc-test/src/foo.c → cc-test/src/foo.c

0
gcc-test/src/i686.S → cc-test/src/i686.S

0
gcc-test/src/i686.asm → cc-test/src/i686.asm

0
gcc-test/src/include/foo.h → cc-test/src/include/foo.h

0
gcc-test/src/lib.rs → cc-test/src/lib.rs

0
gcc-test/src/msvc.c → cc-test/src/msvc.c

0
gcc-test/src/opt_linkage.c → cc-test/src/opt_linkage.c

0
gcc-test/src/windows.c → cc-test/src/windows.c

0
gcc-test/src/x86_64.S → cc-test/src/x86_64.S

0
gcc-test/src/x86_64.asm → cc-test/src/x86_64.asm

4
gcc-test/tests/all.rs → cc-test/tests/all.rs

@ -1,6 +1,6 @@
extern crate gcc_test;
extern crate cc_test;
use gcc_test::*;
use cc_test::*;
#[link(name = "OptLinkage", kind = "static")]
extern "C" {

216
src/lib.rs

@ -5,7 +5,7 @@
//!
//! ```toml
//! [build-dependencies]
//! gcc = "0.3"
//! cc = "1.0"
//! ```
//!
//! The purpose of this crate is to provide the utility functions necessary to
@ -26,18 +26,18 @@
//! Use the `Build` struct to compile `src/foo.c`:
//!
//! ```no_run
//! extern crate gcc;
//! extern crate cc;
//!
//! fn main() {
//! gcc::Build::new()
//! .file("src/foo.c")
//! .define("FOO", Some("bar"))
//! .include("src")
//! .compile("foo");
//! cc::Build::new()
//! .file("src/foo.c")
//! .define("FOO", Some("bar"))
//! .include("src")
//! .compile("foo");
//! }
//! ```
#![doc(html_root_url = "https://docs.rs/gcc/0.3")]
#![doc(html_root_url = "https://docs.rs/cc/1.0")]
#![cfg_attr(test, deny(warnings))]
#![deny(missing_docs)]
@ -52,10 +52,6 @@ use std::process::{Command, Stdio, Child};
use std::io::{self, BufReader, BufRead, Read, Write};
use std::thread::{self, JoinHandle};
#[doc(hidden)]
#[deprecated(since="0.3.51", note="gcc::Config has been renamed to gcc::Build")]
pub type Config = Build;
#[cfg(feature = "parallel")]
use std::sync::Mutex;
@ -73,7 +69,11 @@ mod setup_config;
pub mod windows_registry;
/// Extra configuration to pass to gcc.
/// A builder for compilation of a native static library.
///
/// A `Build` is the main type of the `cc` crate and is used to control all the
/// various configuration options and such of a compile. You'll find more
/// documentation on each method itself.
#[derive(Clone, Debug)]
pub struct Build {
include_directories: Vec<PathBuf>,
@ -103,7 +103,7 @@ pub struct Build {
warnings: bool,
}
/// Represents the types of errors that may occur while using gcc-rs.
/// Represents the types of errors that may occur while using cc-rs.
#[derive(Clone, Debug)]
enum ErrorKind {
/// Error occurred while performing I/O.
@ -292,29 +292,6 @@ impl Object {
}
}
/// Compile a library from the given set of input C files.
///
/// This will simply compile all files into object files and then assemble them
/// into the output. This will read the standard environment variables to detect
/// cross compilations and such.
///
/// This function will also print all metadata on standard output for Cargo.
///
/// # Example
///
/// ```no_run
/// gcc::compile_library("foo", &["foo.c", "bar.c"]);
/// ```
#[deprecated]
#[doc(hidden)]
pub fn compile_library(output: &str, files: &[&str]) {
let mut c = Build::new();
for f in files.iter() {
c.file(*f);
}
c.compile(output);
}
impl Build {
/// Construct a new instance of a blank set of configuration.
///
@ -360,11 +337,11 @@ impl Build {
///
/// let library_path = Path::new("/path/to/library");
///
/// gcc::Build::new()
/// .file("src/foo.c")
/// .include(library_path)
/// .include("src")
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .include(library_path)
/// .include("src")
/// .compile("foo");
/// ```
pub fn include<P: AsRef<Path>>(&mut self, dir: P) -> &mut Build {
self.include_directories.push(dir.as_ref().to_path_buf());
@ -376,11 +353,11 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .define("FOO", "BAR")
/// .define("BAZ", None)
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .define("FOO", "BAR")
/// .define("BAZ", None)
/// .compile("foo");
/// ```
pub fn define<'a, V: Into<Option<&'a str>>>(&mut self, var: &str, val: V) -> &mut Build {
self.definitions.push((var.to_string(), val.into().map(|s| s.to_string())));
@ -398,10 +375,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .flag("-ffunction-sections")
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .flag("-ffunction-sections")
/// .compile("foo");
/// ```
pub fn flag(&mut self, flag: &str) -> &mut Build {
self.flags.push(flag.to_string());
@ -454,11 +431,11 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .flag_if_supported("-Wlogical-op") // only supported by GCC
/// .flag_if_supported("-Wunreachable-code") // only supported by clang
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .flag_if_supported("-Wlogical-op") // only supported by GCC
/// .flag_if_supported("-Wunreachable-code") // only supported by clang
/// .compile("foo");
/// ```
pub fn flag_if_supported(&mut self, flag: &str) -> &mut Build {
self.flags_supported.push(flag.to_string());
@ -473,10 +450,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .shared_flag(true)
/// .compile("libfoo.so");
/// cc::Build::new()
/// .file("src/foo.c")
/// .shared_flag(true)
/// .compile("libfoo.so");
/// ```
pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Build {
@ -492,11 +469,11 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .shared_flag(true)
/// .static_flag(true)
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .shared_flag(true)
/// .static_flag(true)
/// .compile("foo");
/// ```
pub fn static_flag(&mut self, static_flag: bool) -> &mut Build {
self.static_flag = Some(static_flag);
@ -549,7 +526,7 @@ impl Build {
/// Disabled by default.
///
/// Warning: turning warnings into errors only make sense
/// if you are a developer of the crate using gcc-rs.
/// if you are a developer of the crate using cc-rs.
/// Some warnings only appear on some architecture or
/// specific version of the compiler. Any user of this crate,
/// or any other crate depending on it, could fail during
@ -558,10 +535,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .warnings_into_errors(true)
/// .compile("libfoo.a");
/// cc::Build::new()
/// .file("src/foo.c")
/// .warnings_into_errors(true)
/// .compile("libfoo.a");
/// ```
pub fn warnings_into_errors(&mut self, warnings_into_errors: bool) -> &mut Build {
self.warnings_into_errors = warnings_into_errors;
@ -579,10 +556,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .warnings(false)
/// .compile("libfoo.a");
/// cc::Build::new()
/// .file("src/foo.c")
/// .warnings(false)
/// .compile("libfoo.a");
/// ```
pub fn warnings(&mut self, warnings: bool) -> &mut Build {
self.warnings = warnings;
@ -608,11 +585,11 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .shared_flag(true)
/// .cpp_link_stdlib("stdc++")
/// .compile("libfoo.so");
/// cc::Build::new()
/// .file("src/foo.c")
/// .shared_flag(true)
/// .cpp_link_stdlib("stdc++")
/// .compile("libfoo.so");
/// ```
pub fn cpp_link_stdlib<'a, V: Into<Option<&'a str>>>(&mut self, cpp_link_stdlib: V) -> &mut Build {
self.cpp_link_stdlib = Some(cpp_link_stdlib.into().map(|s| s.into()));
@ -647,10 +624,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .cpp_set_stdlib("c++")
/// .compile("libfoo.a");
/// cc::Build::new()
/// .file("src/foo.c")
/// .cpp_set_stdlib("c++")
/// .compile("libfoo.a");
/// ```
pub fn cpp_set_stdlib<'a, V: Into<Option<&'a str>>>(&mut self, cpp_set_stdlib: V) -> &mut Build {
let cpp_set_stdlib = cpp_set_stdlib.into();
@ -667,10 +644,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .target("aarch64-linux-android")
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .target("aarch64-linux-android")
/// .compile("foo");
/// ```
pub fn target(&mut self, target: &str) -> &mut Build {
self.target = Some(target.to_string());
@ -685,10 +662,10 @@ impl Build {
/// # Example
///
/// ```no_run
/// gcc::Build::new()
/// .file("src/foo.c")
/// .host("arm-linux-gnueabihf")
/// .compile("foo");
/// cc::Build::new()
/// .file("src/foo.c")
/// .host("arm-linux-gnueabihf")
/// .compile("foo");
/// ```
pub fn host(&mut self, host: &str) -> &mut Build {
self.host = Some(host.to_string());
@ -972,9 +949,7 @@ impl Build {
///
/// # Example
/// ```no_run
/// let out = gcc::Build::new()
/// .file("src/foo.c")
/// .expand();
/// let out = cc::Build::new().file("src/foo.c").expand();
/// ```
pub fn expand(&self) -> Vec<u8> {
match self.try_expand() {
@ -1112,6 +1087,7 @@ impl Build {
// (specified in the android spec online)
if target.starts_with("armv7-linux-androideabi") {
cmd.args.push("-march=armv7-a".into());
cmd.args.push("-mthumb".into());
cmd.args.push("-mfpu=vfpv3-d16".into());
cmd.args.push("-mfloat-abi=softfp".into());
}
@ -1304,11 +1280,8 @@ impl Build {
Err(_) => return Err(Error::new(ErrorKind::IOError, "Could not copy or create a hard-link to the generated lib file.")),
};
} else {
let ar = self.get_ar()?;
let cmd = ar.file_name()
.ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get archiver (ar) path."))?
.to_string_lossy();
run(self.cmd(&ar)
let (mut ar, cmd) = self.get_ar()?;
run(ar
.arg("crs")
.arg(dst)
.args(&objects)
@ -1565,28 +1538,29 @@ impl Build {
}
}
fn get_ar(&self) -> Result<PathBuf, Error> {
match self.archiver
.clone()
.or_else(|| self.get_var("AR").map(PathBuf::from).ok()) {
Some(p) => Ok(p),
None => {
if self.get_target()?.contains("android") {
Ok(PathBuf::from(format!("{}-ar", self.get_target()?.replace("armv7", "arm"))))
} else if self.get_target()?.contains("emscripten") {
//Windows use bat files so we have to be a bit more specific
let tool = if cfg!(windows) {
"emar.bat"
} else {
"emar"
};
Ok(PathBuf::from(tool))
} else {
Ok(PathBuf::from("ar"))
}
}
fn get_ar(&self) -> Result<(Command, String), Error> {
if let Some(ref p) = self.archiver {
let name = p.file_name().and_then(|s| s.to_str()).unwrap_or("ar");
return Ok((self.cmd(p), name.to_string()))
}
if let Ok(p) = self.get_var("AR") {
return Ok((self.cmd(&p), p))
}
let program = if self.get_target()?.contains("android") {
format!("{}-ar", self.get_target()?.replace("armv7", "arm"))
} else if self.get_target()?.contains("emscripten") {
// Windows use bat files so we have to be a bit more specific
if cfg!(windows) {
let mut cmd = self.cmd("cmd");
cmd.arg("/c").arg("emar.bat");
return Ok((cmd, "emar.bat".to_string()))
}
"emar".to_string()
} else {
"ar".to_string()
};
Ok((self.cmd(&program), program))
}
fn get_target(&self) -> Result<String, Error> {
@ -1780,7 +1754,7 @@ fn spawn(cmd: &mut Command, program: &str) -> Result<(Child, JoinHandle<()>), Er
}
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
let extra = if cfg!(windows) {
" (see https://github.com/alexcrichton/gcc-rs#compile-time-requirements \
" (see https://github.com/alexcrichton/cc-rs#compile-time-requirements \
for help)"
} else {
""

2
tests/cc_env.rs

@ -1,5 +1,5 @@
extern crate tempdir;
extern crate gcc;
extern crate cc;
use std::env;

6
tests/support/mod.rs

@ -6,7 +6,7 @@ use std::fs::{self, File};
use std::io::prelude::*;
use std::path::PathBuf;
use gcc;
use cc;
use tempdir::TempDir;
pub struct Test {
@ -55,8 +55,8 @@ impl Test {
self
}
pub fn gcc(&self) -> gcc::Build {
let mut cfg = gcc::Build::new();
pub fn gcc(&self) -> cc::Build {
let mut cfg = cc::Build::new();
let mut path = env::split_paths(&env::var_os("PATH").unwrap()).collect::<Vec<_>>();
path.insert(0, self.td.path().to_owned());
let target = if self.msvc {

2
tests/test.rs

@ -1,4 +1,4 @@
extern crate gcc;
extern crate cc;
extern crate tempdir;
use support::Test;

Loading…
Cancel
Save