Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
cbde9032
Unverified
提交
cbde9032
authored
5月 31, 2021
作者:
Nazar Mokrynskyi
提交者:
GitHub
5月 31, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rust support on macOS (#567)
上级
3193c767
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
66 行增加
和
17 行删除
+66
-17
mediasoup-rust.yaml
.github/workflows/mediasoup-rust.yaml
+6
-2
utils.rs
rust/src/worker/utils.rs
+1
-4
build.rs
worker/build.rs
+59
-11
没有找到文件。
.github/workflows/mediasoup-rust.yaml
浏览文件 @
cbde9032
...
@@ -7,13 +7,17 @@ env:
...
@@ -7,13 +7,17 @@ env:
jobs
:
jobs
:
ci
:
ci
:
runs-on
:
ubuntu-20.04
strategy
:
strategy
:
matrix
:
matrix
:
os
:
-
ubuntu-20.04
-
macos-10.15
rust
:
rust
:
-
stable
-
stable
# - nightly
# - nightly
runs-on
:
${{ matrix.os }}
steps
:
steps
:
-
name
:
Checkout
-
name
:
Checkout
uses
:
actions/checkout@v2
uses
:
actions/checkout@v2
...
@@ -37,7 +41,7 @@ jobs:
...
@@ -37,7 +41,7 @@ jobs:
~/.cargo/registry
~/.cargo/registry
~/.cargo/git
~/.cargo/git
target
target
key
:
${{
runner
.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
key
:
${{
matrix
.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.toml') }}
-
name
:
cargo fmt
-
name
:
cargo fmt
uses
:
actions-rs/cargo@v1
uses
:
actions-rs/cargo@v1
...
...
rust/src/worker/utils.rs
浏览文件 @
cbde9032
...
@@ -36,10 +36,7 @@ fn pipe() -> [c_int; 2] {
...
@@ -36,10 +36,7 @@ fn pipe() -> [c_int; 2] {
let
mut
fds
=
mem
::
MaybeUninit
::
<
[
c_int
;
2
]
>
::
uninit
();
let
mut
fds
=
mem
::
MaybeUninit
::
<
[
c_int
;
2
]
>
::
uninit
();
if
libc
::
pipe
(
fds
.as_mut_ptr
()
.cast
::
<
c_int
>
())
!=
0
{
if
libc
::
pipe
(
fds
.as_mut_ptr
()
.cast
::
<
c_int
>
())
!=
0
{
panic!
(
panic!
(
"libc::pipe() failed: {:?}"
,
std
::
io
::
Error
::
last_os_error
());
"libc::pipe() failed with code {}"
,
*
libc
::
__errno_location
()
);
}
}
fds
.assume_init
()
fds
.assume_init
()
...
...
worker/build.rs
浏览文件 @
cbde9032
...
@@ -7,10 +7,17 @@ fn main() {
...
@@ -7,10 +7,17 @@ fn main() {
return
;
return
;
}
}
let
current_dir
=
std
::
env
::
current_dir
()
.unwrap
()
.into_os_string
()
.into_string
()
.unwrap
();
let
out_dir
=
env
::
var
(
"OUT_DIR"
)
.unwrap
();
// Add C++ std lib
// Add C++ std lib
#[cfg(target_os
=
"linux"
)]
#[cfg(target_os
=
"linux"
)]
{
{
let
path
=
Command
::
new
(
env
::
var
(
"
c++
"
)
.unwrap_or_else
(|
_
|
"c++"
.to_string
()))
let
path
=
Command
::
new
(
env
::
var
(
"
CXX
"
)
.unwrap_or_else
(|
_
|
"c++"
.to_string
()))
.arg
(
"--print-file-name=libstdc++.a"
)
.arg
(
"--print-file-name=libstdc++.a"
)
.output
()
.output
()
.expect
(
"Failed to start"
)
.expect
(
"Failed to start"
)
...
@@ -31,7 +38,7 @@ fn main() {
...
@@ -31,7 +38,7 @@ fn main() {
target_os
=
"netbsd"
target_os
=
"netbsd"
))]
))]
{
{
let
path
=
Command
::
new
(
env
::
var
(
"
c++
"
)
.unwrap_or_else
(|
_
|
"c++"
.to_string
()))
let
path
=
Command
::
new
(
env
::
var
(
"
CXX
"
)
.unwrap_or_else
(|
_
|
"c++"
.to_string
()))
.arg
(
"--print-file-name=libc++.a"
)
.arg
(
"--print-file-name=libc++.a"
)
.output
()
.output
()
.expect
(
"Failed to start"
)
.expect
(
"Failed to start"
)
...
@@ -47,8 +54,56 @@ fn main() {
...
@@ -47,8 +54,56 @@ fn main() {
}
}
#[cfg(target_os
=
"macos"
)]
#[cfg(target_os
=
"macos"
)]
{
{
panic!
(
"Building on macOS is not currently supported"
);
let
clang_llvm_version
=
"clang+llvm-12.0.0-x86_64-apple-darwin"
;
// TODO: The issue here is `libc++.a` that is not shipped with macOS's `c++` it seems
let
status
=
Command
::
new
(
"curl"
)
.args
(
&
[
"-L"
,
"-s"
,
"-O"
,
&
format!
(
"https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/{}.tar.xz"
,
clang_llvm_version
),
])
.current_dir
(
&
out_dir
)
.status
()
.expect
(
"Failed to start"
);
if
!
status
.success
()
{
panic!
(
"Failed to download libc++"
);
}
let
status
=
Command
::
new
(
"tar"
)
.args
(
&
[
"-xf"
,
&
format!
(
"{}.tar.xz"
,
clang_llvm_version
),
&
format!
(
"{}/lib/libc++.a"
,
clang_llvm_version
),
&
format!
(
"{}/lib/libc++abi.a"
,
clang_llvm_version
),
])
.current_dir
(
&
out_dir
)
.status
()
.expect
(
"Failed to start"
);
if
!
status
.success
()
{
panic!
(
"Failed to download libc++"
);
}
for
file
in
&
[
"libc++.a"
,
"libc++abi.a"
]
{
std
::
fs
::
copy
(
format!
(
"{}/{}/lib/{}"
,
out_dir
,
clang_llvm_version
,
file
),
format!
(
"{}/{}"
,
out_dir
,
file
),
)
.unwrap_or_else
(|
_
|
{
panic!
(
"Failed to copy static library from {}/{}/lib/{} to {}/{}"
,
out_dir
,
clang_llvm_version
,
file
,
out_dir
,
file
)
});
}
std
::
fs
::
remove_file
(
format!
(
"{}/{}.tar.xz"
,
out_dir
,
clang_llvm_version
))
.expect
(
"Failed to remove downloaded clang+llvm archive"
);
std
::
fs
::
remove_dir_all
(
format!
(
"{}/{}"
,
out_dir
,
clang_llvm_version
))
.expect
(
"Failed to remove extracted clang+llvm files"
);
println!
(
"cargo:rustc-link-lib=static=c++"
);
println!
(
"cargo:rustc-link-lib=static=c++abi"
);
}
}
#[cfg(target_os
=
"windows"
)]
#[cfg(target_os
=
"windows"
)]
{
{
...
@@ -56,13 +111,6 @@ fn main() {
...
@@ -56,13 +111,6 @@ fn main() {
// TODO: Didn't bother, feel free to PR
// TODO: Didn't bother, feel free to PR
}
}
let
current_dir
=
std
::
env
::
current_dir
()
.unwrap
()
.into_os_string
()
.into_string
()
.unwrap
();
let
out_dir
=
env
::
var
(
"OUT_DIR"
)
.unwrap
();
// The build here is a bit awkward since we can't just specify custom target directory as
// The build here is a bit awkward since we can't just specify custom target directory as
// openssl will fail to build with `make[1]: /bin/sh: Argument list too long` due to large
// openssl will fail to build with `make[1]: /bin/sh: Argument list too long` due to large
// number of files. So instead we build in place, copy files to out directory and then clean
// number of files. So instead we build in place, copy files to out directory and then clean
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论