Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ebcc76d6
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ebcc76d6
编写于
10月 03, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move the library search into util::filesearch
上级
b25e7852
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
42 addition
and
25 deletion
+42
-25
src/comp/metadata/creader.rs
src/comp/metadata/creader.rs
+17
-25
src/comp/util/filesearch.rs
src/comp/util/filesearch.rs
+25
-0
未找到文件。
src/comp/metadata/creader.rs
浏览文件 @
ebcc76d6
...
...
@@ -8,7 +8,7 @@
import
syntax
::
visit
;
import
syntax
::
codemap
::
span
;
import
back
::
x86
;
import
util
::
common
;
import
util
::
{
common
,
filesearch
}
;
import
std
::{
vec
,
str
,
fs
,
io
,
option
};
import
std
::
option
::{
none
,
some
};
import
std
::
map
::{
hashmap
,
new_int_hash
};
...
...
@@ -131,49 +131,41 @@ fn find_library_crate(sess: session::session, ident: ast::ident,
let
nn
=
default_native_lib_naming
(
sess
,
sess
.get_opts
()
.static
);
let
x
=
find_library_crate_aux
(
nn
,
crate_name
,
metas
,
sess
.filesearch
()
.lib_search_paths
()
);
sess
.filesearch
());
if
x
!=
none
||
sess
.get_opts
()
.static
{
ret
x
;
}
let
nn2
=
default_native_lib_naming
(
sess
,
true
);
ret
find_library_crate_aux
(
nn2
,
crate_name
,
metas
,
sess
.filesearch
()
.lib_search_paths
()
);
sess
.filesearch
());
}
fn
find_library_crate_aux
(
nn
:
{
prefix
:
str
,
suffix
:
str
},
crate_name
:
str
,
metas
:
[
@
ast
::
meta_item
],
library_search_paths
:
[
str
]
)
->
filesearch
:
filesearch
::
filesearch
)
->
option
::
t
<
{
ident
:
str
,
data
:
@
[
u8
]}
>
{
let
prefix
:
str
=
nn
.prefix
+
crate_name
;
let
suffix
:
str
=
nn
.suffix
;
// FIXME: we could probably use a 'glob' function in std::fs but it will
// be much easier to write once the unsafe module knows more about FFI
// tricks. Currently the glob(3) interface is a bit more than we can
// stomach from here, and writing a C++ wrapper is more work than just
// manually filtering fs::list_dir here.
for
library_search_path
:
str
in
library_search_paths
{
log
#
fmt
[
"searching %s"
,
library_search_path
];
for
path
:
str
in
fs
::
list_dir
(
library_search_path
)
{
log
#
fmt
[
"searching %s"
,
path
];
ret
filesearch
::
search
(
filesearch
,
{
|
path
|
let
f
:
str
=
fs
::
basename
(
path
);
if
!
(
str
::
starts_with
(
f
,
prefix
)
&&
str
::
ends_with
(
f
,
suffix
))
{
log
#
fmt
[
"skipping %s, doesn't look like %s*%s"
,
path
,
prefix
,
suffix
];
cont
;
}
option
::
none
}
else
{
alt
get_metadata_section
(
path
)
{
option
::
some
(
cvec
)
{
if
!
metadata_matches
(
cvec
,
metas
)
{
log
#
fmt
[
"skipping %s, metadata doesn't match"
,
path
];
cont
;
}
option
::
none
}
else
{
log
#
fmt
[
"found %s with matching metadata"
,
path
];
ret
some
({
ident
:
path
,
data
:
cvec
});
option
::
some
({
ident
:
path
,
data
:
cvec
})
}
_
{
}
}
_
{
option
::
none
}
}
}
ret
none
;
})
;
}
fn
get_metadata_section
(
filename
:
str
)
->
option
::
t
<@
[
u8
]
>
{
...
...
src/comp/util/filesearch.rs
浏览文件 @
ebcc76d6
// A module for searching for libraries
import
std
::
option
;
import
std
::
fs
;
import
std
::
vec
;
...
...
@@ -6,6 +8,10 @@
export
filesearch
;
export
mk_filesearch
;
export
pick
;
export
search
;
type
pick
<@
T
>
=
block
(
path
:
fs
::
path
)
->
option
::
t
<
T
>
;
type
filesearch
=
obj
{
fn
sysroot
()
->
fs
::
path
;
...
...
@@ -37,9 +43,28 @@ fn get_target_lib_file_path(file: fs::path) -> fs::path {
}
let
sysroot
=
get_sysroot
(
maybe_sysroot
,
binary_name
);
log
#
fmt
(
"using sysroot = %s"
,
sysroot
);
ret
filesearch_impl
(
sysroot
,
addl_lib_search_paths
,
target_triple
);
}
// FIXME #1001: This can't be an obj method
fn
search
<@
T
>
(
filesearch
:
filesearch
,
pick
:
pick
<
T
>
)
->
option
::
t
<
T
>
{
for
lib_search_path
in
filesearch
.lib_search_paths
()
{
log
#
fmt
[
"searching %s"
,
lib_search_path
];
for
path
in
fs
::
list_dir
(
lib_search_path
)
{
log
#
fmt
[
"testing %s"
,
path
];
let
maybe_picked
=
pick
(
path
);
if
option
::
is_some
(
maybe_picked
)
{
log
#
fmt
(
"picked %s"
,
path
);
ret
maybe_picked
;
}
else
{
log
#
fmt
(
"rejected %s"
,
path
);
}
}
}
ret
option
::
none
;
}
fn
make_target_lib_path
(
sysroot
:
fs
::
path
,
target_triple
:
str
)
->
fs
::
path
{
let
path
=
[
sysroot
,
"lib/rustc"
,
target_triple
,
"lib"
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录