Skip to content

Commit 656281d

Browse files
committed
---
yaml --- r: 3510 b: refs/heads/master c: 64d6081 h: refs/heads/master v: v3
1 parent 33b4430 commit 656281d

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: df8161d44cf8eb9d17a626879e4f5cbc954b4b88
2+
refs/heads/master: 64d60814292d75a4aa370012eebb299b0be01c45

trunk/src/comp/front/attr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@ fn eq(@ast::meta_item a, @ast::meta_item b) -> bool {
9999
}
100100

101101
fn contains(&vec[@ast::meta_item] haystack, @ast::meta_item needle) -> bool {
102+
log #fmt("looking for %s", pretty::pprust::meta_item_to_str(*needle));
102103
for (@ast::meta_item item in haystack) {
104+
log #fmt("looking in %s", pretty::pprust::meta_item_to_str(*item));
103105
if (eq(item, needle)) {
106+
log "found it!";
104107
ret true;
105108
}
106109
}
110+
log "found it not :(";
107111
ret false;
108112
}
109113

trunk/src/comp/front/config.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,30 @@ fn fold_block(&ast::crate_cfg cfg, &ast::block_ b,
7171
// configuration based on the item's attributes
7272
fn in_cfg(&ast::crate_cfg cfg, &@ast::item item) -> bool {
7373

74+
// The "cfg" attributes on the item
7475
auto item_cfg_attrs = attr::find_attrs_by_name(item.attrs, "cfg");
75-
7676
auto item_has_cfg_attrs = vec::len(item_cfg_attrs) > 0u;
7777
if (!item_has_cfg_attrs) { ret true; }
7878

79-
auto item_cfg_metas = attr::attr_metas(item_cfg_attrs);
79+
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
80+
// so we can match against them. This is the list of configurations for
81+
// which the item is valid
82+
auto item_cfg_metas = {
83+
fn extract_metas(&vec[@ast::meta_item] inner_items,
84+
&@ast::meta_item cfg_item)
85+
-> vec[@ast::meta_item] {
86+
87+
alt (cfg_item.node) {
88+
case (ast::meta_list(?name, ?items)) {
89+
assert name == "cfg";
90+
inner_items + items
91+
}
92+
case (_) { inner_items }
93+
}
94+
}
95+
auto cfg_metas = attr::attr_metas(item_cfg_attrs);
96+
vec::foldl(extract_metas, [], cfg_metas)
97+
};
8098

8199
for (@ast::meta_item cfg_mi in item_cfg_metas) {
82100
if (attr::contains(cfg, cfg_mi)) {

trunk/src/lib/std.rc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,20 @@ auth rand::mk_rng = unsafe;
4949
// TODO: Have each os module re-export everything from genericos.
5050
mod generic_os;
5151

52-
alt (target_os) {
53-
case ("win32") {
54-
mod os = "win32_os.rs";
55-
mod os_fs = "win32_fs.rs";
56-
} case ("macos") {
57-
mod os = "macos_os.rs";
58-
mod os_fs = "posix_fs.rs";
59-
} case (_) {
60-
mod os = "linux_os.rs";
61-
mod os_fs = "posix_fs.rs";
62-
}
63-
}
52+
#[cfg(target_os = "win32")]
53+
mod os = "win32_os.rs";
54+
#[cfg(target_os = "win32")]
55+
mod os_fs = "win32_fs.rs";
56+
57+
#[cfg(target_os = "macos")]
58+
mod os = "macos_os.rs";
59+
#[cfg(target_os = "macos")]
60+
mod os_fs = "posix_fs.rs";
61+
62+
#[cfg(target_os = "linux")]
63+
mod os = "linux_os.rs";
64+
#[cfg(target_os = "linux")]
65+
mod os_fs = "posix_fs.rs";
6466

6567
mod run = "run_program.rs";
6668
mod fs;

0 commit comments

Comments
 (0)