Skip to content

Commit b58329a

Browse files
committed
---
yaml --- r: 145251 b: refs/heads/try2 c: cb7756a h: refs/heads/master i: 145249: 18ebdfa 145247: 9563cea v: v3
1 parent 9d6b508 commit b58329a

File tree

22 files changed

+1353
-478
lines changed

22 files changed

+1353
-478
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 36cc41481c788e8d781e24908dcf30120797ed8d
8+
refs/heads/try2: cb7756a81d3cbc48e79ffaa1a1f9d4934b581166
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2388,12 +2388,38 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23882388
let et = ccx.sess.entry_type.unwrap();
23892389
match et {
23902390
session::EntryMain => {
2391-
create_entry_fn(ccx, main_llfn, true);
2391+
let llfn = create_main(ccx, main_llfn);
2392+
create_entry_fn(ccx, llfn, true);
23922393
}
23932394
session::EntryStart => create_entry_fn(ccx, main_llfn, false),
23942395
session::EntryNone => {} // Do nothing.
23952396
}
23962397

2398+
fn create_main(ccx: @mut CrateContext, main_llfn: ValueRef) -> ValueRef {
2399+
let nt = ty::mk_nil();
2400+
let llfty = type_of_rust_fn(ccx, [], nt);
2401+
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
2402+
lib::llvm::CCallConv, llfty);
2403+
2404+
let fcx = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);
2405+
2406+
// the args vector built in create_entry_fn will need
2407+
// be updated if this assertion starts to fail.
2408+
assert!(!fcx.caller_expects_out_pointer);
2409+
2410+
let bcx = fcx.entry_bcx.unwrap();
2411+
// Call main.
2412+
let llenvarg = unsafe {
2413+
let env_arg = fcx.env_arg_pos();
2414+
llvm::LLVMGetParam(llfdecl, env_arg as c_uint)
2415+
};
2416+
let args = ~[llenvarg];
2417+
Call(bcx, main_llfn, args, []);
2418+
2419+
finish_fn(fcx, bcx);
2420+
return llfdecl;
2421+
}
2422+
23972423
fn create_entry_fn(ccx: @mut CrateContext,
23982424
rust_main: ValueRef,
23992425
use_start_lang_item: bool) {

branches/try2/src/librustpkg/api.rs

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use context::*;
1212
use crate::*;
1313
use package_id::*;
1414
use package_source::*;
15-
use target::*;
1615
use version::Version;
1716
use workcache_support::*;
1817

@@ -64,40 +63,56 @@ pub fn new_workcache_context(p: &Path) -> workcache::Context {
6463
pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
6564
lib: Path) {
6665
let cx = default_context(sysroot);
67-
let pkg_src = PkgSrc {
68-
workspace: root.clone(),
69-
start_dir: root.push("src").push(name),
70-
id: PkgId{ version: version, ..PkgId::new(name)},
71-
// n.b. This assumes the package only has one crate
72-
libs: ~[mk_crate(lib)],
66+
let subroot = root.clone();
67+
let subversion = version.clone();
68+
let sublib = lib.clone();
69+
do cx.workcache_context.with_prep(name) |prep| {
70+
let pkg_src = PkgSrc {
71+
workspace: subroot.clone(),
72+
start_dir: subroot.push("src").push(name),
73+
id: PkgId{ version: subversion.clone(), ..PkgId::new(name)},
74+
libs: ~[mk_crate(sublib.clone())],
7375
mains: ~[],
7476
tests: ~[],
7577
benchs: ~[]
7678
};
77-
pkg_src.build(&cx, ~[]);
79+
pkg_src.declare_inputs(prep);
80+
let subcx = cx.clone();
81+
let subsrc = pkg_src.clone();
82+
do prep.exec |exec| {
83+
subsrc.build(exec, &subcx.clone(), ~[]);
84+
}
85+
};
7886
}
7987

8088
pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
8189
main: Path) {
8290
let cx = default_context(sysroot);
83-
let pkg_src = PkgSrc {
84-
workspace: root.clone(),
85-
start_dir: root.push("src").push(name),
86-
id: PkgId{ version: version, ..PkgId::new(name)},
87-
libs: ~[],
88-
// n.b. This assumes the package only has one crate
89-
mains: ~[mk_crate(main)],
90-
tests: ~[],
91-
benchs: ~[]
92-
};
93-
94-
pkg_src.build(&cx, ~[]);
91+
let subroot = root.clone();
92+
let submain = main.clone();
93+
do cx.workcache_context.with_prep(name) |prep| {
94+
let pkg_src = PkgSrc {
95+
workspace: subroot.clone(),
96+
start_dir: subroot.push("src").push(name),
97+
id: PkgId{ version: version.clone(), ..PkgId::new(name)},
98+
libs: ~[],
99+
mains: ~[mk_crate(submain.clone())],
100+
tests: ~[],
101+
benchs: ~[]
102+
};
103+
pkg_src.declare_inputs(prep);
104+
let subsrc = pkg_src.clone();
105+
let subcx = cx.clone();
106+
do prep.exec |exec| {
107+
subsrc.clone().build(exec, &subcx.clone(), ~[]);
108+
}
109+
}
95110
}
96111

97112
pub fn install_pkg(sysroot: Path, workspace: Path, name: ~str, version: Version) {
98113
let cx = default_context(sysroot);
99114
let pkgid = PkgId{ version: version, ..PkgId::new(name)};
100-
cx.install(PkgSrc::new(workspace, false, pkgid), &Everything);
115+
cx.install(PkgSrc::new(workspace, false, pkgid));
101116
}
102117

103118
fn mk_crate(p: Path) -> Crate {

branches/try2/src/librustpkg/exit_codes.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

branches/try2/src/librustpkg/package_id.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ impl PkgId {
108108
}
109109
}
110110

111-
// This is the workcache function name for the *installed*
112-
// binaries for this package (as opposed to the built ones,
113-
// which are per-crate).
114-
pub fn install_tag(&self) -> ~str {
115-
fmt!("install(%s)", self.to_str())
116-
}
117111
}
118112

