代码拉取完成,页面将自动刷新
同步操作将从 leiguangyu/hdc_rust 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
extern crate cc;
use std::env;
use std::path::Path;
const INCLUDE_PATH: &str = "include";
const MEMCPY_PATH: &str = "src/memcpy_s.c";
const MEMSET_PATH: &str = "src/memset_s.c";
const LZ4_CPATH: &str = "lz4.c";
const BCF_PATH: &str = "third_party/bounds_checking_function";
const LZ4_PATH: &str = "third_party/lz4/lib/";
fn main() {
let oh_path = env::var_os("OH_DIR");
let bcf_path = match env::var_os("BCF_DIR") {
Some(path) => path,
None => {
if let Some(path) = oh_path.clone() {
Path::new(&path).join(BCF_PATH).as_os_str().to_owned()
} else {
panic!("neither [BCF_DIR=/path/to/bounds_checking_function] nor [OH_DIR] is not found in env");
}
}
};
let lz4_src = if let Some(path) = oh_path.clone() {
Path::new(&path).join(LZ4_PATH).as_os_str().to_owned()
} else {
panic!("[OH_DIR] is not found in env");
};
let bcf_header = Path::new(&bcf_path).join(INCLUDE_PATH);
let memcpy_src = Path::new(&bcf_path).join(MEMCPY_PATH);
let memset_src = Path::new(&bcf_path).join(MEMSET_PATH);
let lz4_src_cpp = Path::new(&lz4_src).join(LZ4_CPATH).clone();
let cpp_files = vec![
memcpy_src.to_str().unwrap(),
memset_src.to_str().unwrap(),
lz4_src_cpp.to_str().unwrap(),
"src/cffi/serial_struct.cpp",
"src/cffi/uart.cpp",
"src/cffi/uart_wrapper.cpp",
"src/cffi/usb_util.cpp",
"src/cffi/oh_usb.cpp",
"src/cffi/usb_wrapper.cpp",
"src/cffi/mount.cpp",
"src/cffi/mount_wrapper.cpp",
"src/cffi/transfer.cpp",
];
let mut build = cc::Build::new();
build
.include(bcf_header)
.include("/usr/include/")
.include("/usr/lib/gcc/x86_64-linux-gnu/9/include/")
.include(lz4_src)
.files(cpp_files)
.cpp(true)
.flag("--std=c++17");
if cfg!(target_os = "macos") {
build.flag("-D HOST_MAC");
} else if cfg!(target_os = "linux") {
build.flag("-D HOST_LINUX");
}
build.compile("serial_struct");
if cfg!(target_os = "windows") {
const MINGW_PATH: &str =
"prebuilts/mingw-w64/ohos/linux-x86_64/clang-mingw/x86_64-w64-mingw32";
const WINDEP_SRC: &str = "src/cffi/win_dep.cpp";
let mingw_path = match env::var_os("MINGW_DIR") {
Some(path) => path,
None => {
if let Some(path) = oh_path {
Path::new(&path).join(MINGW_PATH).as_os_str().to_owned()
} else {
panic!("neither [MINGW_DIR=/path/to/x86_64-w64-mingw32] nor [OH_DIR] is not found in env");
}
}
};
let include_dep = Path::new(&mingw_path).join(INCLUDE_PATH);
cc::Build::new()
.include(include_dep)
.file(WINDEP_SRC)
.cpp(true)
.flag("--std=c++17")
.compile("win_dep");
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。