diff --git a/src/comp/front/attr.rs b/src/comp/front/attr.rs index 152f81c5b7aa..4fe0b814165b 100644 --- a/src/comp/front/attr.rs +++ b/src/comp/front/attr.rs @@ -99,11 +99,15 @@ fn eq(@ast::meta_item a, @ast::meta_item b) -> bool { } fn contains(&vec[@ast::meta_item] haystack, @ast::meta_item needle) -> bool { + log #fmt("looking for %s", pretty::pprust::meta_item_to_str(*needle)); for (@ast::meta_item item in haystack) { + log #fmt("looking in %s", pretty::pprust::meta_item_to_str(*item)); if (eq(item, needle)) { + log "found it!"; ret true; } } + log "found it not :("; ret false; } diff --git a/src/comp/front/config.rs b/src/comp/front/config.rs index 5d10ea05816b..bbfc90015723 100644 --- a/src/comp/front/config.rs +++ b/src/comp/front/config.rs @@ -71,12 +71,30 @@ fn fold_block(&ast::crate_cfg cfg, &ast::block_ b, // configuration based on the item's attributes fn in_cfg(&ast::crate_cfg cfg, &@ast::item item) -> bool { + // The "cfg" attributes on the item auto item_cfg_attrs = attr::find_attrs_by_name(item.attrs, "cfg"); - auto item_has_cfg_attrs = vec::len(item_cfg_attrs) > 0u; if (!item_has_cfg_attrs) { ret true; } - auto item_cfg_metas = attr::attr_metas(item_cfg_attrs); + // Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes, + // so we can match against them. This is the list of configurations for + // which the item is valid + auto item_cfg_metas = { + fn extract_metas(&vec[@ast::meta_item] inner_items, + &@ast::meta_item cfg_item) + -> vec[@ast::meta_item] { + + alt (cfg_item.node) { + case (ast::meta_list(?name, ?items)) { + assert name == "cfg"; + inner_items + items + } + case (_) { inner_items } + } + } + auto cfg_metas = attr::attr_metas(item_cfg_attrs); + vec::foldl(extract_metas, [], cfg_metas) + }; for (@ast::meta_item cfg_mi in item_cfg_metas) { if (attr::contains(cfg, cfg_mi)) { diff --git a/src/lib/std.rc b/src/lib/std.rc index c4687e6a000b..24cae023c69a 100644 --- a/src/lib/std.rc +++ b/src/lib/std.rc @@ -49,18 +49,20 @@ auth rand::mk_rng = unsafe; // TODO: Have each os module re-export everything from genericos. mod generic_os; -alt (target_os) { - case ("win32") { - mod os = "win32_os.rs"; - mod os_fs = "win32_fs.rs"; - } case ("macos") { - mod os = "macos_os.rs"; - mod os_fs = "posix_fs.rs"; - } case (_) { - mod os = "linux_os.rs"; - mod os_fs = "posix_fs.rs"; - } -} +#[cfg(target_os = "win32")] +mod os = "win32_os.rs"; +#[cfg(target_os = "win32")] +mod os_fs = "win32_fs.rs"; + +#[cfg(target_os = "macos")] +mod os = "macos_os.rs"; +#[cfg(target_os = "macos")] +mod os_fs = "posix_fs.rs"; + +#[cfg(target_os = "linux")] +mod os = "linux_os.rs"; +#[cfg(target_os = "linux")] +mod os_fs = "posix_fs.rs"; mod run = "run_program.rs"; mod fs;