119113
struct Prefixes {

branches/try2/src/librustpkg/package_source.rs

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use path_util::{find_dir_using_rust_path_hack, default_workspace, make_dir_rwx_r
2222
use util::compile_crate;
2323
use workspace::is_workspace;
2424
use workcache_support;
25-
use workcache_support::crate_tag;
2625
use extra::workcache;
2726

2827
// An enumeration of the unpacked source of a package workspace.
@@ -232,7 +231,7 @@ impl PkgSrc {
232231
p.filestem().map_default(false, |p| { p == &self.id.short_name.as_slice() })
233232
}
234233

235-
pub fn push_crate(cs: &mut ~[Crate], prefix: uint, p: &Path) {
234+
fn push_crate(cs: &mut ~[Crate], prefix: uint, p: &Path) {
236235
assert!(p.components.len() > prefix);
237236
let mut sub = Path("");
238237
for c in p.components.slice(prefix, p.components.len()).iter() {
@@ -287,6 +286,7 @@ impl PkgSrc {
287286

288287
fn build_crates(&self,
289288
ctx: &BuildContext,
289+
exec: &mut workcache::Exec,
290290
destination_dir: &Path,
291291
crates: &[Crate],
292292
cfgs: &[~str],
@@ -297,40 +297,25 @@ impl PkgSrc {
297297
let path_str = path.to_str();
298298
let cfgs = crate.cfgs + cfgs;
299299

300-
do ctx.workcache_context.with_prep(crate_tag(&path)) |prep| {
301-
debug!("Building crate %s, declaring it as an input", path.to_str());
302-
prep.declare_input("file", path.to_str(),
303-
workcache_support::digest_file_with_date(&path));
304-
let subpath = path.clone();
305-
let subcfgs = cfgs.clone();
306-
let subpath_str = path_str.clone();
307-
let subcx = ctx.clone();
308-
let id = self.id.clone();
309-
let sub_dir = destination_dir.clone();
310-
let sub_flags = crate.flags.clone();
311-
do prep.exec |exec| {
312-
let result = compile_crate(&subcx,
313-
exec,
314-
&id,
315-
&subpath,
316-
&sub_dir,
317-
sub_flags,
318-
subcfgs,
319-
false,
320-
what).to_str();
321-
debug!("Result of compiling %s was %s", subpath_str, result);
322-
result
323-
}
324-
};
300+
let result =
301+
// compile_crate should return the path of the output artifact
302+
compile_crate(ctx,
303+
exec,
304+
&self.id,
305+
&path,
306+
destination_dir,
307+
crate.flags,
308+
cfgs,
309+
false,
310+
what).to_str();
311+
debug!("Result of compiling %s was %s", path_str, result);
325312
}
326313
}
327314

328315
/// Declare all the crate files in the package source as inputs
329-
/// (to the package)
330316
pub fn declare_inputs(&self, prep: &mut workcache::Prep) {
331317
let to_do = ~[self.libs.clone(), self.mains.clone(),
332318
self.tests.clone(), self.benchs.clone()];
333-
debug!("In declare inputs, self = %s", self.to_str());
334319
for cs in to_do.iter() {
335320
for c in cs.iter() {
336321
let path = self.start_dir.push_rel(&c.file).normalize();
@@ -345,6 +330,7 @@ impl PkgSrc {
345330
// It would be better if build returned a Path, but then Path would have to derive
346331
// Encodable.
347332
pub fn build(&self,
333+
exec: &mut workcache::Exec,
348334
build_context: &BuildContext,
349335
cfgs: ~[~str]) -> ~str {
350336
use conditions::not_a_workspace::cond;
@@ -374,23 +360,13 @@ impl PkgSrc {
374360
let benchs = self.benchs.clone();
375361
debug!("Building libs in %s, destination = %s",
376362
destination_workspace.to_str(), destination_workspace.to_str());
377-
self.build_crates(build_context, &destination_workspace, libs, cfgs, Lib);
363+
self.build_crates(build_context, exec, &destination_workspace, libs, cfgs, Lib);
378364
debug!("Building mains");
379-
self.build_crates(build_context, &destination_workspace, mains, cfgs, Main);
365+
self.build_crates(build_context, exec, &destination_workspace, mains, cfgs, Main);
380366
debug!("Building tests");
381-
self.build_crates(build_context, &destination_workspace, tests, cfgs, Test);
367+
self.build_crates(build_context, exec, &destination_workspace, tests, cfgs, Test);
382368
debug!("Building benches");
383-
self.build_crates(build_context, &destination_workspace, benchs, cfgs, Bench);
369+
self.build_crates(build_context, exec, &destination_workspace, benchs, cfgs, Bench);
384370
destination_workspace.to_str()
385371
}
386-
387-
/// Debugging
388-
pub fn dump_crates(&self) {
389-
let crate_sets = [&self.libs, &self.mains, &self.tests, &self.benchs];
390-
for crate_set in crate_sets.iter() {
391-
for c in crate_set.iter() {
392-
debug!("Built crate: %s", c.file.to_str())
393-
}
394-
}
395-
}
396372
}

0 commit comments

Comments
 (0)