Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/librustc_back/target/asmjs_unknown_emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
// except according to those terms.

use super::{Target, TargetOptions};
use super::emscripten_base::{cmd};

pub fn target() -> Result<Target, String> {
let opts = TargetOptions {
linker: "emcc".to_string(),
ar: "emar".to_string(),
linker: cmd("emcc"),
ar: cmd("emar"),

dynamic_linking: false,
executables: true,
Expand Down
19 changes: 19 additions & 0 deletions src/librustc_back/target/emscripten_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[cfg(not(windows))]
pub fn cmd(name: &str) -> String {
name.to_string()
}

#[cfg(windows)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of #[cfg], could this use cfg! perhaps to get type checking everywhere? Something like:

pub fn cmd(name: &str) -> String {
    if cfg!(windows) {
        format!("{}.bat", name)
    } else {
        name.to_string()
    }
}

pub fn cmd(name: &str) -> String {
[name, ".bat"].concat()
}
1 change: 1 addition & 0 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ mod apple_ios_base;
mod arm_base;
mod bitrig_base;
mod dragonfly_base;
mod emscripten_base;
mod freebsd_base;
mod haiku_base;
mod linux_base;
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_back/target/wasm32_unknown_emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
// except according to those terms.

use super::{Target, TargetOptions};
use super::emscripten_base::{cmd};

pub fn target() -> Result<Target, String> {
let opts = TargetOptions {
linker: "emcc".to_string(),
ar: "emar".to_string(),
linker: cmd("emcc"),
ar: cmd("emar"),

dynamic_linking: false,
executables: true,
Expand Down