-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustpkg: Begin allowing package scripts to call the default build logic
rustpkg/api.rs provides functions intended for package scripts to call. It will probably need more functionality added to it later, but this is a start. Added a test case checking that a package script can use the API. Closes #6401
- Loading branch information
1 parent
22408d9
commit 3789433
Showing
7 changed files
with
166 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2013 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. | ||
|
||
use context::*; | ||
use crate::*; | ||
use package_id::*; | ||
use package_source::*; | ||
use version::Version; | ||
|
||
use core::option::*; | ||
use core::os; | ||
use core::hashmap::*; | ||
use core::path::*; | ||
|
||
/// Convenience functions intended for calling from pkg.rs | ||
fn default_ctxt(p: @Path) -> Ctx { | ||
Ctx { sysroot_opt: Some(p), json: false, dep_cache: @mut HashMap::new() } | ||
} | ||
|
||
pub fn build_lib(sysroot: @Path, root: Path, dest: Path, name: ~str, version: Version, | ||
lib: Path) { | ||
|
||
let pkg_src = PkgSrc { | ||
root: root, | ||
dst_dir: dest, | ||
id: PkgId{ version: version, ..PkgId::new(name)}, | ||
libs: ~[mk_crate(lib)], | ||
mains: ~[], | ||
tests: ~[], | ||
benchs: ~[] | ||
}; | ||
pkg_src.build(&default_ctxt(sysroot), pkg_src.dst_dir, ~[]); | ||
} | ||
|
||
pub fn build_exe(sysroot: @Path, root: Path, dest: Path, name: ~str, version: Version, | ||
main: Path) { | ||
let pkg_src = PkgSrc { | ||
root: root, | ||
dst_dir: dest, | ||
id: PkgId{ version: version, ..PkgId::new(name)}, | ||
libs: ~[], | ||
mains: ~[mk_crate(main)], | ||
tests: ~[], | ||
benchs: ~[] | ||
}; | ||
pkg_src.build(&default_ctxt(sysroot), pkg_src.dst_dir, ~[]); | ||
|
||
} | ||
|
||
pub fn install_lib(sysroot: @Path, | ||
workspace: Path, | ||
name: ~str, | ||
lib_path: Path, | ||
version: Version) { | ||
debug!("self_exe: %?", os::self_exe_path()); | ||
debug!("sysroot = %s", sysroot.to_str()); | ||
debug!("workspace = %s", workspace.to_str()); | ||
// make a PkgSrc | ||
let pkg_id = PkgId{ version: version, ..PkgId::new(name)}; | ||
let build_dir = workspace.push("build"); | ||
let dst_dir = build_dir.push_rel(&*pkg_id.local_path); | ||
let pkg_src = PkgSrc { | ||
root: copy workspace, | ||
dst_dir: copy dst_dir, | ||
id: copy pkg_id, | ||
libs: ~[mk_crate(lib_path)], | ||
mains: ~[], | ||
tests: ~[], | ||
benchs: ~[] | ||
}; | ||
let cx = default_ctxt(sysroot); | ||
pkg_src.build(&cx, dst_dir, ~[]); | ||
cx.install_no_build(&workspace, &pkg_id); | ||
} | ||
|
||
pub fn install_exe(sysroot: @Path, workspace: Path, name: ~str, version: Version) { | ||
default_ctxt(sysroot).install(&workspace, &PkgId{ version: version, | ||
..PkgId::new(name)}); | ||
|
||
} | ||
|
||
fn mk_crate(p: Path) -> Crate { | ||
Crate { file: p, flags: ~[], cfgs: ~[] } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3789433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from brson
at catamorphism@3789433
3789433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging catamorphism/rust/package-scripts = 3789433 into auto
3789433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catamorphism/rust/package-scripts = 3789433 merged ok, testing candidate = c440743
3789433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/115
http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/115
http://buildbot.rust-lang.org/builders/auto-mac-64-nopt/builds/120
http://buildbot.rust-lang.org/builders/auto-mac-64-opt-vg/builds/112
http://buildbot.rust-lang.org/builders/auto-mac-all-opt/builds/116
http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/136
http://buildbot.rust-lang.org/builders/auto-linux-32-nopt/builds/137
http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/135
http://buildbot.rust-lang.org/builders/auto-linux-64-nopt/builds/136
http://buildbot.rust-lang.org/builders/auto-linux-64-opt-vg/builds/132
http://buildbot.rust-lang.org/builders/auto-linux-all-opt/builds/134
http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/117
http://buildbot.rust-lang.org/builders/auto-win-32-nopt/builds/133
3789433
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = c440743